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

This commit is contained in:
sqlcoder 2008-12-28 09:50:33 +00:00
commit e469202b66
13 changed files with 359 additions and 142 deletions

View File

@ -60,6 +60,8 @@ class Site:
self.converter = node.getAttribute("converter") self.converter = node.getAttribute("converter")
self.enabled = node.getAttribute("enabled") self.enabled = node.getAttribute("enabled")
self.aux_window = node.getAttribute("aux_window") self.aux_window = node.getAttribute("aux_window")
self.font = node.getAttribute("font")
self.font_size = node.getAttribute("font_size")
self.layout = {} self.layout = {}
for layout_node in node.getElementsByTagName('layout'): for layout_node in node.getElementsByTagName('layout'):
@ -480,6 +482,19 @@ class Config:
colors['hudfgcolor'] = self.supported_sites[site].hudfgcolor colors['hudfgcolor'] = self.supported_sites[site].hudfgcolor
return colors return colors
def get_default_font(self, site = 'PokerStars'):
(font, font_size) = ("Sans", "8")
if self.supported_sites[site].font == "":
font = "Sans"
else:
font = self.supported_sites[site].font
if self.supported_sites[site].font_size == "":
font_size = "8"
else:
font_size = self.supported_sites[site].font_size
return (font, font_size)
def get_locations(self, site = "PokerStars", max = "8"): def get_locations(self, site = "PokerStars", max = "8"):
try: try:
@ -511,13 +526,16 @@ class Config:
parms["site_name"] = self.supported_sites[site].site_name parms["site_name"] = self.supported_sites[site].site_name
parms["enabled"] = self.supported_sites[site].enabled parms["enabled"] = self.supported_sites[site].enabled
parms["aux_window"] = self.supported_sites[site].aux_window parms["aux_window"] = self.supported_sites[site].aux_window
parms["font"] = self.supported_sites[site].font
parms["font_size"] = self.supported_sites[site].font_size
return parms return parms
def set_site_parameters(self, site_name, converter = None, decoder = None, def set_site_parameters(self, site_name, converter = None, decoder = None,
hudbgcolor = None, hudfgcolor = None, hudbgcolor = None, hudfgcolor = None,
hudopacity = None, screen_name = None, hudopacity = None, screen_name = None,
site_path = None, table_finder = None, site_path = None, table_finder = None,
HH_path = None, enabled = None): HH_path = None, enabled = None,
font = None, font_size = None):
"""Sets the specified site parameters for the specified site.""" """Sets the specified site parameters for the specified site."""
site_node = self.get_site_node(site_name) site_node = self.get_site_node(site_name)
if not db_node == None: if not db_node == None:
@ -531,18 +549,20 @@ class Config:
if not table_finder == None: site_node.setAttribute("table_finder", table_finder) if not table_finder == None: site_node.setAttribute("table_finder", table_finder)
if not HH_path == None: site_node.setAttribute("HH_path", HH_path) if not HH_path == None: site_node.setAttribute("HH_path", HH_path)
if not enabled == None: site_node.setAttribute("enabled", enabled) if not enabled == None: site_node.setAttribute("enabled", enabled)
if not font == None: site_node.setAttribute("font", font)
if not font_size == None: site_node.setAttribute("font_size", font_size)
if self.supported_databases.has_key(db_name): # if self.supported_databases.has_key(db_name):
if not converter == None: self.supported_sites[site].converter = converter # if not converter == None: self.supported_sites[site].converter = converter
if not decoder == None: self.supported_sites[site].decoder = decoder # if not decoder == None: self.supported_sites[site].decoder = decoder
if not hudbgcolor == None: self.supported_sites[site].hudbgcolor = hudbgcolor # if not hudbgcolor == None: self.supported_sites[site].hudbgcolor = hudbgcolor
if not hudfgcolor == None: self.supported_sites[site].hudfgcolor = hudfgcolor # if not hudfgcolor == None: self.supported_sites[site].hudfgcolor = hudfgcolor
if not hudopacity == None: self.supported_sites[site].hudopacity = hudopacity # if not hudopacity == None: self.supported_sites[site].hudopacity = hudopacity
if not screen_name == None: self.supported_sites[site].screen_name = screen_name # if not screen_name == None: self.supported_sites[site].screen_name = screen_name
if not site_path == None: self.supported_sites[site].site_path = site_path # if not site_path == None: self.supported_sites[site].site_path = site_path
if not table_finder == None: self.supported_sites[site].table_finder = table_finder # if not table_finder == None: self.supported_sites[site].table_finder = table_finder
if not HH_path == None: self.supported_sites[site].HH_path = HH_path # if not HH_path == None: self.supported_sites[site].HH_path = HH_path
if not enabled == None: self.supported_sites[site].enabled = enabled # if not enabled == None: self.supported_sites[site].enabled = enabled
return return
def get_aux_windows(self): def get_aux_windows(self):
@ -640,6 +660,7 @@ if __name__== "__main__":
for site in c.supported_sites.keys(): for site in c.supported_sites.keys():
print "site = ", site, print "site = ", site,
print c.get_site_parameters(site) print c.get_site_parameters(site)
print c.get_default_font(site)
for game in c.get_supported_games(): for game in c.get_supported_games():
print c.get_game_parameters(game) print c.get_game_parameters(game)

View File

@ -79,7 +79,8 @@ class Everleaf(HandHistoryConverter):
self.rexx.setHeroCardsRegex('.*\nDealt\sto\s(?P<PNAME>.*)\s\[ (?P<CARDS>.*) \]') self.rexx.setHeroCardsRegex('.*\nDealt\sto\s(?P<PNAME>.*)\s\[ (?P<CARDS>.*) \]')
self.rexx.setActionStepRegex('.*\n(?P<PNAME>.*)(?P<ATYPE>: bets| checks| raises| calls| folds)(\s\[\$ (?P<BET>[.\d]+) USD\])?') self.rexx.setActionStepRegex('.*\n(?P<PNAME>.*)(?P<ATYPE>: bets| checks| raises| calls| folds)(\s\[\$ (?P<BET>[.\d]+) USD\])?')
self.rexx.setShowdownActionRegex('.*\n(?P<PNAME>.*) shows \[ (?P<CARDS>.*) \]') self.rexx.setShowdownActionRegex('.*\n(?P<PNAME>.*) shows \[ (?P<CARDS>.*) \]')
self.rexx.setCollectPotRegex('.*\n(?P<PNAME>.*) wins \$ (?P<POT>[.\d]+) USD(.*\[ (?P<CARDS>.*) \])?') self.rexx.setCollectPotRegex('.*\n(?P<PNAME>.*) wins \$ (?P<POT>[.\d]+) USD(.*?\[ (?P<CARDS>.*?) \])?')
#self.rexx.setCollectPotRegex('.*\n(?P<PNAME>.*) wins \$ (?P<POT>[.\d]+) USD(.*\[ (?P<CARDS>) \S\S, \S\S, \S\S, \S\S, \S\S \])?')
self.rexx.sits_out_re = re.compile('(?P<PNAME>.*) sits out') self.rexx.sits_out_re = re.compile('(?P<PNAME>.*) sits out')
self.rexx.compileRegexes() self.rexx.compileRegexes()
@ -169,7 +170,7 @@ class Everleaf(HandHistoryConverter):
m = self.rexx.action_re.finditer(hand.streets.group(street)) m = self.rexx.action_re.finditer(hand.streets.group(street))
for action in m: for action in m:
if action.group('ATYPE') == ' raises': if action.group('ATYPE') == ' raises':
hand.addRaiseTo( street, action.group('PNAME'), action.group('BET') ) hand.addCallandRaise( street, action.group('PNAME'), action.group('BET') )
elif action.group('ATYPE') == ' calls': elif action.group('ATYPE') == ' calls':
hand.addCall( street, action.group('PNAME'), action.group('BET') ) hand.addCall( street, action.group('PNAME'), action.group('BET') )
elif action.group('ATYPE') == ': bets': elif action.group('ATYPE') == ': bets':

