示例#1
0
    def _transmit(self, queue_item, subscriber):
        config = queue_item.get("destination", {}).get("config", {})

        try:
            with ftp_connect(config) as ftp:

                if config.get("push_associated", False):
                    # Set the working directory for the associated files
                    if "associated_path" in config and config.get(
                            "associated_path"):
                        ftp.cwd("/" +
                                config.get("associated_path", "").lstrip("/"))

                    item = self._get_published_item(queue_item)
                    if item:
                        self._copy_published_media_files(item, ftp)

                    # If the directory was changed to push associated files change it back
                    if "associated_path" in config and config.get(
                            "associated_path"):
                        ftp.cwd("/" + config.get("path").lstrip("/"))

                filename = get_publish_service().get_filename(queue_item)
                b = BytesIO(
                    queue_item.get(
                        "encoded_item",
                        queue_item.get("formatted_item").encode("UTF-8")))
                ftp.storbinary("STOR " + filename, b)
        except PublishFtpError:
            raise
        except Exception as ex:
            raise PublishFtpError.ftpError(ex, queue_item.get("destination"))
示例#2
0
    def _transmit(self, queue_item, subscriber):
        config = queue_item.get('destination', {}).get('config', {})

        try:
            with ftp_connect(config) as ftp:

                if config.get('push_associated', False):
                    # Set the working directory for the associated files
                    if 'associated_path' in config and config.get('associated_path'):
                        ftp.cwd('/' + config.get('associated_path', '').lstrip('/'))

                    item = self._get_published_item(queue_item)
                    if item:
                        self._copy_published_media_files(item, ftp)

                    # If the directory was changed to push associated files change it back
                    if 'associated_path' in config and config.get('associated_path'):
                        ftp.cwd('/' + config.get('path').lstrip('/'))

                filename = get_publish_service().get_filename(queue_item)
                b = BytesIO(queue_item.get('encoded_item', queue_item.get('formatted_item').encode('UTF-8')))
                ftp.storbinary('STOR ' + filename, b)
        except PublishFtpError:
            raise
        except Exception as ex:
            raise PublishFtpError.ftpError(ex, config)
示例#3
0
 def _transmit(self, queue_item, subscriber):
     try:
         config = queue_item["destination"]["config"]
         file_path = config["file_path"]
         if not path.isabs(file_path):
             file_path = "/" + file_path
         with open(path.join(file_path, publish_service.get_publish_service().get_filename(queue_item)), "wb") as f:
             f.write(queue_item["encoded_item"])
     except Exception as ex:
         raise PublishFileError.fileSaveError(ex, config)
 def _transmit(self, queue_item, subscriber):
     try:
         config = queue_item['destination']['config']
         file_path = config['file_path']
         if not path.isabs(file_path):
             file_path = "/" + file_path
         with open(path.join(file_path, publish_service.get_publish_service().get_filename(queue_item)), 'wb') as f:
             f.write(queue_item['encoded_item'])
     except Exception as ex:
         raise PublishFileError.fileSaveError(ex, config)
示例#5
0
    def _transmit(self, queue_item, subscriber):
        config = queue_item.get("destination", {}).get("config", {})

        try:
            with ftp_connect(config) as ftp:
                filename = get_publish_service().get_filename(queue_item)
                b = BytesIO(queue_item["encoded_item"])
                ftp.storbinary("STOR " + filename, b)
        except PublishFtpError:
            raise
        except Exception as ex:
            raise PublishFtpError.ftpError(ex, config)
示例#6
0
    def _transmit(self, queue_item, subscriber):
        config = queue_item.get('destination', {}).get('config', {})

        try:
            with ftp_connect(config) as ftp:
                filename = get_publish_service().get_filename(queue_item)
                b = BytesIO(queue_item['encoded_item'])
                ftp.storbinary("STOR " + filename, b)
        except PublishFtpError:
            raise
        except Exception as ex:
            raise PublishFtpError.ftpError(ex, config)
示例#7
0
 def _transmit(self, queue_item, subscriber):
     try:
         config = queue_item['destination']['config']
         file_path = config['file_path']
         if not path.isabs(file_path):
             file_path = "/" + file_path
         with open(
                 path.join(
                     file_path,
                     publish_service.get_publish_service().get_filename(
                         queue_item)), 'wb') as f:
             f.write(queue_item['encoded_item'])
     except Exception as ex:
         raise PublishFileError.fileSaveError(ex, config)