Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
edx-platform-release
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
1
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Package Registry
Operate
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Admin message
code.vt.edu will be down for maintenance from 0530-0630 EDT Wednesday, March 26th
Show more breadcrumbs
Hsin-Yu Chien
edx-platform-release
Commits
3c60d1a9
Commit
3c60d1a9
authored
12 years ago
by
Calen Pennington
Browse files
Options
Downloads
Patches
Plain Diff
Clean up how errors in import command are handled
parent
feef179e
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
cms/djangoapps/contentstore/management/commands/import.py
+9
-4
9 additions, 4 deletions
cms/djangoapps/contentstore/management/commands/import.py
with
9 additions
and
4 deletions
cms/djangoapps/contentstore/management/commands/import.py
+
9
−
4
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
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment