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))