コード例 #1
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)
コード例 #2
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, PublishService.get_filename(queue_item)), 'wb') as f:
             f.write(queue_item['encoded_item'])
     except Exception as ex:
         raise PublishFileError.fileSaveError(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, PublishService.get_filename(queue_item)), 'wb') as f:
             f.write(queue_item['encoded_item'])
     except Exception as ex:
         raise PublishFileError.fileSaveError(ex, config)
コード例 #4
0
    def _transmit(self, queue_item, subscriber):
        config = queue_item.get('destination', {}).get('config', {})

        try:
            if isinstance(queue_item['formatted_item'], bytes):
                self.copy_file(config, queue_item)
            elif isinstance(queue_item['formatted_item'], str):
                queue_item['formatted_item'] = queue_item['formatted_item'].encode('utf-8')
                self.copy_file(config, queue_item)
            else:
                raise Exception
        except Exception as ex:
            raise PublishFileError.fileSaveError(ex, config)
コード例 #5
0
ファイル: file_output.py プロジェクト: Flowdeeps/superdesk-1
    def _transmit(self, formatted_item, subscriber, output_channel):
        config = output_channel.get('config', {})

        try:
            if isinstance(formatted_item['formatted_item'], bytes):
                self.copy_file(config, formatted_item)
            elif isinstance(formatted_item['formatted_item'], str):
                formatted_item['formatted_item'] = formatted_item['formatted_item'].encode('utf-8')
                self.copy_file(config, formatted_item)
            else:
                raise Exception
        except Exception as ex:
            raise PublishFileError.fileSaveError(ex, output_channel)
コード例 #6
0
ファイル: file_output.py プロジェクト: jey07ro/superdesk
    def _transmit(self, formatted_item, subscriber, output_channel):
        config = output_channel.get('config', {})

        try:
            item = formatted_item['formatted_item']
            if isinstance(item, bytes):
                with open('{}/{}-{}.{}'.format(config['file_path'], formatted_item['item_id'].replace(':', '-'),
                                               str(formatted_item.get('item_version', '')),
                                               'txt'), 'wb') as f:
                    f.write(item)
            else:
                raise Exception
        except Exception as ex:
            raise PublishFileError.fileSaveError(ex, output_channel)
コード例 #7
0
    def _transmit(self, queue_item, subscriber):
        config = queue_item.get('destination', {}).get('config', {})

        try:
            if isinstance(queue_item['formatted_item'], bytes):
                self.copy_file(config, queue_item)
            elif isinstance(queue_item['formatted_item'], str):
                queue_item['formatted_item'] = queue_item[
                    'formatted_item'].encode('utf-8')
                self.copy_file(config, queue_item)
            else:
                raise Exception
        except Exception as ex:
            raise PublishFileError.fileSaveError(ex, config)
コード例 #8
0
# -*- coding: utf-8; -*-
#
# This file is part of Superdesk.
#
# Copyright 2013, 2014 Sourcefabric z.u. and contributors.
#
# For the full copyright and license information, please see the
# AUTHORS and LICENSE files distributed with this source code, or
# at https://www.sourcefabric.org/superdesk/license

from superdesk.publish.publish_service import PublishService
from superdesk.publish import register_transmitter
from superdesk.errors import PublishFileError
from os import path

errors = [PublishFileError.fileSaveError().get_error_description()]


class FilePublishService(PublishService):
    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, PublishService.get_filename(queue_item)), 'wb') as f:
                f.write(queue_item['encoded_item'])
        except Exception as ex:
            raise PublishFileError.fileSaveError(ex, config)

コード例 #9
0
# -*- coding: utf-8; -*-
#
# This file is part of Superdesk.
#
# Copyright 2013, 2014 Sourcefabric z.u. and contributors.
#
# For the full copyright and license information, please see the
# AUTHORS and LICENSE files distributed with this source code, or
# at https://www.sourcefabric.org/superdesk/license

from superdesk.publish import publish_service
from superdesk.publish import register_transmitter
from superdesk.errors import PublishFileError
from os import path

errors = [PublishFileError.fileSaveError().get_error_description()]


class FilePublishService(publish_service.PublishService):
    """Superdesk file transmitter.

    It creates files on superdesk server in configured folder.
    """

    NAME = 'File'

    def _transmit(self, queue_item, subscriber):
        try:
            config = queue_item['destination']['config']
            file_path = config['file_path']
            if not path.isabs(file_path):