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
fcaf3e63
Commit
fcaf3e63
authored
Aug 05, 2013
by
Chris Dodge
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
give some debug message regarding why export might fail
parent
edc62ff6
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
56 additions
and
7 deletions
+56
-7
cms/djangoapps/contentstore/views/assets.py
+24
-5
cms/templates/export.html
+19
-0
common/lib/xmodule/xmodule/exceptions.py
+10
-0
common/lib/xmodule/xmodule/raw_module.py
+3
-2
No files found.
cms/djangoapps/contentstore/views/assets.py
View file @
fcaf3e63
...
...
@@ -3,6 +3,7 @@ import json
import
os
import
tarfile
import
shutil
import
cgi
from
tempfile
import
mkdtemp
from
path
import
path
...
...
@@ -27,7 +28,7 @@ from xmodule.modulestore import Location
from
xmodule.contentstore.content
import
StaticContent
from
xmodule.util.date_utils
import
get_default_time_display
from
xmodule.modulestore
import
InvalidLocationError
from
xmodule.exceptions
import
NotFoundError
from
xmodule.exceptions
import
NotFoundError
,
SerializationError
from
.access
import
get_location_and_verify_access
from
util.json_request
import
JsonResponse
...
...
@@ -336,16 +337,34 @@ def generate_export_course(request, org, course, name):
the course
"""
location
=
get_location_and_verify_access
(
request
,
org
,
course
,
name
)
course_module
=
modulestore
()
.
get_item
(
location
)
loc
=
Location
(
location
)
export_file
=
NamedTemporaryFile
(
prefix
=
name
+
'.'
,
suffix
=
".tar.gz"
)
root_dir
=
path
(
mkdtemp
())
# export out to a tempdir
logging
.
debug
(
'root = {0}'
.
format
(
root_dir
))
try
:
export_to_xml
(
modulestore
(
'direct'
),
contentstore
(),
loc
,
root_dir
,
name
,
modulestore
())
except
SerializationError
,
e
:
failed_item
=
modulestore
()
.
get_item
(
e
.
location
)
parent_locs
=
modulestore
()
.
get_parent_locations
(
failed_item
.
location
,
None
)
if
len
(
parent_locs
)
>
0
:
parent
=
modulestore
()
.
get_item
(
parent_locs
[
0
])
parent_info
=
"Parent Display Name: {0}<br />Parent Identifier: {1}"
.
format
(
parent
.
display_name
,
parent
.
location
.
name
)
else
:
parent_info
=
''
return
render_to_response
(
'export.html'
,
{
'context_course'
:
course_module
,
'successful_import_redirect_url'
:
''
,
'err_msg'
:
"A courseware module has failed to convert to XML. Details: <br />Module Type: {0}<br />Display Name: {1}<br />Identifier: {2}<br />{3}"
.
format
(
failed_item
.
location
.
category
,
failed_item
.
display_name
,
failed_item
.
location
.
name
,
parent_info
)
})
except
Exception
,
e
:
return
render_to_response
(
'export.html'
,
{
'context_course'
:
course_module
,
'successful_import_redirect_url'
:
''
,
'err_msg'
:
str
(
e
)
})
logging
.
debug
(
'tar file being generated at {0}'
.
format
(
export_file
.
name
))
tar_file
=
tarfile
.
open
(
name
=
export_file
.
name
,
mode
=
'w:gz'
)
...
...
cms/templates/export.html
View file @
fcaf3e63
...
...
@@ -6,6 +6,24 @@
<
%
block
name=
"title"
>
${_("Course Export")}
</
%
block>
<
%
block
name=
"bodyclass"
>
is-signedin course tools export
</
%
block>
<
%
block
name=
"jsextra"
>
% if err_msg:
<script
type=
'text/javascript'
>
$
(
document
).
ready
(
function
()
{
var
defaultTitle
=
gettext
(
'There has been an error with your export.'
);
var
msg
=
"${err_msg}"
;
dialog
=
new
CMS
.
Views
.
Alert
.
Confirmation
({
title
:
defaultTitle
,
message
:
msg
,
intent
:
"error"
,
closeIcon
:
false
});
dialog
.
show
();
})
</script>
%endif
</
%
block>
<
%
block
name=
"content"
>
<div
class=
"wrapper-mast wrapper"
>
<header
class=
"mast has-subtitle"
>
...
...
@@ -18,6 +36,7 @@
<div
class=
"main-wrapper"
>
<div
class=
"inner-wrapper"
>
<article
class=
"export-overview"
>
<div
class=
"description"
>
<h2>
${_("About Exporting Courses")}
</h2>
...
...
common/lib/xmodule/xmodule/exceptions.py
View file @
fcaf3e63
...
...
@@ -13,6 +13,7 @@ class ProcessingError(Exception):
'''
pass
class
InvalidVersionError
(
Exception
):
"""
Tried to save an item with a location that a store cannot support (e.g., draft version
...
...
@@ -21,3 +22,12 @@ class InvalidVersionError(Exception):
def
__init__
(
self
,
location
):
super
(
InvalidVersionError
,
self
)
.
__init__
()
self
.
location
=
location
class
SerializationError
(
Exception
):
"""
Thrown when a module cannot be exported to XML
"""
def
__init__
(
self
,
location
,
msg
):
super
(
SerializationError
,
self
)
.
__init__
(
msg
)
self
.
location
=
location
common/lib/xmodule/xmodule/raw_module.py
View file @
fcaf3e63
...
...
@@ -4,6 +4,7 @@ from xmodule.xml_module import XmlDescriptor
import
logging
import
sys
from
xblock.core
import
String
,
Scope
from
exceptions
import
SerializationError
log
=
logging
.
getLogger
(
__name__
)
...
...
@@ -27,11 +28,11 @@ class RawDescriptor(XmlDescriptor, XMLEditingDescriptor):
# re-raise
lines
=
self
.
data
.
split
(
'
\n
'
)
line
,
offset
=
err
.
position
msg
=
(
"Unable to create xml for
problem
{loc}. "
msg
=
(
"Unable to create xml for
module
{loc}. "
"Context: '{context}'"
.
format
(
context
=
lines
[
line
-
1
][
offset
-
40
:
offset
+
40
],
loc
=
self
.
location
))
raise
Exception
,
msg
,
sys
.
exc_info
()[
2
]
raise
SerializationError
(
self
.
location
,
msg
)
class
EmptyDataRawDescriptor
(
XmlDescriptor
,
XMLEditingDescriptor
):
...
...
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