當前位置: 首頁>>代碼示例>>Python>>正文


Python listener.Listener類代碼示例

本文整理匯總了Python中listener.Listener的典型用法代碼示例。如果您正苦於以下問題:Python Listener類的具體用法?Python Listener怎麽用?Python Listener使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了Listener類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: main

def main():
  listener = Listener()
  listener.start()
  while True:
    recv_queue_data = listener.queue.get()
    recv_data = recv_queue_data.msgtype
    distance = recv_queue_data.msg
    if recv_data == 0x05: # Follower to move forward
      totalMoves(distance)
      print ("Received Follower move forward")
    elif recv_data == 0x06: # Follower to move backward
      totalMoves(distance)
      print ("Received Follower move backward")
    elif recv_data == 0x07: # Follower to move left
      totalMoves(distance)
      print ("Received Follower move left")
    elif recv_data == 0x09: # Follower to move right
      totalMoves(distance)
      print ("Received Follower move right")
    elif recv_data == 0x13: # Follower reports found token
      followerTokenFND()
    elif recv_data == 0x15: # Scanning Follower Servo
      print ("Received Scanning Beginning")
    elif recv_data == 0x16: # Scan returned Lead Found
      scanServo()
    elif recv_data == 0x17: # Scan returned Object Found
      scanServo()
    else:
      # Something unexpected happened
      print("Received unexpected data %d" % recv_data)
  try:
    cmdInput(listener.queue)
  except KeyboardInterrupt:
    pass
  listener.close()
開發者ID:mlevy94,項目名稱:ECE4534-Team1,代碼行數:35,代碼來源:follower_debug.py

示例2: _listener

def _listener(arguments):
    """
    Listener subcommand callback
    """
    logging.info('Starting Listener')
    listener = Listener(silence_time=arguments.silence_time, threshold=arguments.threshold, filename_prefix=arguments.filename_prefix)
    listener.get_utterance()
開發者ID:JeffCost,項目名稱:PySpeak,代碼行數:7,代碼來源:commandline.py

示例3: BluetoothPlugin

class BluetoothPlugin(ConnectionPlugin):
    ADDR_FILE = 'config/bluetooth_address'

    def __init__(self):
        super().__init__()
        self.listener = Listener()
        self.addr = self.__get_bluetooth_addr()

    # API method
    def broadcast(self, msg):
        print("BROADCASTING")
        NetworkScanner(msg).start()

    # API method
    def run(self):
        self.listener.start()

    # API method
    def address(self):
        return self.addr

    def __get_bluetooth_addr(self):
        with open(BluetoothPlugin.ADDR_FILE, 'r') as file:
            addr = file.read()

        print("Bluetooth Address: {}".format(addr))
        return addr.strip()
開發者ID:flarecast,項目名稱:bluetooth,代碼行數:27,代碼來源:bluetooth_plugin.py

示例4: __init__

    def __init__(self):
        Listener.__init__(self)

        self.parser = Parser()
        self.connection = Connection()

        self.connection.add_listener("readline", self.readline_handler)
        self.connection.add_listener("connect", self.connect_handler)
        self.connection.add_listener("disconnect", self.disconnect_handler)

        self.connection.connect()
開發者ID:badporcupine,項目名稱:Python-IRCBot,代碼行數:11,代碼來源:client.py

示例5: main

def main(argv):
    input = FileStream(argv[1])
    lexer = aevumLexer(input)
    stream = CommonTokenStream(lexer)
    parser = aevumParser(stream)
    tree = parser.top_level()

    listener = Listener()
    walker = ParseTreeWalker()
    walker.walk(listener, tree)

    listener.typecheck()
    print(listener.emit())
開發者ID:swiftcoder,項目名稱:aevum,代碼行數:13,代碼來源:driver.py

示例6: DataGen

class DataGen(object):
    def __init__(self):
        conn1, conn2 = multiprocessing.Pipe()
        self.conn = conn2
        self.listener = Listener(debug_connection = conn1)
        self.listener.start()
        self.bpm_to_test = [0]
        self.bpm_energies = [0]

    def __iter__(self):
        return self
        
    def next(self):
        while self.conn.poll():
            self.bpm_to_test, self.bpm_energies = self.conn.recv()
        return (self.bpm_to_test, self.bpm_energies)
開發者ID:rdeits,項目名稱:BeatTrack,代碼行數:16,代碼來源:wx_mpl_dynamic_graph.py

示例7: __init__

 def __init__(self):
     conn1, conn2 = multiprocessing.Pipe()
     self.conn = conn2
     self.listener = Listener(debug_connection = conn1)
     self.listener.start()
     self.bpm_to_test = [0]
     self.bpm_energies = [0]
開發者ID:rdeits,項目名稱:BeatTrack,代碼行數:7,代碼來源:wx_mpl_dynamic_graph.py

示例8: loadLevel

 def loadLevel(self):
     if self.networkingEnabled:
         self.broadcaster = Broadcaster()
         self.listener = Listener()
         self.listener.start()
         self.broadcaster.start()
     if self.server or not self.networkingEnabled:
         self.remainingIDs.append([1,""])
         self.remainingIDs.append([2,""])
開發者ID:alexander-jones,項目名稱:Saturn-Racing,代碼行數:9,代碼來源:netMgr.py

示例9: __init__

 def __init__(self):
     threading.Thread.__init__(self)
     self.devices = get_devices()
     self.keyfile = ".keymap"    # Arquivo padrão para o mapa de caracteres
     self.keymap = KeyMap(self.devices)
     self.listener = Listener(self.devices)
     self.history = History()
     self.lock = False
     self.listen()
     self.copy = False
