def run(self): GPIO.setmode(GPIO.BCM) #pylirc.init("pylirc","./irc_conf",blocking) pylirc.init("pylirc", "./irc_conf") allow = pylirc.blocking(0) while True: time.sleep(1) s = pylirc.nextcode() while (s): time.sleep(1) for (code) in s: #print 'Command: ',code["config"] print 'CommandS: ', s lirchar = s[0] print 'Command1:', lirchar self._char = lirchar if self._char == self._quitKey: pylirc.exit() print "QUIT!" return if self._char in self._handlersMap: self._handlersMap[self._char]() if (not blocking): s = pylirc.nextcode() else: s = []
def _lirc_main_loop(self): """ Pylirc main loop. """ code = {"config" : ""} while True: # Delay... time.sleep(self._sleep_time) # reduce osd time if self._osd_time and self._osd_time > 0: self._osd_time -= self._sleep_time # set channel if one digit is set if self._first_digit: self._show_digit_time -= self._sleep_time if self._show_digit_time <= 0: self.set_channel(self._first_digit) # hide osd message if self._osd_time and self._osd_time <= 0: self._osd.hide() self._osd_time = None # Read next code codes = pylirc.nextcode(1) # Loop as long as there are more on the queue # (dont want to wait a second if the user pressed many buttons...) while codes: for code in codes: self.handle_code(code) # Read next code? codes = pylirc.nextcode(1)
def _lirc_main_loop(self): """ Pylirc main loop. """ code = {"config": ""} while True: # Delay... time.sleep(self._sleep_time) # reduce osd time if self._osd_time and self._osd_time > 0: self._osd_time -= self._sleep_time # set channel if one digit is set if self._first_digit: self._show_digit_time -= self._sleep_time if self._show_digit_time <= 0: self.set_channel(self._first_digit) # hide osd message if self._osd_time and self._osd_time <= 0: self._osd.hide() self._osd_time = None # Read next code codes = pylirc.nextcode(1) # Loop as long as there are more on the queue # (dont want to wait a second if the user pressed many buttons...) while codes: for code in codes: self.handle_code(code) # Read next code? codes = pylirc.nextcode(1)
def doRead(self): codes = pylirc.nextcode() output = [] while codes: output.extend(codes) codes = pylirc.nextcode() if output: output.append('') self.protocol.dataReceived('\r\n'.join(output))
def loop(): while True: s = pylirc.nextcode(1) while (s): for (code) in s: print 'Command: ', code["config"] if (not blocking): s = pylirc.nextcode(1) else: s = []
def loop(): while True: s = pylirc.nextcode(1) while (s): for (code) in s: RGB(code['config']) setColor(color) if not blocking: s = pylirc.nextcode(1) else: s = []
def rc(): s = pylirc.nextcode(1) while(s): for (code) in s: # print 'Command: ', code["config"] #For debug: Uncomment this # line to see the return value of buttons IRC(code["config"]) if(not blocking): s = pylirc.nextcode(1) else: s = []
def loop(): while True: s = pylirc.nextcode(1) while (s): for (code) in s: # print 'Command: ', code["config"] #For debug: Uncomment this # line to see the return value of buttons button(code["config"]) if (not blocking): s = pylirc.nextcode(1) else: s = []
def loop(): while True: s = pylirc.nextcode(1) while (s): for (code) in s: myCar = Car() myCar.stop() print('Command: ', code["config"]) IR(code["config"]) if (not blocking): s = pylirc.nextcode(1) else: s = []
def loop(): while True: s = pylirc.nextcode(1) # print(s) while (s): for (code) in s: print("Command: ", code["config"]) #For debug: Uncomment this # line to see the return value of buttons RGB(code["config"]) setColor(color) if (not blocking): s = pylirc.nextcode(1) else: s = []
def loop(): while True: s = pylirc.nextcode(1) while(s): for (code) in s: # print 'Command: ', code["config"] #For debug: Uncomment this # line to see the return value of buttons RGB(code["config"]) setColor(color) if(not blocking): s = pylirc.nextcode(1) else: s = []
def loop(): done = False while True: s = pylirc.nextcode(1) while (s): for (code) in s: done = option(code["config"]) if done: print "Finished!" break elif (not blocking): s = pylirc.nextcode(1) else: s = []
def feeder(): while True: s = pylirc.nextcode(1) while (s): for (code) in s: ball(code["config"]) if (not blocking): s = pylirc.nextcode(1) else: s = [] #should feed if feed == feedBreakfast or feed == feedDinner: foodmix()
def run(self): try: global lastInput global stopThreads if (pylirc.init("lircidle", "/home/myth/scripts/lircrc_lircidle", 0) == 0): syslog.syslog('lircidle.py: unable to init lirc') print('lircidle.py: unable to init lirc') sys.exit(1) while 1: time.sleep(1) c = pylirc.nextcode() if c is not None: #for (code) in c: # syslog.syslog('lircidle.py (debug): code received (' + str(code["config"]) + ')') # print('lircidle.py (debug): code received (' + str(code["config"]) + ')') lastInput = time.time() if stopThreads != 0: break except: syslog.syslog('lircidle.py: unexpected exception: ' + str(sys.exc_info())) print('lircidle.py: unexpected exception: ' + str(sys.exc_info())) finally: pylirc.exit() syslog.syslog('lircidle.py: exiting lirc thread') print('lircidle.py: exiting lirc thread')
def _cb(self, eventmask): while True: btns = pylirc.nextcode(False) if btns is None: return for b in btns: yield UIEvent(b)
def interrupt(): #log.message("----------Begin Interrupt routine",log.DEBUG) global lcd global radio global rss global tunerknob interrupt = False switch = radio.getSwitch() if switch > 0: interrupt = get_switch_states(lcd, radio, rss, tunerknob) ir = pylirc.nextcode(1) if (ir): ir_event(ir, lcd, radio, rss, tunerknob) return True # Rapid display of timer if radio.getTimer() and not interrupt: displayTime(lcd, radio) interrupt = checkTimer(radio) if radio.volumeChanged(): lcd.line2("Volume " + str(radio.getVolume())) time.sleep(0.5) if not interrupt: interrupt = checkState(radio) #log.message("----------End interrupt routine",log.DEBUG) return interrupt
def startRecord(self): code = pylirc.nextcode() if code == None: return print code
def startRemoteControll(self, dataQueue): dataQueue.put(['pid', getpid()]) try: if(pylirc.init('mediacatalog', self.config, self.blocking)): self.configuration.getLogger().info('Remote control process was started') dataQueue.put(['status', 0]) code = "" isTerminate = False DEVNULL = open(os.devnull, 'w') while not isTerminate: codesList = pylirc.nextcode(1) out = subprocess.Popen(['/bin/sh', '-c', 'ps -ae | grep `xdotool getwindowfocus getwindowpid` | grep mediacatalog.py'], stdout=subprocess.PIPE) isHasFocus = out.communicate()[0].rstrip() if (isHasFocus != ""): self.configuration.getLogger().debug('Application has focus') if(codesList): for code in codesList: self.configuration.getLogger().info('Command: %s, Repeat: %d' % (code['config'], code['repeat'])) if code['config'] != None: if code['repeat'] > 1: for i in range(code['repeat']-1): xmacroProc = subprocess.Popen(['xmacroplay', ':0.0'], stdin=subprocess.PIPE, stdout=DEVNULL, stderr=subprocess.STDOUT) xmacroProc.communicate('KeyStrPress ' + code['config'] + ' KeyStrRelease ' + code['config']) else: xmacroProc = subprocess.Popen(['xmacroplay', ':0.0'], stdin=subprocess.PIPE, stdout=DEVNULL, stderr=subprocess.STDOUT) xmacroProc.communicate('KeyStrPress ' + code['config'] + ' KeyStrRelease ' + code['config']) else: self.configuration.getLogger().debug('Application has not focus') except RuntimeError: dataQueue.put(['status', 1]) self.configuration.getLogger().error('Remote control not initialized') self.configuration.getLogger().error(sys.exc_info()[1])
def startPyLirc(self): if(pylirc.init(LIRC_PROG_NAME, self.configFile, 0)): while(self.frontendActive): s = pylirc.nextcode(1) self.handleNextCode(s) sleep(0.1) pylirc.exit()
def work(self): blocking = 0 run = 1 try: if pylirc.init(self.prog, self.tempFile.name): while run: if not blocking: self.plugin.workerLock.acquire() run = self.plugin.workerRunning self.plugin.workerLock.release() if run: time.sleep(0.5) else: break s = pylirc.nextcode(1) blocking = 0 while s: for code in s: self.plugin.send_ir_command(code["config"]) blocking = 1 s = [] except RuntimeError as e: self.logger.warning('LIRC Plugin could not be loaded. Retrying in 5 seconds. %s' % e) pylirc.exit() time.sleep(5) self.work()
def get_events(self): events = [] while True: more_events = pylirc.nextcode() if more_events is None: return events events.extend(more_events)
def remote_command(self, source, cb_condition): codes = pylirc.nextcode() if codes: for code in codes: if code == "quit": gtk.main_quit() return True
def readbutton(self): # 按下按键传递对应的config值,如果没有匹配的key则为None btn = pylirc.nextcode() if btn: return btn[0] else: return None
def main(): lirc.init("radio") while 1: ir_codes = lirc.nextcode() if ir_codes != None: print(ir_codes) time.sleep(0.1)
def _do_poll(self, job, cancellable, p): result = p.poll() for fd, event in result: if event == select.POLLIN: code = pylirc.nextcode() if code: self.notifier.handle_input(code[0]) Gio.io_scheduler_push_job(self._do_poll, p, GLib.PRIORITY_DEFAULT, None)
def browser(args): browser = subprocess.Popen(["/usr/local/bin/mozilla-firefox/firefox"] + args[1:]) time.sleep(5) p1 = subprocess.Popen(["xdotool", "search", "--name", "Mozilla Firefox"], stdout = subprocess.PIPE) p1.wait() windows = p1.stdout.readline().split() for window in windows: print "'%s'" % window subprocess.Popen(["xdotool", "windowfocus", str(window)]) subprocess.Popen(["xdotool", "key", "F11"]) try: if not pylirc.init("mozilla-firefox", "/etc/lirc/lircrc", 1): return "Failed" stop = False while not stop: codes = pylirc.nextcode(1) if codes is None: continue for code in codes: print code if code is None: continue config = code["config"].split() if config[0] == "EXIT": stop = True break if config[0] == "mousestepreset": mousestep = 0 elif config[0] == "mousemove_relative": if mousestep < 10: mousestep += 1 config[2] = str(int(config[2]) * mousestep ** 2) config[3] = str(int(config[3]) * mousestep ** 2) subprocess.Popen(["xdotool"] + config) except KeyboardInterrupt: print "Exiting...." p1 = subprocess.Popen(["xdotool", "search", "--name", "Mozilla Firefox"], stdout = subprocess.PIPE) p1.wait() windows = p1.stdout.readline().split() for window in windows: print "'%s'" % window subprocess.Popen(["xdotool", "windowfocus", str(window)]) subprocess.Popen(["xdotool", "key", "Ctrl+Shift+W"]) # If we found windows and they're still running, wait 3 seconds if len(windows) != 0 and browser.poll() is None: for i in range(30): time.sleep(.1) if browser.poll() is not None: break # Okay now we can forcibly kill browser if browser.poll() is None: browser.terminate() return 0
def consumePylirc(self, lircHandle): try: if(select.select([lircHandle], [], [], 1) == ([], [], [])): pass else: s = pylirc.nextcode(1) self.handleNextCode(s) except Exception as e: logger.warning('Exception during handling a command: ' + str(e))
def __nextcode(self, log): s = [] if (self.lirc_init): # Read next code s = pylirc.nextcode(1) else: log.warn("Pylirc: ughhh something went wrong!") time.sleep(5) return s
def waitForOk(): notDone = True while notDone: codes = pylirc.nextcode() if codes: code = codes[0] if code == 'ok': notDone = False time.sleep(buttonDelay)
def loop(self): while 1: # check for IR signals signal = pylirc.nextcode(1) # open tread to process the signal so it will not wait till process if signal: start_new_thread(self.processIR, (signal,)) time.sleep(0.2)
def consumePylirc(self, lircHandle): try: if (select.select([lircHandle], [], [], 1) == ([], [], [])): pass else: s = pylirc.nextcode(1) self.handleNextCode(s) except Exception as e: logger.warning('Exception during handling a command: ' + str(e))
def test(self): blocking = 0; # if(pylirc.init("pylirc", "./conf", blocking)): code = {"config" : ""} while(code["config"] != "quit"): # Very intuitive indeed if(not blocking): print "." # Delay... time.sleep(1) # Read next code s = pylirc.nextcode(1) # Loop as long as there are more on the queue # (dont want to wait a second if the user pressed many buttons...) while(s): # Print all the configs... for (code) in s: print "Command: %s, Repeat: %d" % (code["config"], code["repeat"]) if(code["config"] == "blocking"): blocking = 1 pylirc.blocking(1) elif(code["config"] == "nonblocking"): blocking = 0 pylirc.blocking(0) # Read next code? if(not blocking): s = pylirc.nextcode(1) else: s = [] # Clean up lirc pylirc.exit()
def run(self): global code if(select.select([self.lirchandle], [], [], 6) == ([], [], [])): print "IRRrec timed out" else: s = pylirc.nextcode() if(s): for code in s: print code
def get_events(): """ Gets all the pylirc codes and converts them to pygame events """ import pylirc events = [] lirc_codes = pylirc.nextcode(1) if lirc_codes: for code in lirc_codes: if code['repeat'] == 0 or code['repeat'] > 2: if key_mapping.has_key(code['config']): events.append(pygame.event.Event(pygame.KEYDOWN, key=key_mapping[code['config']])) return events
def pollLircEvents(self): ''' Create pygame events from lirc events. ''' if not LIRC_ENABLED: return code_list = pylirc.nextcode() if code_list: for each_code in code_list: key_dict = {'key' : ir_key_map[each_code]} new_event = pygame.event.Event(pygame.KEYDOWN, key_dict) pygame.event.post(new_event)
def _loop(self): """ Execute the sensor loop. This runs in a separate thread. """ try: while self._active: data = pylirc.nextcode() self._handle_lirc_code(data) time.sleep(self._wait_delay) except: super(Infrared_Sensor, self).interrupt()
def ir_codes(): global read_ir_key_val GPIO.setup(26, GPIO.IN) pylirc.init("my_lirc", ir_conf_path, 0) ir_codes = pylirc.nextcode(1) # while with time out timeout_start = time.time() while True: ir_codes = pylirc.nextcode(1) if ir_codes != None: conf_key = ir_codes[0]['config'] #print("ircodes = %s"%ir_codes) #print(type(conf_key)) pylirc.exit() read_ir_key_val = conf_key return conf_key elif (time.time() - timeout_start > ir_time_out): pylirc.exit() read_ir_key_val = None print "time out" return -1 time.sleep(0.05)
def run(self): global code print "IRRrec awaits IR commands" if (select.select([self.lirchandle], [], [], 6) == ([], [], [])): print "IRRrec timed out" else: s = pylirc.nextcode() if (s): # Print all the configs... for code in s: print code
def run(self): global code print "IRRrec awaits IR commands" if(select.select([self.lirchandle], [], [], 6) == ([], [], [])): print "IRRrec timed out" else: s = pylirc.nextcode() if(s): # Print all the configs... for code in s: print code
def ffox(args): ffox = subprocess.Popen(["/usr/bin/firefox"] + args[1:]) try: if not pylirc.init("firefox", "~/.lircrc", 1): return "Failed" stop = False while not stop: codes = pylirc.nextcode(1) if codes is None: continue for code in codes: #print code if code is None: continue config = code["config"].split() if config[0] == "EXIT": stop = True break if config[0] == "mousestepreset": mousestep = 0 elif config[0] == "mousemove_relative": if mousestep < 10: mousestep += 1 config[2] = str(int(config[2]) * mousestep ** 2) config[3] = str(int(config[3]) * mousestep ** 2) subprocess.Popen(["xdotool"] + config) except KeyboardInterrupt: print "Exiting...." p1 = subprocess.Popen(["xdotool", "search", "--title", "Mozilla Firefox"], stdout = subprocess.PIPE) p1.wait() windows = p1.stdout.readline().split() for window in windows: #print "'%s'" % window subprocess.Popen(["xdotool", "windowfocus", str(window)]) subprocess.Popen(["xdotool", "key", "ctrl+q"]) # If we found windows and they're still running, wait 3 seconds if len(windows) != 0 and ffox.poll() is None: for i in range(30): time.sleep(.1) if ffox.poll() is not None: break # Okay now we can forcibly kill it if ffox.poll() is None: ffox.terminate() return 0
def listener(): try: if use_pylirc: sockid = pylirc.init("piradio", lircrc, blocking) else: # The following line is for Jessie and Stretch only sockid = lirc.init("piradio", lircrc, blocking) log.message("Listener on socket " + str(socket) + " established", log.DEBUG) # Main Listen loop print("Listening for input on IR sensor") while True: #pdb.set_trace() if use_pylirc: nextcode = pylirc.nextcode() else: nextcode = lirc.nextcode() # For Jessie amend pylirc.nextcode to lirc.nextcode if nextcode != None and len(nextcode) > 0: if remote_led > 0: GPIO.output(remote_led, True) button = nextcode[0] log.message(button, log.DEBUG) print(button) udpSend(button) # Send to radiod program if remote_led > 0: GPIO.output(remote_led, False) else: time.sleep(0.2) except Exception as e: log.message(str(e), log.ERROR) print(str(e)) mesg = "Possible configuration error, check /etc/lirc/lircd.conf" log.message(mesg, log.ERROR) print(mesg) mesg = "Activation IR Remote Control failed - Exiting" log.message(mesg, log.ERROR) print(mesg) sys.exit(1)
def generate_events(self): events = pylirc.nextcode(False) for event in events: if event in self._KEY_LOOKUP: pygame.event.post( pygame.event.Event( pygame.KEYDOWN, key=self._KEY_LOOKUP[event], unicode=event, # This should really be # something that combines # the modifiers. scancode=None)) # Meh, is this "good enough"? We should only look # at KEYDOWN, so it shouldn't be too bad. pygame.event.post( pygame.event.Event(pygame.KEYUP, key=self._KEY_LOOKUP[event]))
def run(self): if self.config_file: x = XKeys() import pylirc #try: if(pylirc.init("irkeys", self.config_file, 0)): while True: s = pylirc.nextcode(1) if s: for evt in s: command = evt["config"] print "IR recived :: " + command x.SendKeyPress( command ) time.sleep(0.1) x.SendKeyRelease( command )
def loop(self): self.logger.info("Starting up.") if(self.lirchandle): inputLirc = [self.lirchandle] timeout = 2 self.logger.info("Succesfully opened lirc, handle is " + str(self.lirchandle)) self.logger.info("Started.") while (not self.stopFlag.is_set()): inputready, outputready, exceptready = select.select(inputLirc,[],[], timeout) s = pylirc.nextcode(1) if(s): for code in s: repeat = code["repeat"] currentCommand = code["config"] self.logger.info("New event received: id: = %s, repeat = %s" % (currentCommand, repeat)) try: self.processorQueue.put_nowait(GeneratorEvent(currentCommand, repeat)) except Queue.Full: self.logger.error("Processor queue is overloaded.") self.logger.info("Shutted down.")
def run(self): if self.config_file: x = XKeys() import pylirc #try: if (pylirc.init("irkeys", self.config_file, 0)): while True: s = pylirc.nextcode(1) if s: for evt in s: command = evt["config"] print "IR recived :: " + command x.SendKeyPress(command) time.sleep(0.1) x.SendKeyRelease(command)
def _handle_lirc_input(): """ callback to handle a button press. """ global _key_delay_times, _last_code, _repeat_count, _last_key_time now = time.time() codes = pylirc.nextcode() if codes == None: # Either end of repeat, or just a delay between repeats... if _last_key_time + _key_delay_map[0] + 0.05 <= now: # Too long since the last key, so reset _last_key_time = 0 _repeat_count = 0 return elif codes == []: if not _key_delay_times: return True # Repeat last key iff we've passed the required key delay i = min(_repeat_count, len(_key_delay_times) - 2) delay = now - _key_delay_times[i][1] if delay >= _key_delay_times[i + 1][0]: codes = [ _last_code ] _key_delay_times[i + 1][1] = now _repeat_count += 1 else: return True else: _key_delay_times = [[0, now]] + [ [x, 0] for x in _key_delay_map ] _repeat_count = 0 _last_key_time = now for code in codes: signal.emit(code) _last_code = code return True
def _handle_lirc_input(): """ callback to handle a button press. """ global _key_delay_times, _last_code, _repeat_count, _last_key_time now = time.time() codes = pylirc.nextcode() if codes == None: # Either end of repeat, or just a delay between repeats... if _last_key_time + _key_delay_map[0] + 0.05 <= now: # Too long since the last key, so reset _last_key_time = 0 _repeat_count = 0 return elif codes == []: if not _key_delay_times: return True # Repeat last key iff we've passed the required key delay i = min(_repeat_count, len(_key_delay_times) - 2) delay = now - _key_delay_times[i][1] if delay >= _key_delay_times[i + 1][0]: codes = [_last_code] _key_delay_times[i + 1][1] = now _repeat_count += 1 else: return True else: _key_delay_times = [[0, now]] + [[x, 0] for x in _key_delay_map] _repeat_count = 0 _last_key_time = now for code in codes: signal.emit(code) _last_code = code return True
def run(self): try: lirchandle = pylirc.init("ude-dbus-lirc-bridge", "/usr/share/ude/dbus-lirc-bridge/lircrc", True) if lirchandle: while True: if self.stopped(): break try: timeout = select.select([lirchandle], [], [], 1) == ([], [], []) except Exception, e: print "IRWorker Exception", e continue if not timeout: s = pylirc.nextcode() if s: for code in s: if dbusobj: dbusobj.IREvent(code) # print "cmd",code pylirc.exit()
def __init__(self, name = "irUI"): self.pub_btn = rospy.Publisher('/arom/UI/buttons', String, queue_size=10) self.pub_beep = rospy.Publisher('/beeper/preset', String, queue_size=5) rospy.init_node('irUI') self.set_feature('remoteCtrl',{'type': "odroid"}) blocking = 0; rate = rospy.Rate(10) pylirc.init("pylirc", "/home/odroid/robozor/station/irConf.conf", blocking) while not rospy.is_shutdown(): try: s = pylirc.nextcode(1) if s: rospy.loginfo(s[0]['config']) self.pub_btn.publish(s[0]['config']) self.pub_beep.publish('btn') s = [] except Exception, e: rospy.logerr(e) rate.sleep()
def read_nextcode(self): next = pylirc.nextcode() if next is None: return for s in next: releases = [] for key in Qt.QKeySequence(s): mod = Qt.Qt.KeyboardModifiers(key & Qt.Qt.MODIFIER_MASK) key &= ~Qt.Qt.MODIFIER_MASK if mod: text = QString('') else: text = Qt.QKeySequence(key).toString() event = Qt.QKeyEvent(Qt.QEvent.KeyPress, key, mod, text=text) Qt.QCoreApplication.sendEvent(self.dest.focusWidget(), event) event = Qt.QKeyEvent(Qt.QEvent.KeyRelease, key, mod, text=text) releases.insert(0, event) for event in releases: Qt.QCoreApplication.sendEvent(self.dest.focusWidget(), event)
def poll(self): if not LIRC: return t = time.time() while True: code = LIRC.nextcode(1) if not code: break count = code[0]['repeat']+1 key = 'lirc' + code[0]['config'] if self.lastkey and self.lastkey != key: self.events.append((self.lastkey, 0)) self.lastkey = key self.lasttime = t self.events.append((key, count)) # timeout keyup if self.lastkey and t - self.lasttime > .25: self.events.append((self.lastkey, 0)) self.lastkey = False
def lirc_handler(self, lirc_socket, condition): cmds = pylirc.nextcode() if cmds: for code in cmds: if code == "KEY_UP": child = self.hbox.get_children()[0] child.grab_focus() continue if code == "KEY_DOWN": child = self.hbox.get_children()[-1] child.grab_focus() continue if code == "KEY_LEFT": prevchild = None for child in self.hbox.get_children(): if child is self.hbox.get_focus_child(): if prevchild: prevchild.grab_focus() break prevchild = child continue if code == "KEY_RIGHT": prevchild = None for child in self.hbox.get_children(): if prevchild is self.hbox.get_focus_child(): child.grab_focus() break prevchild = child continue if code == "KEY_OK": child = self.hbox.get_focus_child() child.emit("clicked") return True if code == "KEY_EXIT": gtk.main_quit() return True return True
def run(self): try: global lastInput global stopThreads if (pylirc.init("lircidle","/home/myth/scripts/lircrc_lircidle",0) == 0): syslog.syslog('lircidle.py: unable to init lirc') print('lircidle.py: unable to init lirc') sys.exit(1) while 1: time.sleep(1) c = pylirc.nextcode() if c is not None: #for (code) in c: # syslog.syslog('lircidle.py (debug): code received (' + str(code["config"]) + ')') # print('lircidle.py (debug): code received (' + str(code["config"]) + ')') lastInput = time.time() if stopThreads != 0: break except: syslog.syslog('lircidle.py: unexpected exception: ' + str(sys.exc_info())) print('lircidle.py: unexpected exception: ' + str(sys.exc_info())) finally: pylirc.exit() syslog.syslog('lircidle.py: exiting lirc thread') print('lircidle.py: exiting lirc thread')
def run(self): try: lirchandle = pylirc.init("ude-dbus-lirc-bridge", "/usr/share/ude/dbus-lirc-bridge/lircrc", True) if lirchandle: while True: if self.stopped(): break try: timeout = select.select([lirchandle], [], [], 1) == ([], [], []) except Exception, e: print "IRWorker Exception", e continue if not timeout: s = pylirc.nextcode() if s: for code in s: if dbusobj: dbusobj.IREvent(code) #print "cmd",code pylirc.exit()