Пример #1
0
def convertZIPEmail(context, auth_token, zip_archive, converter_name='pdf-prince', sender=None, recipient=None, subject=None, body=None):

    if not authorizeRequest(auth_token):
        msg = 'Authorization failed'
        LOG.error(msg, exc_info=True)
        return xmlrpclib.Fault(123, msg)

    try:
        return context.convertZIPEmail(zip_archive, converter_name, sender, recipient, subject, body)
    except Exception, e:
        msg = 'Conversion failed (%s)' % e
        LOG.error(msg, exc_info=True)
        return xmlrpclib.Fault(123, msg)
Пример #2
0
def convertZIP(context, auth_token, zip_archive, converter_name='pdf-prince'):

    if not authorizeRequest(auth_token):
        msg = 'Authorization failed'
        LOG.error(msg, exc_info=True)
        return xmlrpclib.Fault(123, msg)

    try:
        return context.convertZIP(zip_archive, converter_name)
    except Exception, e:
        msg = 'Conversion failed (%s)' % e
        LOG.error(msg, exc_info=True)
        return xmlrpclib.Fault(123, msg)
Пример #3
0
def convertZIPandRedirect(context, auth_token, zip_archive, converter_name='prince-pdf', prefix=None):
    """ This view appects a ZIP archive through a POST request containing all
        relevant information (similar to the XMLRPC API). However the converted
        output file is not returned to the caller but delivered "directly" through
        the SmartPrintNG server (through an URL redirection). The 'prefix'
        parameter can be used to override the basename of filename used within the
        content-disposition header.
        (This class is only a base class for the related http_ and xmlrpc_
         view (in order to avoid redudant code).)
    """

    if not authorizeRequest(auth_token):
        msg = 'Authorization failed'
        LOG.error(msg, exc_info=True)
        return xmlrpclib.Fault(123, msg)

    try:
        output_archivename, output_filename = context._processZIP(zip_archive, converter_name)
        output_ext = os.path.splitext(output_filename)[1]

        # take ident from archive name
        ident = os.path.splitext(os.path.basename(output_archivename))[0]

        # move output file to spool directory
        dest_filename = os.path.join(context.spool_directory, '%s%s' % (ident, output_ext))
        rel_output_filename = dest_filename.replace(context.spool_directory + os.sep, '')
        shutil.move(output_filename, dest_filename)
        host = 'localhost'
        port = 6543
        prefix = prefix or ''
        location = 'http://%s:%s/deliver?filename=%s&prefix=%s' % (host, port, rel_output_filename, prefix)
        return location
    except Exception, e:
        msg = 'Conversion failed (%s)' % e
        LOG.error(msg, exc_info=True)
        return xmlrpclib.Fault(123, msg)