開發者ID:andredalton,項目名稱:bcc,代碼行數:10,代碼來源:kmlogger.py

示例10: main

def main():
    """
    Allows Winston to be installed as a package and to be run from the command line.

    This simply inits Winston using the config file.
    """

    # Define and start a scheduler. These store tasks that are run at given times
    scheduler = config.SCHEDULER
    scheduler.start()

    # Load the commands in the interpreter. These dispatch commands. See the Interpreter's doc for details.
    interpreter = Interpreter(scheduler=config.SCHEDULER)
    for command in config.COMMANDS:
        interpreter.register(command)

    # Create a listener for pocketsphinx. It forwards recognized strings to Interpreters. See Listener's doc for details.
    listener = Listener(fsg_path=config.GRAMMAR_FILE, dict_path=config.DICT_FILE)
    listener.register(interpreter)

    # And wait...
    raw_input()
開發者ID:TugcaEker,項目名稱:winston,代碼行數:22,代碼來源:__main__.py

示例11: __init__

class DIM:
    def __init__(self, host, port):
        # sageGate is the network connection with SAGE
        self.sageGate = SageGate()
        setSageGate(self.sageGate)

        # the event manager takes care of properly dispatching events
        self.evtMgr = EventManager()
        setEvtMgr(self.evtMgr)
        self.evtMgr.addHandlers()

        # sageData keeps the current state of the SAGE windows/apps
        self.sageData = SageData()
        setSageData(self.sageData)
        
        # overlay manager creates, destroys and updates overlays
        self.overlayMgr = OverlayManager()
        setOverlayMgr(self.overlayMgr)

        # contains all the devices and takes care of loading plugins for them
        # also, distributes HW messages to each device 
        self.devMgr = DeviceManager()
        setDevMgr(self.devMgr)

        # connect to SAGE
        for i in range(5):  # try to connect to SAGE for 5 seconds
            if self.sageGate.connectToSage(host, port) != 0:
                self.sageGate.registerSage()
                break
            time.sleep(1)
        else:  # we didn't manage to connect to sage in 5 seconds... so quit
            exitApp()

        # start listening for the device events
        time.sleep(2)   # wait till all the messages come in
        self.listener = Listener(LISTENER_PORT, self.devMgr.onHWMessage)
        self.listener.serve_forever()
開發者ID:MattHung,項目名稱:sage-graphics,代碼行數:37,代碼來源:dim.py

示例12: EmonHub

def EmonHub():
    
    # Load settings
    settings = ConfigObj("emonhub.conf", file_error=True)
    
    # Create queue for node packets
    queue = Queue.Queue(0)

    # Create and start serial listener
    a = Listener(queue,settings)
    a.start()
    
    # Create and start http dispatcher
    b = Dispatcher(queue,settings)
    b.start()

    while 1:
        try:
            time.sleep(0.1)
        except KeyboardInterrupt:
            print "Stopping threads"
            a.stop = True
            b.stop = True
            break
開發者ID:BuloZB,項目名稱:development,代碼行數:24,代碼來源:03.py

示例13: init_listener

    def init_listener(self, address_list, msg_type_list):
        '''Initialise listener that receives messages about new files
        to be processed, etc.
        '''
        # Create Pipe connection
        parent_conn, child_conn = Pipe()
        self.listener_parent_conn = parent_conn
        self.listener_child_conn = child_conn

        # Create a Listener instance
        self.listener = Listener(address_list=address_list, 
                                 msg_type_list=msg_type_list, 
                                 pipe=self.listener_child_conn)
        #self.listener.add_address_list(address_list)
        #self.listener.type_list = msg_type_list

        # Create subscriber
        #self.listener.create_subscriber()
        print "Listener initialised"
開發者ID:uservidya,項目名稱:trollduction,代碼行數:19,代碼來源:trollduction.py

示例14: __init__

    def __init__(self):
        QMainWindow.__init__(self)

        # make variables
        self.voltage = 0
        self.current = 0

        # load gui.ui
        self.ui = loadUi('../gui/gui.ui')

        self.ui.setAttribute(QtCore.Qt.WA_DeleteOnClose, True)
        self.ui.destroyed.connect(self.shutdown)

        # show window
        self.ui.show()

        # make new log object
        self.log = Log(self.ui)

        # make new sender object
        self.sender = Sender(self.ui, self.log)

        # set events
        self.set_events()

        # initial reset
        self.sender.reset()

        # new listener
        self.listener = Listener()

        # new_data_received signal
        self.listener.data_received.connect(self.new_data_received)

        # start listener
        self.listener.start()

        # new interpreter
        self.interpreter = Interpreter(self.log, self.ui)

        # add tree
        self.add_tree()
開發者ID:spaibs,項目名稱:eCARus-IT,代碼行數:42,代碼來源:main.py

示例15: play

    def play(self, args, local):
        # create an intial logger so we can log before args are processed
        self.logger = Logger({"verbose": False})
        self.drawLogo()

        options = self.processArgs(args, local)
        self.options = options

        # set up the logger with the correct options
        self.logger = Logger(self.options)

        listener = Listener(self.logger)
        listener.onChange(self.processFile)

        if os.path.isdir(options['start']) and not os.path.isdir(options['end']):
            os.mkdir(options['end'])

        if self.options['listen']:
            listener.watch(options['start'], options['end'])
        else:
            listener.process(options['start'], options['end'])
            self.logger.log(self.logger.color('Done!', self.logger.PINK))
            sys.exit(0)
開發者ID:ccampbell,項目名稱:mmlx,代碼行數:23,代碼來源:musicbox.py


注:本文中的listener.Listener類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。