def export_courses_to_output_path(output_path):
 content_store = contentstore()
 module_store = modulestore()
 root_dir = output_path
 courses = module_store.get_courses()
 course_ids = [x.id for x in courses]
 failed_export_courses = []
 for course_id in course_ids:
  print (u'-' * 80)
  print u'Exporting course id = {0} to {1}'.format(course_id, output_path)
  try:
   course_dir = course_id.to_deprecated_string().replace('/', '...')
   export_course_to_xml(module_store, content_store, course_id, root_dir, course_dir)
  except Exception as err:
   failed_export_courses.append(unicode(course_id))
   print ((u'=' * 30) + u'> Oops, failed to export {0}'.format(course_id))
   print u'Error:'
   print err
 return (courses, failed_export_courses)

def export_courses_to_output_path ( output_path ) : content_store = contentstore ( ) module_store = modulestore ( ) root_dir = output_path courses = module_store . get_courses ( ) course_ids = [ x . id for x in courses ] failed_export_courses = [ ] for course_id in course_ids : print ( u'-' * 80 ) print u'Exporting course id = {0} to {1}' . format ( course_id , output_path ) try : course_dir = course_id . to_deprecated_string ( ) . replace ( '/' , '...' ) export_course_to_xml ( module_store , content_store , course_id , root_dir , course_dir ) except Exception as err : failed_export_courses . append ( unicode ( course_id ) ) print ( ( u'=' * 30 ) + u'> Oops, failed to export {0}' . format ( course_id ) ) print u'Error:' print err return ( courses , failed_export_courses )
export all courses to target directory and return the list of courses which failed to export .