Esempio n. 1
0
def exportIpod(request, client, filename):
    """
    Export 'client' to an iPod Notes folder tree
    'webDir' is just read from config.webDir
    """
    try:
        # filename is a directory where we will export the notes 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(_('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(_('Folder name %s already exists. '
                            'Please choose another one or delete existing one then try again.') % filename)
            return
        # Now do the export
        ipodExport = IpodExport(self.config, filename)
        ipodExport.export(package)
    except Exception as e:
        client.alert(_('EXPORT FAILED!\n%s') % str(e))
        raise
    client.alert(_('Exported to %s') % filename)
Esempio n. 2
0
def exportIpod(request, client, filename):
    """
    Export 'client' to an iPod Notes folder tree
    'webDir' is just read from config.webDir
    """
    try:
        # filename is a directory where we will export the notes 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(
                _('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(
                _('Folder name %s already exists. '
                  'Please choose another one or delete existing one then try again.'
                  ) % filename)
            return
        # Now do the export
        ipodExport = IpodExport(self.config, filename)
        ipodExport.export(package)
    except Exception as e:
        client.alert(_('EXPORT FAILED!\n%s') % str(e))
        raise
    client.alert(_('Exported to %s') % filename)
Esempio n. 3
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(
                _('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(
                _('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 as e:
        client.alert(_('SAVE FAILED!\n%s' % str(e)))
        raise
    # Show the newly exported web site in a new window
    if not printFlag:
        self._startFile(client, filename)
    # and return a string of the actual directory name,
    # in case the package name was added, etc.:
    return filename.abspath().encode('utf-8')
Esempio n. 4
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 as e:
        log.error("EXPORT FAILED! %s" % filename)
        raise
Esempio n. 5
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 as e:
        log.error("EXPORT FAILED! %s" % filename)
        raise
Esempio n. 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(_('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(_('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 as e:
        client.alert(_('SAVE FAILED!\n%s' % str(e)))
        raise
    # Show the newly exported web site in a new window
    if not printFlag:
       self._startFile(client, filename)
    # and return a string of the actual directory name,
    # in case the package name was added, etc.:
    return filename.abspath().encode('utf-8')
Esempio n. 7
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(
                _('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(
                _('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 as e:
        client.alert(_('EXPORT FAILED!\n%s') % str(e))
        raise

    # show new presentation in a new window
    self._startFile(client, filename)
Esempio n. 8
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(_('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(_('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 as e:
        client.alert(_('EXPORT FAILED!\n%s') % str(e))
        raise

    # show new presentation in a new window
    self._startFile(client, filename)