def success(src, idurl, host, port, conn):
        global _LastPingTimeDict
        global _ConnectionsDict

        if len(src) == 0:
            increase_receiving_delay(idurl)

        else:
            parts = src.splitlines()
            lg.out(14, 'http_node.receive.success %d bytes in %d parts from %s (%s:%s)' % (len(src), len(parts), idurl, host, port))
            for part64 in parts:
                try:
                    part = base64.b64decode(part64.strip())
                except:
                    lg.out(14, 'http_node.receive.success ERROR in base64.b64decode()')
#                    lg.out(1, 'len(part64)=%d' % len(part64))
#                    lg.out(1, 'len(part64.strip())=%d' % len(part64.strip()))
#                    lg.out(1, 'part64=[%s]' % part64)
                    decrease_receiving_delay(idurl)
                    continue
#                fd, filename = tempfile.mkstemp(".dhn-http-in")
                fd, filename = tmpfile.make("http-in", extension='.http')
                os.write(fd, part)
                os.close(fd)
                decrease_receiving_delay(idurl)
                transport_control.receiveStatusReport(
                    filename,
                    'finished',
                    'http',
                    host+':'+port,)
            transport_control.log('http', 'finish connection with %s:%s ' % (host, port))

        conn.disconnect()
        _ConnectionsDict.pop(idurl, None)
Example #2
0
    def success(src, idurl, host, port, conn):
        global _LastPingTimeDict
        global _ConnectionsDict

        if len(src) == 0:
            increase_receiving_delay(idurl)

        else:
            parts = src.splitlines()
            dhnio.Dprint(14, 'transport_http.receive.success %d bytes in %d parts from %s (%s:%s)' % (len(src), len(parts), idurl, host, port))
            for part64 in parts:
                try:
                    part = base64.b64decode(part64.strip())
                except:
                    dhnio.Dprint(14, 'transport_http.receive.success ERROR in base64.b64decode()')
#                    dhnio.Dprint(1, 'len(part64)=%d' % len(part64))
#                    dhnio.Dprint(1, 'len(part64.strip())=%d' % len(part64.strip()))
#                    dhnio.Dprint(1, 'part64=[%s]' % part64)
                    decrease_receiving_delay(idurl)
                    continue
#                fd, filename = tempfile.mkstemp(".dhn-http-in")
                fd, filename = tmpfile.make("http-in")
                os.write(fd, part)
                os.close(fd)
                decrease_receiving_delay(idurl)
                transport_control.receiveStatusReport(
                    filename,
                    'finished',
                    'http',
                    host+':'+port,)
            transport_control.log('http', 'finish connection with %s:%s ' % (host, port))

        conn.disconnect()
        _ConnectionsDict.pop(idurl, None)
Example #3
0
def assemble(file_id, skype_name_from):
    global _InboxFilesNames
    global _InboxFilesSize
    dhnio.Dprint(14, 'transport_skype.assemble file_id:%s from %s' % (str(file_id), skype_name_from))

    files_list = _InboxFilesNames[file_id]
    files_list.sort()

    fd, filename = tempfile.mkstemp(".dhn-skype-in")
    for part_filename in files_list:
        src = dhnio.ReadBinaryFile(part_filename)
        os.write(fd, src)
        if os.access(part_filename, os.W_OK):
            try:
                os.remove(part_filename)
            except:
                dhnio.Dprint(1, 'transport_skype.assemble ERROR removing ' + part_filename)
    try:
        fd.flush()
        os.close(fd)
    except:
        pass
    _InboxFilesNames.pop(file_id, None)
    _InboxFilesSize.pop(file_id, None)
    transport_control.receiveStatusReport(filename, "finished",
        'skype', skype_name_from)
    transport_control.log('skype', 'finish receiving from ' + str(skype_name_from))
Example #4
0
    def err_logout(self, err):
        dhnio.Dprint(6, 'transport_email.err_logout NETERROR' + str(err))
##        transport_control.msg('e', 'error logout from the server')
##        transport_control.connectionStatusCallback('email', self.transport.getPeer(), err, 'error logout from the server')
        transport_control.receiveStatusReport('', 'failed',
            'email', self.transport.getPeer(),
             err, 'error logout from the server')
        self.prepare_loop()
Example #5
0
    def err_delete_msg(self, err):
        dhnio.Dprint(6, 'transport_email.err_delete_msg NETERROR')
##        transport_control.msg('e', 'can not delete message from the server')
##        transport_control.connectionStatusCallback('email', self.transport.getPeer(), err, 'can not delete message from the server')
        transport_control.receiveStatusReport('', 'failed',
            'email', self.transport.getPeer(),
             err, 'can not delete message from the server')
        self.prepare_loop()
Example #6
0
    def err_stat(self, err):
        dhnio.Dprint(6, 'transport_email.err_stat NETERROR ' + str(err))
##        transport_control.msg('e', 'can not retreive list of messages')
##        transport_control.connectionStatusCallback('email', self.transport.getPeer(), err, 'can not retreive list of messages')
        transport_control.receiveStatusReport('', 'failed',
            'email', self.transport.getPeer(),
             err, 'can not retreive list of messages')
        self.finish()
Example #7
0
    def err_retrieve_msg(self, err):
        dhnio.Dprint(6, 'transport_email.err_retrieve_msg '+str(err))
##        print err
##        transport_control.msg('e', 'error retreive message')
##        transport_control.connectionStatusCallback('email', self.transport.getPeer(), err, 'error retreive message')
        transport_control.receiveStatusReport('', 'failed',
            'email', self.transport.getPeer(),
             err, 'error retreive message')
        self.finish()
 def connectionLost(self, reason):
     dhnio.Dprint(14, 'transport_ssh.MyReceiveFilesSubsistem.connectionLost')
     try:
         os.close(self.fout)
         transport_control.receiveStatusReport(
             self.filename,
             "finished",
             'ssh',
             self.transport.getPeer(),
             reason)
     except:
         pass
     if not self.stop_defer.called:
         self.stop_defer.callback('done')
     transport_control.log('ssh', 'income connection finished')
Example #9
0
def ReceiveStatusCallbackDefault(filename, status, proto='', host=None, error=None, message=''):
    try:
        from transport_control import receiveStatusReport
        return receiveStatusReport(filename, status, proto, host, error, message)
    except:
        dhnio.DprintException()
        return None
Example #10
0
    def delete_msg(self, ignore):
        global ready_receiving
        dhnio.Dprint(14, 'transport_email.delete_msg')
        self.cur_message += 1
        if self.cur_message < self.num_messages:
            self.retrieve(self.cur_message).addCallbacks(
                self.do_retrieve_msg, self.err_retrieve_msg)
        else:
            self.no_messages()

        dhnio.Dprint(14, 'transport_email: received file ' + self.current_filename)
        if self.factory.receive_event is not None:
            self.factory.receive_event(self.current_filename)

        transport_control.log('email', 'receiving done. remove message from server')
##        if misc.transport_control_using() and ready_receiving:
        if ready_receiving:
            transport_control.receiveStatusReport(self.current_filename, "finished",
            'email', self.transport.getPeer())
Example #11
0
def receive_status_func(fromUser, filename, status, reason):
    transport_control.receiveStatusReport(filename, status, 'q2q', fromUser, reason)