Beispiel #1
0
 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 _restart_ES(self):
     """ Restart ES if it's running """
     if check_process("emulationstatio"):
         self.m_bPRestart = True
         if check_process(self.m_lProcesses):
             time.sleep(0.5)
             #logging.info("INFO: Pending Reboot...")
             return
         if self.mounted_time():
             logging.info("INFO: Restarting EmulationStation...")
             commandline = "touch /tmp/es-restart "
             commandline += "&& pkill -f \"/opt/retropie"
             commandline += "/supplementary/.*/emulationstation([^.]|$)\""
             os.system(commandline)
             os.system('clear')
         self.m_bPRestart = False
Beispiel #3
0
def restart_ES():
    """ Restart ES if it's running """
    if check_process("emulationstatio"):
        logging.info("INFO: Restarting EmulationStation...")
        commandline = "touch /tmp/es-restart "
        commandline += "&& pkill -f \"/opt/retropie"
        commandline += "/supplementary/.*/emulationstation([^.]|$)\""
        os.system(commandline)
 def _restart_es(self):
     if check_process("emulationstatio"):
         commandline = "touch /tmp/es-restart "
         commandline += "&& pkill -f \"/opt/retropie"
         commandline += "/supplementary/.*/emulationstation([^.]|$)\""
         show_info("RESTARTING EMULATIONSTATION")
         os.system(commandline)
         time.sleep(2)
         sys.exit(1)
Beispiel #5
0
 def check(self, WaitStart=False):
     """ check current status of driver """
     p_iWTime = 2  # time to wait
     start = time.time()
     while True:
         value = check_process(self.PI2JAMMA_BIN)
         if not WaitStart: break
         else:
             if value or (time.time() - start) > p_iWTime:
                 break
     return value
Beispiel #6
0
 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 _restart(self):
     """ Restart system or reboot ES if needed """
     commandline = ""
     if not self.m_bUploadCFG:
         logging.info('INFO: NO changes in /boot/config.txt; ' + \
                      'no reboot needed')
         # check if ES must reboot
         if self.m_bRebootES and check_process("emulationstatio"):
             show_info('CLEANING KEYBOARD CONFIG', 2000)
             show_info('EMULATIONSTATION WILL RESTART NOW')
             commandline = "touch /tmp/es-restart "
             commandline += "&& pkill -f \"/opt/retropie"
             commandline += "/supplementary/.*/emulationstation([^.]|$)\""
             os.system(commandline)
             time.sleep(1)
     else:
         commandline = 'sudo reboot now'
         show_info(self.m_lInfoReboot)
         os.system(commandline)
     sys.exit(0)
 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)
