Merge branch 'master' of git://git.assembla.com/fpdboz

This commit is contained in:
sqlcoder 2009-11-29 17:37:19 +00:00
commit 78004a2e76
7 changed files with 52 additions and 29 deletions

View File

@ -27,5 +27,12 @@ class FpdbMySQLAccessDenied(FpdbDatabaseError):
def __str__(self): def __str__(self):
return repr(self.value +" " + self.errmsg) return repr(self.value +" " + self.errmsg)
class FpdbMySQLNoDatabase(FpdbDatabaseError):
def __init__(self, value='', errmsg=''):
self.value = value
self.errmsg = errmsg
def __str__(self):
return repr(self.value +" " + self.errmsg)
class DuplicateError(FpdbError): class DuplicateError(FpdbError):
pass pass

View File

@ -510,7 +510,7 @@ Map the tuple self.gametype onto the pokerstars string describing it
def printHand(self): def printHand(self):
self.writeHand(sys.stdout) self.writeHand(sys.stdout)
def actionString(self, act): def actionString(self, act, street=None):
if act[1] == 'folds': if act[1] == 'folds':
return ("%s: folds " %(act[0])) return ("%s: folds " %(act[0]))
elif act[1] == 'checks': elif act[1] == 'checks':
@ -535,7 +535,7 @@ Map the tuple self.gametype onto the pokerstars string describing it
elif act[1] == 'bringin': elif act[1] == 'bringin':
return ("%s: brings in for %s%s%s" %(act[0], self.sym, act[2], ' and is all-in' if act[3] else '')) return ("%s: brings in for %s%s%s" %(act[0], self.sym, act[2], ' and is all-in' if act[3] else ''))
elif act[1] == 'discards': elif act[1] == 'discards':
return ("%s: discards %s %s%s" %(act[0], act[2], 'card' if act[2] == 1 else 'cards' , " [" + " ".join(self.discards[act[0]]['DRAWONE']) + "]" if self.hero == act[0] else '')) return ("%s: discards %s %s%s" %(act[0], act[2], 'card' if act[2] == 1 else 'cards' , " [" + " ".join(self.discards[street][act[0]]) + "]" if self.hero == act[0] else ''))
elif act[1] == 'stands pat': elif act[1] == 'stands pat':
return ("%s: stands pat" %(act[0])) return ("%s: stands pat" %(act[0]))
@ -872,7 +872,7 @@ class DrawHand(Hand):
self.streetList = ['BLINDSANTES', 'DEAL', 'DRAWONE', 'DRAWTWO', 'DRAWTHREE'] self.streetList = ['BLINDSANTES', 'DEAL', 'DRAWONE', 'DRAWTWO', 'DRAWTHREE']
self.allStreets = ['BLINDSANTES', 'DEAL', 'DRAWONE', 'DRAWTWO', 'DRAWTHREE'] self.allStreets = ['BLINDSANTES', 'DEAL', 'DRAWONE', 'DRAWTWO', 'DRAWTHREE']
self.holeStreets = ['DEAL', 'DRAWONE', 'DRAWTWO', 'DRAWTHREE'] self.holeStreets = ['DEAL', 'DRAWONE', 'DRAWTWO', 'DRAWTHREE']
self.actionStreets = ['PREDEAL', 'DEAL', 'DRAWONE', 'DRAWTWO', 'DRAWTHREE'] self.actionStreets = ['BLINDSANTES', 'DEAL', 'DRAWONE', 'DRAWTWO', 'DRAWTHREE']
self.communityStreets = [] self.communityStreets = []
Hand.__init__(self, sitename, gametype, handText) Hand.__init__(self, sitename, gametype, handText)
self.sb = gametype['sb'] self.sb = gametype['sb']
@ -953,6 +953,13 @@ class DrawHand(Hand):
act = (player, 'discards', num) act = (player, 'discards', num)
self.actions[street].append(act) self.actions[street].append(act)
def holecardsAsSet(self, street, player):
"""Return holdcards: (oc, nc) as set()"""
(nc,oc) = self.holecards[street][player]
nc = set(nc)
oc = set(oc)
return (nc, oc)
def getStreetTotals(self): def getStreetTotals(self):
# street1Pot INT, /* pot size at flop/street4 */ # street1Pot INT, /* pot size at flop/street4 */
# street2Pot INT, /* pot size at turn/street5 */ # street2Pot INT, /* pot size at turn/street5 */
@ -979,18 +986,19 @@ class DrawHand(Hand):
if 'DEAL' in self.actions: if 'DEAL' in self.actions:
print >>fh, _("*** DEALING HANDS ***") print >>fh, _("*** DEALING HANDS ***")
for player in [x[1] for x in self.players if x[1] in players_who_act_ondeal]: for player in [x[1] for x in self.players if x[1] in players_who_act_ondeal]:
if 'DEAL' in self.holecards[player]: if 'DEAL' in self.holecards:
(nc,oc) = self.holecards[player]['DEAL'] if self.holecards['DEAL'].has_key(player):
print >>fh, _("Dealt to %s: [%s]") % (player, " ".join(nc)) (nc,oc) = self.holecards['DEAL'][player]
print >>fh, _("Dealt to %s: [%s]") % (player, " ".join(nc))
for act in self.actions['DEAL']: for act in self.actions['DEAL']:
print >>fh, self.actionString(act) print >>fh, self.actionString(act, 'DEAL')
if 'DRAWONE' in self.actions: if 'DRAWONE' in self.actions:
print >>fh, _("*** FIRST DRAW ***") print >>fh, _("*** FIRST DRAW ***")
for act in self.actions['DRAWONE']: for act in self.actions['DRAWONE']:
print >>fh, self.actionString(act) print >>fh, self.actionString(act, 'DRAWONE')
if act[0] == self.hero and act[1] == 'discards': if act[0] == self.hero and act[1] == 'discards':
(nc,oc) = self.holecards['DRAWONE'][act[0]] (nc,oc) = self.holecardsAsSet('DRAWONE', act[0])
dc = self.discards['DRAWONE'][act[0]] dc = self.discards['DRAWONE'][act[0]]
kc = oc - dc kc = oc - dc
print >>fh, _("Dealt to %s [%s] [%s]" % (act[0], " ".join(kc), " ".join(nc))) print >>fh, _("Dealt to %s [%s] [%s]" % (act[0], " ".join(kc), " ".join(nc)))
@ -998,9 +1006,9 @@ class DrawHand(Hand):
if 'DRAWTWO' in self.actions: if 'DRAWTWO' in self.actions:
print >>fh, _("*** SECOND DRAW ***") print >>fh, _("*** SECOND DRAW ***")
for act in self.actions['DRAWTWO']: for act in self.actions['DRAWTWO']:
print >>fh, self.actionString(act) print >>fh, self.actionString(act, 'DRAWTWO')
if act[0] == self.hero and act[1] == 'discards': if act[0] == self.hero and act[1] == 'discards':
(nc,oc) = self.holecards['DRAWTWO'][act[0]] (nc,oc) = self.holecardsAsSet('DRAWONE', act[0])
dc = self.discards['DRAWTWO'][act[0]] dc = self.discards['DRAWTWO'][act[0]]
kc = oc - dc kc = oc - dc
print >>fh, _("Dealt to %s [%s] [%s]" % (act[0], " ".join(kc), " ".join(nc))) print >>fh, _("Dealt to %s [%s] [%s]" % (act[0], " ".join(kc), " ".join(nc)))
@ -1008,9 +1016,9 @@ class DrawHand(Hand):
if 'DRAWTHREE' in self.actions: if 'DRAWTHREE' in self.actions:
print >>fh, _("*** THIRD DRAW ***") print >>fh, _("*** THIRD DRAW ***")
for act in self.actions['DRAWTHREE']: for act in self.actions['DRAWTHREE']:
print >>fh, self.actionString(act) print >>fh, self.actionString(act, 'DRAWTHREE')
if act[0] == self.hero and act[1] == 'discards': if act[0] == self.hero and act[1] == 'discards':
(nc,oc) = self.holecards['DRAWTHREE'][act[0]] (nc,oc) = self.holecardsAsSet('DRAWONE', act[0])
dc = self.discards['DRAWTHREE'][act[0]] dc = self.discards['DRAWTHREE'][act[0]]
kc = oc - dc kc = oc - dc
print >>fh, _("Dealt to %s [%s] [%s]" % (act[0], " ".join(kc), " ".join(nc))) print >>fh, _("Dealt to %s [%s] [%s]" % (act[0], " ".join(kc), " ".join(nc)))

