def run(sCommandline, sDBSys=None): oCRT = None if sDBSys: oCRT = CRT(sDBSys) oCRT.screen_calculated(CRT_DB_SYSTEMS_FILE) oRunProcess = subprocess.Popen(shlex.split(sCommandline), shell=False) iExitCode = oRunProcess.wait() if oCRT: oCRT.screen_restore()
def launch_credits(): global oCRT global oBlackScreen global iExitCode ra_version_fixes(RA_GBA_CFG_FILE2) oCRT = CRT(sSystem) oBlackScreen = HideScreen() oBlackScreen.fill() oCRT.screen_calculated(CRT_DB_SYSTEMS_FILE) commandline = "%s -L %s " % (RA_BIN_FILE, RA_GBA_CORE_FILE) commandline += "--config %s " % RA_GBA_CFG_FILE1 commandline += "--appendconfig %s " % RA_GBA_CFG_FILE2 commandline += "\"%s\" " % ROM_FILE commandline += "> /dev/null 2>&1" oRunProcess = subprocess.Popen(commandline, shell=True) iExitCode = oRunProcess.wait() oCRT.screen_restore()
class center(object): """ virtual class for centering pattern """ m_dVideo = {} m_oCRT = None m_oPatternHandle = None m_sEnv = "" m_bRestart = True m_dPatternAdj = {} def __init__(self): self.__temp() self.__clean() self.m_oPatternHandle = generate() def launch(self, p_sArgv="current", p_sRestart=True): logging.info("INFO: arg 1 (test) = %s" % p_sArgv) self.m_sEnv = p_sArgv self.m_bRestart = p_sRestart if self.m_sEnv == "force": logging.info("INFO: Force mode, only apply sys resolution") self._force_system_res() else: self.configure() # rom name work self.prepare() # screen and pattern generator self.run() # launch, wait and cleanup # called at start, called by __init__() def configure(self): """Get from utility.cfg system resolution""" if self.m_sEnv == "current": self.m_sEnv = ini_get(CRT_UTILITY_FILE, "default") def prepare(self): self.screen_prepare() self.m_oPatternHandle.initialize(self.m_sEnv, self.m_dVideo) def run(self): self.start() self.cleanup() def start(self): self.apply_diff_timings() self.screen_set() self.m_oPatternHandle.launch() def apply_diff_timings(self): DiffTimings = self.m_oPatternHandle.get_diff_timings() logging.info("INFO: timing_data_set PRE-CALCULATED Diff - %s" % self.m_dVideo) for timing in DiffTimings: self.m_oCRT.timing_add(timing, int(DiffTimings[timing])) logging.info("INFO: timing_data_set POST-CALCULATED Diff - %s" % self.m_dVideo) def _force_system_res(self): p_oSaveBoot = saveboot() p_oSaveBoot.save() self.m_oCRT = CRT() self.cleanup() self._restart_es() def screen_prepare(self): self.m_oCRT = CRT(self.m_sEnv + "_timings") self.m_dVideo = self.m_oCRT.pattern_data(CRT_UTILITY_FILE) def screen_set(self): self.m_oCRT.resolution_set() def panic(self, p_sErrorLine1, p_sErrorLine2="-", p_bForceQuit=True): """ stop the program and show error to the user """ logging.error("PANIC: %s" % p_sErrorLine1) CRT().screen_restore() something_is_bad(p_sErrorLine1, p_sErrorLine2) if p_bForceQuit: logging.error("EXIT: crt_launcher forced") self.__clean() sys.exit(1) def _restart_es(self): commandline = None if self.m_bRestart: 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) # cleanup code def cleanup(self): self.m_oCRT.screen_restore() logging.info("ES mode recover") os.system('clear') self.__clean() # clean system def __clean(self): pass def __temp(self): if CLEAN_LOG_ONSTART: remove_file(LOG_PATH) logging.basicConfig( filename=LOG_PATH, level=__DEBUG__, format= '[%(asctime)s] %(levelname)s - %(filename)s:%(funcName)s - %(message)s' )