Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
I
insights
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
insights
Commits
3e2036d6
Commit
3e2036d6
authored
Mar 30, 2013
by
Piotr Mitros
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Docstrings
parent
829def4b
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
2 deletions
+12
-2
src/djanalytics/modulefs/modulefs.py
+12
-2
No files found.
src/djanalytics/modulefs/modulefs.py
View file @
3e2036d6
...
@@ -43,8 +43,16 @@ def expire_objects():
...
@@ -43,8 +43,16 @@ def expire_objects():
o
.
delete
()
o
.
delete
()
def
patch_fs
(
fs
,
namespace
,
url_method
):
def
patch_fs
(
fs
,
namespace
,
url_method
):
''' Patch a filesystem object to add get_url method and
''' Patch a filesystem object to add two methods:
expire method.
get_url returns a URL for a resource stored on that filesystem. It takes two parameters:
filename: Which resource
timeout: How long that resource is available for
expire sets a timeout on how long the system should keep the resource. It takes four parameters:
filename: Which resource
seconds: How long we will keep it
days: (optional) More user-friendly if a while
expires: (optional) boolean; if set to False, we keep the resource forever.
Without calling this method, we provide no guarantees on how long resources will stick around.
'''
'''
def
expire
(
self
,
filename
,
seconds
,
days
=
0
,
expires
=
True
):
def
expire
(
self
,
filename
,
seconds
,
days
=
0
,
expires
=
True
):
''' Set the lifespan of a file on the filesystem.
''' Set the lifespan of a file on the filesystem.
...
@@ -60,6 +68,7 @@ def patch_fs(fs, namespace, url_method):
...
@@ -60,6 +68,7 @@ def patch_fs(fs, namespace, url_method):
return
fs
return
fs
def
get_osfs
(
namespace
):
def
get_osfs
(
namespace
):
''' Helper method to get_filesystem for a file system on disk '''
full_path
=
os
.
path
.
join
(
settings
.
DJFS
[
'directory_root'
],
namespace
)
full_path
=
os
.
path
.
join
(
settings
.
DJFS
[
'directory_root'
],
namespace
)
if
not
os
.
path
.
exists
(
full_path
):
if
not
os
.
path
.
exists
(
full_path
):
os
.
makedirs
(
full_path
)
os
.
makedirs
(
full_path
)
...
@@ -68,6 +77,7 @@ def get_osfs(namespace):
...
@@ -68,6 +77,7 @@ def get_osfs(namespace):
return
osfs
return
osfs
def
get_s3fs
(
namespace
):
def
get_s3fs
(
namespace
):
''' Helper method to get_filesystem for a file system on S3 '''
fullpath
=
namespace
fullpath
=
namespace
if
'prefix'
in
settings
.
DJFS
:
if
'prefix'
in
settings
.
DJFS
:
fullpath
=
os
.
path
.
join
(
settings
.
DJFS
[
'prefix'
],
fullpath
)
fullpath
=
os
.
path
.
join
(
settings
.
DJFS
[
'prefix'
],
fullpath
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment