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

Python log.debug函数代码示例

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

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



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

示例1: generalStart

def generalStart (gamemodel, player0tup, player1tup, loaddata=None):
    """ The player tuples are:
        (The type af player in a System.const value,
         A callable creating the player,
         A list of arguments for the callable,
         A preliminary name for the player)

        If loaddata is specified, it should be a tuple of:
        (A text uri or fileobj,
         A Savers.something module with a load function capable of loading it,
         An int of the game in file you want to load,
         The position from where to start the game) """
    log.debug("ionest.generalStart: %s\n %s\n %s\n" % (gamemodel, player0tup, player1tup))
    worker = GtkWorker (lambda w:
            workfunc(w, gamemodel, player0tup, player1tup, loaddata))

    def onPublished (worker, vallist):
        for val in vallist:
            # The worker will start by publishing (gmwidg, game)
            if type(val) == tuple:
                gmwidg, game = val
                gamewidget.attachGameWidget(gmwidg)
                gamenanny.nurseGame(gmwidg, game)
                handler.emit("gmwidg_created", gmwidg, game)

            # Then the worker will publish functions setting up widget stuff
            elif callable(val):
                val()
    worker.connect("published", onPublished)

    def onDone (worker, (gmwidg, game)):
        gmwidg.connect("close_clicked", closeGame, game)
        worker.__del__()
开发者ID:btrent,项目名称:knave,代码行数:33,代码来源:ionest.py


示例2: offer

    def offer(self, offer):
        log.debug("Human.offer: self=%s %s" % (self, offer))
        assert offer.type in OFFER_MESSAGES

        if self.gamemodel.players[1 - self.color].__type__ is LOCAL:
            self.emit("accept", offer)
            return

        heading, text, takes_param = OFFER_MESSAGES[offer.type]
        if takes_param:
            param = offer.param
            if offer.type == TAKEBACK_OFFER and \
                    self.gamemodel.players[1 - self.color].__type__ != REMOTE:
                param = self.gamemodel.ply - offer.param
            heading = heading % param
            text = text % param

        def response_cb(infobar, response, message):
            if response == Gtk.ResponseType.ACCEPT:
                self.emit("accept", offer)
            elif response == Gtk.ResponseType.NO:
                self.emit("decline", offer)
            message.dismiss()

        content = InfoBar.get_message_content(heading, text,
                                              Gtk.STOCK_DIALOG_QUESTION)
        message = InfoBarMessage(Gtk.MessageType.QUESTION, content,
                                 response_cb)
        message.add_button(InfoBarMessageButton(
            _("Accept"), Gtk.ResponseType.ACCEPT))
        message.add_button(InfoBarMessageButton(
            _("Decline"), Gtk.ResponseType.NO))
        message.add_button(InfoBarMessageButton(Gtk.STOCK_CLOSE,
                                                Gtk.ResponseType.CANCEL))
        self.gmwidg.showMessage(message)
开发者ID:TPNguyen,项目名称:pychess,代码行数:35,代码来源:Human.py


示例3: acceptReceived

    def acceptReceived(self, player, offer):
        log.debug("GameModel.acceptReceived: accepter=%s %s" % (
                  repr(player), offer))
        if player == self.players[WHITE]:
            opPlayer = self.players[BLACK]
        else:
            opPlayer = self.players[WHITE]

        if offer in self.offers and self.offers[offer] == opPlayer:
            if offer.type == DRAW_OFFER:
                self.end(DRAW, DRAW_AGREE)
            elif offer.type == TAKEBACK_OFFER:
                log.debug("GameModel.acceptReceived: undoMoves(%s)" % (
                    self.ply - offer.param))
                self.undoMoves(self.ply - offer.param)
            elif offer.type == ADJOURN_OFFER:
                self.end(ADJOURNED, ADJOURNED_AGREEMENT)
            elif offer.type == ABORT_OFFER:
                self.end(ABORTED, ABORTED_AGREEMENT)
            elif offer.type == PAUSE_OFFER:
                self.pause()
            elif offer.type == RESUME_OFFER:
                self.resume()
            del self.offers[offer]
        else:
            player.offerError(offer, ACTION_ERROR_NONE_TO_ACCEPT)
开发者ID:ME7ROPOLIS,项目名称:pychess,代码行数:26,代码来源:GameModel.py


示例4: __onOfferDeclined

 def __onOfferDeclined(self, om, offer):
     for offer_ in list(self.gamemodel.offers.keys()):
         if offer.type == offer_.type:
             offer.param = offer_.param
     log.debug("ICPlayer.__onOfferDeclined: emitting decline for %s" %
               offer)
     self.emit("decline", offer)
开发者ID:jcoffee,项目名称:pychess,代码行数:7,代码来源:ICPlayer.py


示例5: init_chess_db

 def init_chess_db(self):
     """ Create/open polyglot .bin file with extra win/loss/draw stats
         using chess_db parser from https://github.com/mcostalba/chess_db
     """
     if chess_db_path is not None and self.path and self.size > 0:
         try:
             if self.progressbar is not None:
                 self.progressbar.set_text("Creating .bin index file...")
             self.chess_db = Parser(engine=(chess_db_path, ))
             self.chess_db.open(self.path)
             bin_path = os.path.splitext(self.path)[0] + '.bin'
             if not os.path.isfile(bin_path):
                 log.debug("No valid games found in %s" % self.path)
                 self.chess_db = None
             elif getmtime(self.path) > getmtime(bin_path):
                 self.chess_db.make()
         except OSError as err:
             self.chess_db = None
             log.warning("Failed to sart chess_db parser. OSError %s %s" % (err.errno, err.strerror))
         except pexpect.TIMEOUT:
             self.chess_db = None
             log.warning("chess_db parser failed (pexpect.TIMEOUT)")
         except pexpect.EOF:
             self.chess_db = None
             log.warning("chess_db parser failed (pexpect.EOF)")
开发者ID:bboutkov,项目名称:pychess,代码行数:25,代码来源:pgn.py


示例6: __obsGameCreated

 def __obsGameCreated (self, bm, ficsgame):
     if self.gamemodel.ficsplayers[0] == ficsgame.wplayer and \
         self.gamemodel.ficsplayers[1] == ficsgame.bplayer and \
         self.gameno == ficsgame.gameno:
             log.debug("ICPlayer.__obsGameCreated: gameno reappeared: gameno=%s white=%s black=%s" % \
                 (ficsgame.gameno, ficsgame.wplayer.name, ficsgame.bplayer.name))
             self.current = False
开发者ID:vgupta2507,项目名称:pychess,代码行数:7,代码来源:ICPlayer.py


示例7: playerUndoMoves

 def playerUndoMoves(self, movecount, gamemodel):
     log.debug("ICPlayer.playerUndoMoves: id(self)=%d self=%s, undoing movecount=%d" % \
         (id(self), self, movecount))
     # If current player has changed so that it is no longer us to move,
     # We raise TurnInterruprt in order to let GameModel continue the game
     if movecount % 2 == 1 and gamemodel.curplayer != self:
         self.queue.put("int")
开发者ID:jcoffee,项目名称:pychess,代码行数:7,代码来源:ICPlayer.py


示例8: accept

 def accept(self, offer):
     log.debug("OfferManager.accept: %s" % offer)
     if offer.index is not None:
         self.acceptIndex(offer.index)
     else:
         self.connection.client.run_command("accept t %s" %
                                            offerTypeToStr[offer.type])
开发者ID:leogregianin,项目名称:pychess,代码行数:7,代码来源:OfferManager.py


示例9: decline

 def decline(self, offer):
     log.debug("OfferManager.decline: %s" % offer)
     if offer.index is not None:
         self.declineIndex(offer.index)
     else:
         self.connection.client.run_command("decline t %s" %
                                            offerTypeToStr[offer.type])
开发者ID:leogregianin,项目名称:pychess,代码行数:7,代码来源:OfferManager.py


示例10: offerDeclined

 def offerDeclined (self, offer):
     log.debug("Human.offerDeclined: self=%s %s\n" % (self, offer))
     if offer.type not in ACTION_NAMES:
         return
     title = _("%s was declined by your opponent") % ACTION_NAMES[offer.type]
     description = _("You can try to send the offer to your opponent later in the game again.")
     self._message(title, description, gtk.MESSAGE_INFO, gtk.BUTTONS_OK)
开发者ID:jskurka,项目名称:PyChess-Learning-Module,代码行数:7,代码来源:Human.py


示例11: offerWithdrawn

 def offerWithdrawn (self, offer):
     log.debug("Human.offerWithdrawn: self=%s %s\n" % (self, offer))
     if offer.type not in ACTION_NAMES:
         return
     title = _("%s was withdrawn by your opponent") % ACTION_NAMES[offer.type]
     description = _("Your opponent seems to have changed his or her mind.")
     self._message(title, description, gtk.MESSAGE_INFO, gtk.BUTTONS_OK)
开发者ID:jskurka,项目名称:PyChess-Learning-Module,代码行数:7,代码来源:Human.py


示例12: _on_analyze

    def _on_analyze(self, analyzer, analysis, analyzer_type):
        if self.board.view.animating:
            return

        if not self.menuitems[analyzer_type + "_mode"].active:
            return

        if len(analysis) >= 1 and analysis[0] is not None:
            movstrs, score, depth = analysis[0]
            board = analyzer.board
            try:
                moves = listToMoves(board, movstrs, validate=True)
            except ParsingError as e:
                # ParsingErrors may happen when parsing "old" lines from
                # analyzing engines, which haven't yet noticed their new tasks
                log.debug("__parseLine: Ignored (%s) from analyzer: ParsingError%s" %
                          (' '.join(movstrs), e))
                return
            except:
                return

            if moves and (self.gamemodel.curplayer.__type__ == LOCAL or
               [player.__type__ for player in self.gamemodel.players] == [REMOTE, REMOTE] or
               self.gamemodel.status not in UNFINISHED_STATES):
                if moves[0].flag == DROP:
                    piece = lmove.FCORD(moves[0].move)
                    color = board.color if analyzer_type == HINT else 1 - board.color
                    cord0 = board.getHoldingCord(color, piece)
                    self._set_arrow(analyzer_type, (cord0, moves[0].cord1))
                else:
                    self._set_arrow(analyzer_type, moves[0].cords)
            else:
                self._set_arrow(analyzer_type, None)
        return False
开发者ID:CarbonFixer,项目名称:pychess,代码行数:34,代码来源:gamewidget.py


示例13: on_analyze

    def on_analyze(self, engine, analysis):
        if self.boardview.animating:
            return

        if self.boardview.model.isPlayingICSGame():
            return

        if not self.active:
            return

        is_FAN = conf.get("figuresInNotation", False)

        for i, line in enumerate(analysis):
            if line is None:
                self.store[self.path + (i, )] = self.textOnlyRow("")
                continue

            board0 = self.engine.board
            board = board0.clone()

            movstrs, score, depth = line
            try:
                pv = listToMoves(board, movstrs, validate=True)
            except ParsingError as e:
                # ParsingErrors may happen when parsing "old" lines from
                # analyzing engines, which haven't yet noticed their new tasks
                log.debug("__parseLine: Ignored (%s) from analyzer: ParsingError%s" %
                          (' '.join(movstrs), e))
                return
            except:
                return

            move = None
            if pv:
                move = pv[0]

            ply0 = board.ply if self.mode == HINT else board.ply + 1
            counted_pv = []
            for j, pvmove in enumerate(pv):
                ply = ply0 + j
                if ply % 2 == 0:
                    mvcount = "%d." % (ply / 2 + 1)
                elif j == 0:
                    mvcount = "%d..." % (ply / 2 + 1)
                else:
                    mvcount = ""
                counted_pv.append("%s%s" %
                                  (mvcount, toFAN(board, pvmove)
                                   if is_FAN else toSAN(board, pvmove, True)))
                board = board.move(pvmove)

            goodness = (min(max(score, -250), 250) + 250) / 500.0
            if self.engine.board.color == BLACK:
                score = -score

            self.store[self.path + (i, )] = [
                (board0, move, pv),
                (prettyPrintScore(score, depth), 1, goodness), 0, False,
                " ".join(counted_pv), False, False
            ]
