Пример #1
0
def binarychunk_submit(request):
    """Accepts requests which contain a packetized chunk of binary data 
    uploaded for an encounter whose text has already been submitted but is 
    waiting for all binary from the mobile client to be received prior to 
    uploading to the data store. 
        
    Note: There is a naming inconsistency between this function's use of 
    procedure_guid and that of the register_saved_procedure function.

    Request parameters, per BinaryChunkSubmitForm.
    
    Parameters:
        request
            A binary chunk sent from a client.
    """    
    response = ''
    form = BinaryPacketForm(request.POST, request.FILES)

    if form.is_valid():
        logging.info("Received valid binarychunk form")

        procedure_guid = form.cleaned_data['procedure_guid']
        element_id = form.cleaned_data['element_id']
        element_type = form.cleaned_data['element_type']
        binary_guid = form.cleaned_data['binary_guid']
        file_size = form.cleaned_data['file_size']
        byte_start = form.cleaned_data['byte_start']
        byte_end = form.cleaned_data['byte_end']
        byte_data = form.cleaned_data['byte_data']
        logging.info("File _size: %s" % file_size )

        try:
            result, message = register_binary_chunk(procedure_guid,
                                                    element_id,
                                                    element_type,
                                                    binary_guid,
                                                    file_size,
                                                    byte_start,
                                                    byte_end,
                                                    byte_data.chunks())
            if result:
                response = succeed("Successfully saved binary chunk: %s" 
                                        % message)
            else:
                response = fail("Failed to save the binary chunk: %s" 
                                     % message)
        except Exception, e:
            et, val, tb = sys.exc_info()
            trace = traceback.format_tb(tb)
            error = "Exception : %s %s %s" % (et, val, trace[0])
            for tbm in trace:
                logging.error(tbm)
            response = fail(error)
        logging.info("Finished processing binarychunk form")
Пример #2
0
def binarychunk_submit(request):
    """Accepts requests which contain a packetized chunk of binary data 
    uploaded for an encounter whose text has already been submitted but is 
    waiting for all binary from the mobile client to be received prior to 
    uploading to the data store. 
        
    Note: There is a naming inconsistency between this function's use of 
    procedure_guid and that of the register_saved_procedure function.

    Request parameters, per BinaryChunkSubmitForm.
    
    Parameters:
        request
            A binary chunk sent from a client.
    """
    response = ''
    form = BinaryPacketForm(request.POST, request.FILES)

    if form.is_valid():
        logging.info("Received valid binarychunk form")

        procedure_guid = form.cleaned_data['procedure_guid']
        element_id = form.cleaned_data['element_id']
        element_type = form.cleaned_data['element_type']
        binary_guid = form.cleaned_data['binary_guid']
        file_size = form.cleaned_data['file_size']
        byte_start = form.cleaned_data['byte_start']
        byte_end = form.cleaned_data['byte_end']
        byte_data = form.cleaned_data['byte_data']
        logging.info("File _size: %s" % file_size)

        try:
            result, message = register_binary_chunk(procedure_guid, element_id,
                                                    element_type, binary_guid,
                                                    file_size,
                                                    byte_start, byte_end,
                                                    byte_data.chunks())
            if result:
                response = succeed("Successfully saved binary chunk: %s" %
                                   message)
            else:
                response = fail("Failed to save the binary chunk: %s" %
                                message)
        except Exception, e:
            et, val, tb = sys.exc_info()
            trace = traceback.format_tb(tb)
            error = "Exception : %s %s %s" % (et, val, trace[0])
            for tbm in trace:
                logging.error(tbm)
            response = fail(error)
        logging.info("Finished processing binarychunk form")
Пример #3
0
def binarychunk_hack_submit(request):
    """Accepts requests which contain a packetized chunk of binary data 
    encoded as base64 text for an encounter whose text has already been 
    submitted but waiting for all binary data from the mobile client to be 
    received prior to uploading to the data store
        
    Note: There is a naming inconsistency between this function's use of 
    procedure_guid and that of the register_saved_procedure function.
    
    Parameters
        request
            A client request.
    """
    response = ''
    form = Base64PacketForm(request.POST, request.FILES)

    if form.is_valid():
        logging.info("Received valid binarychunk-hack form")

        procedure_guid = form.cleaned_data['procedure_guid']
        element_id = form.cleaned_data['element_id']
        element_type = form.cleaned_data['element_type']
        binary_guid = form.cleaned_data['binary_guid']
        file_size = form.cleaned_data['file_size']
        byte_start = form.cleaned_data['byte_start']
        byte_end = form.cleaned_data['byte_end']
        byte_data = form.cleaned_data['byte_data']

        # This hack submits byte_data as base64 encoded, so decode it.
        byte_data = byte_data.decode('base64')

        try:
            result, message = register_binary_chunk(procedure_guid, element_id,
                                                    element_type, binary_guid,
                                                    file_size, byte_start,
                                                    byte_end, [
                                                        byte_data,
                                                    ])
            if result:
                response = succeed("Successfully saved the binary chunk: %s" %
                                   message)
            else:
                response = fail("Failed to save the binary chunk: %s" %
                                message)
        except Exception, e:
            logging.error("registering binary chunk failed: %s" % e)
            response = fail("Registering binary chunk failed: %s" % e)
        logging.info("Finished processing binarychunk form")
Пример #4
0
def binarychunk_hack_submit(request):
    """Accepts requests which contain a packetized chunk of binary data 
    encoded as base64 text for an encounter whose text has already been 
    submitted but waiting for all binary data from the mobile client to be 
    received prior to uploading to the data store
        
    Note: There is a naming inconsistency between this function's use of 
    procedure_guid and that of the register_saved_procedure function.
    
    Parameters
        request
            A client request.
    """    
    response = ''
    form = Base64PacketForm(request.POST, request.FILES)

    if form.is_valid():
        logging.info("Received valid binarychunk-hack form")

        procedure_guid = form.cleaned_data['procedure_guid']
        element_id = form.cleaned_data['element_id']
        element_type = form.cleaned_data['element_type']
        binary_guid = form.cleaned_data['binary_guid']
        file_size = form.cleaned_data['file_size']
        byte_start = form.cleaned_data['byte_start']
        byte_end = form.cleaned_data['byte_end']
        byte_data = form.cleaned_data['byte_data']

        # This hack submits byte_data as base64 encoded, so decode it.
        byte_data = byte_data.decode('base64')

        try:
            result, message = register_binary_chunk(procedure_guid,
                                                    element_id,
                                                    element_type,
                                                    binary_guid,
                                                    file_size,
                                                    byte_start,
                                                    byte_end,
                                                    [byte_data,])
            if result:
                response = succeed("Successfully saved the binary chunk: %s" % message)
            else:
                response = fail("Failed to save the binary chunk: %s" % message)
        except Exception, e:
            logging.error("registering binary chunk failed: %s" % e)
            response = fail("Registering binary chunk failed: %s" % e)
        logging.info("Finished processing binarychunk form")