• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python System.fident函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: new_func

    def new_func(*args):
        thread = currentThread()
        if thread.name == "MainThread":
            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)
        else:

            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)

            GLib.idle_add(logged_f, *args)
开发者ID:CarbonFixer,项目名称:pychess,代码行数:21,代码来源:idle_add.py


示例17: start_thread_dump

def start_thread_dump ():
    def thread_dumper ():
        def dump_threads ():
            id2thread = {}
            for thread in threading.enumerate():
                id2thread[thread.ident] = thread
            
            stacks = []
            for thread_id, frame in sys._current_frames().items():
                stack = traceback.format_list(traceback.extract_stack(frame))
                stacks.append("Thread: %s (%d)" % (id2thread[thread_id].name, thread_id))
                stacks.append("".join(stack))
            
            log.debug("\n" + "\n".join(stacks))
        
        while True:
            dump_threads()
            time.sleep(10)
    
    t = Thread(target=thread_dumper, name=fident(thread_dumper))
    t.daemon = True
    t.start()
开发者ID:oldstylejoe,项目名称:pychess-timed,代码行数:22,代码来源:debug.py


示例18: __init__

 def __init__ (self, func):
     """ Initialize a new GtkWorker around a specific function """
     GObject.GObject.__init__(self)
     Thread.__init__(self, name=fident(func))
     self.daemon = True
     
     # By some reason we cannot access __gsignals__, so we have to do a
     # little double work here
     #self.connections = {"progressed": 0, "published": 0, "done": 0}
     self.connections = {"published": 0, "done": 0}
     self.handler_ids = {}
     self.name = func.__name__
     self.func = func
     self.cancelled = False
     self.done = False
     #self.progress = 0
     
     ########################################################################
     # Publish and progress queues                                          #
     ########################################################################
     
     self.publisher = EmitPublisher (self, "published",
         'GtkWorker.publisher', Publisher.SEND_LIST)
     self.publisher.start()
开发者ID:Alex-Linhares,项目名称:pychess,代码行数:24,代码来源:GtkWorker.py


示例19: _connect

    def _connect (self):
        self.connecting = True
        self.emit("connecting")
        try:
            self.client = TimeSeal()
            
            self.emit('connectingMsg', _("Connecting to server"))
            for i, port in enumerate(self.ports):
                log.debug("Trying port %d" % port, extra={"task": (self.host, "raw")})
                try:
                    self.client.open(self.host, port)
                except socket.error as e:
                    log.debug("Failed to open port %d %s" % (port, e), extra={"task": (self.host, "raw")})
                    if i+1 == len(self.ports):
                        raise
                    else:
                        continue
                else:
                    break
            
            self.client.read_until("login: ")
            self.emit('connectingMsg', _("Logging on to server"))
            
            # login with registered handle
            if self.password:
                print(self.username, file=self.client)
                got = self.client.read_until("password:",
                                             "enter the server as",
                                             "Try again.")
                if got == 0:
                    self.client.sensitive = True
                    print(self.password, file=self.client)
                    self.client.sensitive = False
                # No such name
                elif got == 1:
                    raise LogOnException(NOTREG % self.username)
                # Bad name
                elif got == 2:
                    raise LogOnException(NOTREG % self.username)
            else:
                if self.username:
                    print(self.username, file=self.client)
                else:
                    print("guest", file=self.client)
                got = self.client.read_until("Press return",
                                             "If it is yours, type the password.")
                if got == 1:
                    raise LogOnException(REGISTERED % self.username)
                print(file=self.client)
            
            while True:
                line = self.client.readline()
                if "Invalid password" in line:
                    raise LogOnException(BADPAS)
                elif "is already logged in" in line:
                    raise LogOnException(ALREADYIN % self.username)
                
                match = re.search("\*\*\*\* Starting FICS session as " +
                    "(%s)%s \*\*\*\*" % (NAMES_RE, TITLES_RE), line)
                if match:
                    self.username = match.groups()[0]
                    break
                
            self.emit('connectingMsg', _("Setting up environment"))
            lines = self.client.readuntil(b"ics%")
            self._post_connect_hook(lines)
            self.FatICS = self.client.FatICS
            self.client.name = self.username
            self.client = PredictionsTelnet(self.client, self.predictions,
                                            self.reply_cmd_dict)
            self.client.lines.line_prefix = "fics%"
            self.client.run_command("iset block 1")
            self.client.lines.block_mode = True
            self.client.run_command("iset defprompt 1")
            self.client.run_command("iset ms 1")
            self.client.run_command("set seek 0")
            
            self._start_managers()
            self.connecting = False
            self.connected = True
            self.emit("connected")

            def keep_alive():
                last = time.time()
                while self.isConnected():
                    if time.time()-last > 59*60:
                        self.client.run_command("date")
                        last = time.time()
                    time.sleep(30)
            t = threading.Thread(target=keep_alive, name=fident(keep_alive))
            t.daemon = True
            t.start()
        
        except CanceledException as e:
            log.info("FICSConnection._connect: %s" % repr(e),
                     extra={"task": (self.host, "raw")})
        finally:
            self.connecting = False
开发者ID:iamLovingJerk,项目名称:pychess,代码行数:98,代码来源:FICSConnection.py


示例20: newFunction

 def newFunction(*args, **kwargs):
     thread = Thread(target=f, name=fident(f), args=args, kwargs=kwargs)
     thread.daemon = True
     thread.start()
开发者ID:ME7ROPOLIS,项目名称:pychess,代码行数:4,代码来源:GameModel.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python log.debug函数代码示例发布时间:2022-05-25
下一篇:
Python discoverer.save函数代码示例发布时间:2022-05-25
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap