def run(no_debug, idle_add_debug, thread_debug, log_viewer, purge_recent, chess_file, ics_host, ics_port): # Start logging if log_viewer: log.logger.addHandler(GLogHandler(logemitter)) log.logger.setLevel(logging.WARNING if no_debug is True else logging.DEBUG) oldlogs = [ l for l in os.listdir(getUserDataPrefix()) if l.endswith(".log") ] conf.set("max_log_files", conf.get("max_log_files", 10)) oldlogs.sort() l = len(oldlogs) while l > conf.get("max_log_files", 10): try: os.remove(addUserDataPrefix(oldlogs[0])) del oldlogs[0] except OSError: pass l -= 1 if purge_recent: items = recentManager.get_items() for item in items: uri = item.get_uri() if item.get_application_info("pychess"): recentManager.remove_item(uri) signal.signal(signal.SIGINT, Gtk.main_quit) signal.signal(signal.SIGTERM, Gtk.main_quit) def cleanup(): ICLogon.stop() SubProcess.finishAllSubprocesses() atexit.register(cleanup) pychess = PyChess(log_viewer, chess_file) idle_add.debug = idle_add_debug sys.stdout = LogPipe(sys.stdout, "stdout") sys.stderr = LogPipe(sys.stderr, "stdout") log.info("PyChess %s %s git %s" % (VERSION_NAME, VERSION, pychess.git_rev)) log.info("Command line args: '%s'" % chess_file) log.info("Platform: %s" % platform.platform()) log.info("Python version: %s.%s.%s" % sys.version_info[0:3]) log.info("Pyglib version: %s.%s.%s" % GLib.pyglib_version) if thread_debug: start_thread_dump() if ics_host: ICLogon.host = ics_host if ics_port: ICLogon.port = ics_port Gtk.main()
def run(no_debug, no_idle_add_debug, no_thread_debug, log_viewer, chess_file, ics_host, ics_port): # Start logging if log_viewer: log.logger.addHandler(GLogHandler(logemitter)) log.logger.setLevel(logging.WARNING if no_debug is True else logging.DEBUG) oldlogs = [ l for l in os.listdir(getUserDataPrefix()) if l.endswith(".log") ] conf.set("max_log_files", conf.get("max_log_files", 10)) if len(oldlogs) >= conf.get("max_log_files", 10): oldlogs.sort() try: os.remove(addUserDataPrefix(oldlogs[0])) except OSError as e: pass signal.signal(signal.SIGINT, Gtk.main_quit) def cleanup(): SubProcess.finishAllSubprocesses() atexit.register(cleanup) pychess = PyChess(log_viewer, chess_file) idle_add.debug = not no_idle_add_debug sys.stdout = LogPipe(sys.stdout, "stdout") sys.stderr = LogPipe(sys.stderr, "stdout") log.info("PyChess %s %s git %s" % (VERSION_NAME, VERSION, pychess.git_rev)) log.info("Command line args: '%s'" % chess_file) log.info("Platform: %s" % platform.platform()) log.info("Python version: %s.%s.%s" % sys.version_info[0:3]) log.info("Pyglib version: %s.%s.%s" % GLib.pyglib_version) if not no_thread_debug: start_thread_dump() if ics_host: ICLogon.host = ics_host if ics_port: ICLogon.port = ics_port Gtk.main()