def close_db(): global dbase if dbase is not None: try: dbase.close() except: print "Error on closing local database: results may be corrupted..." finally: dbase = None CrobotsLibs.close_connection()
cleanup(configuration.label, a) if CrobotsLibs.DATABASE_ENABLE: CrobotsLibs.clean_up(a) close_db() raise SystemExit if action == 'setup': for a in ['f2f', '3vs3', '4vs4']: cleanup(configuration.label, a) init_db(configuration.label, a) init_status(a) close_db() raise SystemExit if action == 'test': CrobotsLibs.test_connection() CrobotsLibs.close_connection() print 'Test completed!' raise SystemExit if check_stop_file_exist(): print 'Crobots.stop file found! Exit application.' close_db() raise SystemExit def run_tournament(ptype, matchParam): global tmppath, logpath, robotPath, configuration, crobotsCmdLine print '%s Starting %s... ' % (time.ctime(), ptype.upper()) clean_up_log_file('%s/%s_%s.log' % (logpath, configuration.label, ptype)) param = crobotsCmdLine % matchParam init_db(configuration.label, ptype)