Пример #1
0
class FileServices(Service):
    @rpc(Mandatory.Unicode, _returns=ByteArray(encoding='hex'))
    def get(ctx, file_name):
        path = os.path.join(os.path.abspath('./files'), file_name)
        if not path.startswith(os.path.abspath('./files')):
            raise ValidationError(file_name)

        try:
            f = open(path, 'rb')
        except IOError:
            raise ResourceNotFoundError(file_name)

        ctx.transport.resp_headers['Content-Disposition'] = (
            'attachment; filename=%s;' % file_name)

        data = f.read(BLOCK_SIZE)
        while len(data) > 0:
            yield data

            data = f.read(BLOCK_SIZE)

        f.close()

    @rpc(Unicode, Unicode, Unicode, ByteArray(min_occurs=1, nullable=False))
    def add(ctx, person_type, action, file_name, file_data):
        logger.info("Person Type: %r" % person_type)
        logger.info("Action: %r" % action)

        path = os.path.join(os.path.abspath('./files'), file_name)
        if not path.startswith(os.path.abspath('./files')):
            raise ValidationError(file_name)

        f = open(path, 'wb')  # if this fails, the client will see an
        # internal error.

        try:
            for data in file_data:
                f.write(data)

            logger.debug("File written: %r" % file_name)

            f.close()

        except:
            f.close()
            os.remove(path)
            logger.debug("File removed: %r" % file_name)
            raise  # again, the client will see an internal error.
Пример #2
0
class MessageResponseType(ComplexModel):
    __namespace__ = SOAP_NAMESPACE

    response = ByteArray.customize(min_occurs=1, nillable=False)

    def __init__(self):
        super(
            MessageResponseType,
            self).__init__(doc=u'Ответ в формате HL7, закодированный в base64')
Пример #3
0
class Mandatory(object):
    """
    This is spyne.model.primitive.Mandatory, but without min_length=1 for
    the Unicode model.
    """
    Unicode = Unicode(type_name='mandatory_unicode', min_occurs=1, nillable=False)
    Integer = Integer(type_name='mandatory_integer', min_occurs=1, nillable=False)
    Boolean = Boolean(type_name='mandatory_boolean', min_occurs=1, nillable=False)
    DateTime = DateTime(type_name='mandatory_date_time', min_occurs=1, nillable=False)
    ByteArray = ByteArray(type_name='mandatory_byte_array', min_occurs=1, nillable=False)
Пример #4
0
class GIBSoapService(ServiceBase):
    @rpc(Unicode(sub_name="fileName"),
         ByteArray(sub_name='binaryData'),
         ByteArray(sub_name="hash"),
         _returns=documentResponse)
    def documentRequest(ctx, file_name, file_data, data_hash):
        incoming_invoice_dir = os.getcwd()

        logger.info("file_name  %r" % file_name)
        logger.info("file_hash: %r" % data_hash)

        path = os.path.join(incoming_invoice_dir, file_name)

        f = open(path, 'wb')
        for data in file_data:
            f.write(data)
        logger.info("File written: %r" % file_name)
        f.close()

        resp = documentResponse()
        resp.msg = "Document was written successfully"
        resp.hash = data_hash

        return resp
Пример #5
0
class MessageRequestType(ComplexModel):
    __namespace__ = SOAP_NAMESPACE

    format = RequestFormatType.customize(
        min_occurs=1,
        max_occurs=1,
        doc=u'Допустимые форматы входных сообщений')
    message = ByteArray.customize(
        min_occurs=1,
        max_occurs=1,
        doc=u'Сообщение в формате HL7 или XML, закодированное в base64')

    def __init__(self):
        super(MessageRequestType, self).__init__(
            doc=u'Содержит входные данные для вызова REST сервиса ЭлРег')
Пример #6
0
class PrintableDocument(ComplexModel):
    __namespace__ = SOAP_NAMESPACE

    printableVersionTitle = Unicode(
        doc=
        u'Название элетронного документа, прилагаемого к данным о статусе заявления'
    )
    printableVersion = ByteArray(
        doc=
        u'Содержание элетронного документа, прилагаемого к данным о статусе заявления'
    )
    printableVersionMimeType = String(
        doc=
        u'Тип содержания (mime-type) элетронного документа, прилагаемого к данным о статусе заявления.'
    )

    def __init__(self, **kwargs):
        super(PrintableDocument, self).__init__(
            doc=
            u'Данные электронного документа, который может быть приложен к информации о статусе заявки',
            **kwargs)
Пример #7
0
 class SomeService(ServiceBase):
     @srpc(ByteArray(nullable=False), _returns=ByteArray)
     def some_call(p):
         pass
Пример #8
0
 class SomeService(ServiceBase):
     @srpc(ByteArray(min_occurs=1), _returns=ByteArray)
     def some_call(p):
         pass
Пример #9
0
class TaskQueue(TableModel):
    __tablename__ = 'task_queue'

    id = Integer32(primary_key=True)
    data = ByteArray(nullable=False)
Пример #10
0
        class Product(ComplexModel):
            __namespace__ = 'some_ns'

            hex = ByteArray(encoding='hex')
            base64_1 = ByteArray(encoding='base64')
            base64_2 = ByteArray