开发者ID:ME7ROPOLIS,项目名称:pychess,代码行数:60,代码来源:bookPanel.py


示例14: cook_some

    def cook_some(self, data):
        if not self.connected:
            log.debug(data, extra={"task": (self.name, "raw")})
            self.connected = True
            if b"FatICS" in data:
                self.FatICS = True
            elif b"puertorico.com" in data:
                self.USCN = True
                data = data.replace(IAC_WONT_ECHO, b"")
            elif b"chessclub.com" in data:
                self.ICC = True
                data = data.replace(IAC_WONT_ECHO, b"")
            elif b"Starting FICS session" in data:
                data = data.replace(IAC_WONT_ECHO, b"")
        else:
            if self.timeseal:
                data, g_count, self.stateinfo = self.decode(data, self.stateinfo)
            data = data.replace(b"\r", b"").replace(b"\x07", b"")
            # enable this only for temporary debugging
            log.debug(data, extra={"task": (self.name, "raw")})

            if self.timeseal:
                for i in range(g_count):
                    self._stream_writer.write(self.encode(bytearray(G_RESPONSE, "utf-8")) + b"\n")
        return data
开发者ID:leogregianin,项目名称:pychess,代码行数:25,代码来源:TimeSeal.py


示例15: setBoard

 def setBoard (self, board):
     log.debug("setBoardAtPly: board=%s" % board, extra={"task":self.defname})
     self._recordMove(board, None, None)
     
     if not self.readyMoves:
         return
     self._searchNow()
开发者ID:fowode,项目名称:pychess,代码行数:7,代码来源:UCIEngine.py


示例16: status_changed

    def status_changed(self, player, prop):
        log.debug(
            "%s" % player,
            extra={"task": (self.connection.username, "PTS.status_changed")})
        if player not in self.players:
            return

        try:
            self.store.set(self.players[player]["ti"], 6,
                           player.display_status)
            self.store.set(self.players[player]["ti"], 7,
                           get_player_tooltip_text(player))
        except KeyError:
            pass

        if player.status == IC_STATUS_PLAYING and player.game and \
                "private" not in self.players[player]:
            self.players[player]["private"] = player.game.connect(
                "notify::private", self.private_changed, player)
        elif player.status != IC_STATUS_PLAYING and \
                "private" in self.players[player]:
            game = player.game
            if game and game.handler_is_connected(self.players[player][
                    "private"]):
                game.disconnect(self.players[player]["private"])
            del self.players[player]["private"]

        if player == self.getSelectedPlayer():
            self.onSelectionChanged(None)

        return False
开发者ID:leogregianin,项目名称:pychess,代码行数:31,代码来源:PlayerListPanel.py


示例17: on_gmwidg_closed

 def on_gmwidg_closed(gmwidg):
     log.debug("GladeHandlers.on_gmwidg_closed")
     del gameDic[gmwidg]
     if not gameDic:
         for widget in MENU_ITEMS:
             gamewidget.getWidgets()[widget].set_property('sensitive',
                                                          False)
开发者ID:TPNguyen,项目名称:pychess,代码行数:7,代码来源:Main.py


示例18: private_changed

 def private_changed(self, game, prop, player):
     log.debug(
         "%s" % player,
         extra={"task": (self.connection.username, "PTS.private_changed")})
     self.status_changed(player, prop)
     self.onSelectionChanged(self.tv.get_selection())
     return False
开发者ID:leogregianin,项目名称:pychess,代码行数:7,代码来源:PlayerListPanel.py


示例19: nurseGame

