当前位置: 首页>>代码示例>>Python>>正文


Python System.fident函数代码示例

本文整理汇总了Python中pychess.System.fident函数的典型用法代码示例。如果您正苦于以下问题:Python fident函数的具体用法?Python fident怎么用?Python fident使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了fident函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: start

 def start(self):
     if self.mode in (ANALYZING, INVERSE_ANALYZING):
         t = Thread(target=self.__startBlocking, name=fident(self.__startBlocking))
         t.daemon = True
         t.start()
     else:
         self.__startBlocking()
开发者ID:sally0813,项目名称:pychess,代码行数:7,代码来源:CECPEngine.py

示例2: repeat_sleep

def repeat_sleep(func, sleeptime, recur=False):
    """
    Runs func in a thread and repeats it approximately each sleeptime [s]
    until func returns False. Notice that we sleep first, then run. Not the
    other way around. If repeat_sleep is called with recur=True, each call
    will be called with the return value of last call as argument. The
    argument has to be optional, as it wont be used first time, and it has
    to be non-None.
    """

    def run():
        last = time.time()
        val = None
        while True:
            time.sleep(time.time() - last + sleeptime)
            if not time:
                # If python has been shutdown while we were sleeping, the
                # imported modules will be None
                return
            last = time.time()
            if recur and val:
                val = func(val)
            else:
                val = func()
            if not val: break

    thread = Thread(target=run, name=fident(func))
    thread.daemon = True
    thread.start()
开发者ID:jcoffee,项目名称:pychess,代码行数:29,代码来源:repeat.py

示例3: __init__

    def __init__ (self, timemodel=None, variant=NormalChess):        
        GObject.GObject.__init__(self)
        Thread.__init__(self, name=fident(self.run))
        self.daemon = True
        self.variant = variant
        self.boards = [variant.board(setup=True)]
        
        self.moves = []
        self.scores = {}
        self.players = []
        
        self.gameno = None
        self.variations = [self.boards]
        
        self.status = WAITING_TO_START
        self.reason = UNKNOWN_REASON
        
        if timemodel is None:
            self.timemodel = TimeModel()
        else:
            self.timemodel = timemodel
        
        self.connections = defaultdict(list)  # mainly for IC subclasses
        
        now = datetime.datetime.now()
        self.tags = {
            "Event": _("Local Event"),
            "Site":  _("Local Site"),
            "Round": 1,
            "Year":  now.year,
            "Month": now.month,
            "Day":   now.day,
            "Time":  "%02d:%02d:00" % (now.hour, now.minute),
            "Result": "*",
        }

        self.endstatus = None
        self.timed = self.timemodel.secs!=0 or self.timemodel.gain!=0

        if self.timed:
            self.tags["TimeControl"] = \
                "%d+%d" % (self.timemodel.minutes*60, self.timemodel.gain)
            # Notice: tags["WhiteClock"] and tags["BlackClock"] are never set
            # on the gamemodel, but simply written or read during saving/
            # loading from pgn. If you want to know the time left for a player,
            # check the time model.
        
        # Keeps track of offers, so that accepts can be spotted
        self.offers = {}
        # True if the game has been changed since last save
        self.needsSave = False
        # The uri the current game was loaded from, or None if not a loaded game
        self.uri = None
        
        self.spectators = {}
        
        self.applyingMoveLock = RLock()
        self.undoLock = RLock()
        self.undoQueue = Queue()
开发者ID:fowode,项目名称:pychess,代码行数:59,代码来源:GameModel.py

示例4: logged_f

 def logged_f(*args):
     if debug:
         msg = '%s(%s)' % (fident(f),
                           ','.join([str(a) for a in args]))
         log.debug(msg,
                   extra={'task': (thread.ident, thread.name,
                                   'idle_add.new_func')})
     f(*args)
开发者ID:CarbonFixer,项目名称:pychess,代码行数:8,代码来源:idle_add.py

示例5: repeat

def repeat (func, *args, **kwargs):
    """ Repeats a function in a new thread until it returns False """
    def run ():
        while func(*args, **kwargs):
            pass
    t = Thread(target=run, name=fident(func))
    t.daemon = True
    t.start()
开发者ID:Alex-Linhares,项目名称:pychess,代码行数:8,代码来源:repeat.py