View File

@ -261,8 +261,8 @@ which it expects to find at self.re_TailSplitHands -- see for e.g. Everleaf.py.
gametype = self.determineGameType(handText) gametype = self.determineGameType(handText)
log.debug("gametype %s" % gametype) log.debug("gametype %s" % gametype)
hand = None hand = None
l = None
if gametype is None: if gametype is None:
l = None
gametype = "unmatched" gametype = "unmatched"
# TODO: not ideal, just trying to not error. # TODO: not ideal, just trying to not error.
# TODO: Need to count failed hands. # TODO: Need to count failed hands.

View File

@ -50,7 +50,7 @@ class PokerStars(HandHistoryConverter):
\s?(?P<TOUR_ISO>%(LEGAL_ISO)s)? \s?(?P<TOUR_ISO>%(LEGAL_ISO)s)?
)\s)? # close paren of tournament info )\s)? # close paren of tournament info
(?P<MIXED>HORSE|8\-Game|HOSE)?\s?\(? (?P<MIXED>HORSE|8\-Game|HOSE)?\s?\(?
(?P<GAME>Hold\'em|Razz|7\sCard\sStud|7\sCard\sStud\sHi/Lo|Omaha|Omaha\sHi/Lo|Badugi|Triple\sDraw\s2\-7\sLowball)\s (?P<GAME>Hold\'em|Razz|7\sCard\sStud|7\sCard\sStud\sHi/Lo|Omaha|Omaha\sHi/Lo|Badugi|Triple\sDraw\s2\-7\sLowball|5\sCard\sDraw)\s
(?P<LIMIT>No\sLimit|Limit|Pot\sLimit)\)?,?\s (?P<LIMIT>No\sLimit|Limit|Pot\sLimit)\)?,?\s
(-\sLevel\s(?P<LEVEL>[IVXLC]+)\s)? (-\sLevel\s(?P<LEVEL>[IVXLC]+)\s)?
\(? # open paren of the stakes \(? # open paren of the stakes
@ -101,7 +101,7 @@ class PokerStars(HandHistoryConverter):
self.re_HeroCards = re.compile(r"^Dealt to %(PLYR)s(?: \[(?P<OLDCARDS>.+?)\])?( \[(?P<NEWCARDS>.+?)\])" % subst, re.MULTILINE) self.re_HeroCards = re.compile(r"^Dealt to %(PLYR)s(?: \[(?P<OLDCARDS>.+?)\])?( \[(?P<NEWCARDS>.+?)\])" % subst, re.MULTILINE)
self.re_Action = re.compile(r""" self.re_Action = re.compile(r"""
^%(PLYR)s:(?P<ATYPE>\sbets|\schecks|\sraises|\scalls|\sfolds|\sdiscards|\sstands\spat) ^%(PLYR)s:(?P<ATYPE>\sbets|\schecks|\sraises|\scalls|\sfolds|\sdiscards|\sstands\spat)
(\s%(CUR)s(?P<BET>[.\d]+))?(\sto\s%(CUR)s(?P<BETTO>[.\d]+))? # the number discarded goes in <BET> (\s(%(CUR)s)?(?P<BET>[.\d]+))?(\sto\s%(CUR)s(?P<BETTO>[.\d]+))? # the number discarded goes in <BET>
(\scards?(\s\[(?P<DISCARDED>.+?)\])?)?""" (\scards?(\s\[(?P<DISCARDED>.+?)\])?)?"""
% subst, re.MULTILINE|re.VERBOSE) % subst, re.MULTILINE|re.VERBOSE)
self.re_ShowdownAction = re.compile(r"^%s: shows \[(?P<CARDS>.*)\]" % player_re, re.MULTILINE) self.re_ShowdownAction = re.compile(r"^%s: shows \[(?P<CARDS>.*)\]" % player_re, re.MULTILINE)
@ -133,6 +133,7 @@ class PokerStars(HandHistoryConverter):
info = {} info = {}
m = self.re_GameInfo.search(handText) m = self.re_GameInfo.search(handText)
if not m: if not m:
print "DEBUG: determineGameType(): did not match"
return None return None
mg = m.groupdict() mg = m.groupdict()
@ -147,6 +148,7 @@ class PokerStars(HandHistoryConverter):
'7 Card Stud Hi/Lo' : ('stud','studhilo'), '7 Card Stud Hi/Lo' : ('stud','studhilo'),
'Badugi' : ('draw','badugi'), 'Badugi' : ('draw','badugi'),
'Triple Draw 2-7 Lowball' : ('draw','27_3draw'), 'Triple Draw 2-7 Lowball' : ('draw','27_3draw'),
'5 Card Draw' : ('draw','fivedraw')
} }
currencies = { u'':'EUR', '$':'USD', '':'T$' } currencies = { u'':'EUR', '$':'USD', '':'T$' }
# I don't think this is doing what we think. mg will always have all # I don't think this is doing what we think. mg will always have all

