Пример #1
0
        if type(command) not in (list, tuple):
            command = [command]
        self.command = command

    def notify(self, packet):
        try:
            if self.command != None:
                for cmd in self.command:
                    if cmd in str(packet).encode('string_escape'):
                        self.command = None
                        self.status = True
        except Exception, ex:
            print ex

command_poller = ResponsePoller()
Receiver.register(command_poller, NETWORK_A)
general_logger.info("Command poller initialized.......")

def h2i(value):
    if type(value) == str:
        return int(value.encode('hex'), 16)

def i2h(value):

    if type(value) == int:
        if value < 255:
            return "\\x%02X" % value
        else:
            val = "%04X" % value
            return "\\x%s\\x%s" % (val[0:2], val[2:4])
    else:
Пример #2
0
 def callback(self, packet):
     if self.__stop:
         raise ThreadExit()
     Receiver.notifyHandlers(packet, self.__network)