示例6: newFunction

 def newFunction(*args, **kw):
     _debug('glocked.newFunction', currentThread(),
            '-> acquire() (f=%s)' % fident(f))
     acquire()
     try:
         return f(*args, **kw)
     finally:
         release()
开发者ID:Alex-Linhares,项目名称:pychess,代码行数:8,代码来源:glock.py

示例7: __onTell

    def __onTell(self, chatManager, name, title, isadmin, text):

        if self.waitingForPassword:
            if text.strip() == self.password or (not self.password and
                                                 text == "none"):
                self.sudos.add(name)
                self.tellHome("%s gained sudo access" % name)
                self.connection.client.run_command(self.waitingForPassword)
            else:
                chatManager.tellPlayer(name, "Wrong password")
                self.tellHome("%s failed sudo access" % name)
            self.waitingForPassword = None
            return

        args = text.split()

        #if args == ["help"]:
        #    chatManager.tellPlayer(name, self.__usage())

        if args[0] == "sudo":
            command = " ".join(args[1:])
            if name in self.sudos or name == self.owner:
                # Notice: This can be used to make nasty loops
                print(command, file=self.connection.client)
            else:
                print(repr(name), self.sudos)
                chatManager.tellPlayer(name, "Please send me the password")
                self.waitingForPassword = command

        elif args == ["sendlog"]:
            if self.log:
                # TODO: Consider email
                chatManager.tellPlayer(name, "\\n".join(self.log))
            else:
                chatManager.tellPlayer(name, "The log is currently empty")

        else:
            if self.ownerOnline:
                self.tellHome("%s told me '%s'" % (name, text))
            else:

                def onlineanswer(message):
                    data = urlopen(
                        "http://www.pandorabots.com/pandora/talk?botid=8d034368fe360895",
                        urlencode({"message": message,
                                   "botcust2": "x"}).encode("utf-8")).read(
                                   ).decode('utf-8')
                    bold_ss = "<b>DMPGirl:</b>"
                    break_es = "<br>"
                    answer = data[data.find(bold_ss) + len(bold_ss):data.find(
                        break_es, data.find(bold_ss))]
                    chatManager.tellPlayer(name, answer)

                thread = Thread(target=onlineanswer,
                                name=fident(onlineanswer),
                                args=(text, ))
                thread.daemon = True
                thread.start()
开发者ID:jcoffee,项目名称:pychess,代码行数:58,代码来源:PyChessFICS.py

示例8: start_thread_dump

def start_thread_dump():
    def thread_dumper():
        while True:
            dump_threads()
            time.sleep(10)

    thread = Thread(target=thread_dumper, name=fident(thread_dumper))
    thread.daemon = True
    thread.start()
开发者ID:teacoffee2017,项目名称:pychess,代码行数:9,代码来源:debug.py

示例9: __go

 def __go (self):
     def ondone (result):
         if not self.forced:
             self.board.applyMove(parseSAN(self.board,result))
             print("move %s" % result)
         # TODO: start pondering, if enabled
     self.thread = Thread(target=PyChess._PyChess__go,
                          name=fident(PyChess._PyChess__go),
                          args=(self,ondone))
     self.thread.daemon = True
     self.thread.start()
开发者ID:fowode,项目名称:pychess,代码行数:11,代码来源:PyChessCECP.py

示例10: __init__

 def __init__ (self):
     GObject.GObject.__init__(self)
     Thread.__init__(self, name=fident(self.run))
     self.daemon = True
     self.stop = False
     self.lowply = 0
     self.status = RUNNING
     self.players = []
     self.moves = []
     self.variant = SetupBoard
     self.boards = [self.variant()]
     self.variations = [self.boards]
开发者ID:sally0813,项目名称:pychess,代码行数:12,代码来源:SetupModel.py

示例11: cacheGladefile

def cacheGladefile(filename):
    """ Gtk.Builder automatically caches the file, so we only need to use this
        file once """
    if filename not in cachedGlades:
        cachedGlades[filename] = Queue()
        def readit ():
            builder = Gtk.Builder()
            builder.set_translation_domain("pychess")
            builder.add_from_file(addDataPrefix("glade/%s" % filename))
            cachedGlades[filename].put(builder)
        t = Thread(target=readit, name=fident(readit))
        t.daemon = True
        t.start()