View File

@ -533,6 +533,10 @@ class fpdb:
except Exceptions.FpdbMySQLAccessDenied: except Exceptions.FpdbMySQLAccessDenied:
self.warning_box("MySQL Server reports: Access denied. Are your permissions set correctly?") self.warning_box("MySQL Server reports: Access denied. Are your permissions set correctly?")
exit() exit()
except Exceptions.FpdbMySQLNoDatabase:
msg = "MySQL client reports: 2002 error. Unable to connect - Please check that the MySQL service has been started"
self.warning_box(msg)
exit
# except FpdbMySQLFailedError: # except FpdbMySQLFailedError:
# self.warning_box("Unable to connect to MySQL! Is the MySQL server running?!", "FPDB ERROR") # self.warning_box("Unable to connect to MySQL! Is the MySQL server running?!", "FPDB ERROR")

View File

@ -106,6 +106,8 @@ class fpdb_db:
except MySQLdb.Error, ex: except MySQLdb.Error, ex:
if ex.args[0] == 1045: if ex.args[0] == 1045:
raise FpdbMySQLAccessDenied(ex.args[0], ex.args[1]) raise FpdbMySQLAccessDenied(ex.args[0], ex.args[1])
elif ex.args[0] == 2002:
raise FpdbMySQLNoDatabase(ex.args[0], ex.args[1])
else: else:
print "*** WARNING UNKNOWN MYSQL ERROR", ex print "*** WARNING UNKNOWN MYSQL ERROR", ex
elif backend == fpdb_db.PGSQL: elif backend == fpdb_db.PGSQL:

