Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
D
django-pyfs
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
OpenEdx
django-pyfs
Commits
d175715e
Commit
d175715e
authored
Sep 23, 2014
by
Piotr Mitros
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Untested commit: Do not connect to S3 on import
parent
a0722e51
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
5 additions
and
3 deletions
+5
-3
djpyfs/djpyfs.py
+5
-3
No files found.
djpyfs/djpyfs.py
View file @
d175715e
...
@@ -36,7 +36,7 @@ elif djfs_settings['type'] == 's3fs':
...
@@ -36,7 +36,7 @@ elif djfs_settings['type'] == 's3fs':
from
boto.s3.key
import
Key
from
boto.s3.key
import
Key
key_id
=
djfs_settings
.
get
(
'aws_access_key_id'
,
None
)
key_id
=
djfs_settings
.
get
(
'aws_access_key_id'
,
None
)
key_secret
=
djfs_settings
.
get
(
'aws_secret_access_key'
,
None
)
key_secret
=
djfs_settings
.
get
(
'aws_secret_access_key'
,
None
)
s3conn
=
S3Connection
(
aws_access_key_id
=
key_id
,
aws_secret_access_key
=
key_secret
)
s3conn
=
None
else
:
else
:
raise
AttributeError
(
"Bad filesystem: "
+
str
(
djfs_settings
[
'type'
]))
raise
AttributeError
(
"Bad filesystem: "
+
str
(
djfs_settings
[
'type'
]))
...
@@ -112,9 +112,11 @@ def get_s3fs(namespace):
...
@@ -112,9 +112,11 @@ def get_s3fs(namespace):
def
get_s3_url
(
self
,
filename
,
timeout
=
60
):
def
get_s3_url
(
self
,
filename
,
timeout
=
60
):
global
s3conn
global
s3conn
try
:
try
:
if
not
s3conn
:
s3conn
=
S3Connection
(
aws_access_key_id
=
key_id
,
aws_secret_access_key
=
key_secret
)
return
s3conn
.
generate_url
(
timeout
,
'GET'
,
bucket
=
djfs_settings
[
'bucket'
],
key
=
os
.
path
.
join
(
fullpath
,
filename
))
return
s3conn
.
generate_url
(
timeout
,
'GET'
,
bucket
=
djfs_settings
[
'bucket'
],
key
=
os
.
path
.
join
(
fullpath
,
filename
))
except
:
# If connection has timed out
except
:
# Retry on error; typically, if the connection has timed out, but the broad except covers all errors.
s3conn
=
S3Connection
()
s3conn
=
S3Connection
(
aws_access_key_id
=
key_id
,
aws_secret_access_key
=
key_secret
)
return
s3conn
.
generate_url
(
timeout
,
'GET'
,
bucket
=
djfs_settings
[
'bucket'
],
key
=
os
.
path
.
join
(
fullpath
,
filename
))
return
s3conn
.
generate_url
(
timeout
,
'GET'
,
bucket
=
djfs_settings
[
'bucket'
],
key
=
os
.
path
.
join
(
fullpath
,
filename
))
s3fs
=
patch_fs
(
s3fs
,
namespace
,
get_s3_url
)
s3fs
=
patch_fs
(
s3fs
,
namespace
,
get_s3_url
)
...
...
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