Ejemplo n.º 1
0
def export(course, export_dir):
    """Export the specified course to course_dir.  Creates dir if it doesn't exist.
    Overwrites files, does not clean out dir beforehand.
    """
    fs = OSFS(export_dir, create=True)
    if not fs.isdirempty("."):
        print ("WARNING: Directory {dir} not-empty." "  May clobber/confuse things".format(dir=export_dir))

    try:
        xml = course.export_to_xml(fs)
        with fs.open("course.xml", mode="w") as f:
            f.write(xml)

        return True
    except:
        print "Export failed!"
        traceback.print_exc()

    return False
Ejemplo n.º 2
0
def export(course, export_dir):
    """Export the specified course to course_dir.  Creates dir if it doesn't exist.
    Overwrites files, does not clean out dir beforehand.
    """
    fs = OSFS(export_dir, create=True)
    if not fs.isdirempty('.'):
        print ('WARNING: Directory {dir} not-empty.'
               '  May clobber/confuse things'.format(dir=export_dir))

    try:
        xml = course.export_to_xml(fs)
        with fs.open('course.xml', mode='w') as f:
            f.write(xml)

        return True
    except:
        print 'Export failed!'
        traceback.print_exc()

    return False
Ejemplo n.º 3
0
def export(course, export_dir):
    """Export the specified course to course_dir.  Creates dir if it doesn't exist.
    Overwrites files, does not clean out dir beforehand.
    """
    fs = OSFS(export_dir, create=True)
    if not fs.isdirempty('.'):
        print ('WARNING: Directory {dir} not-empty.'
               '  May clobber/confuse things'.format(dir=export_dir))

    try:
        course.runtime.export_fs = fs
        root = lxml.etree.Element('root')
        course.add_xml_to_node(root)
        with fs.open('course.xml', mode='w') as f:
            root.write(f)

        return True
    except:
        print 'Export failed!'
        traceback.print_exc()

    return False
Ejemplo n.º 4
0
def export(course, export_dir):
    """
    Export the specified course to course_dir.  Creates dir if it doesn't
    exist.  Overwrites files, does not clean out dir beforehand.
    """
    fs = OSFS(export_dir, create=True)
    if not fs.isdirempty('.'):
        print(u'WARNING: Directory {dir} not-empty.  May clobber/confuse things'.format(dir=export_dir))

    try:
        course.runtime.export_fs = fs
        root = lxml.etree.Element('root')
        course.add_xml_to_node(root)
        with fs.open('course.xml', mode='w') as f:
            root.write(f)

        return True
    except:
        print('Export failed!')
        traceback.print_exc()

    return False