本文整理汇总了Python中DB.setActiveGame方法的典型用法代码示例。如果您正苦于以下问题:Python DB.setActiveGame方法的具体用法?Python DB.setActiveGame怎么用?Python DB.setActiveGame使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DB
的用法示例。
在下文中一共展示了DB.setActiveGame方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: wrap
# 需要导入模块: import DB [as 别名]
# 或者: from DB import setActiveGame [as 别名]
wrap()
def tickWrap(self):
try:
self.tick()
return True
except Exception, e:
print "EventThread error:"
if self.gameCon is not None:
self.gameCon.err = str(e)
if hasattr(self.gameCon, 'game'):
WSSpadesHandler.on_game_change(self.gameCon.game)
traceback.print_exc()
return False
finally:
DB.setActiveGame(getattr(self.gameCon, 'game', None))
def tick(self):
if self.gameCon is None:
# Get list of logs (['YYYY-mm-dd_HHMMSS.log'])
# Unfortunately the server doesn't return an etag for this page; instead we cache based on the number of logs displayed, on the assumption that logs will never be removed
req = requests.get(logURL)
if req.status_code != 200:
raise RuntimeError("Server returned %d looking up log list" % req.status_code)
logs = map(str, lxml.html.fromstring(req.text).xpath('//a[substring-after(@href, ".")="log"]/@href'))
logs = filter(None, map(Shim.onLogLoad, logs))
numGames = len(getGames())
if len(logs) < numGames:
raise RuntimeError("Only got %d %s from server (have %d in database)" % (len(logs), 'log' if len(logs) == 1 else 'logs', numGames))
elif len(logs) == numGames: # No new logs