merge from futz2 branch
This commit is contained in:
commit
d2380ba738
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -1,2 +0,0 @@
|
||||||
*.pyc
|
|
||||||
*~
|
|
|
@ -26,6 +26,12 @@ from HandHistoryConverter import *
|
||||||
# Class for converting Absolute HH format.
|
# Class for converting Absolute HH format.
|
||||||
|
|
||||||
class Absolute(HandHistoryConverter):
|
class Absolute(HandHistoryConverter):
|
||||||
|
|
||||||
|
# Class Variables
|
||||||
|
sitename = "Absolute"
|
||||||
|
filetype = "text"
|
||||||
|
codepage = "cp1252"
|
||||||
|
siteid = 8
|
||||||
|
|
||||||
# Static regexes
|
# Static regexes
|
||||||
re_SplitHands = re.compile(r"\n\n\n+")
|
re_SplitHands = re.compile(r"\n\n\n+")
|
||||||
|
@ -35,7 +41,7 @@ class Absolute(HandHistoryConverter):
|
||||||
#Seat 6 - FETS63 ($0.75 in chips)
|
#Seat 6 - FETS63 ($0.75 in chips)
|
||||||
#Board [10s 5d Kh Qh 8c]
|
#Board [10s 5d Kh Qh 8c]
|
||||||
|
|
||||||
re_GameInfo = re.compile(ur"^Stage #([0-9]+): (?P<GAME>Holdem|) (?P<LIMIT>No Limit|) (?P<CURRENCY>\$| €|)(?P<BB>[0-9]*[.0-9]+)", re.MULTILINE)
|
re_GameInfo = re.compile(ur"^Stage #([0-9]+): (?P<GAME>Holdem|) (?P<LIMIT>No Limit|Pot Limit|Normal) (?P<CURRENCY>\$| €|)(?P<BB>[0-9]*[.0-9]+)", re.MULTILINE)
|
||||||
re_HandInfo = re.compile(ur"^Stage #(?P<HID>[0-9]+): .*(?P<DATETIME>\d\d\d\d-\d\d-\d\d \d\d:\d\d:\d\d).*\nTable: (?P<TABLE>.*) \(Real Money\)", re.MULTILINE)
|
re_HandInfo = re.compile(ur"^Stage #(?P<HID>[0-9]+): .*(?P<DATETIME>\d\d\d\d-\d\d-\d\d \d\d:\d\d:\d\d).*\nTable: (?P<TABLE>.*) \(Real Money\)", re.MULTILINE)
|
||||||
re_Button = re.compile(ur"Seat #(?P<BUTTON>[0-9]) is the ?[dead]* dealer$", re.MULTILINE) # TODO: that's not the right way to match for "dead" dealer is it?
|
re_Button = re.compile(ur"Seat #(?P<BUTTON>[0-9]) is the ?[dead]* dealer$", re.MULTILINE) # TODO: that's not the right way to match for "dead" dealer is it?
|
||||||
re_PlayerInfo = re.compile(ur"^Seat (?P<SEAT>[0-9]) - (?P<PNAME>.*) \((?:\$| €|)(?P<CASH>[0-9]*[.0-9]+) in chips\)", re.MULTILINE)
|
re_PlayerInfo = re.compile(ur"^Seat (?P<SEAT>[0-9]) - (?P<PNAME>.*) \((?:\$| €|)(?P<CASH>[0-9]*[.0-9]+) in chips\)", re.MULTILINE)
|
||||||
|
@ -48,24 +54,6 @@ class Absolute(HandHistoryConverter):
|
||||||
# re_Board = re.compile(ur"\[ (?P<CARDS>.+) \]")
|
# re_Board = re.compile(ur"\[ (?P<CARDS>.+) \]")
|
||||||
|
|
||||||
|
|
||||||
def __init__(self, in_path = '-', out_path = '-', follow = False, autostart=True, debugging=False, index=0):
|
|
||||||
"""\
|
|
||||||
in_path (default '-' = sys.stdin)
|
|
||||||
out_path (default '-' = sys.stdout)
|
|
||||||
follow : whether to tail -f the input
|
|
||||||
autostart: whether to run the thread (or you can call start() yourself)
|
|
||||||
debugging: if False, pass on partially supported game types. If true, have a go and error..."""
|
|
||||||
#print "DEBUG: XXXXXXXXXXXXXXX"
|
|
||||||
HandHistoryConverter.__init__(self, in_path, out_path, sitename="Absolute", follow=follow, index=index)
|
|
||||||
logging.info("Initialising Absolute converter class")
|
|
||||||
self.filetype = "text"
|
|
||||||
self.codepage = "cp1252"
|
|
||||||
self.siteId = 8 # Needs to match id entry in Sites database
|
|
||||||
self.debugging = debugging
|
|
||||||
if autostart:
|
|
||||||
self.start()
|
|
||||||
# otherwise you need to call start yourself.
|
|
||||||
|
|
||||||
def compilePlayerRegexs(self, hand):
|
def compilePlayerRegexs(self, hand):
|
||||||
players = set([player[1] for player in hand.players])
|
players = set([player[1] for player in hand.players])
|
||||||
if not players <= self.compiledPlayers: # x <= y means 'x is subset of y'
|
if not players <= self.compiledPlayers: # x <= y means 'x is subset of y'
|
||||||
|
@ -124,7 +112,7 @@ or None if we fail to get the info """
|
||||||
mg = m.groupdict()
|
mg = m.groupdict()
|
||||||
|
|
||||||
# translations from captured groups to our info strings
|
# translations from captured groups to our info strings
|
||||||
limits = { 'No Limit':'nl', 'PL':'pl', '':'fl' }
|
limits = { 'No Limit':'nl', 'Pot Limit':'pl', 'Normal':'fl' }
|
||||||
games = { # base, category
|
games = { # base, category
|
||||||
"Holdem" : ('hold','holdem'),
|
"Holdem" : ('hold','holdem'),
|
||||||
'Omaha' : ('hold','omahahi'),
|
'Omaha' : ('hold','omahahi'),
|
||||||
|
|
|
@ -79,11 +79,17 @@ class Layout:
|
||||||
|
|
||||||
class Site:
|
class Site:
|
||||||
def __init__(self, node):
|
def __init__(self, node):
|
||||||
|
def normalizePath(path):
|
||||||
|
"Normalized existing pathes"
|
||||||
|
if os.path.exists(path):
|
||||||
|
return os.path.abspath(path)
|
||||||
|
return path
|
||||||
|
|
||||||
self.site_name = node.getAttribute("site_name")
|
self.site_name = node.getAttribute("site_name")
|
||||||
self.table_finder = node.getAttribute("table_finder")
|
self.table_finder = node.getAttribute("table_finder")
|
||||||
self.screen_name = node.getAttribute("screen_name")
|
self.screen_name = node.getAttribute("screen_name")
|
||||||
self.site_path = node.getAttribute("site_path")
|
self.site_path = normalizePath(node.getAttribute("site_path"))
|
||||||
self.HH_path = node.getAttribute("HH_path")
|
self.HH_path = normalizePath(node.getAttribute("HH_path"))
|
||||||
self.decoder = node.getAttribute("decoder")
|
self.decoder = node.getAttribute("decoder")
|
||||||
self.hudopacity = node.getAttribute("hudopacity")
|
self.hudopacity = node.getAttribute("hudopacity")
|
||||||
self.hudbgcolor = node.getAttribute("bgcolor")
|
self.hudbgcolor = node.getAttribute("bgcolor")
|
||||||
|
@ -97,6 +103,8 @@ class Site:
|
||||||
self.xpad = node.getAttribute("xpad")
|
self.xpad = node.getAttribute("xpad")
|
||||||
self.ypad = node.getAttribute("ypad")
|
self.ypad = node.getAttribute("ypad")
|
||||||
self.layout = {}
|
self.layout = {}
|
||||||
|
|
||||||
|
print self.site_name, self.HH_path
|
||||||
|
|
||||||
for layout_node in node.getElementsByTagName('layout'):
|
for layout_node in node.getElementsByTagName('layout'):
|
||||||
lo = Layout(layout_node)
|
lo = Layout(layout_node)
|
||||||
|
@ -310,7 +318,7 @@ class Config:
|
||||||
try:
|
try:
|
||||||
log.info("Reading configuration file %s" % (file))
|
log.info("Reading configuration file %s" % (file))
|
||||||
doc = xml.dom.minidom.parse(file)
|
doc = xml.dom.minidom.parse(file)
|
||||||
except:
|
except:
|
||||||
log.error("Error parsing %s. See error log file." % (file))
|
log.error("Error parsing %s. See error log file." % (file))
|
||||||
traceback.print_exc(file=sys.stderr)
|
traceback.print_exc(file=sys.stderr)
|
||||||
print "press enter to continue"
|
print "press enter to continue"
|
||||||
|
@ -607,8 +615,8 @@ class Config:
|
||||||
path = os.path.expanduser(self.supported_sites[site].HH_path)
|
path = os.path.expanduser(self.supported_sites[site].HH_path)
|
||||||
assert(os.path.isdir(path) or os.path.isfile(path)) # maybe it should try another site?
|
assert(os.path.isdir(path) or os.path.isfile(path)) # maybe it should try another site?
|
||||||
paths['hud-defaultPath'] = paths['bulkImport-defaultPath'] = path
|
paths['hud-defaultPath'] = paths['bulkImport-defaultPath'] = path
|
||||||
except:
|
except AssertionError:
|
||||||
paths['hud-defaultPath'] = paths['bulkImport-defaultPath'] = "default"
|
paths['hud-defaultPath'] = paths['bulkImport-defaultPath'] = "** ERROR DEFAULT PATH IN CONFIG DOES NOT EXIST **"
|
||||||
return paths
|
return paths
|
||||||
|
|
||||||
def get_frames(self, site = "PokerStars"):
|
def get_frames(self, site = "PokerStars"):
|
||||||
|
|
|
@ -1052,6 +1052,22 @@ class Database:
|
||||||
print "Error during fdb.lock_for_insert:", str(sys.exc_value)
|
print "Error during fdb.lock_for_insert:", str(sys.exc_value)
|
||||||
#end def lock_for_insert
|
#end def lock_for_insert
|
||||||
|
|
||||||
|
def getGameTypeId(self, siteid, game):
|
||||||
|
c = self.get_cursor()
|
||||||
|
#FIXME: Fixed for NL at the moment
|
||||||
|
c.execute(self.sql.query['getGametypeNL'], (siteid, game['type'], game['category'], game['limitType'],
|
||||||
|
int(Decimal(game['sb'])*100), int(Decimal(game['bb'])*100)))
|
||||||
|
tmp = c.fetchone()
|
||||||
|
if (tmp == None):
|
||||||
|
hilo = "h"
|
||||||
|
if game['category'] in ['studhilo', 'omahahilo']:
|
||||||
|
hilo = "s"
|
||||||
|
elif game['category'] in ['razz','27_3draw','badugi']:
|
||||||
|
hilo = "l"
|
||||||
|
tmp = self.insertGameTypes( (siteid, game['type'], game['base'], game['category'], game['limitType'], hilo,
|
||||||
|
int(Decimal(game['sb'])*100), int(Decimal(game['bb'])*100), 0, 0) )
|
||||||
|
return tmp[0]
|
||||||
|
|
||||||
def getSqlPlayerIDs(self, pnames, siteid):
|
def getSqlPlayerIDs(self, pnames, siteid):
|
||||||
result = {}
|
result = {}
|
||||||
if(self.pcache == None):
|
if(self.pcache == None):
|
||||||
|
@ -1165,11 +1181,16 @@ class Database:
|
||||||
boardcard2,
|
boardcard2,
|
||||||
boardcard3,
|
boardcard3,
|
||||||
boardcard4,
|
boardcard4,
|
||||||
boardcard5
|
boardcard5,
|
||||||
|
street1Pot,
|
||||||
|
street2Pot,
|
||||||
|
street3Pot,
|
||||||
|
street4Pot,
|
||||||
|
showdownPot
|
||||||
)
|
)
|
||||||
VALUES
|
VALUES
|
||||||
(%s, %s, %s, %s, %s, %s, %s, %s, %s, %s,
|
(%s, %s, %s, %s, %s, %s, %s, %s, %s, %s,
|
||||||
%s, %s)"""
|
%s, %s, %s, %s, %s, %s, %s)"""
|
||||||
#--- texture,
|
#--- texture,
|
||||||
#-- playersVpi,
|
#-- playersVpi,
|
||||||
#-- playersAtStreet1,
|
#-- playersAtStreet1,
|
||||||
|
@ -1182,11 +1203,6 @@ class Database:
|
||||||
#-- street2Raises,
|
#-- street2Raises,
|
||||||
#-- street3Raises,
|
#-- street3Raises,
|
||||||
#-- street4Raises,
|
#-- street4Raises,
|
||||||
#-- street1Pot,
|
|
||||||
#-- street2Pot,
|
|
||||||
#-- street3Pot,
|
|
||||||
#-- street4Pot,
|
|
||||||
#-- showdownPot
|
|
||||||
#-- seats,
|
#-- seats,
|
||||||
|
|
||||||
q = q.replace('%s', self.sql.query['placeholder'])
|
q = q.replace('%s', self.sql.query['placeholder'])
|
||||||
|
@ -1205,7 +1221,7 @@ class Database:
|
||||||
p['boardcard2'],
|
p['boardcard2'],
|
||||||
p['boardcard3'],
|
p['boardcard3'],
|
||||||
p['boardcard4'],
|
p['boardcard4'],
|
||||||
p['boardcard5'])
|
p['boardcard5'],
|
||||||
# hudCache['playersVpi'],
|
# hudCache['playersVpi'],
|
||||||
# hudCache['playersAtStreet1'],
|
# hudCache['playersAtStreet1'],
|
||||||
# hudCache['playersAtStreet2'],
|
# hudCache['playersAtStreet2'],
|
||||||
|
@ -1217,12 +1233,12 @@ class Database:
|
||||||
# hudCache['street2Raises'],
|
# hudCache['street2Raises'],
|
||||||
# hudCache['street3Raises'],
|
# hudCache['street3Raises'],
|
||||||
# hudCache['street4Raises'],
|
# hudCache['street4Raises'],
|
||||||
# hudCache['street1Pot'],
|
p['street1Pot'],
|
||||||
# hudCache['street2Pot'],
|
p['street2Pot'],
|
||||||
# hudCache['street3Pot'],
|
p['street3Pot'],
|
||||||
# hudCache['street4Pot'],
|
p['street4Pot'],
|
||||||
# hudCache['showdownPot']
|
p['showdownPot']
|
||||||
)
|
))
|
||||||
#return getLastInsertId(backend, conn, cursor)
|
#return getLastInsertId(backend, conn, cursor)
|
||||||
# def storeHand
|
# def storeHand
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
|
|
||||||
class FpdbError(Exception):
|
class FpdbError(Exception):
|
||||||
pass
|
def __init__(self, value):
|
||||||
|
self.value = value
|
||||||
|
def __str__(self):
|
||||||
|
return repr(self.value)
|
||||||
|
|
||||||
class FpdbParseError(FpdbError):
|
class FpdbParseError(FpdbError):
|
||||||
def __init__(self,value='',hid=''):
|
def __init__(self,value='',hid=''):
|
||||||
|
@ -13,8 +15,4 @@ class FpdbParseError(FpdbError):
|
||||||
return repr(self.value)
|
return repr(self.value)
|
||||||
|
|
||||||
class DuplicateError(FpdbError):
|
class DuplicateError(FpdbError):
|
||||||
def __init__(self, value):
|
pass
|
||||||
self.value = value
|
|
||||||
def __str__(self):
|
|
||||||
return repr(self.value)
|
|
||||||
|
|
||||||
|
|
|
@ -29,11 +29,12 @@ class Fulltilt(HandHistoryConverter):
|
||||||
|
|
||||||
sitename = "Fulltilt"
|
sitename = "Fulltilt"
|
||||||
filetype = "text"
|
filetype = "text"
|
||||||
codepage = "cp1252"
|
codepage = "utf-16"
|
||||||
siteId = 1 # Needs to match id entry in Sites database
|
siteId = 1 # Needs to match id entry in Sites database
|
||||||
|
|
||||||
# Static regexes
|
# Static regexes
|
||||||
re_GameInfo = re.compile('''(?:(?P<TOURNAMENT>.+)\s\((?P<TOURNO>\d+)\),\s)?
|
re_GameInfo = re.compile('''.*\#(?P<HID>[0-9]+):\s
|
||||||
|
(?:(?P<TOURNAMENT>.+)\s\((?P<TOURNO>\d+)\),\s)?
|
||||||
.+
|
.+
|
||||||
-\s(?P<CURRENCY>\$|)?
|
-\s(?P<CURRENCY>\$|)?
|
||||||
(?P<SB>[.0-9]+)/
|
(?P<SB>[.0-9]+)/
|
||||||
|
@ -56,7 +57,7 @@ class Fulltilt(HandHistoryConverter):
|
||||||
(?:.*?\n(?P<CANCELLED>Hand\s\#(?P=HID)\shas\sbeen\scanceled))?
|
(?:.*?\n(?P<CANCELLED>Hand\s\#(?P=HID)\shas\sbeen\scanceled))?
|
||||||
''', re.VERBOSE|re.DOTALL)
|
''', re.VERBOSE|re.DOTALL)
|
||||||
re_Button = re.compile('^The button is in seat #(?P<BUTTON>\d+)', re.MULTILINE)
|
re_Button = re.compile('^The button is in seat #(?P<BUTTON>\d+)', re.MULTILINE)
|
||||||
re_PlayerInfo = re.compile('Seat (?P<SEAT>[0-9]+): (?P<PNAME>.*) \(\$?(?P<CASH>[,.0-9]+)\)$', re.MULTILINE)
|
re_PlayerInfo = re.compile('Seat (?P<SEAT>[0-9]+): (?P<PNAME>.*) \(\$?(?P<CASH>[,.0-9]+)\)', re.MULTILINE)
|
||||||
re_Board = re.compile(r"\[(?P<CARDS>.+)\]")
|
re_Board = re.compile(r"\[(?P<CARDS>.+)\]")
|
||||||
|
|
||||||
# These regexes are for FTP only
|
# These regexes are for FTP only
|
||||||
|
@ -66,6 +67,7 @@ class Fulltilt(HandHistoryConverter):
|
||||||
|
|
||||||
mixes = { 'HORSE': 'horse', '7-Game': '7game', 'HOSE': 'hose', 'HA': 'ha'}
|
mixes = { 'HORSE': 'horse', '7-Game': '7game', 'HOSE': 'hose', 'HA': 'ha'}
|
||||||
|
|
||||||
|
|
||||||
def compilePlayerRegexs(self, hand):
|
def compilePlayerRegexs(self, hand):
|
||||||
players = set([player[1] for player in hand.players])
|
players = set([player[1] for player in hand.players])
|
||||||
if not players <= self.compiledPlayers: # x <= y means 'x is subset of y'
|
if not players <= self.compiledPlayers: # x <= y means 'x is subset of y'
|
||||||
|
@ -81,7 +83,7 @@ class Fulltilt(HandHistoryConverter):
|
||||||
self.re_HeroCards = re.compile(r"^Dealt to %s(?: \[(?P<OLDCARDS>.+?)\])?( \[(?P<NEWCARDS>.+?)\])" % player_re, re.MULTILINE)
|
self.re_HeroCards = re.compile(r"^Dealt to %s(?: \[(?P<OLDCARDS>.+?)\])?( \[(?P<NEWCARDS>.+?)\])" % player_re, re.MULTILINE)
|
||||||
self.re_Action = re.compile(r"^%s(?P<ATYPE> bets| checks| raises to| completes it to| calls| folds)( \$?(?P<BET>[.,\d]+))?" % player_re, re.MULTILINE)
|
self.re_Action = re.compile(r"^%s(?P<ATYPE> bets| checks| raises to| completes it to| calls| folds)( \$?(?P<BET>[.,\d]+))?" % player_re, re.MULTILINE)
|
||||||
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)
|
||||||
self.re_CollectPot = re.compile(r"^Seat (?P<SEAT>[0-9]+): %s (\(button\) |\(small blind\) |\(big blind\) )?(collected|showed \[.*\] and won) \(\$(?P<POT>[.\d]+)\)(, mucked| with.*)" % player_re, re.MULTILINE)
|
self.re_CollectPot = re.compile(r"^Seat (?P<SEAT>[0-9]+): %s (\(button\) |\(small blind\) |\(big blind\) )?(collected|showed \[.*\] and won) \(\$?(?P<POT>[.,\d]+)\)(, mucked| with.*)" % player_re, re.MULTILINE)
|
||||||
self.re_SitsOut = re.compile(r"^%s sits out" % player_re, re.MULTILINE)
|
self.re_SitsOut = re.compile(r"^%s sits out" % player_re, re.MULTILINE)
|
||||||
self.re_ShownCards = re.compile(r"^Seat (?P<SEAT>[0-9]+): %s \(.*\) showed \[(?P<CARDS>.*)\].*" % player_re, re.MULTILINE)
|
self.re_ShownCards = re.compile(r"^Seat (?P<SEAT>[0-9]+): %s \(.*\) showed \[(?P<CARDS>.*)\].*" % player_re, re.MULTILINE)
|
||||||
|
|
||||||
|
@ -110,7 +112,7 @@ class Fulltilt(HandHistoryConverter):
|
||||||
if not m:
|
if not m:
|
||||||
return None
|
return None
|
||||||
mg = m.groupdict()
|
mg = m.groupdict()
|
||||||
|
print mg
|
||||||
# translations from captured groups to our info strings
|
# translations from captured groups to our info strings
|
||||||
limits = { 'No Limit':'nl', 'Pot Limit':'pl', 'Limit':'fl' }
|
limits = { 'No Limit':'nl', 'Pot Limit':'pl', 'Limit':'fl' }
|
||||||
games = { # base, category
|
games = { # base, category
|
||||||
|
@ -132,27 +134,9 @@ class Fulltilt(HandHistoryConverter):
|
||||||
if mg['TOURNO'] == None: info['type'] = "ring"
|
if mg['TOURNO'] == None: info['type'] = "ring"
|
||||||
else: info['type'] = "tour"
|
else: info['type'] = "tour"
|
||||||
# NB: SB, BB must be interpreted as blinds or bets depending on limit type.
|
# NB: SB, BB must be interpreted as blinds or bets depending on limit type.
|
||||||
if info['type'] == "tour": return None # importer is screwed on tournies, pass on those hands so we don't interrupt other autoimporting
|
# if info['type'] == "tour": return None # importer is screwed on tournies, pass on those hands so we don't interrupt other autoimporting
|
||||||
return info
|
return info
|
||||||
|
|
||||||
#Following function is a hack, we should be dealing with this in readFile (i think correct codepage....)
|
|
||||||
# Same function as parent class, removing the 2 end characters. - CG
|
|
||||||
def allHandsAsList(self):
|
|
||||||
"""Return a list of handtexts in the file at self.in_path"""
|
|
||||||
#TODO : any need for this to be generator? e.g. stars support can email one huge file of all hands in a year. Better to read bit by bit than all at once.
|
|
||||||
self.readFile()
|
|
||||||
|
|
||||||
# FIXME: it's a hack
|
|
||||||
if self.obs[:2] == u'\xff\xfe':
|
|
||||||
self.obs = self.obs[2:].replace('\x00', '')
|
|
||||||
|
|
||||||
self.obs = self.obs.strip()
|
|
||||||
self.obs = self.obs.replace('\r\n', '\n')
|
|
||||||
if self.obs == "" or self.obs == None:
|
|
||||||
logging.info("Read no hands.")
|
|
||||||
return
|
|
||||||
return re.split(self.re_SplitHands, self.obs)
|
|
||||||
|
|
||||||
def readHandInfo(self, hand):
|
def readHandInfo(self, hand):
|
||||||
m = self.re_HandInfo.search(hand.handText)
|
m = self.re_HandInfo.search(hand.handText)
|
||||||
if(m == None):
|
if(m == None):
|
||||||
|
@ -175,6 +159,16 @@ class Fulltilt(HandHistoryConverter):
|
||||||
hand.gametype['currency'] = 'play'
|
hand.gametype['currency'] = 'play'
|
||||||
|
|
||||||
# TODO: if there's a way to figure these out, we should.. otherwise we have to stuff it with unknowns
|
# TODO: if there's a way to figure these out, we should.. otherwise we have to stuff it with unknowns
|
||||||
|
re_SNGBuyInFee = re.compile('''(?P<CURRENCY>\$)?(?P<BUYIN>[.0-9]+) \+ \$?(?P<FEE>[.0-9]+) (?P<EXTRA_INFO>[\sA-Za-z&()]+)?''')
|
||||||
|
# TO DO : See if important info can be retrieved from EXTRA_INFO (sould be things like Turbo, Matrix, KO, ...)
|
||||||
|
try:
|
||||||
|
n = re_SNGBuyInFee.search(m.group('TOURNAMENT'))
|
||||||
|
#print "cur %s BUYIN %s FEE %s EXTRA %s" %(n.group('CURRENCY'), n.group('BUYIN'), n.group('FEE'), n.group('EXTRA_INFO'))
|
||||||
|
hand.buyin = "%s%s+%s%s" %(n.group('CURRENCY'), n.group('BUYIN'), n.group('CURRENCY'), n.group('FEE'))
|
||||||
|
except:
|
||||||
|
#print "Unable to collect BuyIn/Fee Info"
|
||||||
|
logging.info("Unable to collect BuyIn/Fee Info from HandInfo")
|
||||||
|
|
||||||
if hand.buyin == None:
|
if hand.buyin == None:
|
||||||
hand.buyin = "$0.00+$0.00"
|
hand.buyin = "$0.00+$0.00"
|
||||||
if hand.level == None:
|
if hand.level == None:
|
||||||
|
@ -318,7 +312,7 @@ class Fulltilt(HandHistoryConverter):
|
||||||
|
|
||||||
def readCollectPot(self,hand):
|
def readCollectPot(self,hand):
|
||||||
for m in self.re_CollectPot.finditer(hand.handText):
|
for m in self.re_CollectPot.finditer(hand.handText):
|
||||||
hand.addCollectPot(player=m.group('PNAME'),pot=m.group('POT'))
|
hand.addCollectPot(player=m.group('PNAME'),pot=re.sub(u',',u'',m.group('POT')))
|
||||||
|
|
||||||
def readShownCards(self,hand):
|
def readShownCards(self,hand):
|
||||||
for m in self.re_ShownCards.finditer(hand.handText):
|
for m in self.re_ShownCards.finditer(hand.handText):
|
||||||
|
|
|
@ -136,12 +136,19 @@ class GuiAutoImport (threading.Thread):
|
||||||
def do_import(self):
|
def do_import(self):
|
||||||
"""Callback for timer to do an import iteration."""
|
"""Callback for timer to do an import iteration."""
|
||||||
if self.doAutoImportBool:
|
if self.doAutoImportBool:
|
||||||
|
self.startButton.set_label(u' I M P O R T I N G ')
|
||||||
self.importer.runUpdated()
|
self.importer.runUpdated()
|
||||||
sys.stdout.write(".")
|
sys.stdout.write(".")
|
||||||
sys.stdout.flush()
|
sys.stdout.flush()
|
||||||
|
gobject.timeout_add(1000, self.reset_startbutton)
|
||||||
return True
|
return True
|
||||||
else:
|
else:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
def reset_startbutton(self):
|
||||||
|
self.startButton.set_label(u' _Stop Autoimport ')
|
||||||
|
return False
|
||||||
|
|
||||||
|
|
||||||
def startClicked(self, widget, data):
|
def startClicked(self, widget, data):
|
||||||
"""runs when user clicks start on auto import tab"""
|
"""runs when user clicks start on auto import tab"""
|
||||||
|
@ -161,33 +168,34 @@ class GuiAutoImport (threading.Thread):
|
||||||
# - Ideally we want to release the lock if the auto-import is killed by some
|
# - Ideally we want to release the lock if the auto-import is killed by some
|
||||||
# kind of exception - is this possible?
|
# kind of exception - is this possible?
|
||||||
if self.settings['global_lock'].acquire(False): # returns false immediately if lock not acquired
|
if self.settings['global_lock'].acquire(False): # returns false immediately if lock not acquired
|
||||||
try:
|
print "\nGlobal lock taken ..."
|
||||||
print "\nGlobal lock taken ..."
|
self.doAutoImportBool = True
|
||||||
self.doAutoImportBool = True
|
widget.set_label(u' _Stop Autoimport ')
|
||||||
widget.set_label(u' _Stop Autoimport ')
|
if self.pipe_to_hud is None:
|
||||||
if self.pipe_to_hud is None:
|
if os.name == 'nt':
|
||||||
if os.name == 'nt':
|
command = "python HUD_main.py " + self.settings['cl_options']
|
||||||
command = "python HUD_main.py" + " " + self.settings['cl_options']
|
bs = 0
|
||||||
bs = 0 # windows is not happy with line buffing here
|
else:
|
||||||
self.pipe_to_hud = subprocess.Popen(command, bufsize = bs, stdin = subprocess.PIPE,
|
command = os.path.join(sys.path[0], 'HUD_main.py')
|
||||||
universal_newlines=True)
|
command = [command, ] + string.split(self.settings['cl_options'])
|
||||||
else:
|
bs = 1
|
||||||
command = os.path.join(sys.path[0], 'HUD_main.py')
|
try:
|
||||||
cl = [command, ] + string.split(self.settings['cl_options'])
|
self.pipe_to_hud = subprocess.Popen(command, bufsize = bs, stdin = subprocess.PIPE,
|
||||||
self.pipe_to_hud = subprocess.Popen(cl, bufsize = 1, stdin = subprocess.PIPE,
|
universal_newlines = True)
|
||||||
universal_newlines=True)
|
except:
|
||||||
|
err = traceback.extract_tb(sys.exc_info()[2])[-1]
|
||||||
# Add directories to importer object.
|
print "*** Error: " + err[2] + "(" + str(err[1]) + "): " + str(sys.exc_info()[1])
|
||||||
|
|
||||||
|
print "self.pipe_to_hud = ", self.pipe_to_hud
|
||||||
|
if self.pipe_to_hud is not None:
|
||||||
for site in self.input_settings:
|
for site in self.input_settings:
|
||||||
self.importer.addImportDirectory(self.input_settings[site][0], True, site, self.input_settings[site][1])
|
self.importer.addImportDirectory(self.input_settings[site][0], True, site, self.input_settings[site][1])
|
||||||
print "Adding import directories - Site: " + site + " dir: "+ str(self.input_settings[site][0])
|
print "+Import directory - Site: " + site + " dir: " + str(self.input_settings[site][0])
|
||||||
self.do_import()
|
self.do_import()
|
||||||
|
|
||||||
interval=int(self.intervalEntry.get_text())
|
interval = int(self.intervalEntry.get_text())
|
||||||
gobject.timeout_add(interval*1000, self.do_import)
|
gobject.timeout_add(interval*1000, self.do_import)
|
||||||
except:
|
|
||||||
err = traceback.extract_tb(sys.exc_info()[2])[-1]
|
|
||||||
print "***Error: "+err[2]+"("+str(err[1])+"): "+str(sys.exc_info()[1])
|
|
||||||
else:
|
else:
|
||||||
print "auto-import aborted - global lock not available"
|
print "auto-import aborted - global lock not available"
|
||||||
else: # toggled off
|
else: # toggled off
|
||||||
|
|
|
@ -22,7 +22,6 @@ import gtk
|
||||||
import os
|
import os
|
||||||
import fpdb_simple
|
import fpdb_simple
|
||||||
|
|
||||||
|
|
||||||
import fpdb_import
|
import fpdb_import
|
||||||
import fpdb_db
|
import fpdb_db
|
||||||
from Exceptions import *
|
from Exceptions import *
|
||||||
|
|
|
@ -252,10 +252,10 @@
|
||||||
|
|
||||||
<site enabled="False"
|
<site enabled="False"
|
||||||
site_name="PartyPoker"
|
site_name="PartyPoker"
|
||||||
table_finder="PartyPoker.exe"
|
table_finder="PartyGaming.exe"
|
||||||
screen_name="YOUR SCREEN NAME HERE"
|
screen_name="YOUR SCREEN NAME HERE"
|
||||||
site_path=""
|
site_path="C:/Program Files/PartyGaming/PartyPoker"
|
||||||
HH_path=""
|
HH_path="C:/Program Files/PartyGaming/PartyPoker/HandHistory/YOUR SCREEN NAME HERE/"
|
||||||
decoder="everleaf_decode_table"
|
decoder="everleaf_decode_table"
|
||||||
converter="PartyPokerToFpdb"
|
converter="PartyPokerToFpdb"
|
||||||
supported_games="holdem">
|
supported_games="holdem">
|
||||||
|
|
253
pyfpdb/Hand.py
253
pyfpdb/Hand.py
|
@ -5,12 +5,12 @@
|
||||||
#This program is free software: you can redistribute it and/or modify
|
#This program is free software: you can redistribute it and/or modify
|
||||||
#it under the terms of the GNU Affero General Public License as published by
|
#it under the terms of the GNU Affero General Public License as published by
|
||||||
#the Free Software Foundation, version 3 of the License.
|
#the Free Software Foundation, version 3 of the License.
|
||||||
#
|
#
|
||||||
#This program is distributed in the hope that it will be useful,
|
#This program is distributed in the hope that it will be useful,
|
||||||
#but WITHOUT ANY WARRANTY; without even the implied warranty of
|
#but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
#GNU General Public License for more details.
|
#GNU General Public License for more details.
|
||||||
#
|
#
|
||||||
#You should have received a copy of the GNU Affero General Public License
|
#You should have received a copy of the GNU Affero General Public License
|
||||||
#along with this program. If not, see <http://www.gnu.org/licenses/>.
|
#along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
#In the "official" distribution you can find the license in
|
#In the "official" distribution you can find the license in
|
||||||
|
@ -121,7 +121,7 @@ class Hand(object):
|
||||||
("MIXED", self.mixed),
|
("MIXED", self.mixed),
|
||||||
("LASTBET", self.lastBet),
|
("LASTBET", self.lastBet),
|
||||||
("ACTION STREETS", self.actionStreets),
|
("ACTION STREETS", self.actionStreets),
|
||||||
("STREETS", self.streets),
|
("STREETS", self.streets),
|
||||||
("ALL STREETS", self.allStreets),
|
("ALL STREETS", self.allStreets),
|
||||||
("COMMUNITY STREETS", self.communityStreets),
|
("COMMUNITY STREETS", self.communityStreets),
|
||||||
("HOLE STREETS", self.holeStreets),
|
("HOLE STREETS", self.holeStreets),
|
||||||
|
@ -134,7 +134,7 @@ class Hand(object):
|
||||||
("RAKE", self.rake),
|
("RAKE", self.rake),
|
||||||
("START TIME", self.starttime),
|
("START TIME", self.starttime),
|
||||||
)
|
)
|
||||||
|
|
||||||
structs = ( ("PLAYERS", self.players),
|
structs = ( ("PLAYERS", self.players),
|
||||||
("STACKS", self.stacks),
|
("STACKS", self.stacks),
|
||||||
("POSTED", self.posted),
|
("POSTED", self.posted),
|
||||||
|
@ -190,21 +190,7 @@ db: a connected fpdb_db object"""
|
||||||
sqlids = db.getSqlPlayerIDs([p[1] for p in self.players], self.siteId)
|
sqlids = db.getSqlPlayerIDs([p[1] for p in self.players], self.siteId)
|
||||||
|
|
||||||
#Gametypes
|
#Gametypes
|
||||||
|
gtid = db.getGameTypeId(self.siteId, self.gametype)
|
||||||
print "DEBUG: self.gametype %s" % self.gametype
|
|
||||||
#Nice way to discover if the game is already listed in the db?
|
|
||||||
#Also this is using an old method from fpdb_simple - should probably conform to the rest of the inserts
|
|
||||||
|
|
||||||
hilo = "h"
|
|
||||||
if self.gametype['category'] in ['studhilo', 'omahahilo']:
|
|
||||||
hilo = "s"
|
|
||||||
elif self.gametype['category'] in ['razz','27_3draw','badugi']:
|
|
||||||
hilo = "l"
|
|
||||||
|
|
||||||
gtid = db.insertGameTypes( (self.siteId, self.gametype['type'], self.gametype['base'],
|
|
||||||
self.gametype['category'], self.gametype['limitType'], hilo,
|
|
||||||
int(Decimal(self.gametype['sb'])*100), int(Decimal(self.gametype['bb'])*100), 0, 0) )
|
|
||||||
|
|
||||||
|
|
||||||
# HudCache data to come from DerivedStats class
|
# HudCache data to come from DerivedStats class
|
||||||
# HandsActions - all actions for all players for all streets - self.actions
|
# HandsActions - all actions for all players for all streets - self.actions
|
||||||
|
@ -213,16 +199,11 @@ db: a connected fpdb_db object"""
|
||||||
hh = {}
|
hh = {}
|
||||||
hh['siteHandNo'] = self.handid
|
hh['siteHandNo'] = self.handid
|
||||||
hh['handStart'] = self.starttime
|
hh['handStart'] = self.starttime
|
||||||
hh['gameTypeId'] = gtid[0]
|
hh['gameTypeId'] = gtid
|
||||||
# seats TINYINT NOT NULL,
|
# seats TINYINT NOT NULL,
|
||||||
hh['tableName'] = self.tablename
|
hh['tableName'] = self.tablename
|
||||||
hh['maxSeats'] = self.maxseats
|
hh['maxSeats'] = self.maxseats
|
||||||
hh['seats'] = len(sqlids)
|
hh['seats'] = len(sqlids)
|
||||||
# boardcard1 smallint, /* 0=none, 1-13=2-Ah 14-26=2-Ad 27-39=2-Ac 40-52=2-As */
|
|
||||||
# boardcard2 smallint,
|
|
||||||
# boardcard3 smallint,
|
|
||||||
# boardcard4 smallint,
|
|
||||||
# boardcard5 smallint,
|
|
||||||
# Flop turn and river may all be empty - add (likely) too many elements and trim with range
|
# Flop turn and river may all be empty - add (likely) too many elements and trim with range
|
||||||
boardcards = self.board['FLOP'] + self.board['TURN'] + self.board['RIVER'] + [u'0x', u'0x', u'0x', u'0x', u'0x']
|
boardcards = self.board['FLOP'] + self.board['TURN'] + self.board['RIVER'] + [u'0x', u'0x', u'0x', u'0x', u'0x']
|
||||||
cards = [Card.encodeCard(c) for c in boardcards[0:5]]
|
cards = [Card.encodeCard(c) for c in boardcards[0:5]]
|
||||||
|
@ -232,7 +213,6 @@ db: a connected fpdb_db object"""
|
||||||
hh['boardcard4'] = cards[3]
|
hh['boardcard4'] = cards[3]
|
||||||
hh['boardcard5'] = cards[4]
|
hh['boardcard5'] = cards[4]
|
||||||
|
|
||||||
print hh
|
|
||||||
# texture smallint,
|
# texture smallint,
|
||||||
# playersVpi SMALLINT NOT NULL, /* num of players vpi */
|
# playersVpi SMALLINT NOT NULL, /* num of players vpi */
|
||||||
# Needs to be recorded
|
# Needs to be recorded
|
||||||
|
@ -256,17 +236,14 @@ db: a connected fpdb_db object"""
|
||||||
# Needs to be recorded
|
# Needs to be recorded
|
||||||
# street4Raises TINYINT NOT NULL, /* num big bets paid to see showdown */
|
# street4Raises TINYINT NOT NULL, /* num big bets paid to see showdown */
|
||||||
# Needs to be recorded
|
# Needs to be recorded
|
||||||
# street1Pot INT, /* pot size at flop/street4 */
|
|
||||||
# Needs to be recorded
|
#print "DEBUG: self.getStreetTotals = (%s, %s, %s, %s, %s)" % self.getStreetTotals()
|
||||||
# street2Pot INT, /* pot size at turn/street5 */
|
#FIXME: Pot size still in decimal, needs to be converted to cents
|
||||||
# Needs to be recorded
|
(hh['street1Pot'], hh['street2Pot'], hh['street3Pot'], hh['street4Pot'], hh['showdownPot']) = self.getStreetTotals()
|
||||||
# street3Pot INT, /* pot size at river/street6 */
|
|
||||||
# Needs to be recorded
|
|
||||||
# street4Pot INT, /* pot size at sd/street7 */
|
|
||||||
# Needs to be recorded
|
|
||||||
# showdownPot INT, /* pot size at sd/street7 */
|
|
||||||
# comment TEXT,
|
# comment TEXT,
|
||||||
# commentTs DATETIME
|
# commentTs DATETIME
|
||||||
|
#print hh
|
||||||
handid = db.storeHand(hh)
|
handid = db.storeHand(hh)
|
||||||
# HandsPlayers - ? ... Do we fix winnings?
|
# HandsPlayers - ? ... Do we fix winnings?
|
||||||
# Tourneys ?
|
# Tourneys ?
|
||||||
|
@ -276,8 +253,8 @@ db: a connected fpdb_db object"""
|
||||||
|
|
||||||
def select(self, handId):
|
def select(self, handId):
|
||||||
""" Function to create Hand object from database """
|
""" Function to create Hand object from database """
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def addPlayer(self, seat, name, chips):
|
def addPlayer(self, seat, name, chips):
|
||||||
|
@ -326,14 +303,13 @@ If a player has None chips he won't be added."""
|
||||||
return c
|
return c
|
||||||
|
|
||||||
def addAnte(self, player, ante):
|
def addAnte(self, player, ante):
|
||||||
log.debug("%s %s antes %s" % ('ANTES', player, ante))
|
log.debug("%s %s antes %s" % ('BLINDSANTES', player, ante))
|
||||||
if player is not None:
|
if player is not None:
|
||||||
ante = re.sub(u',', u'', ante) #some sites have commas
|
ante = re.sub(u',', u'', ante) #some sites have commas
|
||||||
self.bets['ANTES'][player].append(Decimal(ante))
|
self.bets['BLINDSANTES'][player].append(Decimal(ante))
|
||||||
self.stacks[player] -= Decimal(ante)
|
self.stacks[player] -= Decimal(ante)
|
||||||
act = (player, 'posts', "ante", ante, self.stacks[player]==0)
|
act = (player, 'posts', "ante", ante, self.stacks[player]==0)
|
||||||
self.actions['ANTES'].append(act)
|
self.actions['BLINDSANTES'].append(act)
|
||||||
#~ self.lastBet['ANTES'] = Decimal(ante)
|
|
||||||
self.pot.addMoney(player, Decimal(ante))
|
self.pot.addMoney(player, Decimal(ante))
|
||||||
|
|
||||||
def addBlind(self, player, blindtype, amount):
|
def addBlind(self, player, blindtype, amount):
|
||||||
|
@ -348,19 +324,19 @@ If a player has None chips he won't be added."""
|
||||||
log.debug("addBlind: %s posts %s, %s" % (player, blindtype, amount))
|
log.debug("addBlind: %s posts %s, %s" % (player, blindtype, amount))
|
||||||
if player is not None:
|
if player is not None:
|
||||||
amount = re.sub(u',', u'', amount) #some sites have commas
|
amount = re.sub(u',', u'', amount) #some sites have commas
|
||||||
self.bets['PREFLOP'][player].append(Decimal(amount))
|
|
||||||
self.stacks[player] -= Decimal(amount)
|
self.stacks[player] -= Decimal(amount)
|
||||||
#print "DEBUG %s posts, stack %s" % (player, self.stacks[player])
|
|
||||||
act = (player, 'posts', blindtype, amount, self.stacks[player]==0)
|
act = (player, 'posts', blindtype, amount, self.stacks[player]==0)
|
||||||
self.actions['BLINDSANTES'].append(act)
|
self.actions['BLINDSANTES'].append(act)
|
||||||
|
|
||||||
|
if blindtype == 'both':
|
||||||
|
amount = self.bb
|
||||||
|
self.bets['BLINDSANTES'][player].append(Decimal(self.sb))
|
||||||
|
self.pot.addCommonMoney(Decimal(self.sb))
|
||||||
|
|
||||||
|
self.bets['PREFLOP'][player].append(Decimal(amount))
|
||||||
self.pot.addMoney(player, Decimal(amount))
|
self.pot.addMoney(player, Decimal(amount))
|
||||||
if blindtype == 'big blind':
|
self.lastBet['PREFLOP'] = Decimal(amount)
|
||||||
self.lastBet['PREFLOP'] = Decimal(amount)
|
|
||||||
elif blindtype == 'both':
|
|
||||||
# extra small blind is 'dead'
|
|
||||||
self.lastBet['PREFLOP'] = Decimal(self.bb)
|
|
||||||
self.posted = self.posted + [[player,blindtype]]
|
self.posted = self.posted + [[player,blindtype]]
|
||||||
#print "DEBUG: self.posted: %s" %(self.posted)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -378,22 +354,22 @@ If a player has None chips he won't be added."""
|
||||||
act = (player, 'calls', amount, self.stacks[player]==0)
|
act = (player, 'calls', amount, self.stacks[player]==0)
|
||||||
self.actions[street].append(act)
|
self.actions[street].append(act)
|
||||||
self.pot.addMoney(player, Decimal(amount))
|
self.pot.addMoney(player, Decimal(amount))
|
||||||
|
|
||||||
def addRaiseBy(self, street, player, amountBy):
|
def addRaiseBy(self, street, player, amountBy):
|
||||||
"""\
|
"""\
|
||||||
Add a raise by amountBy on [street] by [player]
|
Add a raise by amountBy on [street] by [player]
|
||||||
"""
|
"""
|
||||||
#Given only the amount raised by, the amount of the raise can be calculated by
|
#Given only the amount raised by, the amount of the raise can be calculated by
|
||||||
# working out how much this player has already in the pot
|
# working out how much this player has already in the pot
|
||||||
# (which is the sum of self.bets[street][player])
|
# (which is the sum of self.bets[street][player])
|
||||||
# and how much he needs to call to match the previous player
|
# and how much he needs to call to match the previous player
|
||||||
# (which is tracked by self.lastBet)
|
# (which is tracked by self.lastBet)
|
||||||
# let Bp = previous bet
|
# let Bp = previous bet
|
||||||
# Bc = amount player has committed so far
|
# Bc = amount player has committed so far
|
||||||
# Rb = raise by
|
# Rb = raise by
|
||||||
# then: C = Bp - Bc (amount to call)
|
# then: C = Bp - Bc (amount to call)
|
||||||
# Rt = Bp + Rb (raise to)
|
# Rt = Bp + Rb (raise to)
|
||||||
#
|
#
|
||||||
amountBy = re.sub(u',', u'', amountBy) #some sites have commas
|
amountBy = re.sub(u',', u'', amountBy) #some sites have commas
|
||||||
self.checkPlayerExists(player)
|
self.checkPlayerExists(player)
|
||||||
Rb = Decimal(amountBy)
|
Rb = Decimal(amountBy)
|
||||||
|
@ -401,7 +377,7 @@ Add a raise by amountBy on [street] by [player]
|
||||||
Bc = reduce(operator.add, self.bets[street][player], 0)
|
Bc = reduce(operator.add, self.bets[street][player], 0)
|
||||||
C = Bp - Bc
|
C = Bp - Bc
|
||||||
Rt = Bp + Rb
|
Rt = Bp + Rb
|
||||||
|
|
||||||
self._addRaise(street, player, C, Rb, Rt)
|
self._addRaise(street, player, C, Rb, Rt)
|
||||||
#~ self.bets[street][player].append(C + Rb)
|
#~ self.bets[street][player].append(C + Rb)
|
||||||
#~ self.stacks[player] -= (C + Rb)
|
#~ self.stacks[player] -= (C + Rb)
|
||||||
|
@ -419,7 +395,7 @@ For sites which by "raises x" mean "calls and raises putting a total of x in the
|
||||||
C = Bp - Bc
|
C = Bp - Bc
|
||||||
Rb = CRb - C
|
Rb = CRb - C
|
||||||
Rt = Bp + Rb
|
Rt = Bp + Rb
|
||||||
|
|
||||||
self._addRaise(street, player, C, Rb, Rt)
|
self._addRaise(street, player, C, Rb, Rt)
|
||||||
|
|
||||||
def addRaiseTo(self, street, player, amountTo):
|
def addRaiseTo(self, street, player, amountTo):
|
||||||
|
@ -444,9 +420,9 @@ Add a raise on [street] by [player] to [amountTo]
|
||||||
self.actions[street].append(act)
|
self.actions[street].append(act)
|
||||||
self.lastBet[street] = Rt # TODO check this is correct
|
self.lastBet[street] = Rt # TODO check this is correct
|
||||||
self.pot.addMoney(player, C+Rb)
|
self.pot.addMoney(player, C+Rb)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def addBet(self, street, player, amount):
|
def addBet(self, street, player, amount):
|
||||||
log.debug("%s %s bets %s" %(street, player, amount))
|
log.debug("%s %s bets %s" %(street, player, amount))
|
||||||
amount = re.sub(u',', u'', amount) #some sites have commas
|
amount = re.sub(u',', u'', amount) #some sites have commas
|
||||||
|
@ -464,7 +440,7 @@ Add a raise on [street] by [player] to [amountTo]
|
||||||
self.checkPlayerExists(player)
|
self.checkPlayerExists(player)
|
||||||
act = (player, 'stands pat')
|
act = (player, 'stands pat')
|
||||||
self.actions[street].append(act)
|
self.actions[street].append(act)
|
||||||
|
|
||||||
|
|
||||||
def addFold(self, street, player):
|
def addFold(self, street, player):
|
||||||
log.debug("%s %s folds" % (street, player))
|
log.debug("%s %s folds" % (street, player))
|
||||||
|
@ -472,7 +448,7 @@ Add a raise on [street] by [player] to [amountTo]
|
||||||
self.folded.add(player)
|
self.folded.add(player)
|
||||||
self.pot.addFold(player)
|
self.pot.addFold(player)
|
||||||
self.actions[street].append((player, 'folds'))
|
self.actions[street].append((player, 'folds'))
|
||||||
|
|
||||||
|
|
||||||
def addCheck(self, street, player):
|
def addCheck(self, street, player):
|
||||||
#print "DEBUG: %s %s checked" % (street, player)
|
#print "DEBUG: %s %s checked" % (street, player)
|
||||||
|
@ -496,6 +472,7 @@ Add a raise on [street] by [player] to [amountTo]
|
||||||
For when a player shows cards for any reason (for showdown or out of choice).
|
For when a player shows cards for any reason (for showdown or out of choice).
|
||||||
Card ranks will be uppercased
|
Card ranks will be uppercased
|
||||||
"""
|
"""
|
||||||
|
import sys; sys.exit(1)
|
||||||
log.debug("addShownCards %s hole=%s all=%s" % (player, cards, holeandboard))
|
log.debug("addShownCards %s hole=%s all=%s" % (player, cards, holeandboard))
|
||||||
if cards is not None:
|
if cards is not None:
|
||||||
self.addHoleCards(cards,player,shown, mucked)
|
self.addHoleCards(cards,player,shown, mucked)
|
||||||
|
@ -504,10 +481,9 @@ Card ranks will be uppercased
|
||||||
board = set([c for s in self.board.values() for c in s])
|
board = set([c for s in self.board.values() for c in s])
|
||||||
self.addHoleCards(holeandboard.difference(board),player,shown, mucked)
|
self.addHoleCards(holeandboard.difference(board),player,shown, mucked)
|
||||||
|
|
||||||
|
|
||||||
def totalPot(self):
|
def totalPot(self):
|
||||||
"""If all bets and blinds have been added, totals up the total pot size"""
|
"""If all bets and blinds have been added, totals up the total pot size"""
|
||||||
|
|
||||||
# This gives us the total amount put in the pot
|
# This gives us the total amount put in the pot
|
||||||
if self.totalpot is None:
|
if self.totalpot is None:
|
||||||
self.pot.end()
|
self.pot.end()
|
||||||
|
@ -577,6 +553,8 @@ Map the tuple self.gametype onto the pokerstars string describing it
|
||||||
return ("%s: posts big blind %s%s%s" %(act[0], self.sym, act[3], ' and is all-in' if act[4] else ''))
|
return ("%s: posts big blind %s%s%s" %(act[0], self.sym, act[3], ' and is all-in' if act[4] else ''))
|
||||||
elif(act[2] == "both"):
|
elif(act[2] == "both"):
|
||||||
return ("%s: posts small & big blinds %s%s%s" %(act[0], self.sym, act[3], ' and is all-in' if act[4] else ''))
|
return ("%s: posts small & big blinds %s%s%s" %(act[0], self.sym, act[3], ' and is all-in' if act[4] else ''))
|
||||||
|
elif(act[2] == "ante"):
|
||||||
|
return ("%s: posts the ante %s%s%s" %(act[0], self.sym, act[3], ' and is all-in' if act[4] else ''))
|
||||||
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':
|
||||||
|
@ -588,17 +566,20 @@ Map the tuple self.gametype onto the pokerstars string describing it
|
||||||
"""Return a string of the stakes of the current hand."""
|
"""Return a string of the stakes of the current hand."""
|
||||||
return "%s%s/%s%s" % (self.sym, self.sb, self.sym, self.bb)
|
return "%s%s/%s%s" % (self.sym, self.sb, self.sym, self.bb)
|
||||||
|
|
||||||
|
def getStreetTotals(self):
|
||||||
|
pass
|
||||||
|
|
||||||
def writeGameLine(self):
|
def writeGameLine(self):
|
||||||
"""Return the first HH line for the current hand."""
|
"""Return the first HH line for the current hand."""
|
||||||
gs = "PokerStars Game #%s: " % self.handid
|
gs = "PokerStars Game #%s: " % self.handid
|
||||||
|
|
||||||
if self.tourNo != None and self.mixed != None: # mixed tournament
|
if self.tourNo != None and self.mixed != None: # mixed tournament
|
||||||
gs = gs + "Tournament #%s, %s %s (%s) - Level %s (%s) - " % (self.tourNo, self.buyin, self.MS[self.mixed], self.getGameTypeAsString(), self.level, self.getStakesAsString())
|
gs = gs + "Tournament #%s, %s %s (%s) - Level %s (%s) - " % (self.tourNo, self.buyin, self.MS[self.mixed], self.getGameTypeAsString(), self.level, self.getStakesAsString())
|
||||||
elif self.tourNo != None: # all other tournaments
|
elif self.tourNo != None: # all other tournaments
|
||||||
gs = gs + "Tournament #%s, %s %s - Level %s (%s) - " % (self.tourNo,
|
gs = gs + "Tournament #%s, %s %s - Level %s (%s) - " % (self.tourNo,
|
||||||
self.buyin, self.getGameTypeAsString(), self.level, self.getStakesAsString())
|
self.buyin, self.getGameTypeAsString(), self.level, self.getStakesAsString())
|
||||||
elif self.mixed != None: # all other mixed games
|
elif self.mixed != None: # all other mixed games
|
||||||
gs = gs + " %s (%s, %s) - " % (self.MS[self.mixed],
|
gs = gs + " %s (%s, %s) - " % (self.MS[self.mixed],
|
||||||
self.getGameTypeAsString(), self.getStakesAsString())
|
self.getGameTypeAsString(), self.getStakesAsString())
|
||||||
else: # non-mixed cash games
|
else: # non-mixed cash games
|
||||||
gs = gs + " %s (%s) - " % (self.getGameTypeAsString(), self.getStakesAsString())
|
gs = gs + " %s (%s) - " % (self.getGameTypeAsString(), self.getStakesAsString())
|
||||||
|
@ -617,8 +598,8 @@ Map the tuple self.gametype onto the pokerstars string describing it
|
||||||
|
|
||||||
def writeHand(self, fh=sys.__stdout__):
|
def writeHand(self, fh=sys.__stdout__):
|
||||||
# PokerStars format.
|
# PokerStars format.
|
||||||
print >>fh, self.writeGameLine()
|
print >>fh, self.writeGameLine()
|
||||||
print >>fh, self.writeTableLine()
|
print >>fh, self.writeTableLine()
|
||||||
|
|
||||||
|
|
||||||
class HoldemOmahaHand(Hand):
|
class HoldemOmahaHand(Hand):
|
||||||
|
@ -633,9 +614,9 @@ class HoldemOmahaHand(Hand):
|
||||||
Hand.__init__(self, sitename, gametype, handText, builtFrom = "HHC")
|
Hand.__init__(self, sitename, gametype, handText, builtFrom = "HHC")
|
||||||
self.sb = gametype['sb']
|
self.sb = gametype['sb']
|
||||||
self.bb = gametype['bb']
|
self.bb = gametype['bb']
|
||||||
|
|
||||||
#Populate a HoldemOmahaHand
|
#Populate a HoldemOmahaHand
|
||||||
#Generally, we call 'read' methods here, which get the info according to the particular filter (hhc)
|
#Generally, we call 'read' methods here, which get the info according to the particular filter (hhc)
|
||||||
# which then invokes a 'addXXX' callback
|
# which then invokes a 'addXXX' callback
|
||||||
if builtFrom == "HHC":
|
if builtFrom == "HHC":
|
||||||
hhc.readHandInfo(self)
|
hhc.readHandInfo(self)
|
||||||
|
@ -643,6 +624,7 @@ class HoldemOmahaHand(Hand):
|
||||||
hhc.compilePlayerRegexs(self)
|
hhc.compilePlayerRegexs(self)
|
||||||
hhc.markStreets(self)
|
hhc.markStreets(self)
|
||||||
hhc.readBlinds(self)
|
hhc.readBlinds(self)
|
||||||
|
hhc.readAntes(self)
|
||||||
hhc.readButton(self)
|
hhc.readButton(self)
|
||||||
hhc.readHeroCards(self)
|
hhc.readHeroCards(self)
|
||||||
hhc.readShowdownActions(self)
|
hhc.readShowdownActions(self)
|
||||||
|
@ -653,6 +635,7 @@ class HoldemOmahaHand(Hand):
|
||||||
for street in self.actionStreets:
|
for street in self.actionStreets:
|
||||||
if self.streets[street]:
|
if self.streets[street]:
|
||||||
hhc.readAction(self, street)
|
hhc.readAction(self, street)
|
||||||
|
self.pot.markTotal(street)
|
||||||
hhc.readCollectPot(self)
|
hhc.readCollectPot(self)
|
||||||
hhc.readShownCards(self)
|
hhc.readShownCards(self)
|
||||||
self.totalPot() # finalise it (total the pot)
|
self.totalPot() # finalise it (total the pot)
|
||||||
|
@ -668,7 +651,7 @@ class HoldemOmahaHand(Hand):
|
||||||
else:
|
else:
|
||||||
log.warning("HoldemOmahaHand.__init__:Neither HHC nor DB+handid provided")
|
log.warning("HoldemOmahaHand.__init__:Neither HHC nor DB+handid provided")
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
def addShownCards(self, cards, player, shown=True, mucked=False, dealt=False):
|
def addShownCards(self, cards, player, shown=True, mucked=False, dealt=False):
|
||||||
if player == self.hero: # we have hero's cards just update shown/mucked
|
if player == self.hero: # we have hero's cards just update shown/mucked
|
||||||
|
@ -677,6 +660,18 @@ class HoldemOmahaHand(Hand):
|
||||||
else:
|
else:
|
||||||
self.addHoleCards('PREFLOP', player, open=[], closed=cards, shown=shown, mucked=mucked, dealt=dealt)
|
self.addHoleCards('PREFLOP', player, open=[], closed=cards, shown=shown, mucked=mucked, dealt=dealt)
|
||||||
|
|
||||||
|
def getStreetTotals(self):
|
||||||
|
# street1Pot INT, /* pot size at flop/street4 */
|
||||||
|
# street2Pot INT, /* pot size at turn/street5 */
|
||||||
|
# street3Pot INT, /* pot size at river/street6 */
|
||||||
|
# street4Pot INT, /* pot size at sd/street7 */
|
||||||
|
# showdownPot INT, /* pot size at sd/street7 */
|
||||||
|
tmp1 = self.pot.getTotalAtStreet('FLOP')
|
||||||
|
tmp2 = self.pot.getTotalAtStreet('TURN')
|
||||||
|
tmp3 = self.pot.getTotalAtStreet('RIVER')
|
||||||
|
tmp4 = 0
|
||||||
|
tmp5 = 0
|
||||||
|
return (tmp1,tmp2,tmp3,tmp4,tmp5)
|
||||||
|
|
||||||
def writeHTMLHand(self):
|
def writeHTMLHand(self):
|
||||||
from nevow import tags as T
|
from nevow import tags as T
|
||||||
|
@ -711,7 +706,7 @@ class HoldemOmahaHand(Hand):
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
if street in self.actionStreets and self.actions[street]:
|
if street in self.actionStreets and self.actions[street]:
|
||||||
lines.append(
|
lines.append(
|
||||||
T.ol(class_='actions', data=self.actions[street], render=render_action) [
|
T.ol(class_='actions', data=self.actions[street], render=render_action) [
|
||||||
T.li(pattern='list_item')[ T.slot(name='action') ]
|
T.li(pattern='list_item')[ T.slot(name='action') ]
|
||||||
]
|
]
|
||||||
|
@ -745,8 +740,8 @@ class HoldemOmahaHand(Hand):
|
||||||
context.tag[ pat().fillSlots('action', x)]
|
context.tag[ pat().fillSlots('action', x)]
|
||||||
return context.tag
|
return context.tag
|
||||||
|
|
||||||
s = T.p[
|
s = T.p[
|
||||||
T.h1[
|
T.h1[
|
||||||
T.span(class_='site')["%s Game #%s]" % ('PokerStars', self.handid)],
|
T.span(class_='site')["%s Game #%s]" % ('PokerStars', self.handid)],
|
||||||
T.span(class_='type_limit')[ "%s ($%s/$%s)" %(self.getGameTypeAsString(), self.sb, self.bb) ],
|
T.span(class_='type_limit')[ "%s ($%s/$%s)" %(self.getGameTypeAsString(), self.sb, self.bb) ],
|
||||||
T.span(class_='date')[ datetime.datetime.strftime(self.starttime,'%Y/%m/%d - %H:%M:%S ET') ]
|
T.span(class_='date')[ datetime.datetime.strftime(self.starttime,'%Y/%m/%d - %H:%M:%S ET') ]
|
||||||
|
@ -772,7 +767,7 @@ class HoldemOmahaHand(Hand):
|
||||||
|
|
||||||
return str(tidy.parseString(flat.flatten(s), **options))
|
return str(tidy.parseString(flat.flatten(s), **options))
|
||||||
|
|
||||||
|
|
||||||
def writeHand(self, fh=sys.__stdout__):
|
def writeHand(self, fh=sys.__stdout__):
|
||||||
# PokerStars format.
|
# PokerStars format.
|
||||||
super(HoldemOmahaHand, self).writeHand(fh)
|
super(HoldemOmahaHand, self).writeHand(fh)
|
||||||
|
@ -786,7 +781,7 @@ class HoldemOmahaHand(Hand):
|
||||||
if self.actions['BLINDSANTES']:
|
if self.actions['BLINDSANTES']:
|
||||||
for act in self.actions['BLINDSANTES']:
|
for act in self.actions['BLINDSANTES']:
|
||||||
print >>fh, self.actionString(act)
|
print >>fh, self.actionString(act)
|
||||||
|
|
||||||
print >>fh, ("*** HOLE CARDS ***")
|
print >>fh, ("*** HOLE CARDS ***")
|
||||||
for player in self.dealt:
|
for player in self.dealt:
|
||||||
print >>fh, ("Dealt to %s [%s]" %(player, " ".join(self.holecards['PREFLOP'][player][1])))
|
print >>fh, ("Dealt to %s [%s]" %(player, " ".join(self.holecards['PREFLOP'][player][1])))
|
||||||
|
@ -832,7 +827,7 @@ class HoldemOmahaHand(Hand):
|
||||||
numOfHoleCardsNeeded = 2
|
numOfHoleCardsNeeded = 2
|
||||||
if len(self.holecards['PREFLOP'][name]) == numOfHoleCardsNeeded:
|
if len(self.holecards['PREFLOP'][name]) == numOfHoleCardsNeeded:
|
||||||
print >>fh, ("%s shows [%s] (a hand...)" % (name, " ".join(self.holecards['PREFLOP'][name][1])))
|
print >>fh, ("%s shows [%s] (a hand...)" % (name, " ".join(self.holecards['PREFLOP'][name][1])))
|
||||||
|
|
||||||
# Current PS format has the lines:
|
# Current PS format has the lines:
|
||||||
# Uncalled bet ($111.25) returned to s0rrow
|
# Uncalled bet ($111.25) returned to s0rrow
|
||||||
# s0rrow collected $5.15 from side pot
|
# s0rrow collected $5.15 from side pot
|
||||||
|
@ -874,7 +869,7 @@ class HoldemOmahaHand(Hand):
|
||||||
print >>fh, ("Seat %d: %s mucked" % (seatnum, name))
|
print >>fh, ("Seat %d: %s mucked" % (seatnum, name))
|
||||||
|
|
||||||
print >>fh, "\n\n"
|
print >>fh, "\n\n"
|
||||||
|
|
||||||
class DrawHand(Hand):
|
class DrawHand(Hand):
|
||||||
def __init__(self, hhc, sitename, gametype, handText, builtFrom = "HHC"):
|
def __init__(self, hhc, sitename, gametype, handText, builtFrom = "HHC"):
|
||||||
if gametype['base'] != 'draw':
|
if gametype['base'] != 'draw':
|
||||||
|
@ -894,6 +889,7 @@ class DrawHand(Hand):
|
||||||
hhc.compilePlayerRegexs(self)
|
hhc.compilePlayerRegexs(self)
|
||||||
hhc.markStreets(self)
|
hhc.markStreets(self)
|
||||||
hhc.readBlinds(self)
|
hhc.readBlinds(self)
|
||||||
|
hhc.readAntes(self)
|
||||||
hhc.readButton(self)
|
hhc.readButton(self)
|
||||||
hhc.readHeroCards(self)
|
hhc.readHeroCards(self)
|
||||||
hhc.readShowdownActions(self)
|
hhc.readShowdownActions(self)
|
||||||
|
@ -901,6 +897,7 @@ class DrawHand(Hand):
|
||||||
for street in self.streetList:
|
for street in self.streetList:
|
||||||
if self.streets[street]:
|
if self.streets[street]:
|
||||||
hhc.readAction(self, street)
|
hhc.readAction(self, street)
|
||||||
|
self.pot.markTotal(street)
|
||||||
hhc.readCollectPot(self)
|
hhc.readCollectPot(self)
|
||||||
hhc.readShownCards(self)
|
hhc.readShownCards(self)
|
||||||
self.totalPot() # finalise it (total the pot)
|
self.totalPot() # finalise it (total the pot)
|
||||||
|
@ -919,8 +916,8 @@ class DrawHand(Hand):
|
||||||
# - this is a bet of 1 sb, as yet uncalled.
|
# - this is a bet of 1 sb, as yet uncalled.
|
||||||
# Player in the big blind posts
|
# Player in the big blind posts
|
||||||
# - this is a call of 1 sb and a raise to 1 bb
|
# - this is a call of 1 sb and a raise to 1 bb
|
||||||
#
|
#
|
||||||
|
|
||||||
log.debug("addBlind: %s posts %s, %s" % (player, blindtype, amount))
|
log.debug("addBlind: %s posts %s, %s" % (player, blindtype, amount))
|
||||||
if player is not None:
|
if player is not None:
|
||||||
self.bets['DEAL'][player].append(Decimal(amount))
|
self.bets['DEAL'][player].append(Decimal(amount))
|
||||||
|
@ -930,7 +927,7 @@ class DrawHand(Hand):
|
||||||
self.actions['BLINDSANTES'].append(act)
|
self.actions['BLINDSANTES'].append(act)
|
||||||
self.pot.addMoney(player, Decimal(amount))
|
self.pot.addMoney(player, Decimal(amount))
|
||||||
if blindtype == 'big blind':
|
if blindtype == 'big blind':
|
||||||
self.lastBet['DEAL'] = Decimal(amount)
|
self.lastBet['DEAL'] = Decimal(amount)
|
||||||
elif blindtype == 'both':
|
elif blindtype == 'both':
|
||||||
# extra small blind is 'dead'
|
# extra small blind is 'dead'
|
||||||
self.lastBet['DEAL'] = Decimal(self.bb)
|
self.lastBet['DEAL'] = Decimal(self.bb)
|
||||||
|
@ -961,6 +958,14 @@ class DrawHand(Hand):
|
||||||
act = (player, 'discards', num)
|
act = (player, 'discards', num)
|
||||||
self.actions[street].append(act)
|
self.actions[street].append(act)
|
||||||
|
|
||||||
|
def getStreetTotals(self):
|
||||||
|
# street1Pot INT, /* pot size at flop/street4 */
|
||||||
|
# street2Pot INT, /* pot size at turn/street5 */
|
||||||
|
# street3Pot INT, /* pot size at river/street6 */
|
||||||
|
# street4Pot INT, /* pot size at sd/street7 */
|
||||||
|
# showdownPot INT, /* pot size at sd/street7 */
|
||||||
|
return (0,0,0,0,0)
|
||||||
|
|
||||||
|
|
||||||
def writeHand(self, fh=sys.__stdout__):
|
def writeHand(self, fh=sys.__stdout__):
|
||||||
# PokerStars format.
|
# PokerStars format.
|
||||||
|
@ -1042,17 +1047,17 @@ class StudHand(Hand):
|
||||||
if gametype['base'] != 'stud':
|
if gametype['base'] != 'stud':
|
||||||
pass # or indeed don't pass and complain instead
|
pass # or indeed don't pass and complain instead
|
||||||
|
|
||||||
self.allStreets = ['ANTES','THIRD','FOURTH','FIFTH','SIXTH','SEVENTH']
|
self.allStreets = ['BLINDSANTES','THIRD','FOURTH','FIFTH','SIXTH','SEVENTH']
|
||||||
self.communityStreets = []
|
self.communityStreets = []
|
||||||
self.actionStreets = ['ANTES','THIRD','FOURTH','FIFTH','SIXTH','SEVENTH']
|
self.actionStreets = ['BLINDSANTES','THIRD','FOURTH','FIFTH','SIXTH','SEVENTH']
|
||||||
|
|
||||||
self.streetList = ['ANTES','THIRD','FOURTH','FIFTH','SIXTH','SEVENTH'] # a list of the observed street names in order
|
self.streetList = ['BLINDSANTES','THIRD','FOURTH','FIFTH','SIXTH','SEVENTH'] # a list of the observed street names in order
|
||||||
self.holeStreets = ['THIRD','FOURTH','FIFTH','SIXTH','SEVENTH']
|
self.holeStreets = ['THIRD','FOURTH','FIFTH','SIXTH','SEVENTH']
|
||||||
Hand.__init__(self, sitename, gametype, handText)
|
Hand.__init__(self, sitename, gametype, handText)
|
||||||
self.sb = gametype['sb']
|
self.sb = gametype['sb']
|
||||||
self.bb = gametype['bb']
|
self.bb = gametype['bb']
|
||||||
#Populate the StudHand
|
#Populate the StudHand
|
||||||
#Generally, we call a 'read' method here, which gets the info according to the particular filter (hhc)
|
#Generally, we call a 'read' method here, which gets the info according to the particular filter (hhc)
|
||||||
# which then invokes a 'addXXX' callback
|
# which then invokes a 'addXXX' callback
|
||||||
if builtFrom == "HHC":
|
if builtFrom == "HHC":
|
||||||
hhc.readHandInfo(self)
|
hhc.readHandInfo(self)
|
||||||
|
@ -1064,10 +1069,11 @@ class StudHand(Hand):
|
||||||
hhc.readHeroCards(self)
|
hhc.readHeroCards(self)
|
||||||
# Read actions in street order
|
# Read actions in street order
|
||||||
for street in self.actionStreets:
|
for street in self.actionStreets:
|
||||||
if street == 'ANTES': continue # OMG--sometime someone folds in the ante round
|
if street == 'BLINDSANTES': continue # OMG--sometime someone folds in the ante round
|
||||||
if self.streets[street]:
|
if self.streets[street]:
|
||||||
log.debug(street + self.streets[street])
|
log.debug(street + self.streets[street])
|
||||||
hhc.readAction(self, street)
|
hhc.readAction(self, street)
|
||||||
|
self.pot.markTotal(street)
|
||||||
hhc.readCollectPot(self)
|
hhc.readCollectPot(self)
|
||||||
hhc.readShownCards(self) # not done yet
|
hhc.readShownCards(self) # not done yet
|
||||||
self.totalPot() # finalise it (total the pot)
|
self.totalPot() # finalise it (total the pot)
|
||||||
|
@ -1127,7 +1133,7 @@ Add a complete on [street] by [player] to [amountTo]
|
||||||
#~ self.actions[street].append(act)
|
#~ self.actions[street].append(act)
|
||||||
#~ self.lastBet[street] = Rt # TODO check this is correct
|
#~ self.lastBet[street] = Rt # TODO check this is correct
|
||||||
#~ self.pot.addMoney(player, C+Rb)
|
#~ self.pot.addMoney(player, C+Rb)
|
||||||
|
|
||||||
def addBringIn(self, player, bringin):
|
def addBringIn(self, player, bringin):
|
||||||
if player is not None:
|
if player is not None:
|
||||||
log.debug("Bringin: %s, %s" % (player , bringin))
|
log.debug("Bringin: %s, %s" % (player , bringin))
|
||||||
|
@ -1138,20 +1144,28 @@ Add a complete on [street] by [player] to [amountTo]
|
||||||
self.lastBet['THIRD'] = Decimal(bringin)
|
self.lastBet['THIRD'] = Decimal(bringin)
|
||||||
self.pot.addMoney(player, Decimal(bringin))
|
self.pot.addMoney(player, Decimal(bringin))
|
||||||
|
|
||||||
|
def getStreetTotals(self):
|
||||||
|
# street1Pot INT, /* pot size at flop/street4 */
|
||||||
|
# street2Pot INT, /* pot size at turn/street5 */
|
||||||
|
# street3Pot INT, /* pot size at river/street6 */
|
||||||
|
# street4Pot INT, /* pot size at sd/street7 */
|
||||||
|
# showdownPot INT, /* pot size at sd/street7 */
|
||||||
|
return (0,0,0,0,0)
|
||||||
|
|
||||||
|
|
||||||
def writeHand(self, fh=sys.__stdout__):
|
def writeHand(self, fh=sys.__stdout__):
|
||||||
# PokerStars format.
|
# PokerStars format.
|
||||||
|
|
||||||
super(StudHand, self).writeHand(fh)
|
super(StudHand, self).writeHand(fh)
|
||||||
|
|
||||||
players_who_post_antes = set([x[0] for x in self.actions['ANTES']])
|
players_who_post_antes = set([x[0] for x in self.actions['BLINDSANTES']])
|
||||||
|
|
||||||
for player in [x for x in self.players if x[1] in players_who_post_antes]:
|
for player in [x for x in self.players if x[1] in players_who_post_antes]:
|
||||||
#Only print stacks of players who do something preflop
|
#Only print stacks of players who do something preflop
|
||||||
print >>fh, _("Seat %s: %s (%s%s in chips)" %(player[0], player[1], self.sym, player[2]))
|
print >>fh, _("Seat %s: %s (%s%s in chips)" %(player[0], player[1], self.sym, player[2]))
|
||||||
|
|
||||||
if 'ANTES' in self.actions:
|
if 'BLINDSANTES' in self.actions:
|
||||||
for act in self.actions['ANTES']:
|
for act in self.actions['BLINDSANTES']:
|
||||||
print >>fh, _("%s: posts the ante %s%s" %(act[0], self.sym, act[3]))
|
print >>fh, _("%s: posts the ante %s%s" %(act[0], self.sym, act[3]))
|
||||||
|
|
||||||
if 'THIRD' in self.actions:
|
if 'THIRD' in self.actions:
|
||||||
|
@ -1274,7 +1288,7 @@ Add a complete on [street] by [player] to [amountTo]
|
||||||
else:
|
else:
|
||||||
return hc + " ".join(self.holecards[street][player][0]) + ']'
|
return hc + " ".join(self.holecards[street][player][0]) + ']'
|
||||||
|
|
||||||
if street == 'SEVENTH' and player != self.hero: return # only write 7th st line for hero, LDO
|
if street == 'SEVENTH' and player != self.hero: return # only write 7th st line for hero, LDO
|
||||||
return hc + " ".join(self.holecards[street][player][1]) + "] [" + " ".join(self.holecards[street][player][0]) + "]"
|
return hc + " ".join(self.holecards[street][player][1]) + "] [" + " ".join(self.holecards[street][player][0]) + "]"
|
||||||
|
|
||||||
def join_holecards(self, player):
|
def join_holecards(self, player):
|
||||||
|
@ -1296,30 +1310,43 @@ class Pot(object):
|
||||||
|
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.contenders = set()
|
self.contenders = set()
|
||||||
self.committed = {}
|
self.committed = {}
|
||||||
self.total = None
|
self.streettotals = {}
|
||||||
self.returned = {}
|
self.common = Decimal(0)
|
||||||
self.sym = u'$' # this is the default currency symbol
|
self.total = None
|
||||||
|
self.returned = {}
|
||||||
|
self.sym = u'$' # this is the default currency symbol
|
||||||
|
|
||||||
def setSym(self, sym):
|
def setSym(self, sym):
|
||||||
self.sym = sym
|
self.sym = sym
|
||||||
|
|
||||||
def addPlayer(self,player):
|
def addPlayer(self,player):
|
||||||
self.committed[player] = Decimal(0)
|
self.committed[player] = Decimal(0)
|
||||||
|
|
||||||
def addFold(self, player):
|
def addFold(self, player):
|
||||||
# addFold must be called when a player folds
|
# addFold must be called when a player folds
|
||||||
self.contenders.discard(player)
|
self.contenders.discard(player)
|
||||||
|
|
||||||
|
def addCommonMoney(self, amount):
|
||||||
|
self.common += amount
|
||||||
|
|
||||||
def addMoney(self, player, amount):
|
def addMoney(self, player, amount):
|
||||||
# addMoney must be called for any actions that put money in the pot, in the order they occur
|
# addMoney must be called for any actions that put money in the pot, in the order they occur
|
||||||
self.contenders.add(player)
|
self.contenders.add(player)
|
||||||
self.committed[player] += amount
|
self.committed[player] += amount
|
||||||
|
|
||||||
|
def markTotal(self, street):
|
||||||
|
self.streettotals[street] = sum(self.committed.values()) + self.common
|
||||||
|
|
||||||
|
def getTotalAtStreet(self, street):
|
||||||
|
if street in self.streettotals:
|
||||||
|
return self.streettotals[street]
|
||||||
|
return 0
|
||||||
|
|
||||||
def end(self):
|
def end(self):
|
||||||
self.total = sum(self.committed.values())
|
self.total = sum(self.committed.values()) + self.common
|
||||||
|
|
||||||
# Return any uncalled bet.
|
# Return any uncalled bet.
|
||||||
committed = sorted([ (v,k) for (k,v) in self.committed.items()])
|
committed = sorted([ (v,k) for (k,v) in self.committed.items()])
|
||||||
lastbet = committed[-1][0] - committed[-2][0]
|
lastbet = committed[-1][0] - committed[-2][0]
|
||||||
|
@ -1337,7 +1364,7 @@ class Pot(object):
|
||||||
self.pots = []
|
self.pots = []
|
||||||
while len(commitsall) > 0:
|
while len(commitsall) > 0:
|
||||||
commitslive = [(v,k) for (v,k) in commitsall if k in self.contenders]
|
commitslive = [(v,k) for (v,k) in commitsall if k in self.contenders]
|
||||||
v1 = commitslive[0][0]
|
v1 = commitslive[0][0]
|
||||||
self.pots += [sum([min(v,v1) for (v,k) in commitsall])]
|
self.pots += [sum([min(v,v1) for (v,k) in commitsall])]
|
||||||
commitsall = [((v-v1),k) for (v,k) in commitsall if v-v1 >0]
|
commitsall = [((v-v1),k) for (v,k) in commitsall if v-v1 >0]
|
||||||
|
|
||||||
|
@ -1347,7 +1374,7 @@ class Pot(object):
|
||||||
# and y+z+r = x
|
# and y+z+r = x
|
||||||
# for example:
|
# for example:
|
||||||
# Total pot $124.30 Main pot $98.90. Side pot $23.40. | Rake $2
|
# Total pot $124.30 Main pot $98.90. Side pot $23.40. | Rake $2
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
if self.sym is None:
|
if self.sym is None:
|
||||||
self.sym = "C"
|
self.sym = "C"
|
||||||
|
@ -1355,17 +1382,17 @@ class Pot(object):
|
||||||
print "call Pot.end() before printing pot total"
|
print "call Pot.end() before printing pot total"
|
||||||
# NB if I'm sure end() is idempotent, call it here.
|
# NB if I'm sure end() is idempotent, call it here.
|
||||||
raise FpdbParseError
|
raise FpdbParseError
|
||||||
|
|
||||||
ret = "Total pot %s%.2f" % (self.sym, self.total)
|
ret = "Total pot %s%.2f" % (self.sym, self.total)
|
||||||
if len(self.pots) < 2:
|
if len(self.pots) < 2:
|
||||||
return ret;
|
return ret;
|
||||||
ret += " Main pot %s%.2f" % (self.sym, self.pots[0])
|
ret += " Main pot %s%.2f" % (self.sym, self.pots[0])
|
||||||
|
|
||||||
return ret + ''.join([ (" Side pot %s%.2f." % (self.sym, self.pots[x]) ) for x in xrange(1, len(self.pots)) ])
|
return ret + ''.join([ (" Side pot %s%.2f." % (self.sym, self.pots[x]) ) for x in xrange(1, len(self.pots)) ])
|
||||||
|
|
||||||
def assemble(cnxn, handid):
|
def assemble(cnxn, handid):
|
||||||
c = cnxn.cursor()
|
c = cnxn.cursor()
|
||||||
|
|
||||||
# We need at least sitename, gametype, handid
|
# We need at least sitename, gametype, handid
|
||||||
# for the Hand.__init__
|
# for the Hand.__init__
|
||||||
c.execute("""
|
c.execute("""
|
||||||
|
@ -1408,10 +1435,10 @@ limit 1""", {'handid':handid})
|
||||||
h.setCommunityCards('FLOP', cards[0:3])
|
h.setCommunityCards('FLOP', cards[0:3])
|
||||||
if cards[3]:
|
if cards[3]:
|
||||||
h.setCommunityCards('TURN', [cards[3]])
|
h.setCommunityCards('TURN', [cards[3]])
|
||||||
if cards[4]:
|
if cards[4]:
|
||||||
h.setCommunityCards('RIVER', [cards[4]])
|
h.setCommunityCards('RIVER', [cards[4]])
|
||||||
#[Card.valueSuitFromCard(x) for x in cards]
|
#[Card.valueSuitFromCard(x) for x in cards]
|
||||||
|
|
||||||
# HandInfo : HID, TABLE
|
# HandInfo : HID, TABLE
|
||||||
# BUTTON - why is this treated specially in Hand?
|
# BUTTON - why is this treated specially in Hand?
|
||||||
# answer: it is written out in hand histories
|
# answer: it is written out in hand histories
|
||||||
|
@ -1429,7 +1456,7 @@ WHERE h.id = %(handid)s
|
||||||
h.handid = res[0]
|
h.handid = res[0]
|
||||||
h.tablename = res[1]
|
h.tablename = res[1]
|
||||||
h.starttime = res[2] # automatically a datetime
|
h.starttime = res[2] # automatically a datetime
|
||||||
|
|
||||||
# PlayerStacks
|
# PlayerStacks
|
||||||
c.execute("""
|
c.execute("""
|
||||||
SELECT
|
SELECT
|
||||||
|
@ -1454,7 +1481,7 @@ and p.id = hp.playerid
|
||||||
h.addCollectPot(name, winnings)
|
h.addCollectPot(name, winnings)
|
||||||
if position == 'B':
|
if position == 'B':
|
||||||
h.buttonpos = seat
|
h.buttonpos = seat
|
||||||
|
|
||||||
|
|
||||||
# actions
|
# actions
|
||||||
c.execute("""
|
c.execute("""
|
||||||
|
@ -1502,7 +1529,7 @@ ORDER BY
|
||||||
#hc.readShownCards(self)
|
#hc.readShownCards(self)
|
||||||
h.totalPot()
|
h.totalPot()
|
||||||
h.rake = h.totalpot - h.totalcollected
|
h.rake = h.totalpot - h.totalcollected
|
||||||
|
|
||||||
|
|
||||||
return h
|
return h
|
||||||
|
|
||||||
|
|
|
@ -76,11 +76,11 @@ follow : whether to tail -f the input"""
|
||||||
else:
|
else:
|
||||||
# TODO: out_path should be sanity checked.
|
# TODO: out_path should be sanity checked.
|
||||||
out_dir = os.path.dirname(self.out_path)
|
out_dir = os.path.dirname(self.out_path)
|
||||||
if not os.path.isdir(out_dir):
|
if not os.path.isdir(out_dir) and out_dir != '':
|
||||||
log.info("Creating directory '%s'" % out_dir)
|
log.info("Creating directory '%s'" % out_dir)
|
||||||
os.makedirs(out_dir)
|
os.makedirs(out_dir)
|
||||||
try:
|
try:
|
||||||
self.out_fh = open(self.out_path, 'w')
|
self.out_fh = codecs.open(self.out_path, 'w', 'cp1252')
|
||||||
log.debug("out_path %s opened as %s" % (self.out_path, self.out_fh))
|
log.debug("out_path %s opened as %s" % (self.out_path, self.out_fh))
|
||||||
except:
|
except:
|
||||||
log.error("out_path %s couldn't be opened" % (self.out_path))
|
log.error("out_path %s couldn't be opened" % (self.out_path))
|
||||||
|
@ -215,7 +215,7 @@ which it expects to find at self.re_TailSplitHands -- see for e.g. Everleaf.py.
|
||||||
self.obs = self.obs.replace('\r\n', '\n')
|
self.obs = self.obs.replace('\r\n', '\n')
|
||||||
if self.obs == "" or self.obs == None:
|
if self.obs == "" or self.obs == None:
|
||||||
log.info("Read no hands.")
|
log.info("Read no hands.")
|
||||||
return
|
return []
|
||||||
return re.split(self.re_SplitHands, self.obs)
|
return re.split(self.re_SplitHands, self.obs)
|
||||||
|
|
||||||
def processHand(self, handText):
|
def processHand(self, handText):
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
"""Hud.py
|
"""Hud.py
|
||||||
|
|
||||||
Create and manage the hud overlays.
|
Create and manage the hud overlays.
|
||||||
|
@ -95,6 +96,8 @@ class Hud:
|
||||||
if my_import == None:
|
if my_import == None:
|
||||||
continue
|
continue
|
||||||
self.aux_windows.append(my_import(self, config, aux_params))
|
self.aux_windows.append(my_import(self, config, aux_params))
|
||||||
|
|
||||||
|
self.creation_attrs = None
|
||||||
|
|
||||||
def create_mw(self):
|
def create_mw(self):
|
||||||
|
|
||||||
|
@ -146,6 +149,21 @@ class Hud:
|
||||||
self.item4.connect("activate", self.debug_stat_windows)
|
self.item4.connect("activate", self.debug_stat_windows)
|
||||||
self.item4.show()
|
self.item4.show()
|
||||||
|
|
||||||
|
self.item5 = gtk.MenuItem('Set max seats')
|
||||||
|
self.menu.append(self.item5)
|
||||||
|
self.item5.show()
|
||||||
|
self.maxSeatsMenu = gtk.Menu()
|
||||||
|
self.item5.set_submenu(self.maxSeatsMenu)
|
||||||
|
for i in range(2, 11, 1):
|
||||||
|
item = gtk.MenuItem('%d-max' % i)
|
||||||
|
item.ms = i
|
||||||
|
self.maxSeatsMenu.append(item)
|
||||||
|
item.connect("activate", self.change_max_seats)
|
||||||
|
item.show()
|
||||||
|
setattr(self, 'maxSeatsMenuItem%d' % (i-1), item)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
self.ebox.connect_object("button-press-event", self.on_button_press, self.menu)
|
self.ebox.connect_object("button-press-event", self.on_button_press, self.menu)
|
||||||
|
|
||||||
self.main_window.show_all()
|
self.main_window.show_all()
|
||||||
|
@ -162,7 +180,19 @@ class Hud:
|
||||||
self.main_window.gdkhandle.set_transient_for(self.main_window.parentgdkhandle) #
|
self.main_window.gdkhandle.set_transient_for(self.main_window.parentgdkhandle) #
|
||||||
|
|
||||||
self.update_table_position()
|
self.update_table_position()
|
||||||
|
|
||||||
|
def change_max_seats(self, widget):
|
||||||
|
if self.max != widget.ms:
|
||||||
|
print 'change_max_seats', widget.ms
|
||||||
|
self.max = widget.ms
|
||||||
|
try:
|
||||||
|
self.kill()
|
||||||
|
self.create(*self.creation_attrs)
|
||||||
|
self.update(self.hand, self.config)
|
||||||
|
except Exception, e:
|
||||||
|
print "Expcetion:",str(e)
|
||||||
|
pass
|
||||||
|
|
||||||
def update_table_position(self):
|
def update_table_position(self):
|
||||||
if os.name == 'nt':
|
if os.name == 'nt':
|
||||||
if not win32gui.IsWindow(self.table.number):
|
if not win32gui.IsWindow(self.table.number):
|
||||||
|
@ -181,6 +211,11 @@ class Hud:
|
||||||
for i, w in enumerate(self.stat_windows.itervalues()):
|
for i, w in enumerate(self.stat_windows.itervalues()):
|
||||||
(x, y) = loc[adj[i+1]]
|
(x, y) = loc[adj[i+1]]
|
||||||
w.relocate(x, y)
|
w.relocate(x, y)
|
||||||
|
|
||||||
|
# While we're at it, fix the positions of mucked cards too
|
||||||
|
for aux in self.aux_windows:
|
||||||
|
aux.update_card_positions()
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def on_button_press(self, widget, event):
|
def on_button_press(self, widget, event):
|
||||||
|
@ -205,6 +240,7 @@ class Hud:
|
||||||
self.aux_windows = []
|
self.aux_windows = []
|
||||||
|
|
||||||
def reposition_windows(self, *args):
|
def reposition_windows(self, *args):
|
||||||
|
self.update_table_position()
|
||||||
for w in self.stat_windows.itervalues():
|
for w in self.stat_windows.itervalues():
|
||||||
if type(w) == int:
|
if type(w) == int:
|
||||||
# print "in reposition, w =", w
|
# print "in reposition, w =", w
|
||||||
|
@ -264,6 +300,8 @@ class Hud:
|
||||||
#
|
#
|
||||||
# this method also manages the creating and destruction of stat
|
# this method also manages the creating and destruction of stat
|
||||||
# windows via calls to the Stat_Window class
|
# windows via calls to the Stat_Window class
|
||||||
|
self.creation_attrs = hand, config, stat_dict, cards
|
||||||
|
|
||||||
self.hand = hand
|
self.hand = hand
|
||||||
if not self.mw_created:
|
if not self.mw_created:
|
||||||
self.create_mw()
|
self.create_mw()
|
||||||
|
|
|
@ -345,6 +345,22 @@ class Aux_Seats(Aux_Window):
|
||||||
def create_contents(self): pass
|
def create_contents(self): pass
|
||||||
def update_contents(self): pass
|
def update_contents(self): pass
|
||||||
|
|
||||||
|
def update_card_positions(self):
|
||||||
|
# self.adj does not exist until .create() has been run
|
||||||
|
try:
|
||||||
|
adj = self.adj
|
||||||
|
except AttributeError:
|
||||||
|
return
|
||||||
|
loc = self.config.get_aux_locations(self.params['name'], int(self.hud.max))
|
||||||
|
for i in (range(1, self.hud.max + 1) + ['common']):
|
||||||
|
if i == 'common':
|
||||||
|
(x, y) = self.params['layout'][self.hud.max].common
|
||||||
|
else:
|
||||||
|
(x, y) = loc[adj[i]]
|
||||||
|
self.positions[i] = self.card_positions(x, self.hud.table.x, y, self.hud.table.y)
|
||||||
|
self.m_windows[i].move(self.positions[i][0], self.positions[i][1])
|
||||||
|
|
||||||
|
|
||||||
def create(self):
|
def create(self):
|
||||||
self.adj = self.hud.adj_seats(0, self.config) # move adj_seats to aux and get rid of it in Hud.py
|
self.adj = self.hud.adj_seats(0, self.config) # move adj_seats to aux and get rid of it in Hud.py
|
||||||
loc = self.config.get_aux_locations(self.params['name'], int(self.hud.max))
|
loc = self.config.get_aux_locations(self.params['name'], int(self.hud.max))
|
||||||
|
@ -362,7 +378,7 @@ class Aux_Seats(Aux_Window):
|
||||||
self.m_windows[i].set_transient_for(self.hud.main_window)
|
self.m_windows[i].set_transient_for(self.hud.main_window)
|
||||||
self.m_windows[i].set_focus_on_map(False)
|
self.m_windows[i].set_focus_on_map(False)
|
||||||
self.m_windows[i].connect("configure_event", self.configure_event_cb, i)
|
self.m_windows[i].connect("configure_event", self.configure_event_cb, i)
|
||||||
self.positions[i] = (int(x) + self.hud.table.x, int(y) + self.hud.table.y)
|
self.positions[i] = self.card_positions(x, self.hud.table.x, y, self.hud.table.y)
|
||||||
self.m_windows[i].move(self.positions[i][0], self.positions[i][1])
|
self.m_windows[i].move(self.positions[i][0], self.positions[i][1])
|
||||||
if self.params.has_key('opacity'):
|
if self.params.has_key('opacity'):
|
||||||
self.m_windows[i].set_opacity(float(self.params['opacity']))
|
self.m_windows[i].set_opacity(float(self.params['opacity']))
|
||||||
|
@ -374,6 +390,13 @@ class Aux_Seats(Aux_Window):
|
||||||
if self.uses_timer:
|
if self.uses_timer:
|
||||||
self.m_windows[i].hide()
|
self.m_windows[i].hide()
|
||||||
|
|
||||||
|
|
||||||
|
def card_positions(self, x, table_x, y, table_y):
|
||||||
|
_x = int(x) + int(table_x)
|
||||||
|
_y = int(y) + int(table_y)
|
||||||
|
return (_x, _y)
|
||||||
|
|
||||||
|
|
||||||
def update_gui(self, new_hand_id):
|
def update_gui(self, new_hand_id):
|
||||||
"""Update the gui, LDO."""
|
"""Update the gui, LDO."""
|
||||||
for i in self.m_windows.keys():
|
for i in self.m_windows.keys():
|
||||||
|
|
|
@ -2,17 +2,17 @@
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
#
|
#
|
||||||
# Copyright 2009, Grigorij Indigirkin
|
# Copyright 2009, Grigorij Indigirkin
|
||||||
#
|
#
|
||||||
# This program is free software; you can redistribute it and/or modify
|
# This program is free software; you can redistribute it and/or modify
|
||||||
# it under the terms of the GNU General Public License as published by
|
# it under the terms of the GNU General Public License as published by
|
||||||
# the Free Software Foundation; either version 2 of the License, or
|
# the Free Software Foundation; either version 2 of the License, or
|
||||||
# (at your option) any later version.
|
# (at your option) any later version.
|
||||||
#
|
#
|
||||||
# This program is distributed in the hope that it will be useful,
|
# This program is distributed in the hope that it will be useful,
|
||||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
# GNU General Public License for more details.
|
# GNU General Public License for more details.
|
||||||
#
|
#
|
||||||
# You should have received a copy of the GNU General Public License
|
# You should have received a copy of the GNU General Public License
|
||||||
# along with this program; if not, write to the Free Software
|
# along with this program; if not, write to the Free Software
|
||||||
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
@ -21,25 +21,24 @@
|
||||||
import sys
|
import sys
|
||||||
from collections import defaultdict
|
from collections import defaultdict
|
||||||
|
|
||||||
|
from Exceptions import FpdbParseError
|
||||||
from HandHistoryConverter import *
|
from HandHistoryConverter import *
|
||||||
|
|
||||||
# PartyPoker HH Format
|
# PartyPoker HH Format
|
||||||
|
|
||||||
|
class PartyPokerParseError(FpdbParseError):
|
||||||
|
"Usage: raise PartyPokerParseError(<msg>[, hh=<hh>][, hid=<hid>])"
|
||||||
|
def __init__(self, msg='', hh=None, hid=None):
|
||||||
|
if hh is not None:
|
||||||
|
msg += "\n\nHand history attached below:\n" + self.wrapHh(hh)
|
||||||
|
return super(PartyPokerParseError, self).__init__(hid=hid)
|
||||||
|
#return super(PartyPokerParseError, self).__init__(msg, hid=hid)
|
||||||
|
def wrapHh(self, hh):
|
||||||
|
return ("%(DELIMETER)s\n%(HH)s\n%(DELIMETER)s") % \
|
||||||
|
{'DELIMETER': '#'*50, 'HH': hh}
|
||||||
|
|
||||||
class PartyPoker(HandHistoryConverter):
|
class PartyPoker(HandHistoryConverter):
|
||||||
class ParsingException(Exception):
|
|
||||||
"Usage: raise ParsingException(<msg>[, hh=<hh>])"
|
|
||||||
def __init__(self, *args, **kwargs):
|
|
||||||
if len(args)==0: args=[''] + list(args)
|
|
||||||
msg, args = args[0], args[1:]
|
|
||||||
if 'hh' in kwargs:
|
|
||||||
msg += self.wrapHh(kwargs['hh'])
|
|
||||||
del kwargs['hh']
|
|
||||||
return Exception.__init__(self, msg, *args, **kwargs)
|
|
||||||
def wrapHh(self, hh):
|
|
||||||
return ("\n\nHand history attached below:\n"
|
|
||||||
"%(DELIMETER)s\n%(HH)s\n%(DELIMETER)s") % \
|
|
||||||
{'DELIMETER': '#'*50, 'HH': hh}
|
|
||||||
|
|
||||||
############################################################
|
############################################################
|
||||||
# Class Variables
|
# Class Variables
|
||||||
|
|
||||||
|
@ -55,15 +54,15 @@ class PartyPoker(HandHistoryConverter):
|
||||||
# $5 USD NL Texas Hold'em - Saturday, July 25, 07:53:52 EDT 2009
|
# $5 USD NL Texas Hold'em - Saturday, July 25, 07:53:52 EDT 2009
|
||||||
# NL Texas Hold'em $1 USD Buy-in Trny:45685440 Level:8 Blinds-Antes(600/1 200 -50) - Sunday, May 17, 11:25:07 MSKS 2009
|
# NL Texas Hold'em $1 USD Buy-in Trny:45685440 Level:8 Blinds-Antes(600/1 200 -50) - Sunday, May 17, 11:25:07 MSKS 2009
|
||||||
re_GameInfoRing = re.compile("""
|
re_GameInfoRing = re.compile("""
|
||||||
(?P<CURRENCY>\$|)\s*(?P<RINGLIMIT>\d+)\s*(?:USD)?\s*
|
(?P<CURRENCY>\$|)\s*(?P<RINGLIMIT>[0-9,]+)\s*(?:USD)?\s*
|
||||||
(?P<LIMIT>(NL))\s+
|
(?P<LIMIT>(NL|PL|))\s+
|
||||||
(?P<GAME>(Texas\ Hold\'em))
|
(?P<GAME>(Texas\ Hold\'em|Omaha))
|
||||||
\s*\-\s*
|
\s*\-\s*
|
||||||
(?P<DATETIME>.+)
|
(?P<DATETIME>.+)
|
||||||
""", re.VERBOSE)
|
""", re.VERBOSE)
|
||||||
re_GameInfoTrny = re.compile("""
|
re_GameInfoTrny = re.compile("""
|
||||||
(?P<LIMIT>(NL))\s+
|
(?P<LIMIT>(NL|PL|))\s+
|
||||||
(?P<GAME>(Texas\ Hold\'em))\s+
|
(?P<GAME>(Texas\ Hold\'em|Omaha))\s+
|
||||||
(?P<BUYIN>\$?[.0-9]+)\s*(?P<BUYIN_CURRENCY>USD)?\s*Buy-in\s+
|
(?P<BUYIN>\$?[.0-9]+)\s*(?P<BUYIN_CURRENCY>USD)?\s*Buy-in\s+
|
||||||
Trny:\s?(?P<TOURNO>\d+)\s+
|
Trny:\s?(?P<TOURNO>\d+)\s+
|
||||||
Level:\s*(?P<LEVEL>\d+)\s+
|
Level:\s*(?P<LEVEL>\d+)\s+
|
||||||
|
@ -81,7 +80,7 @@ class PartyPoker(HandHistoryConverter):
|
||||||
Seat\s(?P<SEAT>\d+):\s
|
Seat\s(?P<SEAT>\d+):\s
|
||||||
(?P<PNAME>.*)\s
|
(?P<PNAME>.*)\s
|
||||||
\(\s*\$?(?P<CASH>[0-9,.]+)\s*(?:USD|)\s*\)
|
\(\s*\$?(?P<CASH>[0-9,.]+)\s*(?:USD|)\s*\)
|
||||||
""" ,
|
""" ,
|
||||||
re.VERBOSE)
|
re.VERBOSE)
|
||||||
|
|
||||||
re_HandInfo = re.compile("""
|
re_HandInfo = re.compile("""
|
||||||
|
@ -91,41 +90,61 @@ class PartyPoker(HandHistoryConverter):
|
||||||
(?:[^ ]+\s+\#(?P<MTTTABLE>\d+).+)? # table number for mtt
|
(?:[^ ]+\s+\#(?P<MTTTABLE>\d+).+)? # table number for mtt
|
||||||
\((?P<PLAY>Real|Play)\s+Money\)\s+ # FIXME: check if play money is correct
|
\((?P<PLAY>Real|Play)\s+Money\)\s+ # FIXME: check if play money is correct
|
||||||
Seat\s+(?P<BUTTON>\d+)\sis\sthe\sbutton
|
Seat\s+(?P<BUTTON>\d+)\sis\sthe\sbutton
|
||||||
""",
|
""",
|
||||||
re.MULTILINE|re.VERBOSE)
|
re.MULTILINE|re.VERBOSE)
|
||||||
|
|
||||||
|
re_TotalPlayers = re.compile("^Total\s+number\s+of\s+players\s*:\s*(?P<MAXSEATS>\d+)", re.MULTILINE)
|
||||||
re_SplitHands = re.compile('\x00+')
|
re_SplitHands = re.compile('\x00+')
|
||||||
re_TailSplitHands = re.compile('(\x00+)')
|
re_TailSplitHands = re.compile('(\x00+)')
|
||||||
lineSplitter = '\n'
|
lineSplitter = '\n'
|
||||||
re_Button = re.compile('Seat (?P<BUTTON>\d+) is the button', re.MULTILINE)
|
re_Button = re.compile('Seat (?P<BUTTON>\d+) is the button', re.MULTILINE)
|
||||||
re_Board = re.compile(r"\[(?P<CARDS>.+)\]")
|
re_Board = re.compile(r"\[(?P<CARDS>.+)\]")
|
||||||
re_NoSmallBlind = re.compile('^There is no Small Blind in this hand as the Big Blind of the previous hand left the table')
|
re_NoSmallBlind = re.compile(
|
||||||
|
'^There is no Small Blind in this hand as the Big Blind '
|
||||||
|
'of the previous hand left the table', re.MULTILINE)
|
||||||
|
|
||||||
|
|
||||||
def allHandsAsList(self):
|
def allHandsAsList(self):
|
||||||
list = HandHistoryConverter.allHandsAsList(self)
|
list = HandHistoryConverter.allHandsAsList(self)
|
||||||
|
if list is None:
|
||||||
|
return []
|
||||||
return filter(lambda text: len(text.strip()), list)
|
return filter(lambda text: len(text.strip()), list)
|
||||||
|
|
||||||
|
def guessMaxSeats(self, hand):
|
||||||
|
"""Return a guess at max_seats when not specified in HH."""
|
||||||
|
mo = self.maxOccSeat(hand)
|
||||||
|
|
||||||
|
if mo == 10: return mo
|
||||||
|
if mo == 2: return 2
|
||||||
|
if mo <= 6: return 6
|
||||||
|
# there are 9-max tables for cash and 10-max for tournaments
|
||||||
|
return 9 if hand.gametype['type']=='ring' else 10
|
||||||
|
|
||||||
def compilePlayerRegexs(self, hand):
|
def compilePlayerRegexs(self, hand):
|
||||||
players = set([player[1] for player in hand.players])
|
players = set([player[1] for player in hand.players])
|
||||||
if not players <= self.compiledPlayers: # x <= y means 'x is subset of y'
|
if not players <= self.compiledPlayers: # x <= y means 'x is subset of y'
|
||||||
|
|
||||||
self.compiledPlayers = players
|
self.compiledPlayers = players
|
||||||
player_re = "(?P<PNAME>" + "|".join(map(re.escape, players)) + ")"
|
player_re = "(?P<PNAME>" + "|".join(map(re.escape, players)) + ")"
|
||||||
subst = {'PLYR': player_re, 'CUR_SYM': hand.SYMBOL[hand.gametype['currency']],
|
subst = {'PLYR': player_re, 'CUR_SYM': hand.SYMBOL[hand.gametype['currency']],
|
||||||
'CUR': hand.gametype['currency'] if hand.gametype['currency']!='T$' else ''}
|
'CUR': hand.gametype['currency'] if hand.gametype['currency']!='T$' else ''}
|
||||||
for key in ('CUR_SYM', 'CUR'):
|
for key in ('CUR_SYM', 'CUR'):
|
||||||
subst[key] = re.escape(subst[key])
|
subst[key] = re.escape(subst[key])
|
||||||
log.debug("player_re: " + subst['PLYR'])
|
log.debug("player_re: '%s'" % subst['PLYR'])
|
||||||
log.debug("CUR_SYM: " + subst['CUR_SYM'])
|
log.debug("CUR_SYM: '%s'" % subst['CUR_SYM'])
|
||||||
log.debug("CUR: " + subst['CUR'])
|
log.debug("CUR: '%s'" % subst['CUR'])
|
||||||
self.re_PostSB = re.compile(
|
self.re_PostSB = re.compile(
|
||||||
r"^%(PLYR)s posts small blind \[%(CUR_SYM)s(?P<SB>[.0-9]+) ?%(CUR)s\]\." % subst,
|
r"^%(PLYR)s posts small blind \[%(CUR_SYM)s(?P<SB>[.0-9]+) ?%(CUR)s\]\." % subst,
|
||||||
re.MULTILINE)
|
re.MULTILINE)
|
||||||
self.re_PostBB = re.compile(
|
self.re_PostBB = re.compile(
|
||||||
r"^%(PLYR)s posts big blind \[%(CUR_SYM)s(?P<BB>[.0-9]+) ?%(CUR)s\]\." % subst,
|
r"^%(PLYR)s posts big blind \[%(CUR_SYM)s(?P<BB>[.0-9]+) ?%(CUR)s\]\." % subst,
|
||||||
|
re.MULTILINE)
|
||||||
|
# NOTE: comma is used as a fraction part delimeter in re below
|
||||||
|
self.re_PostDead = re.compile(
|
||||||
|
r"^%(PLYR)s posts big blind \+ dead \[(?P<BBNDEAD>[.,0-9]+) ?%(CUR_SYM)s\]\." % subst,
|
||||||
re.MULTILINE)
|
re.MULTILINE)
|
||||||
self.re_Antes = re.compile(
|
self.re_Antes = re.compile(
|
||||||
r"^%(PLYR)s posts ante \[%(CUR_SYM)s(?P<ANTE>[.0-9]+) ?%(CUR)s\]\." % subst,
|
r"^%(PLYR)s posts ante \[%(CUR_SYM)s(?P<ANTE>[.0-9]+) ?%(CUR)s\]" % subst,
|
||||||
re.MULTILINE)
|
re.MULTILINE)
|
||||||
self.re_HeroCards = re.compile(
|
self.re_HeroCards = re.compile(
|
||||||
r"^Dealt to %(PLYR)s \[\s*(?P<NEWCARDS>.+)\s*\]" % subst,
|
r"^Dealt to %(PLYR)s \[\s*(?P<NEWCARDS>.+)\s*\]" % subst,
|
||||||
|
@ -133,28 +152,30 @@ class PartyPoker(HandHistoryConverter):
|
||||||
self.re_Action = re.compile(r"""
|
self.re_Action = re.compile(r"""
|
||||||
^%(PLYR)s\s+(?P<ATYPE>bets|checks|raises|calls|folds|is\sall-In)
|
^%(PLYR)s\s+(?P<ATYPE>bets|checks|raises|calls|folds|is\sall-In)
|
||||||
(?:\s+\[%(CUR_SYM)s(?P<BET>[.,\d]+)\s*%(CUR)s\])?
|
(?:\s+\[%(CUR_SYM)s(?P<BET>[.,\d]+)\s*%(CUR)s\])?
|
||||||
""" % subst,
|
""" % subst,
|
||||||
re.MULTILINE|re.VERBOSE)
|
re.MULTILINE|re.VERBOSE)
|
||||||
self.re_ShownCards = re.compile(
|
self.re_ShownCards = re.compile(
|
||||||
r"^%s (?P<SHOWED>(?:doesn\'t )?shows?) " % player_re +
|
r"^%s (?P<SHOWED>(?:doesn\'t )?shows?) " % player_re +
|
||||||
r"\[ *(?P<CARDS>.+) *\](?P<COMBINATION>.+)\.",
|
r"\[ *(?P<CARDS>.+) *\](?P<COMBINATION>.+)\.",
|
||||||
re.MULTILINE)
|
re.MULTILINE)
|
||||||
self.re_CollectPot = re.compile(
|
self.re_CollectPot = re.compile(
|
||||||
r""""^%(PLYR)s \s+ wins \s+
|
r"""^%(PLYR)s \s+ wins \s+
|
||||||
%(CUR_SYM)s(?P<POT>[.\d]+)\s*%(CUR)s""" % subst,
|
%(CUR_SYM)s(?P<POT>[.,\d]+)\s*%(CUR)s""" % subst,
|
||||||
re.MULTILINE|re.VERBOSE)
|
re.MULTILINE|re.VERBOSE)
|
||||||
|
|
||||||
def readSupportedGames(self):
|
def readSupportedGames(self):
|
||||||
return [["ring", "hold", "nl"],
|
return [["ring", "hold", "nl"],
|
||||||
#["ring", "hold", "pl"],
|
["ring", "hold", "pl"],
|
||||||
#["ring", "hold", "fl"],
|
["ring", "hold", "fl"],
|
||||||
|
|
||||||
["tour", "hold", "nl"],
|
["tour", "hold", "nl"],
|
||||||
#["tour", "hold", "pl"],
|
["tour", "hold", "pl"],
|
||||||
#["tour", "hold", "fl"],
|
["tour", "hold", "fl"],
|
||||||
]
|
]
|
||||||
|
|
||||||
def _getGameType(self, handText):
|
def _getGameType(self, handText):
|
||||||
|
if not hasattr(self, '_gameType'):
|
||||||
|
self._gameType = None
|
||||||
if self._gameType is None:
|
if self._gameType is None:
|
||||||
# let's determine whether hand is trny
|
# let's determine whether hand is trny
|
||||||
# and whether 5-th line contains head line
|
# and whether 5-th line contains head line
|
||||||
|
@ -166,47 +187,45 @@ class PartyPoker(HandHistoryConverter):
|
||||||
self._gameType = m
|
self._gameType = m
|
||||||
return self._gameType
|
return self._gameType
|
||||||
return self._gameType
|
return self._gameType
|
||||||
|
|
||||||
def determineGameType(self, handText):
|
def determineGameType(self, handText):
|
||||||
"""inspect the handText and return the gametype dict
|
"""inspect the handText and return the gametype dict
|
||||||
|
|
||||||
gametype dict is:
|
gametype dict is:
|
||||||
{'limitType': xxx, 'base': xxx, 'category': xxx}"""
|
{'limitType': xxx, 'base': xxx, 'category': xxx}"""
|
||||||
|
|
||||||
log.debug(self.ParsingException().wrapHh( handText ))
|
log.debug(PartyPokerParseError().wrapHh( handText ))
|
||||||
|
|
||||||
info = {}
|
info = {}
|
||||||
m = self._getGameType(handText)
|
m = self._getGameType(handText)
|
||||||
if m is None:
|
if m is None:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
mg = m.groupdict()
|
mg = m.groupdict()
|
||||||
# translations from captured groups to fpdb info strings
|
# translations from captured groups to fpdb info strings
|
||||||
limits = { 'NL':'nl',
|
limits = { 'NL':'nl', 'PL':'pl', '':'fl' }
|
||||||
# 'Pot Limit':'pl', 'Limit':'fl'
|
|
||||||
}
|
|
||||||
games = { # base, category
|
games = { # base, category
|
||||||
"Texas Hold'em" : ('hold','holdem'),
|
"Texas Hold'em" : ('hold','holdem'),
|
||||||
#'Omaha' : ('hold','omahahi'),
|
'Omaha' : ('hold','omahahi'),
|
||||||
}
|
}
|
||||||
currencies = { '$':'USD', '':'T$' }
|
currencies = { '$':'USD', '':'T$' }
|
||||||
|
|
||||||
for expectedField in ['LIMIT', 'GAME']:
|
for expectedField in ['LIMIT', 'GAME']:
|
||||||
if mg[expectedField] is None:
|
if mg[expectedField] is None:
|
||||||
raise self.ParsingException(
|
raise PartyPokerParseError(
|
||||||
"Cannot fetch field '%s'" % expectedField,
|
"Cannot fetch field '%s'" % expectedField,
|
||||||
hh = handText)
|
hh = handText)
|
||||||
try:
|
try:
|
||||||
info['limitType'] = limits[mg['LIMIT']]
|
info['limitType'] = limits[mg['LIMIT'].strip()]
|
||||||
except:
|
except:
|
||||||
raise self.ParsingException(
|
raise PartyPokerParseError(
|
||||||
"Unknown limit '%s'" % mg['LIMIT'],
|
"Unknown limit '%s'" % mg['LIMIT'],
|
||||||
hh = handText)
|
hh = handText)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
(info['base'], info['category']) = games[mg['GAME']]
|
(info['base'], info['category']) = games[mg['GAME']]
|
||||||
except:
|
except:
|
||||||
raise self.ParsingException(
|
raise PartyPokerParseError(
|
||||||
"Unknown game type '%s'" % mg['GAME'],
|
"Unknown game type '%s'" % mg['GAME'],
|
||||||
hh = handText)
|
hh = handText)
|
||||||
|
|
||||||
|
@ -215,36 +234,64 @@ class PartyPoker(HandHistoryConverter):
|
||||||
info['type'] = 'tour'
|
info['type'] = 'tour'
|
||||||
else:
|
else:
|
||||||
info['type'] = 'ring'
|
info['type'] = 'ring'
|
||||||
|
|
||||||
if info['type'] == 'ring':
|
if info['type'] == 'ring':
|
||||||
info['sb'], info['bb'] = ringBlinds(mg['RINGLIMIT'])
|
info['sb'], info['bb'] = ringBlinds(mg['RINGLIMIT'])
|
||||||
# FIXME: there are only $ and play money availible for cash
|
# FIXME: there are only $ and play money availible for cash
|
||||||
|
# to be honest, party doesn't save play money hh
|
||||||
info['currency'] = currencies[mg['CURRENCY']]
|
info['currency'] = currencies[mg['CURRENCY']]
|
||||||
else:
|
else:
|
||||||
info['sb'] = renderTrnyMoney(mg['SB'])
|
info['sb'] = clearMoneyString(mg['SB'])
|
||||||
info['bb'] = renderTrnyMoney(mg['BB'])
|
info['bb'] = clearMoneyString(mg['BB'])
|
||||||
info['currency'] = 'T$'
|
info['currency'] = 'T$'
|
||||||
|
|
||||||
# NB: SB, BB must be interpreted as blinds or bets depending on limit type.
|
# NB: SB, BB must be interpreted as blinds or bets depending on limit type.
|
||||||
return info
|
return info
|
||||||
|
|
||||||
|
|
||||||
def readHandInfo(self, hand):
|
def readHandInfo(self, hand):
|
||||||
info = {}
|
info = {}
|
||||||
m = self.re_HandInfo.search(hand.handText,re.DOTALL)
|
try:
|
||||||
if m:
|
info.update(self.re_Hid.search(hand.handText).groupdict())
|
||||||
info.update(m.groupdict())
|
except:
|
||||||
else:
|
raise PartyPokerParseError("Cannot read HID for current hand", hh=hand.handText)
|
||||||
raise self.ParsingException("Cannot read Handinfo for current hand", hh=hand.handText)
|
|
||||||
m = self._getGameType(hand.handText)
|
try:
|
||||||
if m: info.update(m.groupdict())
|
info.update(self.re_HandInfo.search(hand.handText,re.DOTALL).groupdict())
|
||||||
m = self.re_Hid.search(hand.handText)
|
except:
|
||||||
|
raise PartyPokerParseError("Cannot read Handinfo for current hand",
|
||||||
|
hh=hand.handText, hid = info['HID'])
|
||||||
|
|
||||||
|
try:
|
||||||
|
info.update(self._getGameType(hand.handText).groupdict())
|
||||||
|
except:
|
||||||
|
raise PartyPokerParseError("Cannot read GameType for current hand",
|
||||||
|
hh=hand.handText, hid = info['HID'])
|
||||||
|
|
||||||
|
|
||||||
|
m = self.re_TotalPlayers.search(hand.handText)
|
||||||
if m: info.update(m.groupdict())
|
if m: info.update(m.groupdict())
|
||||||
|
|
||||||
# FIXME: it's a hack cause party doesn't supply hand.maxseats info
|
|
||||||
#hand.maxseats = ???
|
# FIXME: it's dirty hack
|
||||||
hand.mixed = None
|
# party doesnt subtract uncalled money from commited money
|
||||||
|
# so hand.totalPot calculation has to be redefined
|
||||||
|
from Hand import Pot, HoldemOmahaHand
|
||||||
|
def getNewTotalPot(origTotalPot):
|
||||||
|
def totalPot(self):
|
||||||
|
if self.totalpot is None:
|
||||||
|
self.pot.end()
|
||||||
|
self.totalpot = self.pot.total
|
||||||
|
for i,v in enumerate(self.collected):
|
||||||
|
if v[0] in self.pot.returned:
|
||||||
|
self.collected[i][1] = Decimal(v[1]) - self.pot.returned[v[0]]
|
||||||
|
return origTotalPot()
|
||||||
|
return totalPot
|
||||||
|
instancemethod = type(hand.totalPot)
|
||||||
|
hand.totalPot = instancemethod(getNewTotalPot(hand.totalPot), hand, HoldemOmahaHand)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
log.debug("readHandInfo: %s" % info)
|
log.debug("readHandInfo: %s" % info)
|
||||||
for key in info:
|
for key in info:
|
||||||
if key == 'DATETIME':
|
if key == 'DATETIME':
|
||||||
|
@ -260,7 +307,7 @@ class PartyPoker(HandHistoryConverter):
|
||||||
# FIXME: some timezone correction required
|
# FIXME: some timezone correction required
|
||||||
#tzShift = defaultdict(lambda:0, {'EDT': -5, 'EST': -6, 'MSKS': 3})
|
#tzShift = defaultdict(lambda:0, {'EDT': -5, 'EST': -6, 'MSKS': 3})
|
||||||
#hand.starttime -= datetime.timedelta(hours=tzShift[m2.group('TZ')])
|
#hand.starttime -= datetime.timedelta(hours=tzShift[m2.group('TZ')])
|
||||||
|
|
||||||
if key == 'HID':
|
if key == 'HID':
|
||||||
hand.handid = info[key]
|
hand.handid = info[key]
|
||||||
if key == 'TABLE':
|
if key == 'TABLE':
|
||||||
|
@ -270,14 +317,14 @@ class PartyPoker(HandHistoryConverter):
|
||||||
if key == 'TOURNO':
|
if key == 'TOURNO':
|
||||||
hand.tourNo = info[key]
|
hand.tourNo = info[key]
|
||||||
if key == 'BUYIN':
|
if key == 'BUYIN':
|
||||||
#FIXME: it's dirty hack T_T
|
# FIXME: it's dirty hack T_T
|
||||||
|
# code below assumes that rake is equal to zero
|
||||||
cur = info[key][0] if info[key][0] not in '0123456789' else ''
|
cur = info[key][0] if info[key][0] not in '0123456789' else ''
|
||||||
hand.buyin = info[key] + '+%s0' % cur
|
hand.buyin = info[key] + '+%s0' % cur
|
||||||
if key == 'LEVEL':
|
if key == 'LEVEL':
|
||||||
hand.level = info[key]
|
hand.level = info[key]
|
||||||
if key == 'PLAY' and info['PLAY'] != 'Real':
|
if key == 'PLAY' and info['PLAY'] != 'Real':
|
||||||
# TODO: play money wasn't tested
|
# if realy there's no play money hh on party
|
||||||
# hand.currency = 'play' # overrides previously set value
|
|
||||||
hand.gametype['currency'] = 'play'
|
hand.gametype['currency'] = 'play'
|
||||||
|
|
||||||
def readButton(self, hand):
|
def readButton(self, hand):
|
||||||
|
@ -293,13 +340,9 @@ class PartyPoker(HandHistoryConverter):
|
||||||
players = []
|
players = []
|
||||||
for a in m:
|
for a in m:
|
||||||
hand.addPlayer(int(a.group('SEAT')), a.group('PNAME'),
|
hand.addPlayer(int(a.group('SEAT')), a.group('PNAME'),
|
||||||
renderTrnyMoney(a.group('CASH')))
|
clearMoneyString(a.group('CASH')))
|
||||||
|
|
||||||
def markStreets(self, hand):
|
def markStreets(self, hand):
|
||||||
# PREFLOP = ** Dealing down cards **
|
|
||||||
# This re fails if, say, river is missing; then we don't get the ** that starts the river.
|
|
||||||
assert hand.gametype['base'] == "hold", \
|
|
||||||
"wtf! There're no %s games on party" % hand.gametype['base']
|
|
||||||
m = re.search(
|
m = re.search(
|
||||||
r"\*{2} Dealing down cards \*{2}"
|
r"\*{2} Dealing down cards \*{2}"
|
||||||
r"(?P<PREFLOP>.+?)"
|
r"(?P<PREFLOP>.+?)"
|
||||||
|
@ -309,8 +352,8 @@ class PartyPoker(HandHistoryConverter):
|
||||||
, hand.handText,re.DOTALL)
|
, hand.handText,re.DOTALL)
|
||||||
hand.addStreets(m)
|
hand.addStreets(m)
|
||||||
|
|
||||||
def readCommunityCards(self, hand, street):
|
def readCommunityCards(self, hand, street):
|
||||||
if street in ('FLOP','TURN','RIVER'):
|
if street in ('FLOP','TURN','RIVER'):
|
||||||
m = self.re_Board.search(hand.streets[street])
|
m = self.re_Board.search(hand.streets[street])
|
||||||
hand.setCommunityCards(street, renderCards(m.group('CARDS')))
|
hand.setCommunityCards(street, renderCards(m.group('CARDS')))
|
||||||
|
|
||||||
|
@ -319,12 +362,7 @@ class PartyPoker(HandHistoryConverter):
|
||||||
m = self.re_Antes.finditer(hand.handText)
|
m = self.re_Antes.finditer(hand.handText)
|
||||||
for player in m:
|
for player in m:
|
||||||
hand.addAnte(player.group('PNAME'), player.group('ANTE'))
|
hand.addAnte(player.group('PNAME'), player.group('ANTE'))
|
||||||
|
|
||||||
def readBringIn(self, hand):
|
|
||||||
m = self.re_BringIn.search(hand.handText,re.DOTALL)
|
|
||||||
if m:
|
|
||||||
hand.addBringIn(m.group('PNAME'), m.group('BRINGIN'))
|
|
||||||
|
|
||||||
def readBlinds(self, hand):
|
def readBlinds(self, hand):
|
||||||
noSmallBlind = bool(self.re_NoSmallBlind.search(hand.handText))
|
noSmallBlind = bool(self.re_NoSmallBlind.search(hand.handText))
|
||||||
if hand.gametype['type'] == 'ring':
|
if hand.gametype['type'] == 'ring':
|
||||||
|
@ -334,39 +372,44 @@ class PartyPoker(HandHistoryConverter):
|
||||||
hand.addBlind(m.group('PNAME'), 'small blind', m.group('SB'))
|
hand.addBlind(m.group('PNAME'), 'small blind', m.group('SB'))
|
||||||
except: # no small blind
|
except: # no small blind
|
||||||
hand.addBlind(None, None, None)
|
hand.addBlind(None, None, None)
|
||||||
|
|
||||||
for a in self.re_PostBB.finditer(hand.handText):
|
for a in self.re_PostBB.finditer(hand.handText):
|
||||||
hand.addBlind(a.group('PNAME'), 'big blind', a.group('BB'))
|
hand.addBlind(a.group('PNAME'), 'big blind', a.group('BB'))
|
||||||
else:
|
|
||||||
|
deadFilter = lambda s: s.replace(',', '.')
|
||||||
|
for a in self.re_PostDead.finditer(hand.handText):
|
||||||
|
hand.addBlind(a.group('PNAME'), 'both', deadFilter(a.group('BBNDEAD')))
|
||||||
|
else:
|
||||||
# party doesn't track blinds for tournaments
|
# party doesn't track blinds for tournaments
|
||||||
# so there're some cra^Wcaclulations
|
# so there're some cra^Wcaclulations
|
||||||
if hand.buttonpos == 0:
|
if hand.buttonpos == 0:
|
||||||
self.readButton(hand)
|
self.readButton(hand)
|
||||||
# NOTE: code below depends on Hand's implementation
|
# NOTE: code below depends on Hand's implementation
|
||||||
# playersMap - dict {seat: (pname,stack)}
|
# playersMap - dict {seat: (pname,stack)}
|
||||||
playersMap = dict([(f[0], f[1:3]) for f in hand.players])
|
playersMap = dict([(f[0], f[1:3]) for f in hand.players])
|
||||||
maxSeat = max(playersMap)
|
maxSeat = max(playersMap)
|
||||||
|
|
||||||
def findFirstNonEmptySeat(startSeat):
|
def findFirstNonEmptySeat(startSeat):
|
||||||
while startSeat not in playersMap:
|
while startSeat not in playersMap:
|
||||||
if startSeat >= maxSeat:
|
if startSeat >= maxSeat:
|
||||||
startSeat = 0
|
startSeat = 0
|
||||||
startSeat += 1
|
startSeat += 1
|
||||||
return startSeat
|
return startSeat
|
||||||
smartMin = lambda A,B: A if float(A) <= float(B) else B
|
smartMin = lambda A,B: A if float(A) <= float(B) else B
|
||||||
|
|
||||||
if noSmallBlind:
|
if noSmallBlind:
|
||||||
hand.addBlind(None, None, None)
|
hand.addBlind(None, None, None)
|
||||||
|
smallBlindSeat = int(hand.buttonpos)
|
||||||
else:
|
else:
|
||||||
smallBlindSeat = findFirstNonEmptySeat(int(hand.buttonpos) + 1)
|
smallBlindSeat = findFirstNonEmptySeat(int(hand.buttonpos) + 1)
|
||||||
blind = smartMin(hand.sb, playersMap[smallBlindSeat][1])
|
blind = smartMin(hand.sb, playersMap[smallBlindSeat][1])
|
||||||
hand.addBlind(playersMap[smallBlindSeat][0], 'small blind', blind)
|
hand.addBlind(playersMap[smallBlindSeat][0], 'small blind', blind)
|
||||||
|
|
||||||
bigBlindSeat = findFirstNonEmptySeat(smallBlindSeat + 1)
|
bigBlindSeat = findFirstNonEmptySeat(smallBlindSeat + 1)
|
||||||
blind = smartMin(hand.bb, playersMap[bigBlindSeat][1])
|
blind = smartMin(hand.bb, playersMap[bigBlindSeat][1])
|
||||||
hand.addBlind(playersMap[bigBlindSeat][0], 'small blind', blind)
|
hand.addBlind(playersMap[bigBlindSeat][0], 'big blind', blind)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def readHeroCards(self, hand):
|
def readHeroCards(self, hand):
|
||||||
# we need to grab hero's cards
|
# we need to grab hero's cards
|
||||||
|
@ -383,18 +426,39 @@ class PartyPoker(HandHistoryConverter):
|
||||||
m = self.re_Action.finditer(hand.streets[street])
|
m = self.re_Action.finditer(hand.streets[street])
|
||||||
for action in m:
|
for action in m:
|
||||||
acts = action.groupdict()
|
acts = action.groupdict()
|
||||||
if action.group('ATYPE') in ('raises','is all-In'):
|
playerName = action.group('PNAME')
|
||||||
hand.addRaiseBy( street, action.group('PNAME'), action.group('BET') )
|
amount = clearMoneyString(action.group('BET')) if action.group('BET') else None
|
||||||
elif action.group('ATYPE') == 'calls':
|
actionType = action.group('ATYPE')
|
||||||
hand.addCall( street, action.group('PNAME'), action.group('BET') )
|
|
||||||
elif action.group('ATYPE') == 'bets':
|
if actionType == 'is all-In':
|
||||||
hand.addBet( street, action.group('PNAME'), action.group('BET') )
|
# party's allin can mean either raise or bet or call
|
||||||
elif action.group('ATYPE') == 'folds':
|
Bp = hand.lastBet[street]
|
||||||
hand.addFold( street, action.group('PNAME'))
|
if Bp == 0:
|
||||||
elif action.group('ATYPE') == 'checks':
|
actionType = 'bets'
|
||||||
hand.addCheck( street, action.group('PNAME'))
|
elif Bp < Decimal(amount):
|
||||||
|
actionType = 'raises'
|
||||||
|
else:
|
||||||
|
actionType = 'calls'
|
||||||
|
|
||||||
|
if actionType == 'raises':
|
||||||
|
if street == 'PREFLOP' and \
|
||||||
|
playerName in [item[0] for item in hand.actions['BLINDSANTES'] if item[2]!='ante']:
|
||||||
|
# preflop raise from blind
|
||||||
|
hand.addRaiseBy( street, playerName, amount )
|
||||||
|
else:
|
||||||
|
hand.addCallandRaise( street, playerName, amount )
|
||||||
|
elif actionType == 'calls':
|
||||||
|
hand.addCall( street, playerName, amount )
|
||||||
|
elif actionType == 'bets':
|
||||||
|
hand.addBet( street, playerName, amount )
|
||||||
|
elif actionType == 'folds':
|
||||||
|
hand.addFold( street, playerName )
|
||||||
|
elif actionType == 'checks':
|
||||||
|
hand.addCheck( street, playerName )
|
||||||
else:
|
else:
|
||||||
print "DEBUG: unimplemented readAction: '%s' '%s'" %(action.group('PNAME'),action.group('ATYPE'),)
|
raise PartyPokerParseError(
|
||||||
|
"Unimplemented readAction: '%s' '%s'" % (playerName,actionType,),
|
||||||
|
hid = hand.hid, hh = hand.handText )
|
||||||
|
|
||||||
|
|
||||||
def readShowdownActions(self, hand):
|
def readShowdownActions(self, hand):
|
||||||
|
@ -403,7 +467,7 @@ class PartyPoker(HandHistoryConverter):
|
||||||
|
|
||||||
def readCollectPot(self,hand):
|
def readCollectPot(self,hand):
|
||||||
for m in self.re_CollectPot.finditer(hand.handText):
|
for m in self.re_CollectPot.finditer(hand.handText):
|
||||||
hand.addCollectPot(player=m.group('PNAME'),pot=m.group('POT'))
|
hand.addCollectPot(player=m.group('PNAME'),pot=clearMoneyString(m.group('POT')))
|
||||||
|
|
||||||
def readShownCards(self,hand):
|
def readShownCards(self,hand):
|
||||||
for m in self.re_ShownCards.finditer(hand.handText):
|
for m in self.re_ShownCards.finditer(hand.handText):
|
||||||
|
@ -415,22 +479,22 @@ class PartyPoker(HandHistoryConverter):
|
||||||
else: mucked = True
|
else: mucked = True
|
||||||
|
|
||||||
hand.addShownCards(cards=cards, player=m.group('PNAME'), shown=shown, mucked=mucked)
|
hand.addShownCards(cards=cards, player=m.group('PNAME'), shown=shown, mucked=mucked)
|
||||||
|
|
||||||
def ringBlinds(ringLimit):
|
def ringBlinds(ringLimit):
|
||||||
"Returns blinds for current limit"
|
"Returns blinds for current limit in cash games"
|
||||||
ringLimit = float(ringLimit)
|
ringLimit = float(clearMoneyString(ringLimit))
|
||||||
if ringLimit == 5.: ringLimit = 4.
|
if ringLimit == 5.: ringLimit = 4.
|
||||||
return ('%.2f' % (ringLimit/200.), '%.2f' % (ringLimit/100.) )
|
return ('%.2f' % (ringLimit/200.), '%.2f' % (ringLimit/100.) )
|
||||||
|
|
||||||
def renderTrnyMoney(money):
|
def clearMoneyString(money):
|
||||||
"renders 'numbers' like '1 200' and '2,000'"
|
"Renders 'numbers' like '1 200' and '2,000'"
|
||||||
return money.replace(' ', '').replace(',', '')
|
return money.replace(' ', '').replace(',', '')
|
||||||
|
|
||||||
def renderCards(string):
|
def renderCards(string):
|
||||||
"splits strings like ' Js, 4d '"
|
"Splits strings like ' Js, 4d '"
|
||||||
cards = string.strip().split(' ')
|
cards = string.strip().split(' ')
|
||||||
return filter(len, map(lambda x: x.strip(' ,'), cards))
|
return filter(len, map(lambda x: x.strip(' ,'), cards))
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
parser = OptionParser()
|
parser = OptionParser()
|
||||||
|
|
|
@ -37,7 +37,7 @@ class PokerStars(HandHistoryConverter):
|
||||||
mixes = { 'HORSE': 'horse', '8-Game': '8game', 'HOSE': 'hose'} # Legal mixed games
|
mixes = { 'HORSE': 'horse', '8-Game': '8game', 'HOSE': 'hose'} # Legal mixed games
|
||||||
sym = {'USD': "\$", 'CAD': "\$", 'T$': "", "EUR": "\x80", "GBP": "\xa3"} # ADD Euro, Sterling, etc HERE
|
sym = {'USD': "\$", 'CAD': "\$", 'T$': "", "EUR": "\x80", "GBP": "\xa3"} # ADD Euro, Sterling, etc HERE
|
||||||
substitutions = {
|
substitutions = {
|
||||||
'LEGAL_ISO' : "USD|EUR|GBP|CAD", # legal ISO currency codes
|
'LEGAL_ISO' : "USD|EUR|GBP|CAD|FPP", # legal ISO currency codes
|
||||||
'LS' : "\$|\x80|\xa3" # legal currency symbols ADD Euro, Sterling, etc HERE
|
'LS' : "\$|\x80|\xa3" # legal currency symbols ADD Euro, Sterling, etc HERE
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
5685
pyfpdb/SQL.py
5685
pyfpdb/SQL.py
File diff suppressed because it is too large
Load Diff
|
@ -39,6 +39,7 @@ if os.name == 'nt':
|
||||||
|
|
||||||
# FreePokerTools modules
|
# FreePokerTools modules
|
||||||
import Configuration
|
import Configuration
|
||||||
|
from fpdb_simple import LOCALE_ENCODING
|
||||||
|
|
||||||
# Each TableWindow object must have the following attributes correctly populated:
|
# Each TableWindow object must have the following attributes correctly populated:
|
||||||
# tw.name = the table name from the title bar, which must to match the table name
|
# tw.name = the table name from the title bar, which must to match the table name
|
||||||
|
@ -230,11 +231,13 @@ def discover_nt_by_name(c, tablename):
|
||||||
"""Finds poker client window with the given table name."""
|
"""Finds poker client window with the given table name."""
|
||||||
titles = {}
|
titles = {}
|
||||||
win32gui.EnumWindows(win_enum_handler, titles)
|
win32gui.EnumWindows(win_enum_handler, titles)
|
||||||
|
|
||||||
for hwnd in titles:
|
for hwnd in titles:
|
||||||
#print "Tables.py: tablename =", tablename, "title =", titles[hwnd]
|
#print "Tables.py: tablename =", tablename, "title =", titles[hwnd]
|
||||||
try:
|
try:
|
||||||
|
# maybe it's better to make global titles[hwnd] decoding?
|
||||||
# this can blow up in XP on some windows, eg firefox displaying http://docs.python.org/tutorial/classes.html
|
# this can blow up in XP on some windows, eg firefox displaying http://docs.python.org/tutorial/classes.html
|
||||||
if not tablename.lower() in titles[hwnd].lower(): continue
|
if not tablename.lower() in titles[hwnd].decode(LOCALE_ENCODING).lower(): continue
|
||||||
except:
|
except:
|
||||||
continue
|
continue
|
||||||
if 'History for table:' in titles[hwnd]: continue # Everleaf Network HH viewer window
|
if 'History for table:' in titles[hwnd]: continue # Everleaf Network HH viewer window
|
||||||
|
|
|
@ -244,30 +244,27 @@ class fpdb:
|
||||||
if self.obtain_global_lock(): # returns true if successful
|
if self.obtain_global_lock(): # returns true if successful
|
||||||
|
|
||||||
#lock_released = False
|
#lock_released = False
|
||||||
try:
|
dia_confirm = gtk.MessageDialog(parent=None, flags=0, type=gtk.MESSAGE_WARNING,
|
||||||
dia_confirm = gtk.MessageDialog(parent=None, flags=0, type=gtk.MESSAGE_WARNING,
|
buttons=(gtk.BUTTONS_YES_NO), message_format="Confirm deleting and recreating tables")
|
||||||
buttons=(gtk.BUTTONS_YES_NO), message_format="Confirm deleting and recreating tables")
|
diastring = "Please confirm that you want to (re-)create the tables. If there already are tables in the database " \
|
||||||
diastring = "Please confirm that you want to (re-)create the tables. If there already are tables in the database " \
|
+self.db.fdb.database+" on "+self.db.fdb.host+" they will be deleted."
|
||||||
+self.db.fdb.database+" on "+self.db.fdb.host+" they will be deleted."
|
dia_confirm.format_secondary_text(diastring)#todo: make above string with bold for db, host and deleted
|
||||||
dia_confirm.format_secondary_text(diastring)#todo: make above string with bold for db, host and deleted
|
|
||||||
|
|
||||||
response = dia_confirm.run()
|
response = dia_confirm.run()
|
||||||
dia_confirm.destroy()
|
dia_confirm.destroy()
|
||||||
if response == gtk.RESPONSE_YES:
|
if response == gtk.RESPONSE_YES:
|
||||||
#if self.db.fdb.backend == self.fdb_lock.fdb.MYSQL_INNODB:
|
#if self.db.fdb.backend == self.fdb_lock.fdb.MYSQL_INNODB:
|
||||||
# mysql requires locks on all tables or none - easier to release this lock
|
# mysql requires locks on all tables or none - easier to release this lock
|
||||||
# than lock all the other tables
|
# than lock all the other tables
|
||||||
# ToDo: lock all other tables so that lock doesn't have to be released
|
# ToDo: lock all other tables so that lock doesn't have to be released
|
||||||
# self.release_global_lock()
|
# self.release_global_lock()
|
||||||
# lock_released = True
|
# lock_released = True
|
||||||
self.db.recreate_tables()
|
self.db.recreate_tables()
|
||||||
#else:
|
#else:
|
||||||
# for other dbs use same connection as holds global lock
|
# for other dbs use same connection as holds global lock
|
||||||
# self.fdb_lock.fdb.recreate_tables()
|
# self.fdb_lock.fdb.recreate_tables()
|
||||||
elif response == gtk.RESPONSE_NO:
|
elif response == gtk.RESPONSE_NO:
|
||||||
print 'User cancelled recreating tables'
|
print 'User cancelled recreating tables'
|
||||||
except:
|
|
||||||
pass
|
|
||||||
#if not lock_released:
|
#if not lock_released:
|
||||||
self.release_global_lock()
|
self.release_global_lock()
|
||||||
#end def dia_recreate_tables
|
#end def dia_recreate_tables
|
||||||
|
|
|
@ -384,8 +384,9 @@ class Importer:
|
||||||
conv = None
|
conv = None
|
||||||
(stored, duplicates, partial, errors, ttime) = (0, 0, 0, 0, 0)
|
(stored, duplicates, partial, errors, ttime) = (0, 0, 0, 0, 0)
|
||||||
|
|
||||||
|
file = file.decode(fpdb_simple.LOCALE_ENCODING)
|
||||||
|
|
||||||
# Load filter, process file, pass returned filename to import_fpdb_file
|
# Load filter, process file, pass returned filename to import_fpdb_file
|
||||||
|
|
||||||
if self.settings['threads'] > 0 and self.writeq != None:
|
if self.settings['threads'] > 0 and self.writeq != None:
|
||||||
log.info("Converting " + file + " (" + str(q.qsize()) + ")")
|
log.info("Converting " + file + " (" + str(q.qsize()) + ")")
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -26,6 +26,8 @@ import time
|
||||||
import re
|
import re
|
||||||
import sys
|
import sys
|
||||||
from Exceptions import *
|
from Exceptions import *
|
||||||
|
import locale
|
||||||
|
|
||||||
import Card
|
import Card
|
||||||
|
|
||||||
PS = 1
|
PS = 1
|
||||||
|
@ -37,6 +39,8 @@ MYSQL_INNODB = 2
|
||||||
PGSQL = 3
|
PGSQL = 3
|
||||||
SQLITE = 4
|
SQLITE = 4
|
||||||
|
|
||||||
|
LOCALE_ENCODING = locale.getdefaultlocale()[1]
|
||||||
|
|
||||||
#returns an array of the total money paid. intending to add rebuys/addons here
|
#returns an array of the total money paid. intending to add rebuys/addons here
|
||||||
def calcPayin(count, buyin, fee):
|
def calcPayin(count, buyin, fee):
|
||||||
return [buyin + fee for i in xrange(count)]
|
return [buyin + fee for i in xrange(count)]
|
||||||
|
@ -531,7 +535,7 @@ def parseActionType(line):
|
||||||
#parses the ante out of the given line and checks which player paid it, updates antes accordingly.
|
#parses the ante out of the given line and checks which player paid it, updates antes accordingly.
|
||||||
def parseAnteLine(line, isTourney, names, antes):
|
def parseAnteLine(line, isTourney, names, antes):
|
||||||
for i, name in enumerate(names):
|
for i, name in enumerate(names):
|
||||||
if line.startswith(name.encode("latin-1")):
|
if line.startswith(name.encode(LOCALE_ENCODING)):
|
||||||
pos = line.rfind("$") + 1
|
pos = line.rfind("$") + 1
|
||||||
if not isTourney:
|
if not isTourney:
|
||||||
antes[i] += float2int(line[pos:])
|
antes[i] += float2int(line[pos:])
|
||||||
|
@ -693,7 +697,7 @@ def parseHandStartTime(topline):
|
||||||
def findName(line):
|
def findName(line):
|
||||||
pos1 = line.find(":") + 2
|
pos1 = line.find(":") + 2
|
||||||
pos2 = line.rfind("(") - 1
|
pos2 = line.rfind("(") - 1
|
||||||
return unicode(line[pos1:pos2], "latin-1")
|
return unicode(line[pos1:pos2], LOCALE_ENCODING)
|
||||||
|
|
||||||
def parseNames(lines):
|
def parseNames(lines):
|
||||||
return [findName(line) for line in lines]
|
return [findName(line) for line in lines]
|
||||||
|
@ -810,7 +814,7 @@ def parseTourneyNo(topline):
|
||||||
def parseWinLine(line, names, winnings, isTourney):
|
def parseWinLine(line, names, winnings, isTourney):
|
||||||
#print "parseWinLine: line:",line
|
#print "parseWinLine: line:",line
|
||||||
for i,n in enumerate(names):
|
for i,n in enumerate(names):
|
||||||
n = n.encode("latin-1")
|
n = n.encode(LOCALE_ENCODING)
|
||||||
if line.startswith(n):
|
if line.startswith(n):
|
||||||
if isTourney:
|
if isTourney:
|
||||||
pos1 = line.rfind("collected ") + 10
|
pos1 = line.rfind("collected ") + 10
|
||||||
|
@ -1020,14 +1024,15 @@ def recognisePlayerIDs(db, names, site_id):
|
||||||
def recognisePlayerNo(line, names, atype):
|
def recognisePlayerNo(line, names, atype):
|
||||||
#print "recogniseplayerno, names:",names
|
#print "recogniseplayerno, names:",names
|
||||||
for i in xrange(len(names)):
|
for i in xrange(len(names)):
|
||||||
|
encodedName = names[i].encode(LOCALE_ENCODING)
|
||||||
if (atype=="unbet"):
|
if (atype=="unbet"):
|
||||||
if (line.endswith(names[i].encode("latin-1"))):
|
if (line.endswith(encodedName)):
|
||||||
return (i)
|
return (i)
|
||||||
elif (line.startswith("Dealt to ")):
|
elif (line.startswith("Dealt to ")):
|
||||||
#print "recognisePlayerNo, card precut, line:",line
|
#print "recognisePlayerNo, card precut, line:",line
|
||||||
tmp=line[9:]
|
tmp=line[9:]
|
||||||
#print "recognisePlayerNo, card postcut, tmp:",tmp
|
#print "recognisePlayerNo, card postcut, tmp:",tmp
|
||||||
if (tmp.startswith(names[i].encode("latin-1"))):
|
if (tmp.startswith(encodedName)):
|
||||||
return (i)
|
return (i)
|
||||||
elif (line.startswith("Seat ")):
|
elif (line.startswith("Seat ")):
|
||||||
if (line.startswith("Seat 10")):
|
if (line.startswith("Seat 10")):
|
||||||
|
@ -1035,10 +1040,10 @@ def recognisePlayerNo(line, names, atype):
|
||||||
else:
|
else:
|
||||||
tmp=line[8:]
|
tmp=line[8:]
|
||||||
|
|
||||||
if (tmp.startswith(names[i].encode("latin-1"))):
|
if (tmp.startswith(encodedName)):
|
||||||
return (i)
|
return (i)
|
||||||
else:
|
else:
|
||||||
if (line.startswith(names[i].encode("latin-1"))):
|
if (line.startswith(encodedName)):
|
||||||
return (i)
|
return (i)
|
||||||
#if we're here we mustve failed
|
#if we're here we mustve failed
|
||||||
raise FpdbError ("failed to recognise player in: "+line+" atype:"+atype)
|
raise FpdbError ("failed to recognise player in: "+line+" atype:"+atype)
|
||||||
|
|
|
@ -1,271 +1,271 @@
|
||||||
|
|
||||||
# Code from http://ender.snowburst.org:4747/~jjohns/interlocks.py
|
# Code from http://ender.snowburst.org:4747/~jjohns/interlocks.py
|
||||||
# Thanks JJ!
|
# Thanks JJ!
|
||||||
|
|
||||||
import sys
|
import sys
|
||||||
import os, os.path
|
import os, os.path
|
||||||
import subprocess
|
import subprocess
|
||||||
import time
|
import time
|
||||||
import signal
|
import signal
|
||||||
import base64
|
import base64
|
||||||
|
|
||||||
InterProcessLock = None
|
InterProcessLock = None
|
||||||
|
|
||||||
"""
|
"""
|
||||||
Just use me like a thread lock. acquire() / release() / locked()
|
Just use me like a thread lock. acquire() / release() / locked()
|
||||||
|
|
||||||
Differences compared to thread locks:
|
Differences compared to thread locks:
|
||||||
1. By default, acquire()'s wait parameter is false.
|
1. By default, acquire()'s wait parameter is false.
|
||||||
2. When acquire fails, SingleInstanceError is thrown instead of simply returning false.
|
2. When acquire fails, SingleInstanceError is thrown instead of simply returning false.
|
||||||
3. acquire() can take a 3rd parameter retry_time, which, if wait is True, tells the locking
|
3. acquire() can take a 3rd parameter retry_time, which, if wait is True, tells the locking
|
||||||
mechanism how long to sleep between retrying the lock. Has no effect for unix/InterProcessLockFcntl.
|
mechanism how long to sleep between retrying the lock. Has no effect for unix/InterProcessLockFcntl.
|
||||||
|
|
||||||
Differences in fpdb version to JJ's original:
|
Differences in fpdb version to JJ's original:
|
||||||
1. Changed acquire() to return false like other locks
|
1. Changed acquire() to return false like other locks
|
||||||
2. Made acquire fail if same process already has the lock
|
2. Made acquire fail if same process already has the lock
|
||||||
"""
|
"""
|
||||||
|
|
||||||
class SingleInstanceError(RuntimeError):
|
class SingleInstanceError(RuntimeError):
|
||||||
"Thrown when you try to acquire an InterProcessLock and another version of the process is already running."
|
"Thrown when you try to acquire an InterProcessLock and another version of the process is already running."
|
||||||
|
|
||||||
class InterProcessLockBase:
|
class InterProcessLockBase:
|
||||||
def __init__(self, name=None ):
|
def __init__(self, name=None ):
|
||||||
self._has_lock = False
|
self._has_lock = False
|
||||||
if not name:
|
if not name:
|
||||||
name = sys.argv[0]
|
name = sys.argv[0]
|
||||||
self.name = name
|
self.name = name
|
||||||
|
|
||||||
def getHashedName(self):
|
def getHashedName(self):
|
||||||
return base64.b64encode(self.name).replace('=','')
|
return base64.b64encode(self.name).replace('=','')
|
||||||
|
|
||||||
def acquire_impl(self, wait): abstract
|
def acquire_impl(self, wait): abstract
|
||||||
|
|
||||||
def acquire(self, wait=False, retry_time=1):
|
def acquire(self, wait=False, retry_time=1):
|
||||||
if self._has_lock: # make sure 2nd acquire in same process fails
|
if self._has_lock: # make sure 2nd acquire in same process fails
|
||||||
return False
|
return False
|
||||||
while not self._has_lock:
|
while not self._has_lock:
|
||||||
try:
|
try:
|
||||||
self.acquire_impl(wait)
|
self.acquire_impl(wait)
|
||||||
self._has_lock = True
|
self._has_lock = True
|
||||||
#print 'i have the lock'
|
#print 'i have the lock'
|
||||||
except SingleInstanceError:
|
except SingleInstanceError:
|
||||||
if not wait:
|
if not wait:
|
||||||
# raise # change back to normal acquire functionality, sorry JJ!
|
# raise # change back to normal acquire functionality, sorry JJ!
|
||||||
return False
|
return False
|
||||||
time.sleep(retry_time)
|
time.sleep(retry_time)
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def release(self):
|
def release(self):
|
||||||
self.release_impl()
|
self.release_impl()
|
||||||
self._has_lock = False
|
self._has_lock = False
|
||||||
|
|
||||||
def locked(self):
|
def locked(self):
|
||||||
if self._has_lock:
|
if self._has_lock:
|
||||||
return True
|
return True
|
||||||
try:
|
try:
|
||||||
self.acquire()
|
self.acquire()
|
||||||
self.release()
|
self.release()
|
||||||
return False
|
return False
|
||||||
except SingleInstanceError:
|
except SingleInstanceError:
|
||||||
return True
|
return True
|
||||||
|
|
||||||
LOCK_FILE_DIRECTORY = '/tmp'
|
LOCK_FILE_DIRECTORY = '/tmp'
|
||||||
|
|
||||||
class InterProcessLockFcntl(InterProcessLockBase):
|
class InterProcessLockFcntl(InterProcessLockBase):
|
||||||
def __init__(self, name=None):
|
def __init__(self, name=None):
|
||||||
InterProcessLockBase.__init__(self, name)
|
InterProcessLockBase.__init__(self, name)
|
||||||
self.lockfd = 0
|
self.lockfd = 0
|
||||||
self.lock_file_name = os.path.join(LOCK_FILE_DIRECTORY, self.getHashedName() + '.lck')
|
self.lock_file_name = os.path.join(LOCK_FILE_DIRECTORY, self.getHashedName() + '.lck')
|
||||||
assert(os.path.isdir(LOCK_FILE_DIRECTORY))
|
assert(os.path.isdir(LOCK_FILE_DIRECTORY))
|
||||||
|
|
||||||
# This is the suggested way to get a safe file name, but I like having a descriptively named lock file.
|
# This is the suggested way to get a safe file name, but I like having a descriptively named lock file.
|
||||||
def getHashedName(self):
|
def getHashedName(self):
|
||||||
import re
|
import re
|
||||||
bad_filename_character_re = re.compile(r'/\?<>\\\:;\*\|\'\"\^=\.\[\]')
|
bad_filename_character_re = re.compile(r'/\?<>\\\:;\*\|\'\"\^=\.\[\]')
|
||||||
return bad_filename_character_re.sub('_',self.name)
|
return bad_filename_character_re.sub('_',self.name)
|
||||||
|
|
||||||
def acquire_impl(self, wait):
|
def acquire_impl(self, wait):
|
||||||
self.lockfd = open(self.lock_file_name, 'w')
|
self.lockfd = open(self.lock_file_name, 'w')
|
||||||
fcntrl_options = fcntl.LOCK_EX
|
fcntrl_options = fcntl.LOCK_EX
|
||||||
if not wait:
|
if not wait:
|
||||||
fcntrl_options |= fcntl.LOCK_NB
|
fcntrl_options |= fcntl.LOCK_NB
|
||||||
try:
|
try:
|
||||||
fcntl.flock(self.lockfd, fcntrl_options)
|
fcntl.flock(self.lockfd, fcntrl_options)
|
||||||
except IOError:
|
except IOError:
|
||||||
self.lockfd.close()
|
self.lockfd.close()
|
||||||
self.lockfd = 0
|
self.lockfd = 0
|
||||||
raise SingleInstanceError('Could not acquire exclusive lock on '+self.lock_file_name)
|
raise SingleInstanceError('Could not acquire exclusive lock on '+self.lock_file_name)
|
||||||
|
|
||||||
def release_impl(self):
|
def release_impl(self):
|
||||||
fcntl.lockf(self.lockfd, fcntl.LOCK_UN)
|
fcntl.lockf(self.lockfd, fcntl.LOCK_UN)
|
||||||
self.lockfd.close()
|
self.lockfd.close()
|
||||||
self.lockfd = 0
|
self.lockfd = 0
|
||||||
try:
|
try:
|
||||||
os.unlink(self.lock_file_name)
|
os.unlink(self.lock_file_name)
|
||||||
except IOError:
|
except IOError:
|
||||||
# We don't care about the existence of the file too much here. It's the flock() we care about,
|
# We don't care about the existence of the file too much here. It's the flock() we care about,
|
||||||
# And that should just go away magically.
|
# And that should just go away magically.
|
||||||
pass
|
pass
|
||||||
|
|
||||||
class InterProcessLockWin32(InterProcessLockBase):
|
class InterProcessLockWin32(InterProcessLockBase):
|
||||||
def __init__(self, name=None):
|
def __init__(self, name=None):
|
||||||
InterProcessLockBase.__init__(self, name)
|
InterProcessLockBase.__init__(self, name)
|
||||||
self.mutex = None
|
self.mutex = None
|
||||||
|
|
||||||
def acquire_impl(self,wait):
|
def acquire_impl(self,wait):
|
||||||
self.mutex = win32event.CreateMutex(None, 0, self.getHashedName())
|
self.mutex = win32event.CreateMutex(None, 0, self.getHashedName())
|
||||||
if win32api.GetLastError() == winerror.ERROR_ALREADY_EXISTS:
|
if win32api.GetLastError() == winerror.ERROR_ALREADY_EXISTS:
|
||||||
self.mutex.Close()
|
self.mutex.Close()
|
||||||
self.mutex = None
|
self.mutex = None
|
||||||
raise SingleInstanceError('Could not acquire exclusive lock on ' + self.name)
|
raise SingleInstanceError('Could not acquire exclusive lock on ' + self.name)
|
||||||
|
|
||||||
def release_impl(self):
|
def release_impl(self):
|
||||||
self.mutex.Close()
|
self.mutex.Close()
|
||||||
|
|
||||||
class InterProcessLockSocket(InterProcessLockBase):
|
class InterProcessLockSocket(InterProcessLockBase):
|
||||||
def __init__(self, name=None):
|
def __init__(self, name=None):
|
||||||
InterProcessLockBase.__init__(self, name)
|
InterProcessLockBase.__init__(self, name)
|
||||||
self.socket = None
|
self.socket = None
|
||||||
self.portno = 65530 - abs(self.getHashedName().__hash__()) % 32749
|
self.portno = 65530 - abs(self.getHashedName().__hash__()) % 32749
|
||||||
|
|
||||||
def acquire_impl(self, wait):
|
def acquire_impl(self, wait):
|
||||||
self.socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
self.socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
||||||
try:
|
try:
|
||||||
self.socket.bind(('127.0.0.1', self.portno))
|
self.socket.bind(('127.0.0.1', self.portno))
|
||||||
except socket.error:
|
except socket.error:
|
||||||
self.socket.close()
|
self.socket.close()
|
||||||
self.socket = None
|
self.socket = None
|
||||||
raise SingleInstanceError('Could not acquire exclusive lock on ' + self.name)
|
raise SingleInstanceError('Could not acquire exclusive lock on ' + self.name)
|
||||||
|
|
||||||
def release_impl(self):
|
def release_impl(self):
|
||||||
self.socket.close()
|
self.socket.close()
|
||||||
self.socket = None
|
self.socket = None
|
||||||
|
|
||||||
# Set InterProcessLock to the correct type given the sysem parameters available
|
# Set InterProcessLock to the correct type given the sysem parameters available
|
||||||
try:
|
try:
|
||||||
import fcntl
|
import fcntl
|
||||||
InterProcessLock = InterProcessLockFcntl
|
InterProcessLock = InterProcessLockFcntl
|
||||||
except ImportError:
|
except ImportError:
|
||||||
try:
|
try:
|
||||||
import win32event
|
import win32event
|
||||||
import win32api
|
import win32api
|
||||||
import winerror
|
import winerror
|
||||||
InterProcessLock = InterProcessLockWin32
|
InterProcessLock = InterProcessLockWin32
|
||||||
except ImportError:
|
except ImportError:
|
||||||
import socket
|
import socket
|
||||||
InterProcessLock = InterProcessLockSocket
|
InterProcessLock = InterProcessLockSocket
|
||||||
|
|
||||||
def test_construct():
|
def test_construct():
|
||||||
"""
|
"""
|
||||||
# Making the name of the test unique so it can be executed my multiple users on the same machine.
|
# Making the name of the test unique so it can be executed my multiple users on the same machine.
|
||||||
>>> test_name = 'InterProcessLockTest' +str(os.getpid()) + str(time.time())
|
>>> test_name = 'InterProcessLockTest' +str(os.getpid()) + str(time.time())
|
||||||
|
|
||||||
>>> lock1 = InterProcessLock(name=test_name)
|
>>> lock1 = InterProcessLock(name=test_name)
|
||||||
>>> lock1.acquire()
|
>>> lock1.acquire()
|
||||||
|
|
||||||
>>> lock2 = InterProcessLock(name=test_name)
|
>>> lock2 = InterProcessLock(name=test_name)
|
||||||
>>> lock3 = InterProcessLock(name=test_name)
|
>>> lock3 = InterProcessLock(name=test_name)
|
||||||
|
|
||||||
# Since lock1 is locked, other attempts to acquire it fail.
|
# Since lock1 is locked, other attempts to acquire it fail.
|
||||||
>>> lock2.acquire()
|
>>> lock2.acquire()
|
||||||
Traceback (most recent call last):
|
Traceback (most recent call last):
|
||||||
...
|
...
|
||||||
SingleInstanceError: Could not acquire exclusive lock on /tmp/test.lck
|
SingleInstanceError: Could not acquire exclusive lock on /tmp/test.lck
|
||||||
|
|
||||||
>>> lock3.acquire()
|
>>> lock3.acquire()
|
||||||
Traceback (most recent call last):
|
Traceback (most recent call last):
|
||||||
...
|
...
|
||||||
SingleInstanceError: Could not acquire exclusive lock on /tmp/test.lck
|
SingleInstanceError: Could not acquire exclusive lock on /tmp/test.lck
|
||||||
|
|
||||||
# Release the lock and let lock2 have it.
|
# Release the lock and let lock2 have it.
|
||||||
>>> lock1.release()
|
>>> lock1.release()
|
||||||
>>> lock2.acquire()
|
>>> lock2.acquire()
|
||||||
|
|
||||||
>>> lock3.acquire()
|
>>> lock3.acquire()
|
||||||
Traceback (most recent call last):
|
Traceback (most recent call last):
|
||||||
...
|
...
|
||||||
SingleInstanceError: Could not acquire exclusive lock on /tmp/test.lck
|
SingleInstanceError: Could not acquire exclusive lock on /tmp/test.lck
|
||||||
|
|
||||||
# Release it and give it back to lock1
|
# Release it and give it back to lock1
|
||||||
>>> lock2.release()
|
>>> lock2.release()
|
||||||
>>> lock1.acquire()
|
>>> lock1.acquire()
|
||||||
|
|
||||||
>>> lock2.acquire()
|
>>> lock2.acquire()
|
||||||
Traceback (most recent call last):
|
Traceback (most recent call last):
|
||||||
...
|
...
|
||||||
SingleInstanceError: Could not acquire exclusive lock on /tmp/test.lck
|
SingleInstanceError: Could not acquire exclusive lock on /tmp/test.lck
|
||||||
|
|
||||||
# Test lock status
|
# Test lock status
|
||||||
>>> lock2.locked()
|
>>> lock2.locked()
|
||||||
True
|
True
|
||||||
>>> lock3.locked()
|
>>> lock3.locked()
|
||||||
True
|
True
|
||||||
>>> lock1.locked()
|
>>> lock1.locked()
|
||||||
True
|
True
|
||||||
|
|
||||||
>>> lock1.release()
|
>>> lock1.release()
|
||||||
|
|
||||||
>>> lock2.locked()
|
>>> lock2.locked()
|
||||||
False
|
False
|
||||||
>>> lock3.locked()
|
>>> lock3.locked()
|
||||||
False
|
False
|
||||||
>>> lock1.locked()
|
>>> lock1.locked()
|
||||||
False
|
False
|
||||||
|
|
||||||
>>> if os.name == 'posix':
|
>>> if os.name == 'posix':
|
||||||
... def os_independent_kill(pid):
|
... def os_independent_kill(pid):
|
||||||
... import signal
|
... import signal
|
||||||
... os.kill(pid, signal.SIGKILL)
|
... os.kill(pid, signal.SIGKILL)
|
||||||
... else:
|
... else:
|
||||||
... assert(os.name == 'nt')
|
... assert(os.name == 'nt')
|
||||||
... def os_independent_kill(pid):
|
... def os_independent_kill(pid):
|
||||||
... ''' http://www.python.org/doc/faq/windows/#how-do-i-emulate-os-kill-in-windows '''
|
... ''' http://www.python.org/doc/faq/windows/#how-do-i-emulate-os-kill-in-windows '''
|
||||||
... import win32api
|
... import win32api
|
||||||
... import win32con
|
... import win32con
|
||||||
... import pywintypes
|
... import pywintypes
|
||||||
... handle = win32api.OpenProcess(win32con.PROCESS_TERMINATE , pywintypes.FALSE, pid)
|
... handle = win32api.OpenProcess(win32con.PROCESS_TERMINATE , pywintypes.FALSE, pid)
|
||||||
... return (0 != win32api.TerminateProcess(handle, 0))
|
... return (0 != win32api.TerminateProcess(handle, 0))
|
||||||
|
|
||||||
# Test to acquire the lock in another process.
|
# Test to acquire the lock in another process.
|
||||||
>>> def execute(cmd):
|
>>> def execute(cmd):
|
||||||
... cmd = 'import time;' + cmd + 'time.sleep(10);'
|
... cmd = 'import time;' + cmd + 'time.sleep(10);'
|
||||||
... process = subprocess.Popen([sys.executable, '-c', cmd])
|
... process = subprocess.Popen([sys.executable, '-c', cmd])
|
||||||
... pid = process.pid
|
... pid = process.pid
|
||||||
... time.sleep(2) # quick hack, but we test synchronization in the end
|
... time.sleep(2) # quick hack, but we test synchronization in the end
|
||||||
... return pid
|
... return pid
|
||||||
|
|
||||||
>>> pid = execute('import interlocks;a=interlocks.InterProcessLock(name=\\''+test_name+ '\\');a.acquire();')
|
>>> pid = execute('import interlocks;a=interlocks.InterProcessLock(name=\\''+test_name+ '\\');a.acquire();')
|
||||||
|
|
||||||
>>> lock1.acquire()
|
>>> lock1.acquire()
|
||||||
Traceback (most recent call last):
|
Traceback (most recent call last):
|
||||||
...
|
...
|
||||||
SingleInstanceError: Could not acquire exclusive lock on /tmp/test.lck
|
SingleInstanceError: Could not acquire exclusive lock on /tmp/test.lck
|
||||||
|
|
||||||
>>> os_independent_kill(pid)
|
>>> os_independent_kill(pid)
|
||||||
|
|
||||||
>>> time.sleep(1)
|
>>> time.sleep(1)
|
||||||
|
|
||||||
>>> lock1.acquire()
|
>>> lock1.acquire()
|
||||||
>>> lock1.release()
|
>>> lock1.release()
|
||||||
|
|
||||||
# Testing wait
|
# Testing wait
|
||||||
|
|
||||||
>>> pid = execute('import interlocks;a=interlocks.InterProcessLock(name=\\''+test_name+ '\\');a.acquire();')
|
>>> pid = execute('import interlocks;a=interlocks.InterProcessLock(name=\\''+test_name+ '\\');a.acquire();')
|
||||||
|
|
||||||
>>> lock1.acquire()
|
>>> lock1.acquire()
|
||||||
Traceback (most recent call last):
|
Traceback (most recent call last):
|
||||||
...
|
...
|
||||||
SingleInstanceError: Could not acquire exclusive lock on /tmp/test.lck
|
SingleInstanceError: Could not acquire exclusive lock on /tmp/test.lck
|
||||||
|
|
||||||
>>> os_independent_kill(pid)
|
>>> os_independent_kill(pid)
|
||||||
|
|
||||||
>>> lock1.acquire(True)
|
>>> lock1.acquire(True)
|
||||||
>>> lock1.release()
|
>>> lock1.release()
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
pass
|
pass
|
||||||
|
|
||||||
if __name__=='__main__':
|
if __name__=='__main__':
|
||||||
import doctest
|
import doctest
|
||||||
doctest.testmod(optionflags=doctest.IGNORE_EXCEPTION_DETAIL)
|
doctest.testmod(optionflags=doctest.IGNORE_EXCEPTION_DETAIL)
|
||||||
|
|
|
@ -1,27 +1,27 @@
|
||||||
|
|
||||||
# script to update indexes on mysql (+other?) database
|
# script to update indexes on mysql (+other?) database
|
||||||
|
|
||||||
select '1. Dropping indexes' as ' ';
|
select '1. Dropping indexes' as ' ';
|
||||||
select 'Can''t drop messages indicate index already gone' as ' ';
|
select 'Can''t drop messages indicate index already gone' as ' ';
|
||||||
|
|
||||||
ALTER TABLE `fpdb`.`Settings` DROP INDEX `id`;
|
ALTER TABLE `fpdb`.`Settings` DROP INDEX `id`;
|
||||||
ALTER TABLE `fpdb`.`Sites` DROP INDEX `id`;
|
ALTER TABLE `fpdb`.`Sites` DROP INDEX `id`;
|
||||||
ALTER TABLE `fpdb`.`Gametypes` DROP INDEX `id`;
|
ALTER TABLE `fpdb`.`Gametypes` DROP INDEX `id`;
|
||||||
ALTER TABLE `fpdb`.`Players` DROP INDEX `id`;
|
ALTER TABLE `fpdb`.`Players` DROP INDEX `id`;
|
||||||
ALTER TABLE `fpdb`.`Autorates` DROP INDEX `id`;
|
ALTER TABLE `fpdb`.`Autorates` DROP INDEX `id`;
|
||||||
ALTER TABLE `fpdb`.`Hands` DROP INDEX `id`;
|
ALTER TABLE `fpdb`.`Hands` DROP INDEX `id`;
|
||||||
ALTER TABLE `fpdb`.`BoardCards` DROP INDEX `id`;
|
ALTER TABLE `fpdb`.`BoardCards` DROP INDEX `id`;
|
||||||
ALTER TABLE `fpdb`.`TourneyTypes` DROP INDEX `id`;
|
ALTER TABLE `fpdb`.`TourneyTypes` DROP INDEX `id`;
|
||||||
ALTER TABLE `fpdb`.`Tourneys` DROP INDEX `id`;
|
ALTER TABLE `fpdb`.`Tourneys` DROP INDEX `id`;
|
||||||
ALTER TABLE `fpdb`.`TourneysPlayers` DROP INDEX `id`;
|
ALTER TABLE `fpdb`.`TourneysPlayers` DROP INDEX `id`;
|
||||||
ALTER TABLE `fpdb`.`HandsPlayers` DROP INDEX `id`;
|
ALTER TABLE `fpdb`.`HandsPlayers` DROP INDEX `id`;
|
||||||
ALTER TABLE `fpdb`.`HandsActions` DROP INDEX `id`;
|
ALTER TABLE `fpdb`.`HandsActions` DROP INDEX `id`;
|
||||||
ALTER TABLE `fpdb`.`HudCache` DROP INDEX `id`;
|
ALTER TABLE `fpdb`.`HudCache` DROP INDEX `id`;
|
||||||
|
|
||||||
select '2. Adding extra indexes on useful fields' as ' ';
|
select '2. Adding extra indexes on useful fields' as ' ';
|
||||||
select 'Duplicate key name messages indicate new indexes already there' as ' ';
|
select 'Duplicate key name messages indicate new indexes already there' as ' ';
|
||||||
|
|
||||||
ALTER TABLE `fpdb`.`tourneys` ADD INDEX `siteTourneyNo`(`siteTourneyNo`);
|
ALTER TABLE `fpdb`.`tourneys` ADD INDEX `siteTourneyNo`(`siteTourneyNo`);
|
||||||
ALTER TABLE `fpdb`.`hands` ADD INDEX `siteHandNo`(`siteHandNo`);
|
ALTER TABLE `fpdb`.`hands` ADD INDEX `siteHandNo`(`siteHandNo`);
|
||||||
ALTER TABLE `fpdb`.`players` ADD INDEX `name`(`name`);
|
ALTER TABLE `fpdb`.`players` ADD INDEX `name`(`name`);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user