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
829def4b
Commit
829def4b
authored
Mar 30, 2013
by
Piotr Mitros
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
s3fs/untested implementation
parent
484258bb
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
1 deletions
+14
-1
src/djanalytics/modulefs/modulefs.py
+14
-1
No files found.
src/djanalytics/modulefs/modulefs.py
View file @
829def4b
...
@@ -11,6 +11,9 @@ if settings.DJFS['type'] == 'osfs':
...
@@ -11,6 +11,9 @@ if settings.DJFS['type'] == 'osfs':
from
fs.osfs
import
OSFS
from
fs.osfs
import
OSFS
elif
settings
.
DJFS
[
'type'
]
==
'sf3s'
:
elif
settings
.
DJFS
[
'type'
]
==
'sf3s'
:
from
fs.s3fs
import
S3FS
from
fs.s3fs
import
S3FS
from
boto.s3.connection
import
S3Connection
from
boto.s3.key
import
Key
s3conn
=
S3Connection
()
else
:
else
:
raise
AttributeError
(
"Bad filesystem"
)
raise
AttributeError
(
"Bad filesystem"
)
...
@@ -61,7 +64,7 @@ def get_osfs(namespace):
...
@@ -61,7 +64,7 @@ def get_osfs(namespace):
if
not
os
.
path
.
exists
(
full_path
):
if
not
os
.
path
.
exists
(
full_path
):
os
.
makedirs
(
full_path
)
os
.
makedirs
(
full_path
)
osfs
=
OSFS
(
full_path
)
osfs
=
OSFS
(
full_path
)
osfs
=
patch_fs
(
osfs
,
namespace
,
lambda
self
,
filename
:
os
.
path
.
join
(
settings
.
DJFS
[
'url_root'
],
namespace
,
filename
))
osfs
=
patch_fs
(
osfs
,
namespace
,
lambda
self
,
filename
,
timeout
=
0
:
os
.
path
.
join
(
settings
.
DJFS
[
'url_root'
],
namespace
,
filename
))
return
osfs
return
osfs
def
get_s3fs
(
namespace
):
def
get_s3fs
(
namespace
):
...
@@ -69,5 +72,15 @@ def get_s3fs(namespace):
...
@@ -69,5 +72,15 @@ def get_s3fs(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
)
s3fs
=
S3FS
(
settings
.
DJFS
[
'bucket'
],
fullpath
)
s3fs
=
S3FS
(
settings
.
DJFS
[
'bucket'
],
fullpath
)
def
get_s3_url
(
self
,
filename
,
timeout
=
60
):
global
s3conn
try
:
return
s3conn
.
generate_s3_url
(
timeout
,
'GET'
,
bucket
=
settings
.
DJFS
[
'bucket'
],
key
=
filename
)
except
:
# If connection has timed out
s3conn
=
S3Connection
()
return
s3conn
.
generate_s3_url
(
timeout
,
'GET'
,
bucket
=
settings
.
DJFS
[
'bucket'
],
key
=
filename
)
s3fs
=
patchfs
(
fs
,
namespace
,
get_s3_url
)
return
s3fs
return
s3fs
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