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


Python log.debug函数代码示例

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


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


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