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
3c60d1a9
Commit
3c60d1a9
authored
Jun 29, 2012
by
Calen Pennington
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Clean up how errors in import command are handled
parent
feef179e
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
4 deletions
+9
-4
cms/djangoapps/contentstore/management/commands/import.py
+9
-4
No files found.
cms/djangoapps/contentstore/management/commands/import.py
View file @
3c60d1a9
###
###
### One-off script for importing courseware form XML format
###
from
django.core.management.base
import
BaseCommand
from
django.core.management.base
import
BaseCommand
,
CommandError
from
keystore.django
import
keystore
from
raw_module
import
RawDescriptor
from
lxml
import
etree
...
...
@@ -17,13 +17,18 @@ unnamed_modules = 0
etree
.
set_default_parser
(
etree
.
XMLParser
(
dtd_validation
=
False
,
load_dtd
=
False
,
remove_comments
=
True
))
class
Command
(
BaseCommand
):
help
=
\
'''Import the specified data directory into the default keystore'''
def
handle
(
self
,
*
args
,
**
options
):
if
len
(
args
)
!=
3
:
raise
CommandError
(
"import requires 3 arguments: <org> <course> <data directory>"
)
org
,
course
,
data_dir
=
args
data_dir
=
path
(
data_dir
)
class
ImportSystem
(
XMLParsingSystem
):
def
__init__
(
self
):
self
.
load_item
=
keystore
()
.
get_item
...
...
@@ -33,8 +38,8 @@ class Command(BaseCommand):
try
:
xml_data
=
etree
.
fromstring
(
xml
)
except
:
print
xml
raise
raise
CommandError
(
"Unable to parse xml: "
+
xml
)
if
not
xml_data
.
get
(
'name'
):
global
unnamed_modules
unnamed_modules
+=
1
...
...
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