Exemple #1
0
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 rev. %s %s started" % (VERSION_NAME, VERSION, pychess.hg_rev, pychess.hg_date))
    log.info("Command line args: '%s'" % chess_file)
    if not no_thread_debug:
        start_thread_dump()
    if ics_host:
        ICLogon.host = ics_host
    if ics_port:
        ICLogon.port = ics_port
    
    Gtk.main()
Exemple #2
0
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()
Exemple #3
0
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()
Exemple #4
0
 def saveGameDb(self, game):
     if conf.get("saveOwnGames", False) and not game.hasLocalPlayer():
         return True
     pychess_pdb = os.path.join(addUserDataPrefix("pychess.pdb"))
     pychess_pdb = conf.get("autosave_db_file", pychess_pdb)
     saver = database
     append = True
     try:
         game.save(pychess_pdb, saver, append)
         return True
     except IOError:
         return False
Exemple #5
0
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()
Exemple #6
0
def run(no_debug, no_glock_debug, no_thread_debug, log_viewer, chess_file,
        ics_host, ics_port):
    # Start logging
    log.logger.setLevel(logging.WARNING if no_debug is True else logging.DEBUG)
    if log_viewer:
        Log.set_gui_log_emitter()
    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)
    Gdk.threads_init()
    GObject.threads_init()
    Gdk.threads_enter()

    pychess = PyChess(log_viewer, chess_file)
    glock.debug = not no_glock_debug
    log.info("PyChess %s %s rev. %s %s started" %
             (VERSION_NAME, VERSION, pychess.hg_rev, pychess.hg_date))
    log.info("Command line args: '%s'" % chess_file)
    if not no_thread_debug:
        start_thread_dump()
    if ics_host:
        ICLogon.host = ics_host
    if ics_port:
        ICLogon.port = ics_port

    Gtk.main()
    Gdk.threads_leave()
Exemple #7
0
    Column('black_id', Integer),
    Column('result', SmallInteger),
    Column('white_elo', SmallInteger),
    Column('black_elo', SmallInteger),
    Column('ply_count', SmallInteger),
    Column('eco', CHAR(3)),
    Column('board', SmallInteger),
    Column('fen', String(128)),
    Column('variant', SmallInteger),
    Column('annotator_id', Integer),
    Column('collection_id', Integer),
    Column('movelist', LargeBinary),
    Column('comments', UnicodeText)
    )

def ini_collection():
    conn = engine.connect()
    new_values = [
        {"id": LOCAL, "name": unicode("Local game")},
        {"id": ARTIFICIAL, "name": unicode("Chess engine(s)")},
        {"id": REMOTE, "name": unicode("ICS game")},
        ]
    conn.execute(collection.insert(), new_values)
    conn.close()

pychess_pdb = os.path.join(addUserDataPrefix("pychess.pdb"))
set_engine("sqlite:///" + pychess_pdb)
if not os.path.isfile(pychess_pdb):
    metadata.create_all(engine)
    ini_collection()
Exemple #8
0
             Column('variant', SmallInteger), Column('annotator_id', Integer),
             Column('collection_id', Integer), Column('movelist', LargeBinary),
             Column('comments', UnicodeText))


def ini_collection():
    conn = engine.connect()
    new_values = [
        {
            "id": LOCAL,
            "name": unicode("Local game")
        },
        {
            "id": ARTIFICIAL,
            "name": unicode("Chess engine(s)")
        },
        {
            "id": REMOTE,
            "name": unicode("ICS game")
        },
    ]
    conn.execute(collection.insert(), new_values)
    conn.close()


pychess_pdb = os.path.join(addUserDataPrefix("pychess.pdb"))
set_engine("sqlite:///" + pychess_pdb)
if not os.path.isfile(pychess_pdb):
    metadata.create_all(engine)
    ini_collection()
Exemple #9
0
 def __init__(self, progress_file):
     GObject.GObject.__init__(self)
     UserDict.__init__(self)
     self.progress_file = addUserDataPrefix(progress_file)
Exemple #10
0
 def __init__(self, progress_file):
     GObject.GObject.__init__(self)
     UserDict.__init__(self)
     self.progress_file = addUserDataPrefix(progress_file)