Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
edx-platform
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-platform
Commits
a28b02ae
Commit
a28b02ae
authored
Aug 22, 2013
by
Julian Arni
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Pep8 and pylint fixes
parent
fcd11d93
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
24 deletions
+22
-24
cms/djangoapps/contentstore/tests/test_import_export.py
+8
-9
cms/djangoapps/contentstore/views/import_export.py
+14
-15
No files found.
cms/djangoapps/contentstore/tests/test_import_export.py
View file @
a28b02ae
...
...
@@ -32,10 +32,10 @@ class ImportTestCase(CourseTestCase):
os
.
utime
(
name
,
None
)
# Create tar test files -----------------------------------------------
# OK course:
# OK course:
good_dir
=
tempfile
.
mkdtemp
(
dir
=
self
.
content_dir
)
os
.
makedirs
(
os
.
path
.
join
(
good_dir
,
"course"
))
with
open
(
os
.
path
.
join
(
good_dir
,
"course.xml"
)
,
"w+"
)
as
f
:
with
open
(
os
.
path
.
join
(
good_dir
,
"course.xml"
),
"w+"
)
as
f
:
f
.
write
(
'<course url_name="2013_Spring" org="EDx" course="0.00x"/>'
)
with
open
(
os
.
path
.
join
(
good_dir
,
"course"
,
"2013_Spring.xml"
),
"w+"
)
as
f
:
...
...
@@ -44,7 +44,7 @@ class ImportTestCase(CourseTestCase):
self
.
good_tar
=
os
.
path
.
join
(
self
.
content_dir
,
"good.tar.gz"
)
with
tarfile
.
open
(
self
.
good_tar
,
"w:gz"
)
as
gtar
:
gtar
.
add
(
good_dir
)
# Bad course (no 'course.xml' file):
bad_dir
=
tempfile
.
mkdtemp
(
dir
=
self
.
content_dir
)
touch
(
os
.
path
.
join
(
bad_dir
,
"bad.xml"
))
...
...
@@ -62,11 +62,11 @@ class ImportTestCase(CourseTestCase):
"""
with
open
(
self
.
bad_tar
)
as
btar
:
resp
=
self
.
client
.
post
(
self
.
url
,
{
"name"
:
self
.
bad_tar
,
"course-data"
:
[
btar
]
})
self
.
url
,
{
"name"
:
self
.
bad_tar
,
"course-data"
:
[
btar
]
})
self
.
assertEquals
(
resp
.
status_code
,
415
)
def
test_with_coursexml
(
self
):
...
...
@@ -82,4 +82,3 @@ class ImportTestCase(CourseTestCase):
"course-data"
:
[
gtar
]
})
self
.
assert2XX
(
resp
.
status_code
)
cms/djangoapps/contentstore/views/import_export.py
View file @
a28b02ae
...
...
@@ -19,7 +19,6 @@ from django.core.files.temp import NamedTemporaryFile
from
django.views.decorators.http
import
require_http_methods
from
mitxmako.shortcuts
import
render_to_response
from
cache_toolbox.core
import
del_cached_content
from
auth.authz
import
create_all_course_groups
from
xmodule.modulestore.xml_importer
import
import_from_xml
...
...
@@ -38,7 +37,7 @@ __all__ = ['import_course', 'generate_export_course', 'export_course']
log
=
logging
.
getLogger
(
__name__
)
MAX_UP_LENGTH
=
20000352
# Max chunk size for uploads
MAX_UP_LENGTH
=
20000352
# Max chunk size for uploads
# Regex to capture Content-Range header ranges.
CONTENT_RE
=
re
.
compile
(
r"(?P<start>\d{1,11})-(?P<stop>\d{1,11})/(?P<end>\d{1,11})"
)
...
...
@@ -113,18 +112,18 @@ def import_course(request, org, course, name):
if
int
(
content_range
[
'stop'
])
!=
int
(
content_range
[
'end'
])
-
1
:
# More chunks coming
return
JsonResponse
({
"files"
:
[{
"name"
:
filename
,
"size"
:
size
,
"deleteUrl"
:
""
,
"deleteType"
:
""
,
"url"
:
reverse
(
'import_course'
,
kwargs
=
{
'org'
:
location
.
org
,
'course'
:
location
.
course
,
'name'
:
location
.
name
}),
"thumbnailUrl"
:
""
}]
"files"
:
[{
"name"
:
filename
,
"size"
:
size
,
"deleteUrl"
:
""
,
"deleteType"
:
""
,
"url"
:
reverse
(
'import_course'
,
kwargs
=
{
'org'
:
location
.
org
,
'course'
:
location
.
course
,
'name'
:
location
.
name
}),
"thumbnailUrl"
:
""
}]
})
else
:
# This was the last chunk.
...
...
@@ -147,7 +146,7 @@ def import_course(request, org, course, name):
def
get_all_files
(
directory
):
"""
For each file in the directory, yield a 2-tuple of (file-name,
directory-path)
directory-path)
"""
for
dirpath
,
_dirnames
,
filenames
in
os
.
walk
(
directory
):
for
filename
in
filenames
:
...
...
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