Exemple #1
0
def exportPresentation(request, client, filename, stylesDir):
    """
    export client to a DOM presentation
    """

    try:
        # filename is a directory where we will export the website to
        # We assume that the user knows what they are doing
        # and don't check if the directory is already full or not
        # and we just overwrite what's already there
        filename = Path(filename)
        # Append the package name to the folder path if necessary
        if filename.basename() != package.name:
            filename /= package.name
        if not filename.exists():
            filename.makedirs()
        elif not filename.isdir():
            client.alert(_(u"Filename %s is a file, cannot replace it") % filename)
            log.error("Couldn't export web page: " + "Filename %s is a file, cannot replace it" % filename)
            return
        else:
            client.alert(
                _(u"Folder name %s already exists. " "Please choose another one or delete existing one then try again.")
                % filename
            )
            return
        # Now do the export
        presentationExport = PresentationExport(self.config, stylesDir, filename)
        presentationExport.export(package)
    except Exception, e:
        client.alert(_("EXPORT FAILED!\n%s") % str(e))
        raise
def exportPresentation(request, client, filename, stylesDir):
    """
    export client to a DOM presentation
    """

    try:
        # filename is a directory where we will export the website to
        # We assume that the user knows what they are doing
        # and don't check if the directory is already full or not
        # and we just overwrite what's already there
        filename = Path(filename)
        # Append the package name to the folder path if necessary
        if filename.basename() != package.name:
            filename /= package.name
        if not filename.exists():
            filename.makedirs()
        elif not filename.isdir():
            client.alert(
                _(u'Filename %s is a file, cannot replace it') % filename)
            log.error("Couldn't export web page: " +
                      "Filename %s is a file, cannot replace it" % filename)
            return
        else:
            client.alert(
                _(u'Folder name %s already exists. '
                  'Please choose another one or delete existing one then try again.'
                  ) % filename)
            return
        # Now do the export
        presentationExport = PresentationExport(self.config, stylesDir,
                                                filename)
        presentationExport.export(package)
    except Exception, e:
        client.alert(_('EXPORT FAILED!\n%s') % str(e))
        raise
Exemple #3
0
def exportWebSite2(request, client, filename, stylesDir):
    """Overwrite allowed, proceed"""
    try:
        filename = Path(filename)
        if filename.exists():
            if filename.isdir():
                shutil.rmtree(filename)
            else:
                os.remove(filename)
        filename.makedirs()
        websiteExport = WebsiteExport(self.config, stylesDir, filename)
        websiteExport.export(package)
        self._startFile(client, filename)
    except Exception, e:
        log.error("EXPORT FAILED! %s" % filename)
        raise
def exportWebSite2(request, client, filename, stylesDir):
    '''Overwrite allowed, proceed'''
    try:
        filename = Path(filename)
        if filename.exists():
            if filename.isdir():
                shutil.rmtree(filename)
            else:
                os.remove(filename)
        filename.makedirs()
        websiteExport = WebsiteExport(self.config, stylesDir, filename)
        websiteExport.export(package)
        self._startFile(client, filename)
    except Exception, e:
        log.error("EXPORT FAILED! %s" % filename)
        raise
def exportSinglePage(request, client, filename, webDir, stylesDir, \
                     printFlag):
    """
    Export 'client' to a single web page,
    'webDir' is just read from config.webDir
    'stylesDir' is where to copy the style sheet information from
    'printFlag' indicates whether or not this is for print 
                (and whatever else that might mean)
    """
    try:
        imagesDir = webDir.joinpath('images')
        scriptsDir = webDir.joinpath('scripts')
        templatesDir = webDir.joinpath('templates')
        # filename is a directory where we will export the website to
        # We assume that the user knows what they are doing
        # and don't check if the directory is already full or not
        # and we just overwrite what's already there
        filename = Path(filename)
        # Append the package name to the folder path if necessary
        if filename.basename() != package.name:
            filename /= package.name
        if not filename.exists():
            filename.makedirs()
        elif not filename.isdir():
            client.alert(
                _(u'Filename %s is a file, cannot replace it') % filename)
            log.error("Couldn't export web page: " +
                      "Filename %s is a file, cannot replace it" % filename)
            return
        else:
            client.alert(
                _(u'Folder name %s already exists. '
                  'Please choose another one or delete existing one then try again.'
                  ) % filename)
            return
        # Now do the export
        singlePageExport = SinglePageExport(stylesDir, filename, \
                                     imagesDir, scriptsDir, templatesDir)
        singlePageExport.export(package, printFlag)
    except Exception, e:
        client.alert(_('SAVE FAILED!\n%s' % str(e)))
        raise
Exemple #6
0
def exportSinglePage(request, client, filename, webDir, stylesDir, printFlag):
    """
    Export 'client' to a single web page,
    'webDir' is just read from config.webDir
    'stylesDir' is where to copy the style sheet information from
    'printFlag' indicates whether or not this is for print 
                (and whatever else that might mean)
    """
    try:
        imagesDir = webDir.joinpath("images")
        scriptsDir = webDir.joinpath("scripts")
        templatesDir = webDir.joinpath("templates")
        # filename is a directory where we will export the website to
        # We assume that the user knows what they are doing
        # and don't check if the directory is already full or not
        # and we just overwrite what's already there
        filename = Path(filename)
        # Append the package name to the folder path if necessary
        if filename.basename() != package.name:
            filename /= package.name
        if not filename.exists():
            filename.makedirs()
        elif not filename.isdir():
            client.alert(_(u"Filename %s is a file, cannot replace it") % filename)
            log.error("Couldn't export web page: " + "Filename %s is a file, cannot replace it" % filename)
            return
        else:
            client.alert(
                _(u"Folder name %s already exists. " "Please choose another one or delete existing one then try again.")
                % filename
            )
            return
        # Now do the export
        singlePageExport = SinglePageExport(stylesDir, filename, imagesDir, scriptsDir, templatesDir)
        singlePageExport.export(package, printFlag)
    except Exception, e:
        client.alert(_("SAVE FAILED!\n%s" % str(e)))
        raise