Exemple #1
0
def exportText(self, client, filename):
    try:
        filename = Path(filename)
        log.debug(u"exportWebsite, filename=%s" % filename)
        # Append an extension if required
        if not filename.lower().endswith(".txt"):
            filename += ".txt"
            if Path(filename).exists():
                msg = _(u'"%s" already exists.\nPlease try again with a different filename') % filename
                client.alert(_(u"EXPORT FAILED!\n%s" % msg))
                return
        # Do the export
        textExport = TextExport(filename)
        textExport.export(package)
    except Exception, e:
        client.alert(_("EXPORT FAILED!\n%s" % str(e)))
        raise
def exportText(self, client, filename):
    try:
        filename = Path(filename)
        log.debug(u"exportWebsite, filename=%s" % filename)
        # Append an extension if required
        if not filename.lower().endswith('.txt'):
            filename += '.txt'
            if Path(filename).exists():
                msg = _(
                    u'"%s" already exists.\nPlease try again with a different filename'
                ) % filename
                client.alert(_(u'EXPORT FAILED!\n%s' % msg))
                return
        # Do the export
        textExport = TextExport(filename)
        textExport.export(package)
    except Exception, e:
        client.alert(_('EXPORT FAILED!\n%s' % str(e)))
        raise
Exemple #3
0
def exportScorm(request, client, filename, stylesDir, scormType):
    """
    Exports this package to a scorm package file
    """
    try:
        filename = Path(filename)
        log.debug(u"exportScorm, filename=%s" % filename)
        # Append an extension if required
        if not filename.lower().endswith(".zip"):
            filename += ".zip"
            if Path(filename).exists():
                msg = _(u'"%s" already exists.\nPlease try again with a different filename') % filename
                client.alert(_(u"EXPORT FAILED!\n%s" % msg))
                return
        # Do the export
        scormExport = ScormExport(self.config, stylesDir, filename, scormType)
        scormExport.export(package)
    except Exception, e:
        client.alert(_("EXPORT FAILED!\n%s" % str(e)))
        raise
def extractPackage(request, package, filename, existOk):
    """
    Create a new package consisting of the current node and export
    'existOk' means the user has been informed of existance and ok'd it
    """
    filename = Path(filename)
    saveDir = filename.dirname()
    if saveDir and not saveDir.exists():
        client.alert(
            _(u'Cannot access directory named ') + unicode(saveDir) +
            _(u'. Please use ASCII names.'))
        return

    # Add the extension if its not already there
    if not filename.lower().endswith('.elp'):
        filename += '.elp'

    if Path(filename).exists() and existOk != 'true':
        msg = _(
            u'"%s" already exists.\nPlease try again with a different filename'
        ) % filename
        client.alert(_(u'EXTRACT FAILED!\n%s' % msg))
        return

    try:
        # Create a new package for the extracted nodes
        newPackage = package.extractNode()

        # trigger a rename of all of the internal nodes and links,
        # and to remove any old anchors from the dest package,
        # and remove any zombie links via isExtract:
        newNode = newPackage.root
        if newNode:
            newNode.RenamedNodePath(isExtract=True)

        # Save the new package
        newPackage.save(filename)
    except Exception, e:
        client.alert(_('EXTRACT FAILED!\n%s' % str(e)))
        raise
def exportScorm(request, client, filename, stylesDir, scormType):
    """
    Exports this package to a scorm package file
    """
    try:
        filename = Path(filename)
        log.debug(u"exportScorm, filename=%s" % filename)
        # Append an extension if required
        if not filename.lower().endswith('.zip'):
            filename += '.zip'
            if Path(filename).exists():
                msg = _(
                    u'"%s" already exists.\nPlease try again with a different filename'
                ) % filename
                client.alert(_(u'EXPORT FAILED!\n%s' % msg))
                return
        # Do the export
        scormExport = ScormExport(self.config, stylesDir, filename, scormType)
        scormExport.export(package)
    except Exception, e:
        client.alert(_('EXPORT FAILED!\n%s' % str(e)))
        raise
Exemple #6
0
def extractPackage(request, package, filename, existOk):

    """
    Create a new package consisting of the current node and export
    'existOk' means the user has been informed of existance and ok'd it
    """
    filename = Path(filename)
    saveDir = filename.dirname()
    if saveDir and not saveDir.exists():
        client.alert(_(u"Cannot access directory named ") + unicode(saveDir) + _(u". Please use ASCII names."))
        return

    # Add the extension if its not already there
    if not filename.lower().endswith(".elp"):
        filename += ".elp"

    if Path(filename).exists() and existOk != "true":
        msg = _(u'"%s" already exists.\nPlease try again with a different filename') % filename
        client.alert(_(u"EXTRACT FAILED!\n%s" % msg))
        return

    try:
        # Create a new package for the extracted nodes
        newPackage = package.extractNode()

        # trigger a rename of all of the internal nodes and links,
        # and to remove any old anchors from the dest package,
        # and remove any zombie links via isExtract:
        newNode = newPackage.root
        if newNode:
            newNode.RenamedNodePath(isExtract=True)

        # Save the new package
        newPackage.save(filename)
    except Exception, e:
        client.alert(_("EXTRACT FAILED!\n%s" % str(e)))
        raise