예제 #1
0
def save_as(src_path,
            formats_options,
            indesign_server_url,
            indesign_client_workdir,
            indesign_server_workdir,
            indesign_server_path_style="posix",
            clean_workdir=True,
            ftp_params=None,
            logger=None,
            logger_extra=None):
    """SOAP call to an InDesign Server to convert an InDesign file. """

    if not logger:
        logger = logging.getLogger('simpleidml.indesign')
        logger.addHandler(logging.NullHandler())
    logger_extra = logger_extra or {}

    src_name = os.path.basename(src_path)
    src_client_copy_filename = os.path.join(indesign_client_workdir, src_name)
    ftp.copy(src_path, src_client_copy_filename, ftp_params)

    responses = [
        _save_as(src_name, format_options, indesign_server_url,
                 indesign_client_workdir, indesign_server_workdir,
                 indesign_server_path_style, ftp_params, clean_workdir, logger,
                 logger_extra) for format_options in formats_options
    ]

    if clean_workdir:
        ftp.unlink(src_client_copy_filename, ftp_params)

    return responses
예제 #2
0
 def copy_script_on_working_directory(self):
     javascript_master_filename = os.path.join(SCRIPTS_DIR, self.javascript_basename)
     self.javascript_client_copy_filename = os.path.join(self.client_workdir, self.javascript_basename)
     self.javascript_server_copy_filename = self.server_path_mod.join(self.server_workdir,
                                                                      self.javascript_basename)
     ftp.copy(javascript_master_filename, self.javascript_client_copy_filename,
              self.ftp_params, src_open_mode="rb")
예제 #3
0
 def copy_script_on_working_directory(self):
     javascript_master_filename = os.path.join(SCRIPTS_DIR,
                                               self.javascript_basename)
     self.javascript_client_copy_filename = os.path.join(
         self.client_workdir, self.javascript_basename)
     self.javascript_server_copy_filename = self.server_path_mod.join(
         self.server_workdir, self.javascript_basename)
     ftp.copy(javascript_master_filename,
              self.javascript_client_copy_filename,
              self.ftp_params,
              src_open_mode="rb")
예제 #4
0
def save_as(src_filename,
            dst_formats_params,
            indesign_server_url,
            indesign_client_workdir,
            indesign_server_workdir,
            indesign_server_path_style="posix",
            clean_workdir=True,
            ftp_params=None,
            logger=None,
            logger_extra=None):
    """SOAP call to an InDesign Server to make one or more conversions. """

    if not logger:
        logger = logging.getLogger('simpleidml.indesign')
        logger.addHandler(logging.NullHandler())
    logger_extra = logger_extra or {}

    def _save_as(dst_format_params):
        """
        o *_client_copy_filename : path/to/file as seen by the SOAP client.
        o *_server_copy_filename : localized/path/to/file as seen by the InDesign Server.
        """
        dst_format = dst_format_params["fmt"]
        js_params = dst_format_params.get("params", {})

        if dst_format in ('idml', 'pdf', 'jpeg'):
            klass = Export
        elif dst_format == 'zip':
            klass = PackageForPrint
        else:
            klass = SaveAs

        script = klass(src_filename, dst_format, js_params,
                       indesign_server_url, indesign_client_workdir,
                       indesign_server_workdir, indesign_server_path_style,
                       ftp_params, clean_workdir, logger, logger_extra)

        return script.execute()

    src_basename = os.path.basename(src_filename)
    src_client_copy_filename = os.path.join(indesign_client_workdir,
                                            src_basename)
    ftp.copy(src_filename, src_client_copy_filename, ftp_params)

    cl = Client("%s/service?wsdl" % indesign_server_url)
    cl.set_options(location=indesign_server_url, timeout=90)

    responses = [_save_as(fmt) for fmt in dst_formats_params]
    if clean_workdir:
        ftp.unlink(src_client_copy_filename, ftp_params)

    return responses
예제 #5
0
def save_as(src_filename, dst_formats_params, indesign_server_url, indesign_client_workdir,
            indesign_server_workdir, indesign_server_path_style="posix",
            clean_workdir=True, ftp_params=None, logger=None, logger_extra=None):
    """SOAP call to an InDesign Server to make one or more conversions. """

    if not logger:
        logger = logging.getLogger('simpleidml.indesign')
        logger.addHandler(logging.NullHandler())
    logger_extra = logger_extra or {}

    def _save_as(dst_format_params):
        """
        o *_client_copy_filename : path/to/file as seen by the SOAP client.
        o *_server_copy_filename : localized/path/to/file as seen by the InDesign Server.
        """
        dst_format = dst_format_params["fmt"]
        js_params = dst_format_params.get("params", {})

        if dst_format in ('idml', 'pdf', 'jpeg'):
            klass = Export
        elif dst_format == 'zip':
            klass = PackageForPrint
        else:
            klass = SaveAs

        script = klass(src_filename, dst_format, js_params, indesign_server_url, indesign_client_workdir,
                       indesign_server_workdir, indesign_server_path_style, ftp_params, clean_workdir,
                       logger, logger_extra)

        return script.execute()

    src_basename = os.path.basename(src_filename)
    src_client_copy_filename = os.path.join(indesign_client_workdir, src_basename)
    ftp.copy(src_filename, src_client_copy_filename, ftp_params)

    cl = Client("%s/service?wsdl" % indesign_server_url)
    cl.set_options(location=indesign_server_url, timeout=90)

    responses = [_save_as(fmt) for fmt in dst_formats_params]
    if clean_workdir:
        ftp.unlink(src_client_copy_filename, ftp_params)

    return responses