View File

@ -635,6 +635,11 @@ class FpdbSQLQueries:
elif(self.dbname == 'SQLite'): elif(self.dbname == 'SQLite'):
self.query['getPlayerId'] = """SELECT id from Players where name = %s""" self.query['getPlayerId'] = """SELECT id from Players where name = %s"""
if(self.dbname == 'MySQL InnoDB') or (self.dbname == 'PostgreSQL'):
self.query['getSiteId'] = """SELECT id from Sites where name = %s"""
elif(self.dbname == 'SQLite'):
self.query['getSiteId'] = """SELECT id from Sites where name = %s"""
if(self.dbname == 'MySQL InnoDB') or (self.dbname == 'PostgreSQL'): if(self.dbname == 'MySQL InnoDB') or (self.dbname == 'PostgreSQL'):
self.query['getRingProfitAllHandsPlayerIdSite'] = """ self.query['getRingProfitAllHandsPlayerIdSite'] = """
SELECT hp.handId, hp.winnings, coalesce(hp.ante,0) + SUM(ha.amount) SELECT hp.handId, hp.winnings, coalesce(hp.ante,0) + SUM(ha.amount)
@ -643,8 +648,10 @@ class FpdbSQLQueries:
INNER JOIN Players pl ON hp.playerId = pl.id INNER JOIN Players pl ON hp.playerId = pl.id
INNER JOIN Hands h ON h.id = hp.handId INNER JOIN Hands h ON h.id = hp.handId
INNER JOIN HandsActions ha ON ha.handPlayerId = hp.id INNER JOIN HandsActions ha ON ha.handPlayerId = hp.id
WHERE pl.name = %s where pl.id in <player_test>
AND pl.siteId = %s AND pl.siteId in <site_test>
AND h.handStart > '<startdate_test>'
AND h.handStart < '<enddate_test>'
AND hp.tourneysPlayersId IS NULL AND hp.tourneysPlayersId IS NULL
GROUP BY hp.handId, hp.winnings, h.handStart, hp.ante GROUP BY hp.handId, hp.winnings, h.handStart, hp.ante
ORDER BY h.handStart""" ORDER BY h.handStart"""
@ -656,8 +663,10 @@ class FpdbSQLQueries:
INNER JOIN Players pl ON hp.playerId = pl.id INNER JOIN Players pl ON hp.playerId = pl.id
INNER JOIN Hands h ON h.id = hp.handId INNER JOIN Hands h ON h.id = hp.handId
INNER JOIN HandsActions ha ON ha.handPlayerId = hp.id INNER JOIN HandsActions ha ON ha.handPlayerId = hp.id
WHERE pl.name = %s where pl.id in <player_test>
AND pl.siteId = %s AND pl.siteId in <site_test>
AND h.handStart > '<startdate_test>'
AND h.handStart < '<enddate_test>'
AND hp.tourneysPlayersId IS NULL AND hp.tourneysPlayersId IS NULL
GROUP BY hp.handId, hp.winnings, h.handStart GROUP BY hp.handId, hp.winnings, h.handStart
ORDER BY h.handStart""" ORDER BY h.handStart"""

View File