开发者ID:Alex-Linhares,项目名称:pychess,代码行数:13,代码来源:uistuff.py

示例12: __init__

    def __init__ (self, store, tv, boardview):
        Thread.__init__(self, name=fident(self.run))
        self.daemon = True
        # FIXME 'Advisor.name = ...' in Advisor.__init__ overwrites Thread.name
        Advisor.__init__(self, store, _("Endgame Table"), ENDGAME)
        self.egtb = EndgameTable()
        self.tv = tv
        self.boardview = boardview
        self.tooltip = _("The endgame table will show exact analysis when there are few pieces on the board.")
        # TODO: Show a message if tablebases for the position exist but are neither installed nor allowed.

        self.egtb.connect("scored", self.on_scored)
        self.queue = Queue()
        self.start()
开发者ID:ZeepXanflorp,项目名称:pychess,代码行数:14,代码来源:bookPanel.py

示例13: putMessage

 def putMessage (self, message):
     def answer (message):
         try:
             data = urlopen("http://www.pandorabots.com/pandora/talk?botid=8d034368fe360895",
                            urlencode({"message":message, "botcust2":"x"}).encode("utf-8")).read().decode('utf-8')
         except IOError as e:
             log.warning("Couldn't answer message from online bot: '%s'" % e,
                      extra={"task":self.defname})
             return
         ss = "<b>DMPGirl:</b>"
         es = "<br>"
         answer = data[data.find(ss)+len(ss) : data.find(es,data.find(ss))]
         self.emit("offer", Offer(CHAT_ACTION, answer))
     t = Thread(target=answer, name=fident(answer), args=(message,))
     t.daemon = True
     t.start()
开发者ID:Alex-Linhares,项目名称:pychess,代码行数:16,代码来源:Engine.py

示例14: __init__

    def __init__ (self, host, ports, username, password):
        GObject.GObject.__init__(self)
        Thread.__init__(self, name=fident(self.run))
        self.daemon = True
        self.host = host
        self.ports = ports
        self.username = username
        self.password = password
        
        self.connected = False
        self.connecting = False
        
        self.predictions = set()
        self.predictionsDict = {}
        self.reply_cmd_dict = defaultdict(list)

        # Are we connected to FatICS ?
        self.FatICS = False
开发者ID:iamLovingJerk,项目名称:pychess,代码行数:18,代码来源:FICSConnection.py

示例15: run_analyze

    def run_analyze(button, *args):
        old_check_value = conf.get("analyzer_check", True)
        conf.set("analyzer_check", True)
        widgets["analyze_ok_button"].set_sensitive(False)
        gmwidg = gamewidget.cur_gmwidg()
        gamemodel = gameDic[gmwidg]
        analyzer = gamemodel.spectators[HINT]

        def analyse_moves():
            move_time = int(conf.get("max_analysis_spin", 3))
            thresold = int(conf.get("variation_thresold_spin", 50))
            for board in gamemodel.boards:
                if stop_event.is_set():
                    break
                glock.acquire()
                try:
                    gmwidg.board.view.setShownBoard(board)
                finally:
                    glock.release()
                analyzer.setBoard(board)
                time.sleep(move_time + 0.1)

                ply = board.ply
                if ply - 1 in gamemodel.scores:
                    color = (ply - 1) % 2
                    oldmoves, oldscore, olddepth = gamemodel.scores[ply - 1]
                    oldscore = oldscore * -1 if color == BLACK else oldscore
                    moves, score, depth = gamemodel.scores[ply]
                    score = score * -1 if color == WHITE else score
                    diff = score - oldscore
                    if (diff > thresold and color == BLACK) or (diff < -1 * thresold and color == WHITE):
                        gamemodel.add_variation(gamemodel.boards[ply - 1], oldmoves)

            widgets["analyze_game"].hide()
            widgets["analyze_ok_button"].set_sensitive(True)
            conf.set("analyzer_check", old_check_value)

        t = threading.Thread(target=analyse_moves, name=fident(analyse_moves))
        t.daemon = True
        t.start()
        return True
开发者ID:fowode,项目名称:pychess,代码行数:41,代码来源:analyzegameDialog.py


注:本文中的pychess.System.fident函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。