Beispiel #1
0
def on_unregister_file_sending(transfer_id,
                               status,
                               bytes_sent,
                               error_message=None):
    """
    Called from transport plug-in after finish sending a single file.
    """
    if transfer_id is None:
        return False
    if _Debug:
        lg.out(
            _DebugLevel,
            'gateway.on_unregister_file_sending %s %s' % (transfer_id, status))
    pkt_out, work_item = packet_out.search_by_transfer_id(transfer_id)
    if pkt_out is None:
        if _Debug:
            lg.out(_DebugLevel, '        %s is not found' % str(transfer_id))
        return False
    pkt_out.automat('unregister-item',
                    (transfer_id, status, bytes_sent, error_message))
    control.request_update([('stream', transfer_id)])
    if status == 'finished':
        if _Debug:
            lg.out(
                _DebugLevel, '>>> OUT >>> %s (%d) [%s://%s] %s with %d bytes' %
                (pkt_out.description, transfer_id, work_item.proto,
                 work_item.host, status.upper(), bytes_sent))
    else:
        if _Debug:
            lg.out(
                _DebugLevel, '>>> OUT >>> %s (%d) [%s://%s] %s : %s' %
                (pkt_out.description, transfer_id, work_item.proto,
                 work_item.host, str(status).upper(), error_message))
    return True
Beispiel #2
0
def cancel_output_file(transferID, why=None):
    pkt_out, work_item = packet_out.search_by_transfer_id(transferID)
    if pkt_out is None:
        lg.warn("%s is not found" % str(transferID))
        return False
    pkt_out.automat("cancel", why)
    if _Debug:
        lg.out(_DebugLevel - 4, "gateway.cancel_output_file    %s" % transferID)
    return True
Beispiel #3
0
def cancel_outbox_file_by_transfer_id(transferID, why=None):
    pkt_out, _ = packet_out.search_by_transfer_id(transferID)
    if pkt_out is None:
        lg.warn('%s is not found' % str(transferID))
        return False
    if _Debug:
        lg.out(_DebugLevel - 4,
               'gateway.cancel_outbox_file_by_transfer_id : %s' % transferID)
    pkt_out.automat('cancel', why)
    return True
Beispiel #4
0
def on_unregister_file_sending(transfer_id, status, bytes_sent, error_message=None):
    """
    Called from transport plug-in after finish sending a single file.
    """
    if transfer_id is None:
        return False
    if _Debug:
        lg.out(_DebugLevel, "gateway.on_unregister_file_sending %s %s" % (transfer_id, status))
    pkt_out, work_item = packet_out.search_by_transfer_id(transfer_id)
    if pkt_out is None:
        if _Debug:
            lg.out(_DebugLevel, "        %s is not found" % str(transfer_id))
        return False
    pkt_out.automat("unregister-item", (transfer_id, status, bytes_sent, error_message))
    control.request_update([("stream", transfer_id)])
    if status == "finished":
        if _Debug:
            lg.out(
                _DebugLevel,
                ">>> OUT >>> %s (%d) [%s://%s] %s with %d bytes"
                % (pkt_out.description, transfer_id, work_item.proto, work_item.host, status.upper(), bytes_sent),
            )
    else:
        if _Debug:
            lg.out(
                _DebugLevel,
                ">>> OUT >>> %s (%d) [%s://%s] %s : %s"
                % (
                    pkt_out.description,
                    transfer_id,
                    work_item.proto,
                    work_item.host,
                    str(status).upper(),
                    error_message,
                ),
            )
    return True