View File

@ -95,16 +95,16 @@ def testStudImport():
(stored, dups, partial, errs, ttime) = importer.runImport() (stored, dups, partial, errs, ttime) = importer.runImport()
importer.clearFileList() importer.clearFileList()
#def testDrawImport(): def testDrawImport():
# db.recreate_tables() db.recreate_tables()
# importer = fpdb_import.Importer(False, settings, config) importer = fpdb_import.Importer(False, settings, config)
# importer.setDropIndexes("don't drop") importer.setDropIndexes("don't drop")
# importer.setFailOnError(True) importer.setFailOnError(True)
# importer.setThreads(-1) importer.setThreads(-1)
# importer.addBulkImportImportFileOrDir( importer.addBulkImportImportFileOrDir(
# """regression-test-files/cash/Stars/Draw/3-Draw-Limit-USD-0.10-0.20-200911.txt""", site="PokerStars") """regression-test-files/cash/Stars/Draw/3-Draw-Limit-USD-0.10-0.20-200911.txt""", site="PokerStars")
# importer.addBulkImportImportFileOrDir( importer.addBulkImportImportFileOrDir(
# """regression-test-files/cash/Stars/Draw/5-Carddraw-USD-0.10-0.20-200911.txt""", site="PokerStars") """regression-test-files/cash/Stars/Draw/5-Carddraw-USD-0.10-0.20-200911.txt""", site="PokerStars")
# importer.setCallHud(False) importer.setCallHud(False)
# (stored, dups, partial, errs, ttime) = importer.runImport() (stored, dups, partial, errs, ttime) = importer.runImport()
# importer.clearFileList() importer.clearFileList()