def playLevel(level, withLogging=True, **kwargs): ''' For testing new Levels - launches Trosnoth in single player mode with the given level. ''' import sys from trosnoth.run.solotest import Main if withLogging: from trosnoth.utils.utils import initLogging initLogging() main = Main(level=level, **kwargs) if '--profile' in sys.argv[1:]: import cProfile from trosnoth.utils.profiling import KCacheGrindOutputter prof = cProfile.Profile() try: prof.runcall(main.run_twisted) except SystemExit: pass finally: kg = KCacheGrindOutputter(prof) with open('{}.log'.format(level.__class__.__name__), 'w') as f: kg.output(f) else: main.run_twisted()
def playLevel(level, withLogging=True, **kwargs): ''' For testing new Levels - launches Trosnoth in single player mode with the given level. ''' from trosnoth.run.solotest import Main if withLogging: from trosnoth.utils.utils import initLogging initLogging() Main(level=level, **kwargs).run_twisted()
def main(): args = _getParser().parse_args() token = input().encode('ascii') logPrefix = args.logPrefix + '-bots' if args.logPrefix else 'bots' if os.name == 'nt': logpath = data.getPath(data.user, 'authserver', 'logs') data.makeDirs(logpath) initLogging( logFile=os.path.join(logpath, 'log{}.txt'.format(logPrefix))) else: initLogging(prefix='[{}] '.format(logPrefix)) reactor.callWhenRunning(_twisted_main, args, token) reactor.run()
def main(): from argparse import ArgumentParser parser = ArgumentParser(description='Trosnoth server') parser.add_argument('-D', '--datapath', action='store', dest='dataPath', default=None, help='path to authentication server data and settings') parser.add_argument('-d', '--debug', action='store_true', dest='debug', help='show debug-level messages on console') parser.add_argument('-l', '--log-file', action='store', dest='logFile', help='file to write logs to') parser.add_argument('--profile', action='store_true', dest='profile', help='dump kcachegrind profiling data to trosnoth.log') parser.add_argument( '--no-browser', action='store_false', dest='browser', help='do not attempt to launch a web browser for the UI') parser.add_argument('--safemode', action='store_true', help='use safe values for all start-up settings') options = parser.parse_args() initLogging(options.debug, options.logFile) kwargs = dict( dataPath=options.dataPath, browser=options.browser, safemode=options.safemode, ) if options.profile: runWithProfiling(**kwargs) else: startServer(**kwargs)
def main(): parser = makeOptionParser() options, args = makeOptionParser().parse_args() options.replayFile = None if len(args) == 1: (replayFile, ) = args if not os.path.exists(replayFile): parser.error('Replay file not found: {}'.format(replayFile)) options.normal = 'replay' options.replayFile = replayFile elif len(args) > 1: parser.error('too many arguments') initLogging(options.debug, options.logFile) processOptions(options, parser) if options.mode == 'listais': listAIs() return if options.mode == 'normal': mainObject = Main(showReplay=options.replayFile) elif options.mode == 'auth': mainObject = Main(serverDetails=(options.host, options.port)) elif options.mode == 'solo': from trosnoth.run import solotest mainObject = solotest.Main(**options.soloArgs) else: assert False, 'Unknown mode' if options.log_reactor_calls or options.profile_reactor_calls: from trosnoth.utils import twistdebug twistdebug.start(profiling=options.profile_reactor_calls) if options.profile: mainObject.run_with_profiling(twisted=True) else: mainObject.run_twisted()
def main(): from optparse import OptionParser parser = OptionParser() parser.add_option('-p', '--port', action='store', dest='port', default=6787, help='which port to run the authentication server on') parser.add_option('-D', '--datapath', action='store', dest='dataPath', default=None, help='where to store the authentication server data') parser.add_option('-m', '--manhole', action='store', dest='manholePort', default=6799, help='which port to run the manhole on') parser.add_option('--password', action='store', dest='manholePassword', default=None, help='the password to use for the manhole') parser.add_option( '-w', '--webport', action='store', dest='webPort', default='8080', help='the port on which to launch the web service. ' 'Default is 8080. To disable web service, use --webport= with no ' 'parameter.') parser.add_option('-d', '--debug', action='store_true', dest='debug', help='show debug-level messages on console') parser.add_option('-l', '--log-file', action='store', dest='logFile', help='file to write logs to') parser.add_option('--profile', action='store_true', dest='profile', help='dump kcachegrind profiling data to trosnoth.log') options, args = parser.parse_args() if len(args) > 0: parser.error('no arguments expected') initLogging(options.debug, options.logFile) if not options.webPort: webPort = None else: try: webPort = int(options.webPort) except ValueError: options.error('Invalid port: %r' % (options.webPort, )) kwargs = dict( port=int(options.port), dataPath=options.dataPath, manholePort=int(options.manholePort), password=options.manholePassword, webPort=webPort, ) if options.profile: runWithProfiling(**kwargs) else: startServer(**kwargs)