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
d0c99151
Commit
d0c99151
authored
Jul 27, 2012
by
Calen Pennington
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Continue during backcompat imports by replacing contents with error xml
parent
7ae0836f
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
24 additions
and
21 deletions
+24
-21
common/lib/xmodule/xmodule/backcompat_module.py
+24
-21
No files found.
common/lib/xmodule/xmodule/backcompat_module.py
View file @
d0c99151
...
...
@@ -5,6 +5,7 @@ from x_module import XModuleDescriptor
from
lxml
import
etree
from
functools
import
wraps
import
logging
import
traceback
log
=
logging
.
getLogger
(
__name__
)
...
...
@@ -21,29 +22,31 @@ def process_includes(fn):
next_include
=
xml_object
.
find
(
'include'
)
while
next_include
is
not
None
:
file
=
next_include
.
get
(
'file'
)
if
file
is
not
None
:
try
:
ifp
=
system
.
resources_fs
.
open
(
file
)
except
Exception
:
msg
=
'Error in problem xml include:
%
s
\n
'
%
(
etree
.
tostring
(
next_include
,
pretty_print
=
True
))
msg
+=
'Cannot find file
%
s in
%
s'
%
(
file
,
dir
)
log
.
exception
(
msg
)
system
.
error_handler
(
msg
)
raise
try
:
# read in and convert to XML
incxml
=
etree
.
XML
(
ifp
.
read
())
except
Exception
:
msg
=
'Error in problem xml include:
%
s
\n
'
%
(
etree
.
tostring
(
next_include
,
pretty_print
=
True
))
msg
+=
'Cannot parse XML in
%
s'
%
(
file
)
log
.
exception
(
msg
)
system
.
error_handler
(
msg
)
raise
parent
=
next_include
.
getparent
()
if
file
is
None
:
continue
try
:
ifp
=
system
.
resources_fs
.
open
(
file
)
# read in and convert to XML
incxml
=
etree
.
XML
(
ifp
.
read
())
# insert new XML into tree in place of inlcude
parent
=
next_include
.
getparent
()
parent
.
insert
(
parent
.
index
(
next_include
),
incxml
)
except
Exception
:
msg
=
"Error in problem xml include:
%
s"
%
(
etree
.
tostring
(
next_include
,
pretty_print
=
True
))
log
.
exception
(
msg
)
parent
=
next_include
.
getparent
()
errorxml
=
etree
.
Element
(
'error'
)
messagexml
=
etree
.
SubElement
(
errorxml
,
'message'
)
messagexml
.
text
=
msg
stackxml
=
etree
.
SubElement
(
errorxml
,
'stacktrace'
)
stackxml
.
text
=
traceback
.
format_exc
()
# insert error XML in place of include
parent
.
insert
(
parent
.
index
(
next_include
),
errorxml
)
parent
.
remove
(
next_include
)
next_include
=
xml_object
.
find
(
'include'
)
...
...
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