def _changed_dbfile(self, val, oldval): stats.dbclose(restart=True) if not stats.dbcheck(): QtGui.QMessageBox.warning(self, 'DB Version Mismatch', 'Database version mismatch.\nUpgrade database with -D switch.\n\nReverted to previous value.') conf.dbfile = oldval self.settings.setValue('files/dbfile', oldval) stats.dbclose(restart=True) stats.dbcheck() stats.dbopen()
def runmain(): if upgrade_db: stats.dbremove() stats.initialize() dbcheck() global testmode if testmode: if not os.path.exists(conf.logdir): print 'Log directory does not exist:', conf.logdir print 'test mode disabled' testmode = False stats.dbopen() if tournament: import datetime dt = datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S') print 'Beginning tournament with %s battles.' % nbattles for battle in range(nbattles): print 'Battle', battle + 1 game = Game(testmode, dt) game.run() world.Robot.nrobots = 0 view.Robot.nrobots = 0 results = stats.tournament_results(dt) print print print print 'Tournament Results' print nbattles, 'battles between', len(results), 'robots' print for line in results: print line[1], ':', line[4], 'wins', ':', line[ 6], 'defeated', ':', line[7], 'dmg caused' elif pyqtgraphics: import qt4view qt4view.run() else: game = Game(testmode, gameID=gameID, robots=gamerobots) game.run() stats.dbclose() # Clean up log directory if not in test mode if not testmode and os.path.exists(conf.logdir): for f in os.listdir(conf.logdir): fpath = os.path.join(conf.logdir, f) os.remove(fpath)
def _changed_dbfile(self, val, oldval): stats.dbclose(restart=True) if not stats.dbcheck(): QtGui.QMessageBox.warning( self, 'DB Version Mismatch', 'Database version mismatch.\nUpgrade database with -D switch.\n\nReverted to previous value.' ) conf.dbfile = oldval self.settings.setValue('files/dbfile', oldval) stats.dbclose(restart=True) stats.dbcheck() stats.dbopen()
def runmain(): if upgrade_db: stats.dbremove() stats.initialize() dbcheck() global testmode if testmode: if not os.path.exists(conf.logdir): print 'Log directory does not exist:', conf.logdir print 'test mode disabled' testmode = False stats.dbopen() if tournament: import datetime dt = datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S') print 'Beginning tournament with %s battles.' % nbattles for battle in range(nbattles): print 'Battle', battle+1 game = Game(testmode, dt) game.run() world.Robot.nrobots = 0 view.Robot.nrobots = 0 results = stats.tournament_results(dt) print;print;print; print 'Tournament Results' print nbattles, 'battles between', len(results), 'robots' print for line in results: print line[1], ':', line[4], 'wins', ':', line[6], 'defeated', ':', line[7], 'dmg caused' elif pyqtgraphics: import qt4view qt4view.run() else: game = Game(testmode, gameID=gameID,robots=gamerobots) game.run() stats.dbclose() # Clean up log directory if not in test mode if not testmode and os.path.exists(conf.logdir): for f in os.listdir(conf.logdir): fpath = os.path.join(conf.logdir, f) os.remove(fpath)
def _changed_base_dir(self, val, oldval): if not os.path.exists(val): os.mkdir(val) stats.dbclose(restart=True) if not stats.dbcheck(): QtGui.QMessageBox.warning(self, 'DB Version Mismatch', 'Database version mismatch.') stats.dbopen() import shutil #print 'ONV', oldval, conf.template, val scriptdir = os.path.dirname(os.path.abspath(__file__)) robotsdir = os.path.join(scriptdir, 'robots') template = os.path.join(robotsdir, conf.template) shutil.copy(template, val) examples = os.path.join(robotsdir, 'examples') shutil.copytree(examples, os.path.join(val, 'examples'))
def runmain(): if qtreset: reset_qt_settings() check_pybox2d_version() if upgrade_db: print 'Upgrading Database' stats.dbremove() stats.dbopen() return dbcheck() stats.dbopen() global tournament global nbattles if not pyqtgraphics and not tournament: tournament = True nbattles = 1 if tournament and pyqtgraphics: print 'When using PyQt interface, run tournaments from GUI.' elif tournament: if tournament is True: import datetime dt = datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S') else: dt = tournament print 'Beginning tournament with %s battles.' % nbattles for battle in range(nbattles): print 'Battle', battle + 1 game = Game(testmode, dt) game.run() world.Robot.nrobots = 0 view.Robot.nrobots = 0 results = stats.tournament_results(dt) print print print print 'Tournament Results' print nbattles, 'battles between', len(results), 'robots' print for line in results: print line[1], ':', line[4], 'wins', ':', line[ 6], 'outlasted', ':', line[7], 'dmg caused', ':', line[ 8], 'kills' elif pyqtgraphics: import qt4view qt4view.run(testmode) else: game = Game(testmode) game.run() stats.dbclose() if not tournament: stats.dbopen() stats.top10() # Clean up log directory if not in test mode logdir = os.path.join(conf.base_dir, conf.logdir) if not testmode and os.path.exists(logdir): for f in os.listdir(logdir): fpath = os.path.join(logdir, f) try: os.remove(fpath) except OSError: pass