@ -104,9 +104,12 @@ 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:
self.importer.runUpdated() self.importer.runUpdated()
print "GuiAutoImport.import_dir done" print "GuiAutoImport.import_dir done"
return self.doAutoImportBool return True
else:
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"""
@ -150,11 +153,14 @@ class GuiAutoImport (threading.Thread):
gobject.timeout_add(interval*1000, self.do_import) gobject.timeout_add(interval*1000, self.do_import)
else: # toggled off else: # toggled off
self.doAutoImportBool = False # do_import will return this and stop the gobject callback timer self.doAutoImportBool = False # do_import will return this and stop the gobject callback timer
#TODO: other clean up, such as killing HUD
print "Stopping autoimport" print "Stopping autoimport"
self.pipe_to_hud.communicate('\n') # waits for process to terminate print >>self.pipe_to_hud.stdin, "\n"
#self.pipe_to_hud.communicate('\n') # waits for process to terminate
self.pipe_to_hud = None self.pipe_to_hud = None
widget.set_label(u'Start Autoimport') self.startButton.set_label(u'Start Autoimport')
#end def GuiAutoImport.startClicked #end def GuiAutoImport.startClicked
def get_vbox(self): def get_vbox(self):

View File

@ -50,22 +50,27 @@ class GuiGraphViewer (threading.Thread):
try: self.canvas.destroy() try: self.canvas.destroy()
except AttributeError: pass except AttributeError: pass
# Whaich sites are selected? sitenos = []
# TODO: playerids = []
# What hero names for the selected site?
# TODO:
name = self.heroes[self.sites] # Which sites are selected?
for site in self.sites:
if self.sites[site] == True:
sitenos.append(self.siteid[site])
self.cursor.execute(self.sql.query['getPlayerId'], (self.heroes[site],))
result = self.db.cursor.fetchall()
if len(result) == 1:
playerids.append(result[0][0])
if self.sites == "PokerStars": if sitenos == []:
site=2 #Should probably pop up here.
sitename="PokerStars: " print "No sites selected - defaulting to PokerStars"
elif self.sites=="Full Tilt": sitenos = [2]
site=1
sitename="Full Tilt: "
else: if playerids == []:
print "invalid text in site selection in graph, defaulting to PS" print "No player ids found"
site=2 return
self.fig = Figure(figsize=(5,4), dpi=100) self.fig = Figure(figsize=(5,4), dpi=100)
@ -74,7 +79,7 @@ class GuiGraphViewer (threading.Thread):
#Get graph data from DB #Get graph data from DB
starttime = time() starttime = time()
line = self.getRingProfitGraph(name, site) line = self.getRingProfitGraph(playerids, sitenos)
print "Graph generated in: %s" %(time() - starttime) print "Graph generated in: %s" %(time() - starttime)
self.ax.set_title("Profit graph for ring games") self.ax.set_title("Profit graph for ring games")
@ -87,7 +92,8 @@ class GuiGraphViewer (threading.Thread):
#TODO: Do something useful like alert user #TODO: Do something useful like alert user
print "No hands returned by graph query" print "No hands returned by graph query"
else: else:
text = "All Hands, " + sitename + str(name) + "\nProfit: $" + str(line[-1]) + "\nTotal Hands: " + str(len(line)) # text = "All Hands, " + sitename + str(name) + "\nProfit: $" + str(line[-1]) + "\nTotal Hands: " + str(len(line))
text = "All Hands, " + "\nProfit: $" + str(line[-1]) + "\nTotal Hands: " + str(len(line))
self.ax.annotate(text, self.ax.annotate(text,
xy=(10, -10), xy=(10, -10),
@ -103,8 +109,34 @@ class GuiGraphViewer (threading.Thread):
self.canvas.show() self.canvas.show()
#end of def showClicked #end of def showClicked
def getRingProfitGraph(self, name, site): def getRingProfitGraph(self, names, sites):
self.cursor.execute(self.sql.query['getRingProfitAllHandsPlayerIdSite'], (name, site)) tmp = self.sql.query['getRingProfitAllHandsPlayerIdSite']
# print "DEBUG: getRingProfitGraph"
start_date, end_date = self.__get_dates()
if start_date == '':
start_date = '1970-01-01'
if end_date == '':
end_date = '2020-12-12'
#Buggered if I can find a way to do this 'nicely' take a list of intergers and longs
# and turn it into a tuple readale by sql.
# [5L] into (5) not (5,) and [5L, 2829L] into (5, 2829)
nametest = str(tuple(names))
sitetest = str(tuple(sites))
nametest = nametest.replace("L", "")
nametest = nametest.replace(",)",")")
sitetest = sitetest.replace(",)",")")
#Must be a nicer way to deal with tuples of size 1 ie. (2,) - which makes sql barf
tmp = tmp.replace("<player_test>", nametest)
tmp = tmp.replace("<site_test>", sitetest)
tmp = tmp.replace("<startdate_test>", start_date)
tmp = tmp.replace("<enddate_test>", end_date)
# print "DEBUG: sql query:"
# print tmp
self.cursor.execute(tmp)
#returns (HandId,Winnings,Costs,Profit) #returns (HandId,Winnings,Costs,Profit)
winnings = self.db.cursor.fetchall() winnings = self.db.cursor.fetchall()
@ -125,7 +157,6 @@ class GuiGraphViewer (threading.Thread):
pname.set_text(player) pname.set_text(player)
pname.set_width_chars(20) pname.set_width_chars(20)
hbox.pack_start(pname, False, True, 0) hbox.pack_start(pname, False, True, 0)
#TODO: Need to connect a callback here
pname.connect("changed", self.__set_hero_name, site) pname.connect("changed", self.__set_hero_name, site)
#TODO: Look at GtkCompletion - to fill out usernames #TODO: Look at GtkCompletion - to fill out usernames
pname.show() pname.show()
@ -134,7 +165,7 @@ class GuiGraphViewer (threading.Thread):
def __set_hero_name(self, w, site): def __set_hero_name(self, w, site):
self.heroes[site] = w.get_text() self.heroes[site] = w.get_text()
print "DEBUG: settings heroes[%s]: %s"%(site, self.heroes[site]) # print "DEBUG: settings heroes[%s]: %s"%(site, self.heroes[site])
def createSiteLine(self, hbox, site): def createSiteLine(self, hbox, site):
cb = gtk.CheckButton(site) cb = gtk.CheckButton(site)
@ -144,8 +175,9 @@ class GuiGraphViewer (threading.Thread):
def __set_site_select(self, w, site): def __set_site_select(self, w, site):
# This doesn't behave as intended - self.site only allows 1 site for the moment. # This doesn't behave as intended - self.site only allows 1 site for the moment.
self.sites = site print w.get_active()
print "self.sites set to %s" %(self.sites) self.sites[site] = w.get_active()
print "self.sites[%s] set to %s" %(site, self.sites[site])
def fillPlayerFrame(self, vbox): def fillPlayerFrame(self, vbox):
for site in self.conf.supported_sites.keys(): for site in self.conf.supported_sites.keys():
@ -162,6 +194,13 @@ class GuiGraphViewer (threading.Thread):
vbox.pack_start(hbox, False, True, 0) vbox.pack_start(hbox, False, True, 0)
hbox.show() hbox.show()
self.createSiteLine(hbox, site) self.createSiteLine(hbox, site)
#Get db site id for filtering later
self.cursor.execute(self.sql.query['getSiteId'], (site,))
result = self.db.cursor.fetchall()
if len(result) == 1:
self.siteid[site] = result[0][0]
else:
print "Either 0 or more than one site matched - EEK"
def fillDateFrame(self, vbox): def fillDateFrame(self, vbox):
# Hat tip to Mika Bostrom - calendar code comes from PokerStats # Hat tip to Mika Bostrom - calendar code comes from PokerStats
@ -261,7 +300,8 @@ class GuiGraphViewer (threading.Thread):
self.sql=querylist self.sql=querylist
self.conf = config self.conf = config
self.sites = "PokerStars" self.sites = {}
self.siteid = {}
self.heroes = {} self.heroes = {}
# For use in date ranges. # For use in date ranges.

View File

@ -49,7 +49,7 @@
<location seat="2" x="10" y="288"> </location> <location seat="2" x="10" y="288"> </location>
</layout> </layout>
</site> </site>
<site enabled="True" site_name="Full Tilt" table_finder="FullTiltPoker.exe" screen_name="ENTER HERO NAME" site_path="~/.wine/drive_c/Program Files/Full Tilt Poker/" HH_path="~/.wine/drive_c/Program Files/Full Tilt Poker/HandHistory/abc/" decoder="fulltilt_decode_table" converter="passthrough" supported_games="holdem,razz,omahahi,omahahilo,studhi,studhilo"> <site enabled="True" site_name="Full Tilt Poker" table_finder="FullTiltPoker.exe" screen_name="ENTER HERO NAME" site_path="~/.wine/drive_c/Program Files/Full Tilt Poker/" HH_path="~/.wine/drive_c/Program Files/Full Tilt Poker/HandHistory/abc/" decoder="fulltilt_decode_table" converter="passthrough" supported_games="holdem,razz,omahahi,omahahilo,studhi,studhilo">
<layout fav_seat="0" height="547" max="8" width="794"> <layout fav_seat="0" height="547" max="8" width="794">
<location seat="1" x="640" y="64"> </location> <location seat="1" x="640" y="64"> </location>
<location seat="2" x="650" y="230"> </location> <location seat="2" x="650" y="230"> </location>

View File

@ -22,14 +22,11 @@ Main for FreePokerTools HUD.
######################################################################## ########################################################################
# to do kill window on my seat
# to do adjust for preferred seat
# to do allow window resizing # to do allow window resizing
# to do hud to echo, but ignore non numbers # to do hud to echo, but ignore non numbers
# to do no hud window for hero # to do no stat window for hero
# to do things to add to config.xml # to do things to add to config.xml
# to do font and size # to do font and size
# to do opacity
# Standard Library modules # Standard Library modules
import sys import sys
@ -68,8 +65,11 @@ def create_HUD(new_hand_id, table, db_name, table_name, max, poker_game, db_conn
global hud_dict global hud_dict
gtk.gdk.threads_enter() gtk.gdk.threads_enter()
try: try:
hud_dict[table_name] = Hud.Hud(table, max, poker_game, config, db_name) hud_dict[table_name] = Hud.Hud(table, max, poker_game, config, db_connection)
hud_dict[table_name].create(new_hand_id, config) hud_dict[table_name].create(new_hand_id, config)
for m in hud_dict[table_name].aux_windows:
m.update_data(new_hand_id, db_connection)
m.update_gui(new_hand_id)
hud_dict[table_name].update(new_hand_id, config, stat_dict) hud_dict[table_name].update(new_hand_id, config, stat_dict)
hud_dict[table_name].reposition_windows() hud_dict[table_name].reposition_windows()
return False return False
@ -114,7 +114,6 @@ def read_stdin(): # This is the thread function
is_tournament = False is_tournament = False
(tour_number, tab_number) = (0, 0) (tour_number, tab_number) = (0, 0)
mat_obj = tourny_finder.search(table_name) mat_obj = tourny_finder.search(table_name)
# if len(mat_obj.groups) == 2:
if mat_obj: if mat_obj:
is_tournament = True is_tournament = True
(tour_number, tab_number) = mat_obj.group(1, 2) (tour_number, tab_number) = mat_obj.group(1, 2)
@ -125,11 +124,13 @@ def read_stdin(): # This is the thread function
if hud_dict.has_key(table_name): if hud_dict.has_key(table_name):
# update the data for the aux_windows # update the data for the aux_windows
for aw in hud_dict[table_name].aux_windows: for aw in hud_dict[table_name].aux_windows:
aw.update_data(new_hand_id) aw.update_data(new_hand_id, db_connection)
update_HUD(new_hand_id, table_name, config, stat_dict) update_HUD(new_hand_id, table_name, config, stat_dict)
# if a hud for this TOURNAMENT table exists, just update it # if a hud for this TOURNAMENT table exists, just update it
elif hud_dict.has_key(tour_number): elif hud_dict.has_key(tour_number):
update_HUD(new_hand_id, tour_number, config, stat_dict) update_HUD(new_hand_id, tour_number, config, stat_dict)
# otherwise create a new hud # otherwise create a new hud
else: else:
if is_tournament: if is_tournament:

View File

@ -204,25 +204,62 @@ Card ranks will be uppercased
print "DEBUG %s calls %s, stack %s" % (player, amount, self.stacks[player]) print "DEBUG %s calls %s, stack %s" % (player, amount, self.stacks[player])
self.actions[street] += [(player, 'calls', amount, self.stacks[player]==0)] self.actions[street] += [(player, 'calls', amount, self.stacks[player]==0)]
def addRaiseBy(self, street, player, amountBy):
"""\
Add a raise by amountBy on [street] by [player]
"""
#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
# (which is the sum of self.bets[street][player])
# and how much he needs to call to match the previous player
# (which is tracked by self.lastBet)
# let Bp = previous bet
# Bc = amount player has committed so far
# Rb = raise by
# then: C = Bp - Bc (amount to call)
# Rt = Bp + Rb (raise to)
#
self.checkPlayerExists(player)
Rb = Decimal(amountBy)
Bp = self.lastBet[street]
Bc = reduce(operator.add, self.bets[street][player], 0)
C = Bp - Bc
Rt = Bp + Rb
self.bets[street][player].append(C + Rb)
self.stacks[player] -= (C + Rb)
self.actions[street] += [(player, 'raises', Rb, Rt, C, self.stacks[player]==0)]
self.lastBet[street] = Rt
def addCallandRaise(self, street, player, amount):
"""\
For sites which by "raises x" mean "calls and raises putting a total of x in the por". """
self.checkPlayerExists(player)
CRb = Decimal(amount)
Bp = self.lastBet[street]
Bc = reduce(operator.add, self.bets[street][player], 0)
C = Bp - Bc
Rb = CRb - C
Rt = Bp + Rb
self._addRaise(street, player, C, Rb, Rt)
def _addRaise(self, street, player, C, Rb, Rt):
self.bets[street][player].append(C + Rb)
self.stacks[player] -= (C + Rb)
self.actions[street] += [(player, 'raises', Rb, Rt, C, self.stacks[player]==0)]
self.lastBet[street] = Rt
def addRaiseTo(self, street, player, amountTo): def addRaiseTo(self, street, player, amountTo):
"""\ """\
Add a raise on [street] by [player] to [amountTo] Add a raise on [street] by [player] to [amountTo]
""" """
#Given only the amount raised to, the amount of the raise can be calculated by
# working out how much this player has already in the pot
# (which is the sum of self.bets[street][player])
# and how much he needs to call to match the previous player
# (which is tracked by self.lastBet)
self.checkPlayerExists(player) self.checkPlayerExists(player)
committedThisStreet = reduce(operator.add, self.bets[street][player], 0) Bc = reduce(operator.add, self.bets[street][player], 0)
amountToCall = self.lastBet[street] - committedThisStreet Rt = Decimal(amountTo)
self.lastBet[street] = Decimal(amountTo) C = Bp - Bc
amountBy = Decimal(amountTo) - amountToCall Rb = Rt - C
self.bets[street][player].append(amountBy+amountToCall) self._addRaise(street, player, C, Rb, Rt)
self.stacks[player] -= (Decimal(amountBy)+Decimal(amountToCall))
print "DEBUG %s stack %s" % (player, self.stacks[player])
self.actions[street] += [(player, 'raises', amountBy, amountTo, amountToCall, self.stacks[player]==0)]
def addBet(self, street, player, amount): def addBet(self, street, player, amount):
@ -259,11 +296,8 @@ Add a raise on [street] by [player] to [amountTo]
if self.totalpot is None: if self.totalpot is None:
self.totalpot = 0 self.totalpot = 0
# player names:
# print [x[1] for x in self.players]
for player in [x[1] for x in self.players]: for player in [x[1] for x in self.players]:
for street in self.streetList: for street in self.streetList:
#print street, self.bets[street][player]
self.totalpot += reduce(operator.add, self.bets[street][player], 0) self.totalpot += reduce(operator.add, self.bets[street][player], 0)
print "DEBUG conventional totalpot:", self.totalpot print "DEBUG conventional totalpot:", self.totalpot
@ -271,7 +305,13 @@ Add a raise on [street] by [player] to [amountTo]
self.totalpot = 0 self.totalpot = 0
for street in self.actions: players_who_act_preflop = set([x[0] for x in self.actions['PREFLOP']])
self.pot = Pot(players_who_act_preflop)
# this can now be pruned substantially if Pot is working.
#for street in self.actions:
for street in [x for x in self.streetList if x in self.actions]:
uncalled = 0 uncalled = 0
calls = [0] calls = [0]
for act in self.actions[street]: for act in self.actions[street]:
@ -280,18 +320,30 @@ Add a raise on [street] by [player] to [amountTo]
uncalled = Decimal(act[2]) # only the last bet or raise can be uncalled uncalled = Decimal(act[2]) # only the last bet or raise can be uncalled
calls = [0] calls = [0]
print "uncalled: ", uncalled print "uncalled: ", uncalled
self.pot.addMoney(act[0], Decimal(act[2]))
elif act[1] == 'raises': # [name, 'raises', amountby, amountto, amountcalled] elif act[1] == 'raises': # [name, 'raises', amountby, amountto, amountcalled]
print "calls %s and raises %s to %s" % (act[4],act[2],act[3]) print "calls %s and raises %s to %s" % (act[4],act[2],act[3])
self.totalpot += Decimal(act[2]) + Decimal(act[4]) self.totalpot += Decimal(act[2]) + Decimal(act[4])
calls = [0] calls = [0]
uncalled = Decimal(act[2]) uncalled = Decimal(act[2])
print "uncalled: ", uncalled print "uncalled: ", uncalled
self.pot.addMoney(act[0], Decimal(act[2])+Decimal(act[4]))
elif act[1] == 'calls': # [name, 'calls', amount] elif act[1] == 'calls': # [name, 'calls', amount]
self.totalpot += Decimal(act[2]) self.totalpot += Decimal(act[2])
calls = calls + [Decimal(act[2])] calls = calls + [Decimal(act[2])]
print "calls:", calls print "calls:", calls
self.pot.addMoney(act[0], Decimal(act[2]))
elif act[1] == 'posts': elif act[1] == 'posts':
self.totalpot += Decimal(act[3]) self.totalpot += Decimal(act[3])
self.pot.addMoney(act[0], Decimal(act[3]))
if act[2] == 'big blind': if act[2] == 'big blind':
# the bb gets called by out-of-blinds posts; but sb+bb only calls bb # the bb gets called by out-of-blinds posts; but sb+bb only calls bb
if uncalled == Decimal(act[3]): # a bb is already posted if uncalled == Decimal(act[3]): # a bb is already posted
@ -306,14 +358,15 @@ Add a raise on [street] by [player] to [amountTo]
uncalled = Decimal(act[3]) uncalled = Decimal(act[3])
calls = [0] calls = [0]
pass pass
elif act[1] == 'folds':
self.pot.addFold(act[0])
if uncalled > 0 and max(calls+[0]) < uncalled: if uncalled > 0 and max(calls+[0]) < uncalled:
print "DEBUG returning some bet, calls:", calls print "DEBUG returning some bet, calls:", calls
print "DEBUG returned: %.2f from %.2f" % ((uncalled - max(calls)), self.totalpot,) print "DEBUG returned: %.2f from %.2f" % ((uncalled - max(calls)), self.totalpot,)
self.totalpot -= (uncalled - max(calls)) self.totalpot -= (uncalled - max(calls))
print "DEBUG new totalpot:", self.totalpot print "DEBUG new totalpot:", self.totalpot
print "DEBUG new Pot.total:", self.pot
if self.totalcollected is None: if self.totalcollected is None:
self.totalcollected = 0; self.totalcollected = 0;
@ -358,9 +411,7 @@ Map the tuple self.gametype onto the pokerstars string describing it
print >>fh, _("Table '%s' %d-max Seat #%s is the button" %(self.tablename, self.maxseats, self.buttonpos)) print >>fh, _("Table '%s' %d-max Seat #%s is the button" %(self.tablename, self.maxseats, self.buttonpos))
players_who_act_preflop = set([x[0] for x in self.actions['PREFLOP']]) players_who_act_preflop = set([x[0] for x in self.actions['PREFLOP']])
#print players_who_act_preflop
#print [x[1] for x in self.players]
#print [x for x in self.players if x[1] in players_who_act_preflop]
for player in [x for x in self.players if x[1] in players_who_act_preflop]: for player in [x for x in self.players if x[1] in players_who_act_preflop]:
#Only print stacks of players who do something preflop #Only print stacks of players who do something preflop
print >>fh, _("Seat %s: %s ($%s)" %(player[0], player[1], player[2])) print >>fh, _("Seat %s: %s ($%s)" %(player[0], player[1], player[2]))
@ -409,7 +460,8 @@ Map the tuple self.gametype onto the pokerstars string describing it
print >>fh, "DEBUG: what do they show" print >>fh, "DEBUG: what do they show"
print >>fh, _("*** SUMMARY ***") print >>fh, _("*** SUMMARY ***")
print >>fh, _("Total pot $%s | Rake $%.2f" % (self.totalpot, self.rake)) # TODO: side pots print >>fh, "%s | Rake $%.2f" % (self.pot, self.rake)
#print >>fh, _("Total pot $%s | Rake $%.2f" % (self.totalpot, self.rake)) # TODO: side pots
board = [] board = []
for s in self.board.values(): for s in self.board.values():
@ -468,10 +520,6 @@ Map the tuple self.gametype onto the pokerstars string describing it
def bestHand(self, side, cards): def bestHand(self, side, cards):
return HandHistoryConverter.eval.best('hi', cards, []) return HandHistoryConverter.eval.best('hi', cards, [])
# from pokergame.py
def bestHandValue(self, side, serial):
(value, cards) = self.bestHand(side, serial)
return value
# from pokergame.py # from pokergame.py
# got rid of the _ for internationalisation # got rid of the _ for internationalisation
@ -507,3 +555,61 @@ Map the tuple self.gametype onto the pokerstars string describing it
class FpdbParseError(Exception): pass class FpdbParseError(Exception): pass
class Pot(object):
def __init__(self, contenders):
self.contenders = contenders
self.committed = dict([(player,Decimal(0)) for player in contenders])
self.total = Decimal(0)
def addFold(self, player):
self.contenders.remove(player)
def addMoney(self, player, amount):
self.committed[player] += amount
def __str__(self):
self.total = sum(self.committed.values())
committed = sorted([ (v,k) for (k,v) in self.committed.items()])
lastbet = committed[-1][0] - committed[-2][0]
if lastbet > 0: # uncalled
returnto = committed[-1][1]
#print "returning %f to %s" % (lastbet, returnto)
self.total -= lastbet
self.committed[returnto] -= lastbet
# now: for those contenders still contending..
commitsall = sorted([(v,k) for (k,v) in self.committed.items() if v >0])
pots = []
while len(commitsall) > 0:
commitslive = [(v,k) for (v,k) in commitsall if k in self.contenders]
v1 = commitslive[0][0]
pots += [sum([min(v,v1) for (v,k) in commitsall])]
#print "all: ", commitsall
#print "live:", commitslive
commitsall = [((v-v1),k) for (v,k) in commitsall if v-v1 >0]
#print "[**]", pots
# TODO: I think rake gets taken out of the pots.
# so it goes:
# total pot x. main pot y, side pot z. | rake r
# and y+z+r = x
# for example:
# Total pot $124.30 Main pot $98.90. Side pot $23.40. | Rake $2
# so....... that's tricky.
if len(pots) == 1: # (only use Total pot)
#return "Main pot $%.2f." % pots[0]
return "Total pot $%.2f" % (self.total,)
elif len(pots) == 2:
return "Total pot $%.2f Main pot $%.2f. Side pot $%2.f." % (self.total, pots[0],pots[1])
elif len(pots) == 3:
return "Total pot $%.2f Main pot $%.2f. Side pot-1 $%2.f. Side pot-2 $.2f." % (self.total, pots[0],pots[1],pots[2])
else:
return "too many pots.. fix me.", pots

View File

@ -47,12 +47,12 @@ import HUD_main
class Hud: class Hud:
def __init__(self, table, max, poker_game, config, db_name): def __init__(self, table, max, poker_game, config, db_connection):
self.table = table self.table = table
self.config = config self.config = config
self.poker_game = poker_game self.poker_game = poker_game
self.max = max self.max = max
self.db_name = db_name self.db_connection = db_connection
self.deleted = False self.deleted = False
self.stacked = True self.stacked = True
self.site = table.site self.site = table.site
@ -61,7 +61,13 @@ class Hud:
self.stat_windows = {} self.stat_windows = {}
self.popup_windows = {} self.popup_windows = {}
self.aux_windows = [] self.aux_windows = []
(font, font_size) = config.get_default_font(self.table.site)
print "font = ", font, "size = ", font_size
if font == None or font_size == None:
self.font = pango.FontDescription("Sans 7") self.font = pango.FontDescription("Sans 7")
else:
print "Setting font to ", font + " " + font_size
self.font = pango.FontDescription(font + " " + font_size)
# Set up a main window for this this instance of the HUD # Set up a main window for this this instance of the HUD
self.main_window = gtk.Window() self.main_window = gtk.Window()
@ -184,9 +190,9 @@ class Hud:
try: try:
if int(config.supported_sites[self.table.site].layout[self.max].fav_seat) > 0: if int(config.supported_sites[self.table.site].layout[self.max].fav_seat) > 0:
fav_seat = config.supported_sites[self.table.site].layout[self.max].fav_seat fav_seat = config.supported_sites[self.table.site].layout[self.max].fav_seat
db_connection = Database.Database(config, self.db_name, 'temp') # db_connection = Database.Database(config, self.db_name, 'temp')
actual_seat = db_connection.get_actual_seat(hand, config.supported_sites[self.table.site].screen_name) actual_seat = self.db_connection.get_actual_seat(hand, config.supported_sites[self.table.site].screen_name)
db_connection.close_connection() # db_connection.close_connection()
for i in range(0, self.max + 1): for i in range(0, self.max + 1):
j = actual_seat + i j = actual_seat + i
if j > self.max: j = j - self.max if j > self.max: j = j - self.max
@ -234,7 +240,7 @@ class Hud:
game_params = config.get_game_parameters(self.poker_game) game_params = config.get_game_parameters(self.poker_game)
if not game_params['aux'] == "": if not game_params['aux'] == "":
aux_params = config.get_aux_parameters(game_params['aux']) aux_params = config.get_aux_parameters(game_params['aux'])
self.aux_windows.append(eval("%s.%s(gtk.Window(), self, config, 'fpdb')" % (aux_params['module'], aux_params['class']))) self.aux_windows.append(eval("%s.%s(gtk.Window(), self, config, aux_params)" % (aux_params['module'], aux_params['class'])))
if os.name == "nt": if os.name == "nt":
gobject.timeout_add(500, self.update_table_position) gobject.timeout_add(500, self.update_table_position)
@ -410,7 +416,7 @@ class Stat_Window:
self.e_box[r][c].add(self.label[r][c]) self.e_box[r][c].add(self.label[r][c])
self.e_box[r][c].connect("button_press_event", self.button_press_cb) self.e_box[r][c].connect("button_press_event", self.button_press_cb)
font = pango.FontDescription("Sans 7") # font = pango.FontDescription(self.font)
self.label[r][c].modify_font(font) self.label[r][c].modify_font(font)
self.window.set_opacity(parent.colors['hudopacity']) self.window.set_opacity(parent.colors['hudopacity'])
@ -479,12 +485,12 @@ class Popup_window:
break break
# get a database connection # get a database connection
db_connection = Database.Database(stat_window.parent.config, stat_window.parent.db_name, 'temp') # db_connection = Database.Database(stat_window.parent.config, stat_window.parent.db_name, 'temp')
# calculate the stat_dict and then create the text for the pu # calculate the stat_dict and then create the text for the pu
# stat_dict = db_connection.get_stats_from_hand(stat_window.parent.hand, stat_window.player_id) # stat_dict = db_connection.get_stats_from_hand(stat_window.parent.hand, stat_window.player_id)
stat_dict = db_connection.get_stats_from_hand(stat_window.parent.hand) stat_dict = self.db_connection.get_stats_from_hand(stat_window.parent.hand)
db_connection.close_connection() # db_connection.close_connection()
pu_text = "" pu_text = ""
for s in stat_list: for s in stat_list:

View File

@ -36,14 +36,13 @@ import Configuration
import Database import Database
class Aux_Window: class Aux_Window:
def __init__(self, parent, hud, config, db_name): def __init__(self, container, hud, params, config):
self.config = hud self.config = hud
self.config = config self.config = config
self.parent = parent self.container = container
self.db_name = db_name
self.vbox = gtk.VBox() self.vbox = gtk.VBox()
self.parent.add(self.vbox) self.container.add(self.vbox)
def update_data(self): def update_data(self):
pass pass
@ -52,40 +51,49 @@ class Aux_Window:
pass pass
class Stud_mucked(Aux_Window): class Stud_mucked(Aux_Window):
def __init__(self, parent, hud, config, db_name): def __init__(self, container, hud, config, params):
self.hud = hud # hud object that this aux window supports self.hud = hud # hud object that this aux window supports
self.config = config # configuration object for this aux window to use self.config = config # configuration object for this aux window to use
self.parent = parent # parent container for this aux window widget self.container = container # parent container for this aux window widget
self.db_name = db_name # database for this aux window to use self.params = params # hash aux params from config
try:
site_params = self.config.get_site_parameters(self.hud.site)
self.hero = site_params['screen_name']
except:
self.hero = ''
self.vbox = gtk.VBox() self.vbox = gtk.VBox()
self.parent.add(self.vbox) self.container.add(self.vbox)
self.mucked_list = Stud_list(self.vbox, config, db_name) self.mucked_list = Stud_list(self.vbox, self, params, config, self.hero)
self.mucked_cards = Stud_cards(self.vbox, config, db_name) self.mucked_cards = Stud_cards(self.vbox, self, params, config)
self.mucked_list.mucked_cards = self.mucked_cards self.mucked_list.mucked_cards = self.mucked_cards
self.parent.show_all() self.container.show_all()
def update_data(self, new_hand_id): def update_data(self, new_hand_id, db_connection):
self.mucked_cards.update_data(new_hand_id) self.mucked_cards.update_data(new_hand_id, db_connection)
self.mucked_list.update_data(new_hand_id) self.mucked_list.update_data(new_hand_id, db_connection)
def update_gui(self, new_hand_id): def update_gui(self, new_hand_id):
self.mucked_cards.update_gui(new_hand_id) self.mucked_cards.update_gui(new_hand_id)
self.mucked_list.update_gui(new_hand_id) self.mucked_list.update_gui(new_hand_id)
class Stud_list: class Stud_list:
def __init__(self, parent, config, db_name): def __init__(self, container, parent, params, config, hero):
self.container = container
self.parent = parent self.parent = parent
self.params = params
self.config = config self.config = config
self.db_name = db_name self.hero = hero
# self.db_name = db_name
# set up a scrolled window to hold the listbox # set up a scrolled window to hold the listbox
self.scrolled_window = gtk.ScrolledWindow() self.scrolled_window = gtk.ScrolledWindow()
self.scrolled_window.set_policy(gtk.POLICY_NEVER, gtk.POLICY_ALWAYS) self.scrolled_window.set_policy(gtk.POLICY_NEVER, gtk.POLICY_ALWAYS)
self.parent.add(self.scrolled_window) self.container.add(self.scrolled_window)
# create a ListStore to use as the model # create a ListStore to use as the model
self.liststore = gtk.ListStore(str, str, str, str) self.liststore = gtk.ListStore(str, str, str, str)
@ -123,17 +131,17 @@ class Stud_list:
self.scrolled_window.add_with_viewport(self.treeview) self.scrolled_window.add_with_viewport(self.treeview)
def activated_event(self, path, column, data=None): def activated_event(self, path, column, data=None):
sel = self.treeview.get_selection() pass
(model, iter) = sel.get_selected() # sel = self.treeview.get_selection()
self.mucked_cards.update_data(model.get_value(iter, 0)) # (model, iter) = sel.get_selected()
self.mucked_cards.update_gui(model.get_value(iter, 0)) # self.mucked_cards.update_data(model.get_value(iter, 0))
# self.mucked_cards.update_gui(model.get_value(iter, 0))
def update_data(self, new_hand_id): def update_data(self, new_hand_id, db_connection):
"""Updates the data needed for the list box.""" """Updates the data needed for the list box."""
db_connection = Database.Database(self.config, 'fpdb', '') # db_connection = Database.Database(self.config, 'fpdb', '')
self.winners = db_connection.get_winners_from_hand(new_hand_id) self.winners = db_connection.get_winners_from_hand(new_hand_id)
db_connection.close_connection()
pot = 0 pot = 0
winners = '' winners = ''
for player in self.winners.keys(): for player in self.winners.keys():
@ -143,7 +151,21 @@ class Stud_list:
winners = winners + player winners = winners + player
pot_dec = "%.2f" % (float(pot)/100) pot_dec = "%.2f" % (float(pot)/100)
self.info_row = ((new_hand_id, "xxxx", pot_dec, winners), ) hero_cards = self.get_hero_cards(self.parent.hero, self.parent.mucked_cards.cards)
self.info_row = ((new_hand_id, hero_cards, pot_dec, winners), )
def get_hero_cards(self, hero, cards):
"""Formats the hero cards for inclusion in the tree."""
trans = ('0', 'A', '2', '3', '4', '5', '6', '7', '8', '9', 'T', 'J', 'Q', 'K', 'A')
if hero == '':
return "xxxxxx"
else:
for k in cards.keys():
if cards[k]['screen_name'] == hero:
return trans[cards[k]['card1Value']] + cards[k]['card1Suit'] \
+ trans[cards[k]['card2Value']] + cards[k]['card2Suit'] \
+ trans[cards[k]['card3Value']] + cards[k]['card3Suit']
return "xxxxxx"
def update_gui(self, new_hand_id): def update_gui(self, new_hand_id):
iter = self.liststore.append(self.info_row[0]) iter = self.liststore.append(self.info_row[0])
@ -154,11 +176,13 @@ class Stud_list:
vadj.set_value(vadj.upper) vadj.set_value(vadj.upper)
class Stud_cards: class Stud_cards:
def __init__(self, parent, config, db_name = 'fpdb'): def __init__(self, container, parent, params, config):
self.parent = parent #this is the parent of the mucked cards widget self.container = container #this is the parent container of the mucked cards widget
self.parent = parent
self.params = params
self.config = config self.config = config
self.db_name = db_name # self.db_name = db_name
self.card_images = self.get_card_images() self.card_images = self.get_card_images()
self.seen_cards = {} self.seen_cards = {}
@ -196,7 +220,7 @@ class Stud_cards:
for r in range(0, self.rows): for r in range(0, self.rows):
self.grid.attach(self.grid_contents[(c, r)], c, c+1, r, r+1, xpadding = 1, ypadding = 1) self.grid.attach(self.grid_contents[(c, r)], c, c+1, r, r+1, xpadding = 1, ypadding = 1)
self.parent.add(self.grid) self.container.add(self.grid)
def translate_cards(self, old_cards): def translate_cards(self, old_cards):
ranks = ('', '', '2', '3', '4', '5', '6', '7', '8', '9', 'T', 'J', 'Q', 'K', 'A') ranks = ('', '', '2', '3', '4', '5', '6', '7', '8', '9', 'T', 'J', 'Q', 'K', 'A')
@ -212,10 +236,9 @@ class Stud_cards:
old_cards[c][key] = ranks[old_cards[c][rank]] + old_cards[c][suit] old_cards[c][key] = ranks[old_cards[c][rank]] + old_cards[c][suit]
return old_cards return old_cards
def update_data(self, new_hand_id): def update_data(self, new_hand_id, db_connection):
db_connection = Database.Database(self.config, 'fpdb', '') # db_connection = Database.Database(self.config, 'fpdb', '')
cards = db_connection.get_cards(new_hand_id) cards = db_connection.get_cards(new_hand_id)
self.clear()
self.cards = self.translate_cards(cards) self.cards = self.translate_cards(cards)
self.tips = [] self.tips = []
@ -232,9 +255,9 @@ class Stud_cards:
else: else:
temp = temp + "\n" temp = temp + "\n"
self.tips.append(temp) self.tips.append(temp)
db_connection.close_connection()
def update_gui(self, new_hand_id): def update_gui(self, new_hand_id):
self.clear()
for c in self.cards.keys(): for c in self.cards.keys():
self.grid_contents[(1, self.cards[c]['seat_number'] - 1)].set_text(self.cards[c]['screen_name']) self.grid_contents[(1, self.cards[c]['seat_number'] - 1)].set_text(self.cards[c]['screen_name'])
for i in ((0, 'hole_card_1'), (1, 'hole_card_2'), (2, 'hole_card_3'), (3, 'hole_card_4'), for i in ((0, 'hole_card_1'), (1, 'hole_card_2'), (2, 'hole_card_3'), (3, 'hole_card_4'),
@ -262,11 +285,12 @@ class Stud_cards:
for c in range(0, 7): for c in range(0, 7):
self.seen_cards[(c, r)].set_from_pixbuf(self.card_images[('B', 'S')]) self.seen_cards[(c, r)].set_from_pixbuf(self.card_images[('B', 'S')])
self.eb[(c, r)].set_tooltip_text('') self.eb[(c, r)].set_tooltip_text('')
def get_card_images(self): def get_card_images(self):
card_images = {} card_images = {}
suits = ('S', 'H', 'D', 'C') suits = ('S', 'H', 'D', 'C')
ranks = ('A', 'K', 'Q', 'J', 'T', '9', '8', '7', '6', '5', '4', '3', '2', 'B') ranks = ('A', 'K', 'Q', 'J', 'T', '9', '8', '7', '6', '5', '4', '3', '2', 'B')
pb = gtk.gdk.pixbuf_new_from_file(self.config.execution_path("54PFozzycards0.png")) pb = gtk.gdk.pixbuf_new_from_file(self.config.execution_path(self.params['deck']))
for j in range(0, 14): for j in range(0, 14):
for i in range(0, 4): for i in range(0, 4):
@ -282,24 +306,24 @@ if __name__== "__main__":
def destroy(*args): # call back for terminating the main eventloop def destroy(*args): # call back for terminating the main eventloop
gtk.main_quit() # used only for testing gtk.main_quit() # used only for testing
def process_new_hand(source, condition): #callback from stdin watch -- testing only def process_new_hand(source, condition, db_connection): #callback from stdin watch -- testing only
# there is a new hand_id to be processed # there is a new hand_id to be processed
# just read it and pass it to update # just read it and pass it to update
new_hand_id = sys.stdin.readline() new_hand_id = sys.stdin.readline()
new_hand_id = new_hand_id.rstrip() # remove trailing whitespace new_hand_id = new_hand_id.rstrip() # remove trailing whitespace
m.update_data(new_hand_id) m.update_data(new_hand_id, db_connection)
m.update_gui(new_hand_id) m.update_gui(new_hand_id)
return(True) return(True)
config = Configuration.Config() config = Configuration.Config()
# db_connection = Database.Database(config, 'fpdb', '') db_connection = Database.Database(config, 'fpdb', '')
main_window = gtk.Window() main_window = gtk.Window()
main_window.set_keep_above(True) main_window.set_keep_above(True)
main_window.connect("destroy", destroy) main_window.connect("destroy", destroy)
aux_to_call = "Stud_mucked" aux_to_call = "stud_mucked"
m = eval("%s(main_window, None, config, 'fpdb')" % aux_to_call) aux_params = config.get_aux_parameters(aux_to_call)
main_window.show_all() m = eval("%s(main_window, None, config, aux_params)" % aux_params['class'])
s_id = gobject.io_add_watch(sys.stdin, gobject.IO_IN, process_new_hand) s_id = gobject.io_add_watch(sys.stdin, gobject.IO_IN, process_new_hand, db_connection)
gtk.main() gtk.main()

View File

@ -196,6 +196,7 @@ class fpdb_db:
self.cursor.execute("INSERT INTO Settings VALUES (118);") self.cursor.execute("INSERT INTO Settings VALUES (118);")
self.cursor.execute("INSERT INTO Sites VALUES (DEFAULT, 'Full Tilt Poker', 'USD');") self.cursor.execute("INSERT INTO Sites VALUES (DEFAULT, 'Full Tilt Poker', 'USD');")
self.cursor.execute("INSERT INTO Sites VALUES (DEFAULT, 'PokerStars', 'USD');") self.cursor.execute("INSERT INTO Sites VALUES (DEFAULT, 'PokerStars', 'USD');")
self.cursor.execute("INSERT INTO Sites VALUES (DEFAULT, 'Everleaf', 'USD');")
self.cursor.execute("INSERT INTO TourneyTypes VALUES (DEFAULT, 1, 0, 0, 0, False);") self.cursor.execute("INSERT INTO TourneyTypes VALUES (DEFAULT, 1, 0, 0, 0, False);")
#end def fillDefaultData #end def fillDefaultData

View File

@ -1170,14 +1170,16 @@ def parseHandStartTime(topline, site):
tmp=topline[pos1:pos2] tmp=topline[pos1:pos2]
isUTC=True isUTC=True
else: else:
tmp=topline[-30:] tmp=topline
#print "parsehandStartTime, tmp:", tmp #print "parsehandStartTime, tmp:", tmp
pos = tmp.find("-")+2 pos = tmp.find("-")+2
tmp = tmp[pos:] tmp = tmp[pos:]
#Need to match either #Need to match either
# 2008/09/07 06:23:14 ET or # 2008/09/07 06:23:14 ET or
# 2008/08/17 - 01:14:43 (ET) # 2008/08/17 - 01:14:43 (ET) or
m = re.match('(?P<YEAR>[0-9]{4})\/(?P<MON>[0-9]{2})\/(?P<DAY>[0-9]{2})[\- ]+(?P<HR>[0-9]{2}):(?P<MIN>[0-9]{2}):(?P<SEC>[0-9]{2})',tmp) # 2008/11/12 9:33:31 CET [2008/11/12 3:33:31 ET]
rexx = '(?P<YEAR>[0-9]{4})\/(?P<MON>[0-9]{2})\/(?P<DAY>[0-9]{2})[\- ]+(?P<HR>[0-9]+):(?P<MIN>[0-9]+):(?P<SEC>[0-9]+)'
m = re.search(rexx,tmp)
#print "year:", int(m.group('YEAR')), "month", int(m.group('MON')), "day", int(m.group('DAY')), "hour", int(m.group('HR')), "minute", int(m.group('MIN')), "second", int(m.group('SEC')) #print "year:", int(m.group('YEAR')), "month", int(m.group('MON')), "day", int(m.group('DAY')), "hour", int(m.group('HR')), "minute", int(m.group('MIN')), "second", int(m.group('SEC'))
result = datetime.datetime(int(m.group('YEAR')), int(m.group('MON')), int(m.group('DAY')), int(m.group('HR')), int(m.group('MIN')), int(m.group('SEC'))) result = datetime.datetime(int(m.group('YEAR')), int(m.group('MON')), int(m.group('DAY')), int(m.group('HR')), int(m.group('MIN')), int(m.group('SEC')))
else: else:

Binary file not shown.