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 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 suspend(self): """ cleanup pylirc, close devices """ logger.log(9, 'Lirc.suspend()') self.dispatcher.unregister() pylirc.exit()
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 suspend(self): """ cleanup pylirc, close devices """ logger.log( 9, 'Lirc.suspend()') self.dispatcher.unregister() 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 exit(self): ''' Code to clean up before exit. ''' if LIRC_ENABLED: pylirc.exit() pygame.quit() sys.exit()
def deactivate(self): """ Deactivate the infrared sensor. """ super(Infrared_Sensor, self).deactivate() self._active = False pylirc.exit()
def destroy(): p_R.stop() p_G.stop() p_B.stop() GPIO.output(Rpin, GPIO.HIGH) # Turn off all leds GPIO.output(Gpin, GPIO.HIGH) GPIO.output(Bpin, GPIO.HIGH) GPIO.cleanup() pylirc.exit()
def quit(self): """ Screen.quit() -- close all components """ pygame.display.quit() os.unlink(os.path.expanduser(os.path.join('~', '.cmus', 'inhibit-osd'))) if hasattr(self, 'lircsock'): pylirc.exit() if self.thread and self.queue: self.queue.put('quit', False) self.queue.join() self.activate_screensaver()
def stop(): """ Callback for shutdown. """ global _dispatcher if not _dispatcher: # already disconnected return _dispatcher.unregister() _dispatcher = None pylirc.exit() kaa.main.signals["shutdown"].disconnect(stop)
def start_main_loop(self): """ Read lirc config file and start main pylirc main loop. """ if pylirc.init("tvtuner", "~/.lircrc", False): try: self._lirc_main_loop() except KeyboardInterrupt: self._osd.hide() pylirc.exit() del self._osd logging.debug('Exiting..')
def runPylirc(configuration): if pylirc is None: logger.debug('Not initializing pylirc') yield return logger.debug('Initializing pylirc with configuration: ' + configuration) fd = pylirc.init('browser', configuration) if not fd: raise RuntimeError('Failed to initialize pylirc') try: yield fd finally: pylirc.exit()
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): 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 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): 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 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 main(): usage = "usage: pstream3_client_lirc [options]" parser = OptionParser(usage) parser.add_option("--daemon", help="Run me as daemon", action="store_true", dest="daemon") parser.add_option("--ip", help="Ip where should i listen", dest="ip") parser.add_option("--port", help="Port where should i bind", dest="port") parser.add_option("--dump", help="Folder where should i dump", dest="dump") parser.add_option("--lirc-config", help="Path to lirc config", dest="lirc_config") parser.add_option("--pid", help="Process pid", dest="pid") (options, args) = parser.parse_args() if options.daemon: ret= createDaemon() if options.pid: pid= os.getpid() f= open(options.pid, "w") f.write(str(pid)) f.close() if options.ip and options.port: ip= options.ip port= options.port else: ip= "localhost" port= str(8400) client = xmlrpclib.ServerProxy("http://%s:%s/" % (ip, port)) h264_client= None blocking= 1 if options.lirc_config: lirc_path= options.lirc_config else: lirc_path="/etc/pstream/conf" if(pylirc.init("pylirc", lirc_path, blocking)): code= {"config": ""} while(code["config"] != "quit"): #Read next code s= pylirc.nextcode(1) #Right now i don't care what you press on remote. code["config"]= "start_stream" status= None if(code["config"] == "start_stream"): try: status=h264_client.GetAppRunStatus() except: status=None if (status!=AppStatus.RUNNING) or not status: print("Creating new app") h264= client.CreateApp("h264Stream") notifyCopyProcess= client.CreateApp("NotifyCopyProcess") notifyCopyProcess_client= xmlrpclib.ServerProxy("http://%s:%s/" % (ip,port) + str(notifyCopyProcess)) print h264, client.GetAppInstances() h264_client= xmlrpclib.ServerProxy("http://%s:%s/" % (ip,port) + str(h264)) h264_client.SetAppValue("auto_restart", 1) if options.dump: h264_client.SetAppValue("dumpfolder", options.dump) else: h264_client.SetAppValue("dumpfolder", "/home/recode/dump") h264_client.StartApp() else: print("Stoping stream") client.DestroyInstance(h264) client.DestroyInstance(notifyCopyProcess) continue while h264_client.GetAppRunStatus()!=AppStatus.RUNNING: print "here" sleep(.5) print("Next code") client.DestroyInstances() pylirc.exit()
def destroy(): pylirc.exit()
print code lirchandle = pylirc.init("pylirc", "./conf", blocking) if (lirchandle): print "Succesfully opened lirc, handle is " + str(lirchandle) tim = Timer() tim.start() irrec = IRRec(lirchandle) irrec.start() code = "" while (code != "quit"): if (irrec.isAlive() == 0): irrec = IRRec(lirchandle) irrec.start() # Very intuitive indeed #if(not blocking): print "." # Delay... time.sleep(1) # Clean up lirc pylirc.exit()
def quit(self): pylirc.exit()
scores = sorted(scores) winningScore = scores[-1] winningPlayers = [] for player in players: if player['score'] == winningScore: winningPlayers.append(player['name']) winners = ' and '.join(winningPlayers) if len(winningPlayers) > 1: titleText = 'The winning players are:' else: titleText = 'The winning player is:' titleHeight = font.size(titleText)[1] titleWidth = font.size(titleText)[0] title = font.render(titleText, 1, [0,0,0]) screen.blit(title, [(width/2)-(titleWidth/2), (height/4)-(titleHeight/2)]) winnerHeight = font.size(winners)[1] winnerWidth = font.size(winners)[0] winnerText = font.render(winners, 1, [255,0,0]) screen.blit(winnerText, [(width/2)-(winnerWidth/2), (height/2)-(winnerHeight/2)]) pygame.display.flip() waitForOk() displayScores(players, 'Final Scores') pylirc.exit()
def shutdown(self): self.logger.debug("Shutting down.") self.stopFlag.set() pylirc.exit()
def suspend(self): """ cleanup pylirc, close devices """ _debug_('Lirc.suspend()', 2) pylirc.exit()
def stop(): pylirc.exit()
def __del__(self): import pylirc pylirc.exit() os.remove(self.config_file)
def startPyLirc(self): lircHandle = pylirc.init(LIRC_PROG_NAME, self.configFile, 0) if(lircHandle != 0): while(self.frontendActive): self.consumePylirc(lircHandle) pylirc.exit()
def cleanup(self): # Clean up lirc pylirc.exit()
def __del__(self): pylirc.exit()
def main(): #build ipcam list from config.xml config = 'config.xml' parser = XmlParser(config) cam_list = parser.build_cam_list() print 'Full List' for item in cam_list: print item.get_name() default = 0 current_proc = subprocess.Popen(['omxplayer', cam_list[default].get_rem_addr()] , stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE ) #ir input section blocking = 0; if(pylirc.init("pylirc", "./pylirc/conf", blocking)): code = {"config" : ""} while (code["config"] != "0"): # Very intuitive indeed if(not blocking): print "." # Delay... sleep(0.5) # 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: char = code["config"] print "Command: %s, Repeat: %d" % (code["config"], code["repeat"]) # Read next code? if(not blocking): s = pylirc.nextcode(1) else: s = [] # if 0 pressed exit close player and pylirc # if int(char) == 0: # subprocess.Popen(['killall', 'omxplayer.bin']) # pylirc.exit() # break if (int(char) <= len(cam_list) and int(char) != 0): index = int(char)-1 url = cam_list[index].get_rem_addr() print url #comment try: next_proc = subprocess.Popen(['omxplayer', url], stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE) #current_proc.communicate('p') #current_proc.stdin.flush() #print next_proc.stdout current_proc.communicate('q') temp = current_proc current_proc = next_proc next_proc = temp except: out, err = current_proc.communicate() print ("Error: " + err.rstrip()) else: print ("there are no cam corresponding to this number") sleep(0.1) subprocess.Popen(['killall', 'omxplayer.bin']) pylirc.exit()
def startPyLirc(self): lircHandle = pylirc.init(LIRC_PROG_NAME, self.configFile, 0) if (lircHandle != 0): while (self.frontendActive): self.consumePylirc(lircHandle) pylirc.exit()
def destroy(): GPIO.cleanup() pylirc.exit()
def on_exit(self, result): self.logger.info('Exited with (%s)' % result) pylirc.exit() os.unlink(self.tmpFileName)
def suspend(self): """ cleanup pylirc, close devices """ pylirc.exit()