def run_ophis(args): CmdLine.parse_args(args) Frontend.pragma_modules.append(CorePragmas) if CmdLine.enable_undoc_ops: Opcodes.opcodes.update(Opcodes.undocops) elif CmdLine.enable_65c02_exts: Opcodes.opcodes.update(Opcodes.c02extensions) CorePragmas.reset() return run_all()
def main(): interpretor = CmdLine() l = interpretor.precmd('launch') r = interpretor.onecmd(l) r = interpretor.postcmd(r, l) if not r: interpretor.cmdloop()
def main(): interpretor = CmdLine() l = interpretor.precmd('launch') r = interpretor.onecmd(l) r = interpretor.postcmd(r,l) if not r: interpretor.cmdloop()
def MainLoop(): global dataDir global redirectFileName global locale random.seed() app = wx.App(False) app.SetAppName("SeriesMgr") parser = ArgumentParser( epilog= 'Example: {} --series MySeries.smn --races MyRace1.cmn=RegularPoints" "MyRace2.cmn=DoublePoints" MyRace2.cmn' .format(os.path.basename(sys.argv[0]))) parser.add_argument("filename", help="series file", nargs="?", metavar="SeriesFile.smn") parser.add_argument("-q", "--quiet", action="store_false", dest="verbose", default=True, help='hide splash screen') parser.add_argument("-r", "--regular", action="store_false", dest="fullScreen", default=True, help='regular size (not full screen)') parser.add_argument( '--series', default=None, metavar="SeriesFile.smn", help= 'Specifiy a <series_mgr_file>.smn file to use for the points structures. Optional if --score_by_time or --score_by_points options are used.' ) parser.add_argument( '--score_by_points', action='store_true', help= 'If specified, races will be scored by the points structures. This is the default.' ) parser.add_argument( '--score_by_time', action='store_true', help='If specified, races will be scored by the total time.') parser.add_argument( '--score_by_percent', action='store_true', help= 'If specified, races will be scored by the percent of the winning time.' ) parser.add_argument('--output', default=None, help='Output file (default is <series_mgr_file>.html)') parser.add_argument( '--races', metavar="Race.cmn[=point_structure]", nargs='+', default=[], help=' '.join(( 'Each race is of the form "Race.cmn[=point_structure]" and Race.cmn is a CrossMgr race, with the optional name of the points structure of the series to use to score that race.', 'If no point_structure is specified for a race, the first point_structure in the --series will be used.', 'No point_structure is required if the --score_by_time or --score_by_percent options are specified.', 'If no --races are defined, the races defined in the --series file will be used.', ))) args = parser.parse_args() if not args.filename and any([ args.series, args.score_by_points, args.score_by_time, args.score_by_percent, args.output, args.races ]): sys.exit(CmdLine.CmdLine(args)) dataDir = Utils.getHomeDir() redirectFileName = os.path.join(dataDir, 'SeriesMgr.log') # Set up the log file. Otherwise, show errors on the screen unbuffered. if __name__ == '__main__': Utils.disable_stdout_buffering() else: try: logSize = os.path.getsize(redirectFileName) if logSize > 1000000: os.remove(redirectFileName) except: pass try: app.RedirectStdio(redirectFileName) except: pass Utils.initTranslation() locale = wx.Locale(wx.LANGUAGE_ENGLISH) Utils.writeLog('start: {}'.format(Version.AppVerName)) # Configure the main window. sWidth, sHeight = wx.GetDisplaySize() mainWin = MainWin(None, title=Version.AppVerName, size=(sWidth * 0.9, sHeight * 0.9)) if args.fullScreen: mainWin.Maximize(True) mainWin.refreshAll() mainWin.CenterOnScreen() mainWin.Show() # Set the upper left icon. icon = wx.Icon(os.path.join(Utils.getImageFolder(), 'SeriesMgr.ico'), wx.BITMAP_TYPE_ICO) #mainWin.SetIcon( icon ) # Set the taskbar icon. #tbicon = wx.TaskBarIcon() #tbicon.SetIcon( icon, "SeriesMgr" ) if args.verbose: ShowSplashScreen() # ShowTipAtStartup() # Try to open a specified filename. fileName = args.filename # Try to load a series. if fileName and fileName.lower().endswith('.smn'): try: mainWin.openSeries(fileName) except (IndexError, AttributeError, ValueError): pass # Start processing events. mainWin.GetSizer().Layout() try: app.MainLoop() except: xc = traceback.format_exception(*sys.exc_info()) wx.MessageBox(''.join(xc))
elif char == '}': self.popState() else: if not char.isspace(): self.putChar(char) class RtfTester(RtfParser): def __init__(self, foutput): RtfParser.__init__(self) self.level = 0 self.foutput = foutput def pushState(self): self.foutput.write(unicode(self.level) + ' pushState ' + unicode(self.level + 1) + '\n') self.level = self.level + 1 def popState(self): self.foutput.write(unicode(self.level) + ' popState ' + unicode(self.level - 1) + '\n') self.level = self.level - 1 def putChar(self,ch): self.foutput.write(unicode(self.level) + ' putChar ' + unicode(ch)) def doControl(self,token,arg): self.foutput.write(unicode(self.level) + ' doControl ' + unicode(token) + ' ' + unicode(arg)) if __name__ == '__main__': import CmdLine CmdLine.main(RtfTester)
def popState(self): dest = self.destinations[-1] dest.popState(self) def putChar(self,ch): dest = self.destinations[-1] if not (ch=='\n' or ch=='\r'): dest.putChar(unicode(ch)) def doControl(self,token,arg): dest = self.destinations[-1] dest.doControl(token,arg) def close(self): for dest in self.destinations: dest.close() def getTxt(rtf): """ get the Text from a string that contain Rtf """ import StringIO s = StringIO.StringIO() parser = Rtf2Txt(s) parser.feed(rtf) parser.close() return s.getvalue() if __name__ == '__main__': import CmdLine CmdLine.main(Rtf2Txt)
dest.popState(self) def putChar(self,ch): dest = self.destinations[-1] dest.putChar(ch) def doControl(self,token,arg): dest = self.destinations[-1] dest.doControl(token,arg) def close(self): for dest in self.destinations: dest.close() self.foutput.write('</body></html>\n') def getHtml(rtf): """ get the Html from a string that contain Rtf """ try: import cStringIO as StringIO except ImportError: import StringIO s = StringIO.StringIO() parser = Rtf2Html(s) parser.feed(rtf) parser.close() return s.getvalue() if __name__ == '__main__': import CmdLine CmdLine.main(Rtf2Html)
def main(): sys.stdout = Unbuffered(sys.stdout) try: parameters = CmdLine.analyse_cmdline(sys.argv) if len(parameters) == 0: print("Usage: "+ sys.argv[0] + " PROJECT BRANCH [CONFIGS...]\n") print("PROJECT: the name of a project to be compiled.") print("BRANCH: branch to select for compilation.") print("CONFIGS: list of configuration to compile - if ignored all configurations will be used") return begin = time.perf_counter() total = 0 successful = 0 successful_details = {} project_info = JsonInfo.load_project_info(parameters) print("Compiling project \""+parameters[0]+"\" on branch \""+parameters[1]+"\".") selected_configs=select_configurations(project_info, parameters[2]) print("The following configurations have being selected:") for machine, dic in selected_configs.items(): configlist = "" for config in dic: configlist = configlist + " " + config print("- for machine \""+machine+"\":"+configlist) print() print("Starting compilation process...") for machine, dic in selected_configs.items(): print("- Compiling on machine \""+machine+"\"...") print(" -> Starting machine") if not Machine.start_machine(project_info["machines"], machine): print(" FAILED to launch machine") for config, desc in dic.items(): total = total+1 successful_details[config] = (False, 0) continue print(" -> Testing connection") if not Machine.test_connection_to_machine(project_info["machines"], machine): print(" FAILED to connect to machine") for config, desc in dic.items(): total = total+1 successful_details[config] = (False, 0) else: for config, desc in dic.items(): print(" -> Compiling configuration \""+config+"\"...") begin_local = time.perf_counter() successful_local = Machine.compile_config(project_info["machines"], desc, parameters[1]) end_local = time.perf_counter() total = total + 1 successful_details[config] = (successful_local, end_local-begin_local) if successful_local: successful = successful + 1 print(" -> Stopping machine") if not Machine.stop_machine(project_info["machines"], machine): print(" FAILED to stop machine") print(" To prevent possible multiple vm execution, stopping compilation sequence") break end = time.perf_counter() ellapsed = end-begin print() print("Results:") for config, info in successful_details.items(): if info[0]: text = "OK" else: text = "FAILED" print("- " + config + ": " + text + " ("+format_time(info[1])+")") print() print(str(successful)+"/"+str(total)+" successful builds for a total time of "+format_time(ellapsed) + " (" +str(ellapsed)+" seconds)") except Exception as exc: print(exc) return