本文整理汇总了Python中pychess.System.Log.log.info函数的典型用法代码示例。如果您正苦于以下问题:Python info函数的具体用法?Python info怎么用?Python info使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了info函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: run
def run (cls, uri=None):
cls._ensureReady()
if cls.widgets["newgamedialog"].props.visible:
cls.widgets["newgamedialog"].present()
return
if not uri:
res = ionest.opendialog.run()
ionest.opendialog.hide()
if res != Gtk.ResponseType.ACCEPT:
return
else:
if not uri[uri.rfind(".")+1:] in ionest.enddir:
log.info("Ignoring strange file: %s" % uri)
return
cls.loadSidePanel.set_filename(uri)
cls.filechooserbutton.emit("file-activated")
cls._hideOthers()
cls.widgets["newgamedialog"].set_title(_("Open Game"))
cls.widgets["loadsidepanel"].show()
def _validate(gamemodel):
return True
def _callback (gamemodel, p0, p1):
if not cls.loadSidePanel.isEmpty():
uri = cls.loadSidePanel.get_filename()
loader = ionest.enddir[uri[uri.rfind(".")+1:]]
position = cls.loadSidePanel.getPosition()
gameno = cls.loadSidePanel.getGameno()
ionest.generalStart(gamemodel, p0, p1, (uri, loader, gameno, position))
else:
ionest.generalStart(gamemodel, p0, p1)
cls._generalRun(_callback, _validate)
开发者ID:jcoffee,项目名称:pychess,代码行数:35,代码来源:newGameDialog.py
示例2: run
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()
开发者ID:metiscus,项目名称:pychess,代码行数:35,代码来源:Main.py
示例3: __init__
def __init__(self, handle, progressbar):
ChessFile.__init__(self, handle)
self.handle = handle
self.progressbar = progressbar
self.pgn_is_string = isinstance(handle, StringIO)
if self.pgn_is_string:
self.games = [self.load_game_tags(), ]
else:
self.skip = 0
self.limit = 100
self.order_col = game.c.offset
self.is_desc = False
self.reset_last_seen()
# filter expressions to .sqlite .bin .scout
self.tag_query = None
self.fen = None
self.scout_query = None
self.init_tag_database()
self.scoutfish = None
self.init_scoutfish()
self.chess_db = None
self.init_chess_db()
self.games, self.offs_ply = self.get_records(0)
log.info("%s contains %s game(s)" % (self.path, self.count), extra={"task": "SQL"})
开发者ID:bboutkov,项目名称:pychess,代码行数:30,代码来源:pgn.py
示例4: onGameStarted
def onGameStarted(self, gamemodel):
if gamemodel.examined:
if gamemodel.players[0].name == gamemodel.connection.username:
self.player = gamemodel.players[0]
self.opplayer = gamemodel.players[1]
else:
self.player = gamemodel.players[1]
self.opplayer = gamemodel.players[0]
elif gamemodel.isObservationGame():
# no local player but enable chat to send/receive whisper/kibitz
pass
elif gamemodel.players[0].__type__ == LOCAL:
self.player = gamemodel.players[0]
self.opplayer = gamemodel.players[1]
if gamemodel.players[1].__type__ == LOCAL:
log.warning("Chatpanel loaded with two local players")
elif gamemodel.players[1].__type__ == LOCAL:
self.player = gamemodel.players[1]
self.opplayer = gamemodel.players[0]
else:
log.info("Chatpanel loaded with no local players")
self.chatView.hide()
if isinstance(gamemodel, ICGameModel):
if gamemodel.connection.ICC:
gamemodel.connection.client.run_command("set-2 %s 1" % DG_PLAYERS_IN_MY_GAME)
else:
allob = 'allob ' + str(gamemodel.ficsgame.gameno)
gamemodel.connection.client.run_command(allob)
if hasattr(self, "player") and not gamemodel.examined and self.player_cid is None:
self.player_cid = self.player.connect("messageReceived", self.onMessageRecieved)
self.chatView.enable()
开发者ID:leogregianin,项目名称:pychess,代码行数:34,代码来源:chatPanel.py
示例5: zero_reached
def zero_reached(self, timemodel, color):
if conf.get('autoCallFlag', False) and self.players[1 - color].__type__ == ARTIFICIAL:
if self.status == RUNNING and timemodel.getPlayerTime(color) <= 0:
log.info(
'Automatically sending flag call on behalf of player %s.' %
self.players[1 - color].name)
self.players[1 - color].emit("offer", Offer(FLAG_CALL))
开发者ID:ME7ROPOLIS,项目名称:pychess,代码行数:7,代码来源:GameModel.py
示例6: zero_reached
def zero_reached(self, timemodel, color):
if conf.get('autoCallFlag', False) and \
self.gamemodel.status == RUNNING and \
timemodel.getPlayerTime(1 - self.color) <= 0:
log.info('Automatically sending flag call on behalf of player %s.'
% self.name)
self.emit("offer", Offer(FLAG_CALL))
开发者ID:TPNguyen,项目名称:pychess,代码行数:7,代码来源:Human.py
示例7: resume
def resume(self, game):
if not game.opponent.adjournment:
log.warning("AdjournManager.resume: no adjourned game vs %s" %
game.opponent)
return
log.info("AdjournManager.resume: offering resume for adjourned game=%s"
% game)
self.connection.client.run_command("match %s" % game.opponent.name)
开发者ID:bboutkov,项目名称:pychess,代码行数:8,代码来源:AdjournManager.py
示例8: resign
def resign (self, game):
""" This is (and draw and abort) are possible even when one's
opponent is not logged on """
if not game.opponent.adjournment:
log.warning("AdjournManager.resign: no adjourned game vs %s" % game.opponent)
return
log.info("AdjournManager.resign: resigning adjourned game=%s" % game)
self.connection.client.run_command("resign %s" % game.opponent.name)
开发者ID:vgupta2507,项目名称:pychess,代码行数:8,代码来源:AdjournManager.py
示例9: abort
def abort(self, game):
if not game.opponent.adjournment:
log.warning("AdjournManager.abort: no adjourned game vs %s" %
game.opponent)
return
log.info("AdjournManager.abort: offering sabort for adjourned game=%s"
% game)
self.connection.client.run_command("sabort %s" % game.opponent.name)
开发者ID:bboutkov,项目名称:pychess,代码行数:8,代码来源:AdjournManager.py
示例10: draw
def draw(self, game):
if not game.opponent.adjournment:
log.warning("AdjournManager.draw: no adjourned game vs %s" %
game.opponent)
return
log.info("AdjournManager.draw: offering sdraw for adjourned game=%s" %
game)
self.connection.client.run_command("sdraw %s" % game.opponent.name)
开发者ID:bboutkov,项目名称:pychess,代码行数:8,代码来源:AdjournManager.py
示例11: write
def write(self, string):
logstr = "*" * len(string) if self.sensitive else string
self.sensitive = False
log.info(logstr, extra={"task": (self.name, "raw")})
if self.timeseal:
self.transport.write(self.protocol.encode(bytearray(string, "utf-8")) + b"\n")
else:
self.transport.write(string.encode() + b"\n")
开发者ID:leogregianin,项目名称:pychess,代码行数:9,代码来源:TimeSeal.py
示例12: __init__
def __init__(self):
GObject.GObject.__init__(self)
self.engines = []
self.jsonpath = addUserConfigPrefix("engines.json")
try:
self._engines = json.load(open(self.jsonpath))
except ValueError as err:
log.warning(
"engineNest: Couldn\'t read engines.json, renamed it to .bak\n%s\n%s"
% (self.jsonpath, err))
os.rename(self.jsonpath, self.jsonpath + ".bak")
self._engines = deepcopy(backup)
except IOError as err:
log.info(
"engineNest: Couldn\'t open engines.json, creating a new.\n%s"
% err)
self._engines = deepcopy(backup)
# Try to detect engines shipping .eng files on Linux (suggested by HGM on talkcess.com forum)
for protocol in ("xboard", "uci"):
for path in ("/usr/local/share/games/plugins",
"/usr/share/games/plugins"):
path = os.path.join(path, protocol)
if os.path.isdir(path):
for entry in os.listdir(path):
ext = os.path.splitext(entry)[1]
if ext == ".eng":
with open(os.path.join(path, entry)) as file_handle:
plugin_spec = file_handle.readline().strip()
if not plugin_spec.startswith("plugin spec"):
continue
engine_command = file_handle.readline().strip()
supported_variants = file_handle.readline().strip()
if not supported_variants.startswith("chess"):
continue
new_engine = {}
if engine_command.startswith("cd ") and engine_command.find(";") > 0:
parts = engine_command.split(";")
working_directory = parts[0][3:]
engine_command = parts[1]
new_engine["workingDirectory"] = working_directory
find = False
for engine in self._engines:
if engine["name"] == engine_command:
find = True
break
if not find:
new_engine["protocol"] = protocol
new_engine["name"] = engine_command
self._engines.append(new_engine)
开发者ID:teacoffee2017,项目名称:pychess,代码行数:55,代码来源:engineNest.py
示例13: __init__
def __init__(self):
self.libgtb = None
self.initialized = False
# Get a list of files in the tablebase folder.
configuredTbPath = conf.get("egtb_path", "")
tbPath = configuredTbPath or getDataPrefix()
try:
tbPathContents = os.listdir(tbPath)
except OSError as e:
if configuredTbPath:
log.warning("Unable to open Gaviota TB folder: %s" % repr(e))
return
# Find files named *.gtb.cp# and pick the most common "#".
# (This is the compression scheme; the library currently only uses one at a time.)
schemeCount = [0] * 10
for filename in tbPathContents:
match = re.search("\.gtb\.cp(\d)$", filename)
if match:
schemeCount[int(match.group(1))] += 1
compressionScheme = max(zip(schemeCount, range(10)))
if compressionScheme[0] == 0:
if configuredTbPath:
log.warning("Could not find any Gaviota TB files in %s" %
configuredTbPath)
return
compressionScheme = compressionScheme[1]
# Locate and load the library.
if not self._loadLibrary():
return
self._setupFunctionPrototypes()
self.pathList = self.tbpaths_init()
self.pathList = self.tbpaths_add(self.pathList, tbPath.encode())
initInfo = self.tb_init(True, compressionScheme, self.pathList)
self.initialized = (self.tb_is_initialized() != 0)
if not self.initialized:
log.warning(initInfo or
"Failed to initialize Gaviota EGTB library")
self.pathList = self.tbpaths_done(self.pathList)
return
elif initInfo:
log.info(initInfo)
# TODO: Set up a WDL cache area once the engine can use it.
self.initialized &= self.tbcache_init(4 * 1024 * 1024, 0)
if not self.initialized:
log.warning("Failed to initialize Gaviota EGTB cache")
self.tb_done()
self.pathList = self.tbpaths_done(self.pathList)
return
self.availability = self.tb_availability()
开发者ID:CarbonFixer,项目名称:pychess,代码行数:55,代码来源:egtb_gaviota.py
示例14: run
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()
开发者ID:TPNguyen,项目名称:pychess,代码行数:53,代码来源:Main.py
示例15: write
def write(self, str):
self.writebuf += bytearray(str, "utf-8")
if b"\n" not in self.writebuf:
return
if not self.connected:
return
i = self.writebuf.rfind(b"\n")
str = self.writebuf[:i]
self.writebuf = self.writebuf[i+1:]
logstr = "*"*len(str) if self.sensitive else str
log.info(logstr, extra={"task": (self.name, "raw")})
str = self.encode(str)
self.sock.send(str+b"\n")
开发者ID:Alex-Linhares,项目名称:pychess,代码行数:15,代码来源:TimeSeal.py
示例16: run
def run(self):
try:
try:
if not self.isConnected():
self._connect()
while self.isConnected():
self.client.parse()
except Exception as e:
log.info("FICSConnection.run: %s" % repr(e), extra={"task": (self.host, "raw")})
self.close()
if isinstance(e, (IOError, LogOnException, EOFError, socket.error, socket.gaierror, socket.herror)):
self.emit("error", e)
else:
raise
finally:
self.emit("disconnected")
开发者ID:ggjj1122,项目名称:pychess,代码行数:16,代码来源:FICSConnection.py
示例17: end
def end(self, status, reason):
if self.status not in UNFINISHED_STATES:
log.info(
"GameModel.end: Can't end a game that's already ended: %s %s" %
(status, reason))
return
if self.status not in (WAITING_TO_START, PAUSED, RUNNING):
self.needsSave = True
log.debug("GameModel.end: players=%s, self.ply=%s: Ending a game with status %d for reason %d" % (
repr(self.players), str(self.ply), status, reason))
self.status = status
self.reason = reason
self.emit("game_ended", reason)
self.__pause()
开发者ID:ME7ROPOLIS,项目名称:pychess,代码行数:17,代码来源:GameModel.py
示例18: onGameStarted
def onGameStarted (self, gamemodel):
if gamemodel.players[0].__type__ == LOCAL:
self.player = gamemodel.players[0]
self.opplayer = gamemodel.players[1]
if gamemodel.players[1].__type__ == LOCAL:
log.warning("Chatpanel loaded with two local players")
elif gamemodel.players[1].__type__ == LOCAL:
self.player = gamemodel.players[1]
self.opplayer = gamemodel.players[0]
else:
log.info("Chatpanel loaded with no local players")
self.chatView.hide()
if hasattr(self, "player"):
self.player.connect("messageRecieved", self.onMessageReieved)
self.chatView.enable()
开发者ID:oldstylejoe,项目名称:pychess-timed,代码行数:17,代码来源:chatPanel.py
示例19: onGameStarted
def onGameStarted (self, gamemodel):
if gamemodel.isObservationGame() or gamemodel.examined:
# no local player but enable chat to send/receive whisper/kibitz
pass
elif gamemodel.players[0].__type__ == LOCAL:
self.player = gamemodel.players[0]
self.opplayer = gamemodel.players[1]
if gamemodel.players[1].__type__ == LOCAL:
log.warning("Chatpanel loaded with two local players")
elif gamemodel.players[1].__type__ == LOCAL:
self.player = gamemodel.players[1]
self.opplayer = gamemodel.players[0]
else:
log.info("Chatpanel loaded with no local players")
self.chatView.hide()
if hasattr(self, "player"):
self.player.connect("messageReceived", self.onMessageReieved)
self.chatView.enable()
开发者ID:sally0813,项目名称:pychess,代码行数:20,代码来源:chatPanel.py
示例20: __init__
def __init__(self):
GObject.GObject.__init__(self)
self.engines = []
self.jsonpath = addUserConfigPrefix("engines.json")
try:
self._engines = json.load(open(self.jsonpath))
except ValueError as e:
log.warning("engineNest: Couldn't read engines.json, renamed it to .bak\n%s" % (self.jsonpath, e))
os.rename(self.jsonpath, self.jsonpath + ".bak")
self._engines = deepcopy(backup)
except IOError as e:
log.info("engineNest: Couldn't open engines.json, creating a new.\n%s" % e)
self._engines = deepcopy(backup)
for protocol in ("xboard", "uci"):
for path in ("/usr/local/share/games/plugins", "/usr/share/games/plugins"):
path = os.path.join(path, protocol)
if os.path.isdir(path):
for entry in os.listdir(path):
name, ext = os.path.splitext(entry)
if ext == ".eng":
with open(os.path.join(path, entry)) as f:
plugin_spec = f.readline().strip()
engine_command = f.readline().strip()
new_engine = {}
if engine_command.startswith("cd ") and engine_command.find(";") > 0:
parts = engine_command.split(";")
working_directory = parts[0][3:]
engine_command = parts[1]
new_engine["workingDirectory"] = working_directory
find = False
for engine in self._engines:
if engine["name"] == engine_command:
find = True
break
if not find:
new_engine["protocol"] = protocol
new_engine["name"] = engine_command
self._engines.append(new_engine)
开发者ID:oldstylejoe,项目名称:pychess-timed,代码行数:40,代码来源:engineNest.py
注:本文中的pychess.System.Log.log.info函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论