Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
edx-ora2
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
edx-ora2
Commits
c1d9a692
Commit
c1d9a692
authored
May 13, 2014
by
Will Daly
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use settings for AWS credentials when connecting to S3, if provided
parent
46fb1936
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
1 deletions
+11
-1
apps/openassessment/management/commands/upload_oa_data.py
+11
-1
No files found.
apps/openassessment/management/commands/upload_oa_data.py
View file @
c1d9a692
...
...
@@ -11,6 +11,7 @@ import tarfile
import
boto
from
boto.s3.key
import
Key
from
django.core.management.base
import
BaseCommand
,
CommandError
from
django.conf
import
settings
from
openassessment.data
import
CsvWriter
...
...
@@ -129,7 +130,16 @@ class Command(BaseCommand):
str: URL to access the uploaded archive.
"""
conn
=
boto
.
connect_s3
()
# Try to get the AWS credentials from settings if they are available
# If not, these will default to `None`, and boto will try to use
# environment vars or configuration files instead.
aws_access_key_id
=
getattr
(
settings
,
'AWS_ACCESS_KEY_ID'
,
None
)
aws_secret_access_key
=
getattr
(
settings
,
'AWS_SECRET_ACCESS_KEY'
,
None
)
conn
=
boto
.
connect_s3
(
aws_access_key_id
=
aws_access_key_id
,
aws_secret_access_key
=
aws_secret_access_key
)
bucket
=
conn
.
get_bucket
(
s3_bucket
)
key_name
=
os
.
path
.
join
(
course_id
,
os
.
path
.
split
(
file_path
)[
1
])
key
=
Key
(
bucket
=
bucket
,
name
=
key_name
)
...
...
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