Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions cms/djangoapps/contentstore/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,9 @@ def export_olx(self, user_id, course_key_string, language):

try:
self.status.set_state('Exporting')
set_custom_attribute("exporting_started", str(courselike_key))
tarball = create_export_tarball(courselike_block, courselike_key, {}, self.status)
set_custom_attribute("exporting_completed", str(courselike_key))
artifact = UserTaskArtifact(status=self.status, name='Output')
artifact.file.save(name=os.path.basename(tarball.name), content=File(tarball))
artifact.save()
Expand All @@ -412,10 +414,13 @@ def create_export_tarball(course_block, course_key, context, status=None):
if isinstance(course_key, LibraryLocator):
export_library_to_xml(modulestore(), contentstore(), course_key, root_dir, name)
else:
set_custom_attribute("exporting_course_to_xml_started", str(course_key))
export_course_to_xml(modulestore(), contentstore(), course_block.id, root_dir, name)

set_custom_attribute("exporting_course_to_xml_completed", str(course_key))
if status:
status.set_state('Compressing')
set_custom_attribute("compressing_started", str(course_key))
status.increment_completed_steps()
LOGGER.debug('tar file being generated at %s', export_file.name)
with tarfile.open(name=export_file.name, mode='w:gz') as tar_file:
Expand Down Expand Up @@ -456,6 +461,7 @@ def create_export_tarball(course_block, course_key, context, status=None):
if os.path.exists(root_dir / name):
shutil.rmtree(root_dir / name)

set_custom_attribute("compressing_completed", str(course_key))
return export_file


Expand Down
9 changes: 9 additions & 0 deletions xmodule/modulestore/xml_exporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from json import dumps

import lxml.etree
from edx_django_utils.monitoring import set_custom_attribute
from fs.osfs import OSFS
from opaque_keys.edx.locator import CourseLocator, LibraryLocator
from xblock.fields import Reference, ReferenceList, ReferenceValueDict, Scope
Expand Down Expand Up @@ -207,6 +208,7 @@ def process_root(self, root, export_fs):

def process_extra(self, root, courselike, root_courselike_dir, xml_centric_courselike_key, export_fs):
# Export the modulestore's asset metadata.
set_custom_attribute("export_asset_started", str(courselike))
asset_dir = root_courselike_dir + '/' + AssetMetadata.EXPORTED_ASSET_DIR + '/'
if not os.path.isdir(asset_dir):
os.makedirs(asset_dir)
Expand All @@ -220,6 +222,7 @@ def process_extra(self, root, courselike, root_courselike_dir, xml_centric_cours
lxml.etree.ElementTree(asset_root).write(asset_xml_file, encoding='utf-8')

# export the static assets
set_custom_attribute("export_static_assets_started", str(courselike))
policies_dir = export_fs.makedir('policies', recreate=True)
if self.contentstore:
self.contentstore.export_all_for_course(
Expand Down Expand Up @@ -248,24 +251,28 @@ def process_extra(self, root, courselike, root_courselike_dir, xml_centric_cours
course_image_file.write(course_image.data)

# export the static tabs
set_custom_attribute("export_tabs_started", str(courselike))
export_extra_content(
export_fs, self.modulestore, self.courselike_key, xml_centric_courselike_key,
'static_tab', 'tabs', '.html'
)

# export the custom tags
set_custom_attribute("export_custom_tags_started", str(courselike))
export_extra_content(
export_fs, self.modulestore, self.courselike_key, xml_centric_courselike_key,
'custom_tag_template', 'custom_tags'
)

# export the course updates
set_custom_attribute("export_course_updates_started", str(courselike))
export_extra_content(
export_fs, self.modulestore, self.courselike_key, xml_centric_courselike_key,
'course_info', 'info', '.html'
)

# export the 'about' data (e.g. overview, etc.)
set_custom_attribute("export_about_started", str(courselike))
export_extra_content(
export_fs, self.modulestore, self.courselike_key, xml_centric_courselike_key,
'about', 'about', '.html'
Expand All @@ -280,10 +287,12 @@ def process_extra(self, root, courselike, root_courselike_dir, xml_centric_cours
sort_keys=True, indent=4).encode('utf-8'))

# export all of the course metadata in policy.json
set_custom_attribute("export_policy_started", str(courselike))
with course_run_policy_dir.open('policy.json', 'wb') as course_policy:
policy = {'course/' + courselike.location.run: own_metadata(courselike)}
course_policy.write(dumps(policy, cls=EdxJSONEncoder, sort_keys=True, indent=4).encode('utf-8'))

set_custom_attribute("export_drafts_started", str(courselike))
_export_drafts(self.modulestore, self.courselike_key, export_fs, xml_centric_courselike_key)

courselike_key_str = str(self.courselike_key)
Expand Down
Loading