Beispiel #9
0
    def screen_ingame(self, p_iShow = 30, p_iInfoUpdate = 1):
        if not check_process(PNAME_LAUNCHER): return False
        """ Start screen refresh daemon for system & title """
        t = threading.Thread(target=self.ingame_get_info)
        t.setDaemon(True)
        t.start()

        global STOP_SCREEN
        global INFO_IMG
        X_POS = 0
        Y_POS = 0
        p_sTitle = self.m_sGM_Game
        p_iTime = time.time()
        p_iInfoGlobal = 0
        p_iInfoSGTime = 0
        p_iInfoNetTime = 0

        p_iRefreshTime = 0.2
        p_iTitleOversize = 0
        p_iTitleMove = 0
        p_iScroll = 0
        p_iScrollWait = 3
        p_iScrollWaitCtrl = time.time()
        p_sPrev_Title = None

        time.sleep(0.3)
        while not STOP_SCREEN and not STOP_SERVICE:
            if not check_process(PNAME_LAUNCHER): 
                break
            """ Get gaming time """
            p_iGameTime = time.strftime('%Hh:%Mm:%Ss', time.gmtime(time.time() - self.m_iGM_StartTime))
            """ Switch system and game file names """
            if p_iInfoSGTime == 0 or time.time() - p_iInfoSGTime >= 30: # 30 seconds per info line
                p_iInfoSGTime = time.time()
                if p_sTitle == self.m_sGM_System:
                    p_sTitle = self.m_sGM_Game
                else: p_sTitle = self.m_sGM_System
            """ Switch Netplay info """
            if p_iInfoNetTime == 0 or time.time() - p_iInfoNetTime >= 3: # 3 seconds per info line
                try: p_sNet 
                except: p_sNet = self.m_sPublic
                p_iInfoNetTime = time.time()
                if p_sNet == self.m_sNetplay:
                    p_sNet = self.m_sPublic
                else: p_sNet = self.m_sNetplay
                p_iTextWidth = self.m_oDraw.textsize(p_sNet, font=self.m_oFont10)[0]
                p_iNetInfoPosX = int(self.m_iDspWidth / 2) - int(p_iTextWidth / 2)
            """ Title scroll """
            if p_sTitle != p_sPrev_Title:
                p_sPrev_Title = p_sTitle
                p_iTextWidth = self.m_oDraw.textsize(p_sPrev_Title, font=self.m_oFont2)[0]
                p_iTitleOversize = p_iTextWidth - self.m_iDspWidth # oversize
                p_iTitleOversize += 5
                p_iTitleMove = 0
                if p_iTitleOversize >= 0: 
                    p_iScroll = -5
                    p_iTitleOversize = abs(p_iTitleOversize)
                else:
                    p_iScroll = 0
                    p_iTitleOversize = 0
                    p_iSysGamePosX = int(self.m_iDspWidth / 2) - int(p_iTextWidth / 2) - 2
            
            if p_iScroll != 0:
                if p_iTitleMove == 0 or abs(p_iTitleMove) == abs(p_iTitleOversize):
                    if time.time() - p_iScrollWaitCtrl > p_iScrollWait:
                        p_iTitleMove += p_iScroll
                else:
                    if p_iTitleMove + p_iScroll >= -p_iTitleOversize and p_iTitleMove + p_iScroll <= 0:
                        p_iTitleMove += p_iScroll
                    elif p_iTitleMove + p_iScroll <= -p_iTitleOversize:
                        p_iTitleMove = -p_iTitleOversize
                    elif p_iTitleMove + p_iScroll > 0:
                        p_iTitleMove = 0
                    if abs(p_iTitleMove) == abs(p_iTitleOversize) or p_iTitleMove == 0:
                        p_iScroll = -p_iScroll
                        p_iScrollWaitCtrl = time.time()

            """ Draw info elements on screen """
            if time.time() - p_iInfoGlobal > 3:
                p_iInfoGlobal = time.time()
                self.m_oOutput.paste(self.m_oImage2, (0, 0))
                self.m_oDraw.text((X_POS + 49, Y_POS + 28), "PLAYING TIME:", 
                                   font=self.m_oFont10, fill=255)
                self.m_oDraw.text((X_POS + self.m_iTimingPosX, Y_POS -1), self.m_sTimings, 
                                   font=self.m_oFont10, fill=1)
                self.m_oDraw.text((X_POS + self.m_iRatePosX, Y_POS -1), self.m_sRate, 
                                   font=self.m_oFont10, fill=1)
                self.m_oDraw.text((X_POS + p_iNetInfoPosX, Y_POS + 54), p_sNet, 
                                   font=self.m_oFont10, fill=1)
                if p_iScroll == 0:
                    self.m_oDraw.rectangle((0, 12, 128, 29), outline=0, fill=0)
                    self.m_oDraw.text((p_iSysGamePosX, 12), p_sPrev_Title, 
                                       font=self.m_oFont2, fill=1)
            if p_iScroll != 0:
                self.m_oDraw.rectangle((0, 12, 128, 29), outline=0, fill=0)
                self.m_oDraw.text((p_iTitleMove, 12), p_sPrev_Title, 
                                   font=self.m_oFont2, fill=1)
            self.m_oDraw.rectangle((58, 41, 128, 48), outline=0, fill=0)
            self.m_oDraw.text((X_POS + 60, Y_POS + 39), p_iGameTime, 
                               font=self.m_oFont10, fill=1)
            self.draw()
            time.sleep(p_iRefreshTime)
            if time.time() - p_iTime >= p_iShow: break
        if not STOP_SCREEN:
            STOP_SCREEN = True
            t.join()
            STOP_SCREEN = False
        else:
            t.join()
        return True
Beispiel #10
0
 def _restart_system(self):
     """ Restart system and close ES if it's running """
     if check_process("emulationstatio"):
         commandline = 'sudo killall emulationstation && clear'
         os.system(commandline)
     os.system('sudo reboot now')