def doReadAndUnserialize(self, *args, **kwargs): """ Action method. """ from transport import gateway self.status, self.bytes_received, self.error_message = args[0] if _PacketLogFileEnabled: lg.out( 0, ' \033[2;49;32mRECEIVED %d bytes from %s://%s TID:%s\033[0m' % (self.bytes_received, self.proto, self.host, self.transfer_id), log_name='packet', showtime=True) # DO UNSERIALIZE HERE , no exceptions newpacket = gateway.inbox(self) if newpacket is None: if _Debug: lg.out( _DebugLevel, '<<< IN <<< !!!NONE!!! [%s] %s from %s %s' % ( self.proto.upper().ljust(5), self.status.ljust(8), self.host, os.path.basename(self.filename), )) # net_misc.ConnectionFailed(None, proto, 'receiveStatusReport %s' % host) try: fd, _ = tmpfile.make('error', extension='.inbox') data = bpio.ReadBinaryFile(self.filename) os.write( fd, strng.to_bin('from %s:%s %s\n' % (self.proto, self.host, self.status))) os.write(fd, data) os.close(fd) except: lg.exc() if os.path.isfile(self.filename): try: os.remove(self.filename) except: lg.exc() self.automat('unserialize-failed', None) return self.label = '[%s(%s)]' % (newpacket.Command, newpacket.PacketID) if _Debug: lg.out(_DebugLevel, 'packet_in.doReadAndUnserialize: %s' % newpacket) self.automat('valid-inbox-packet', newpacket) if False: events.send('inbox-packet-recevied', data=dict( packet_id=newpacket.PacketID, command=newpacket.Command, creator_id=newpacket.CreatorID, date=newpacket.Date, size=len(newpacket.Payload), remote_id=newpacket.RemoteID, ))
def doReadAndUnserialize(self, arg): """ Action method. """ from transport import gateway self.status, self.bytes_received, self.error_message = arg # DO UNSERIALIZE HERE , no exceptions newpacket = gateway.inbox(self) if newpacket is None: if _Debug: lg.out( _DebugLevel, '<<< IN <<< !!!NONE!!! [%s] %s from %s %s' % ( self.proto.upper().ljust(5), self.status.ljust(8), self.host, os.path.basename(self.filename), )) # net_misc.ConnectionFailed(None, proto, 'receiveStatusReport %s' % host) try: fd, _ = tmpfile.make('error', extension='.inbox') data = bpio.ReadBinaryFile(self.filename) os.write( fd, 'from %s:%s %s\n' % (self.proto, self.host, self.status)) os.write(fd, data) os.close(fd) except: lg.exc() try: os.remove(self.filename) except: lg.exc() self.automat('unserialize-failed', None) return self.label += '_%s[%s]' % (newpacket.Command, newpacket.PacketID) if _Debug: lg.out(_DebugLevel + 2, 'packet_in.doReadAndUnserialize: %s' % newpacket) self.automat('valid-inbox-packet', newpacket) events.send('inbox-packet-recevied', data=dict( packet_id=newpacket.PacketID, command=newpacket.Command, creator_id=newpacket.CreatorID, date=newpacket.Date, size=len(newpacket.Payload), remote_id=newpacket.RemoteID, ))