def wait(self): commandline = self.m_sOMXPCommand % \ self.m_lVideoLST[self.m_nVideoPOS] self.m_oRunProcess = os.system(commandline) logging.info("Subprocess running: %s" % commandline) logging.info("wait omxplayer to finish") while True: wait_process('omxplayer.bin') exit_code = os.WEXITSTATUS(self.m_oRunProcess) if exit_code == 3: break else: if self.m_sPlayAll == "True": self.m_nVideoPOS += 1 try: self.m_lVideoLST[self.m_nVideoPOS] logging.info("Playing video: %s" % \ self.m_lVideoLST[self.m_nVideoPOS]) commandline = self.m_sOMXPCommand % \ self.m_lVideoLST[self.m_nVideoPOS] self.m_oRunProcess = os.system(commandline) logging.info("Subprocess running: %s", commandline) except: break else: break time.sleep(0.5) logging.info("process end")
def _loop(self, p_iTime=20, p_iLoops=4): """ MAIN PROGRAM. Will be checking during x loops and y seconds per loop if any jamma cable is selected and apply its needed sofware. After cycle if no one jamma cable is detected on config.txt daemon will be closed. """ logging.info('INFO: starting main search cycle of ' + \ '{%s loops}x{%s seconds}' % (p_iLoops, p_iTime)) iCounter = 0 while iCounter < p_iLoops: if check_process(PNAME_CONFIG): wait_process(PNAME_CONFIG) self._get_config() self._halt_daemon() self._recovery_mode() self._load_cable() time.sleep(p_iTime) # Wait until next cycle iCounter += 1 if self.m_bCableLoaded: # Keep daemon if any jamma cable logging.info('INFO: JAMMA CABLE FOUND; ' + \ 'clearing search cycle') iCounter = 0 else: logging.info('INFO: starting checking round: %s' % iCounter) logging.info('INFO: NO JAMMA CABLE FOUND after search cycle ' + \ 'of {%s loops}x{%s seconds}' \ % (p_iLoops, p_iTime)) self._quit()
def _halt_daemon(self): """ Will wait or close daemon if one of next conditions happen If daemon is disabled it will do nothing, only exit. """ if not self.m_bDaemonEna: logging.info("WARNING: daemon disabled in /boot/config.txt") self._quit() if check_process('resize2fs'): logging.info("WARNING: Wait until resize2fs finish") wait_process('resize2fs')
def _check_if_first_boot(self): """ Check if resize2fs is working on expanding SD partition """ if check_process(self.m_sFstBootApp): logging.info("WARNING: Wait until resize2fs finish") wait_process(self.m_sFstBootApp, 'stop', 1, 5)