本文整理汇总了Python中Tc2Config.handleException方法的典型用法代码示例。如果您正苦于以下问题:Python Tc2Config.handleException方法的具体用法?Python Tc2Config.handleException怎么用?Python Tc2Config.handleException使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Tc2Config
的用法示例。
在下文中一共展示了Tc2Config.handleException方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: handleBetPot
# 需要导入模块: import Tc2Config [as 别名]
# 或者: from Tc2Config import handleException [as 别名]
def handleBetPot(self, hotkey, template, inputEvent):
data = self.readData()
if not data: return
if not data['hwndBetBox']: return
if not data['betBoxIsVisible']: return
pointTopLeft = template.points['PotTopLeft']
pointBottomRight = template.points['PotBottomRight']
if pointTopLeft == Tc2Config.PointNone:
Tc2Config.globalObject.feedbackMessage.emit('%s: -- Point Pot Top Left Not Set -' % template.name() )
return
if pointBottomRight == Tc2Config.PointNone:
Tc2Config.globalObject.feedbackMessage.emit('%s: -- Point Pot Bottom Right Not Set -' % template.name() )
return
# grab pot rect
pixmap = QtGui.QPixmap.grabWindow(self.hwnd,
pointTopLeft.x(),
pointTopLeft.y(),
pointBottomRight.x() - pointTopLeft.x(),
pointBottomRight.y() - pointTopLeft.y(),
)
pgmImage = gocr.ImagePGM.fromQPixmap(pixmap)
# scan pot
num, err = gocr.scanImage(
pgmImage=pgmImage,
chars='0-9,.',
dustSize=0,
outputType=gocr.OutputTypeFloat,
outputPattern=self.PatPot,
)
if num is None:
# try again with inverted image
num, err = gocr.scanImage(
pgmImage=pgmImage,
flagInvertImage=True,
chars='0-9,.',
dustSize=0,
outputType=gocr.OutputTypeFloat,
outputPattern=self.PatPot,
)
if num is None:
try:
raise ValueError('Could not scan pot\n<image>%s</image>' % base64.b64encode(pgmImage.toString()))
except:
Tc2Config.handleException()
Tc2Config.globalObject.feedbackMessage.emit('%s: Error - Could not scan pot' % hotkey.action() )
return
newBet = hotkey.applyAction(inputEvent, blinds=(data['smallBlind'], data['bigBlind']), bet=num)
if newBet is None:
return
Tc2Win32.windowSetText(data['hwndBetBox'], text=newBet, isUnicode=False)
Tc2Config.globalObject.feedbackMessage.emit('%s - %s -- %s' % (template.name() , hotkey.action(), newBet) )
示例2: onNetworkGetData
# 需要导入模块: import Tc2Config [as 别名]
# 或者: from Tc2Config import handleException [as 别名]
def onNetworkGetData(self, networkReply):
url = networkReply.url()
if url.scheme() == 'hand':
handNo = int(url.path()[1:])
if handNo > 0:
data = self.handHistoryFile[handNo -1]
try:
hand = self.handParser.parse(data)
except:
Tc2Config.handleException('\n' + data)
#TODO: data = ?
else:
formatter = Tc2Config.handFormatter('HtmlTabular')
data = formatter.dump(hand)
self.sideBarContainer.handleHandSet(hand)
networkReply.setData(data, 'text/html; charset=UTF-8')
示例3: __init__
# 需要导入模块: import Tc2Config [as 别名]
# 或者: from Tc2Config import handleException [as 别名]
def __init__(self, *args, **kws):
PokerStarsWindow.__init__(self, *args, **kws)
self._timer = QtCore.QTimer(self.siteHandler)
self._timer.setInterval(Tc2Config.HandGrabberTimeout * 1000)
self._timer.timeout.connect(self.grabHand)
#self._timer.setSingleShot(True)
self._handParser = Tc2SitePokerStarsHandGrabber.HandParser()
self._handFormatter = Tc2Config.handFormatter('HtmlTabular')
self._data = ''
self._hwndEdit = None
for hwnd in Tc2Win32.windowChildren(self.hwnd):
if Tc2Win32.windowGetClassName(hwnd) == self.WidgetClassName:
self._hwndEdit = hwnd
break
if self._hwndEdit is None:
try:
raise ValueError('Instant hand history edit box not found')
except:
Tc2Config.handleException()
else:
self._timer.start()
示例4: grabHand
# 需要导入模块: import Tc2Config [as 别名]
# 或者: from Tc2Config import handleException [as 别名]
def grabHand(self):
#NOTE: we could be faced with an arbitrary windowat this point or an inavlid handle
if Tc2Win32.windowGetTextLength(self._hwndEdit) > Tc2Config.MaxHandHistoryText:
#TODO: have to find a better way to give feedback on what hapens on hand grabbing
Tc2Config.globalObject.feedbackMessage.emit(self.parent(), 'Hand text too long')
return
data = Tc2Win32.windowGetText(self._hwndEdit, maxSize=Tc2Config.MaxHandHistoryText)
if data and data != self._data:
self._data = data
handData = ''
hand = Tc2HandTypes.PokerHand()
#TODO: very sloppy test to minimize risk we are grabbing 'show summary only' in instant hand history
if not ('*** HOLE CARDS ***' in data or '*** 3rd STREET ***' in data or '*** DEALING HANDS ***' in data):
pass
else:
#NOTE: we are let Tc2Config handle errors because we are maybe working with arbitrary data
# from an unknown window
try:
hand = self._handParser.parse(data)
except:
Tc2Config.handleException('\n' + data)
else:
handData = self._handFormatter.dump(hand)
self.siteHandler.handGrabbed.emit(hand, handData)