def nurseGame (gmwidg, gamemodel):
    """ Call this function when gmwidget is just created """
    log.debug("nurseGame: %s %s" % (gmwidg, gamemodel))
    gmwidg.connect("infront", on_gmwidg_infront)
    gmwidg.connect("closed", on_gmwidg_closed)
    gmwidg.connect("title_changed", on_gmwidg_title_changed)
    
    # Because of the async loading of games, the game might already be started,
    # when nurseGame is called.
    # Thus we support both cases.
    if gamemodel.status == WAITING_TO_START:
        gamemodel.connect("game_started", on_game_started, gmwidg)
        gamemodel.connect("game_loaded", game_loaded, gmwidg)
    else:
        if gamemodel.uri:
            game_loaded(gamemodel, gamemodel.uri, gmwidg)
        on_game_started(gamemodel, gmwidg)
    
    gamemodel.connect("game_saved", game_saved, gmwidg)
    gamemodel.connect("game_ended", game_ended, gmwidg)
    gamemodel.connect("game_unended", game_unended, gmwidg)
    gamemodel.connect("game_resumed", game_unended, gmwidg)
    gamemodel.connect("game_changed", game_changed, gmwidg)
    gamemodel.connect("game_paused", game_paused, gmwidg)

    if isinstance(gamemodel, ICGameModel):
        gamemodel.connection.connect("disconnected", on_disconnected, gmwidg)
开发者ID:sally0813,项目名称:pychess,代码行数:27,代码来源:gamenanny.py


示例20: analyse_moves

        def analyse_moves():
            should_black = conf.get("shouldBlack", True)
            should_white = conf.get("shouldWhite", True)
            from_current = conf.get("fromCurrent", True)
            start_ply = gmwidg.board.view.shown if from_current else 0
            move_time = int(conf.get("max_analysis_spin", 3))
            threshold = int(conf.get("variation_threshold_spin", 50))
            for board in gamemodel.boards[start_ply:]:
                if stop_event.is_set():
                    break

                @idle_add
                def do():
                    gmwidg.board.view.setShownBoard(board)
                do()
                analyzer.setBoard(board)
                if threat_PV:
                    inv_analyzer.setBoard(board)
                time.sleep(move_time + 0.1)

                ply = board.ply
                color = (ply - 1) % 2
                if ply - 1 in gamemodel.scores and ply in gamemodel.scores and (
                        (color == BLACK and should_black) or (color == WHITE and should_white)):
                    oldmoves, oldscore, olddepth = gamemodel.scores[ply - 1]
                    oldscore = oldscore * -1 if color == BLACK else oldscore
                    score_str = prettyPrintScore(oldscore, olddepth)
                    moves, score, depth = gamemodel.scores[ply]
                    score = score * -1 if color == WHITE else score
                    diff = score - oldscore
                    if (diff > threshold and color == BLACK) or (diff < -1 * threshold and color == WHITE):
                        if threat_PV:
                            try:
                                if ply - 1 in gamemodel.spy_scores:
                                    oldmoves0, oldscore0, olddepth0 = gamemodel.spy_scores[ply - 1]
                                    score_str0 = prettyPrintScore(oldscore0, olddepth0)
                                    pv0 = listToMoves(gamemodel.boards[ply - 1], ["--"] + oldmoves0, validate=True)
                                    if len(pv0) > 2:
                                        gamemodel.add_variation(gamemodel.boards[ply - 1], pv0,
                                                                comment="Treatening", score=score_str0)
                            except ParsingError as e:
                                # ParsingErrors may happen when parsing "old" lines from
                                # analyzing engines, which haven't yet noticed their new tasks
                                log.debug("__parseLine: Ignored (%s) from analyzer: ParsingError%s" %
                                          (' '.join(oldmoves), e))
                        try:
                            pv = listToMoves(gamemodel.boards[ply - 1], oldmoves, validate=True)
                            gamemodel.add_variation(gamemodel.boards[ply - 1], pv, comment="Better is", score=score_str)
                        except ParsingError as e:
                            # ParsingErrors may happen when parsing "old" lines from
                            # analyzing engines, which haven't yet noticed their new tasks
                            log.debug("__parseLine: Ignored (%s) from analyzer: ParsingError%s" %
                                      (' '.join(oldmoves), e))

            widgets["analyze_game"].hide()
            widgets["analyze_ok_button"].set_sensitive(True)
            conf.set("analyzer_check", old_check_value)
            if threat_PV:
                conf.set("inv_analyzer_check", old_inv_check_value)
            message.dismiss()
开发者ID:JoelMon,项目名称:pychess,代码行数:60,代码来源:analyzegameDialog.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python log.error函数代码示例发布时间:2022-05-25
下一篇:
Python System.fident函数代码示例发布时间: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