From c5bd036b6ed0e5e6ced1c9f4585590d6f0f5b712 Mon Sep 17 00:00:00 2001 From: steffen123 Date: Mon, 9 Aug 2010 23:22:58 +0200 Subject: [PATCH 01/10] add tourney viewer that displays info from TT and T, but not yet TP --- pyfpdb/Database.py | 14 +++++++ pyfpdb/GuiTourneyViewer.py | 86 ++++++++++++++++++++++++++++++++++++++ pyfpdb/SQL.py | 7 ++++ pyfpdb/fpdb.pyw | 9 ++++ 4 files changed, 116 insertions(+) create mode 100644 pyfpdb/GuiTourneyViewer.py diff --git a/pyfpdb/Database.py b/pyfpdb/Database.py index 7672d33c..90a464ba 100644 --- a/pyfpdb/Database.py +++ b/pyfpdb/Database.py @@ -2115,6 +2115,20 @@ class Database: result = c.fetchall() return result #end def getTourneyTypesIds + + def getTourneyInfo(self, siteName, tourneyNo): + c = self.get_cursor() + c.execute(self.sql.query['getTourneyInfo'], (siteName, tourneyNo)) + columnNames=c.description + #print "columnNames:",columnNames + + names=[] + for column in columnNames: + names.append(column[0]) + + data=c.fetchone() + return (names,data) + #end def getTourneyInfo #end class Database # Class used to hold all the data needed to write a hand to the db diff --git a/pyfpdb/GuiTourneyViewer.py b/pyfpdb/GuiTourneyViewer.py new file mode 100644 index 00000000..ab0bb38d --- /dev/null +++ b/pyfpdb/GuiTourneyViewer.py @@ -0,0 +1,86 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +#Copyright 2010 Steffen Schaumburg +#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 +#the Free Software Foundation, version 3 of the License. +# +#This program is distributed in the hope that it will be useful, +#but WITHOUT ANY WARRANTY; without even the implied warranty of +#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +#GNU General Public License for more details. +# +#You should have received a copy of the GNU Affero General Public License +#along with this program. If not, see . +#In the "official" distribution you can find the license in agpl-3.0.txt. + +import threading +import pygtk +pygtk.require('2.0') +import gtk + +class GuiTourneyViewer (threading.Thread): + def __init__(self, config, db, sql, mainwin, debug=True): + self.db = db + + self.mainVBox = gtk.VBox() + self.interfaceHBox = gtk.HBox() + self.mainVBox.pack_start(self.interfaceHBox, expand=False) + + self.siteBox = gtk.combo_box_new_text() + for site in config.supported_sites: + self.siteBox.append_text(site) + self.siteBox.set_active(0) + self.interfaceHBox.add(self.siteBox) + + label=gtk.Label("Enter the tourney number you want to display:") + self.interfaceHBox.add(label) + + self.entryBox = gtk.Entry() + self.interfaceHBox.add(self.entryBox) + + self.button = gtk.Button("_Display") + self.button.connect('clicked', self.displayClicked) + self.interfaceHBox.add(self.button) + + self.table = gtk.Table(columns=10, rows=9) + self.mainVBox.add(self.table) + + self.mainVBox.show_all() + #end def __init__ + + def displayClicked(self, widget, data=None): + tourneyNo=int(self.entryBox.get_text()) + siteName=self.siteBox.get_active_text() + + self.table.destroy() + self.table=gtk.Table(columns=10, rows=9) + self.mainVBox.add(self.table) + + result=self.db.getTourneyInfo(siteName, tourneyNo) + x=0 + y=0 + for i in range(1,len(result[0])): + if y==9: + x+=2 + y=0 + + label=gtk.Label(result[0][i]) + self.table.attach(label,x,x+1,y,y+1) + + if result[1][i]==None: + label=gtk.Label("N/A") + else: + label=gtk.Label(result[1][i]) + self.table.attach(label,x+1,x+2,y,y+1) + + y+=1 + self.mainVBox.show_all() + #def displayClicked + + def get_vbox(self): + """returns the vbox of this thread""" + return self.mainVBox + #end def get_vbox +#end class GuiTourneyViewer diff --git a/pyfpdb/SQL.py b/pyfpdb/SQL.py index 9b43241b..216d91cc 100644 --- a/pyfpdb/SQL.py +++ b/pyfpdb/SQL.py @@ -3812,6 +3812,13 @@ class Sql: WHERE tt.siteId=%s AND t.siteTourneyNo=%s """ + self.query['getTourneyInfo'] = """SELECT tt.*, t.* + FROM Tourneys t + INNER JOIN TourneyTypes tt ON (t.tourneyTypeId = tt.id) + INNER JOIN Sites s ON (tt.siteId = s.id) + WHERE s.name=%s AND t.siteTourneyNo=%s + """ + self.query['insertTourney'] = """INSERT INTO Tourneys (tourneyTypeId, siteTourneyNo, entries, prizepool, startTime, endTime, tourneyName, matrixIdProcessed, diff --git a/pyfpdb/fpdb.pyw b/pyfpdb/fpdb.pyw index 70986c3e..75faebf2 100755 --- a/pyfpdb/fpdb.pyw +++ b/pyfpdb/fpdb.pyw @@ -106,6 +106,7 @@ import GuiBulkImport import ImapFetcher import GuiRingPlayerStats import GuiTourneyPlayerStats +import GuiTourneyViewer import GuiPositionalStats import GuiAutoImport import GuiGraphViewer @@ -794,6 +795,7 @@ class fpdb: + @@ -833,6 +835,7 @@ class fpdb: ('graphs', None, '_Graphs', 'G', 'Graphs', self.tabGraphViewer), ('ringplayerstats', None, 'Ring _Player Stats (tabulated view)', 'P', 'Ring Player Stats (tabulated view)', self.tab_ring_player_stats), ('tourneyplayerstats', None, '_Tourney Player Stats (tabulated view, mysql only)', 'T', 'Tourney Player Stats (tabulated view, mysql only)', self.tab_tourney_player_stats), + ('tourneyviewer', None, 'Tourney _Viewer', None, 'Tourney Viewer)', self.tab_tourney_viewer_stats), ('posnstats', None, 'P_ositional Stats (tabulated view)', 'O', 'Positional Stats (tabulated view)', self.tab_positional_stats), ('sessionstats', None, 'Session Stats', None, 'Session Stats', self.tab_session_stats), ('database', None, '_Database'), @@ -1033,6 +1036,12 @@ class fpdb: ps_tab=new_ps_thread.get_vbox() self.add_and_display_tab(ps_tab, "Tourney Player Stats") + def tab_tourney_viewer_stats(self, widget, data=None): + new_thread = GuiTourneyViewer.GuiTourneyViewer(self.config, self.db, self.sql, self.window) + self.threads.append(new_thread) + tab=new_thread.get_vbox() + self.add_and_display_tab(tab, "Tourney Viewer") + def tab_positional_stats(self, widget, data=None): new_ps_thread = GuiPositionalStats.GuiPositionalStats(self.config, self.sql) self.threads.append(new_ps_thread) From bb743b45677e74c60a70f7a49c86766278ba69e8 Mon Sep 17 00:00:00 2001 From: steffen123 Date: Mon, 9 Aug 2010 23:41:48 +0200 Subject: [PATCH 02/10] add button to display info from TP to tourneyviewer --- pyfpdb/Database.py | 14 ++++++++++- pyfpdb/GuiTourneyViewer.py | 51 ++++++++++++++++++++++++++++++++------ pyfpdb/SQL.py | 9 +++++++ 3 files changed, 66 insertions(+), 8 deletions(-) diff --git a/pyfpdb/Database.py b/pyfpdb/Database.py index 90a464ba..6b902921 100644 --- a/pyfpdb/Database.py +++ b/pyfpdb/Database.py @@ -2120,7 +2120,6 @@ class Database: c = self.get_cursor() c.execute(self.sql.query['getTourneyInfo'], (siteName, tourneyNo)) columnNames=c.description - #print "columnNames:",columnNames names=[] for column in columnNames: @@ -2129,6 +2128,19 @@ class Database: data=c.fetchone() return (names,data) #end def getTourneyInfo + + def getTourneyPlayerInfo(self, siteName, tourneyNo, playerName): + c = self.get_cursor() + c.execute(self.sql.query['getTourneyPlayerInfo'], (siteName, tourneyNo, playerName)) + columnNames=c.description + + names=[] + for column in columnNames: + names.append(column[0]) + + data=c.fetchone() + return (names,data) + #end def getTourneyPlayerInfo #end class Database # Class used to hold all the data needed to write a hand to the db diff --git a/pyfpdb/GuiTourneyViewer.py b/pyfpdb/GuiTourneyViewer.py index ab0bb38d..1499e8a6 100644 --- a/pyfpdb/GuiTourneyViewer.py +++ b/pyfpdb/GuiTourneyViewer.py @@ -37,21 +37,28 @@ class GuiTourneyViewer (threading.Thread): label=gtk.Label("Enter the tourney number you want to display:") self.interfaceHBox.add(label) - self.entryBox = gtk.Entry() - self.interfaceHBox.add(self.entryBox) + self.entryTourney = gtk.Entry() + self.interfaceHBox.add(self.entryTourney) - self.button = gtk.Button("_Display") - self.button.connect('clicked', self.displayClicked) - self.interfaceHBox.add(self.button) + self.displayButton = gtk.Button("_Display") + self.displayButton.connect('clicked', self.displayClicked) + self.interfaceHBox.add(self.displayButton) + + self.entryPlayer = gtk.Entry() + self.interfaceHBox.add(self.entryPlayer) + + self.playerButton = gtk.Button("Display _Player") + self.playerButton.connect('clicked', self.displayPlayerClicked) + self.interfaceHBox.add(self.playerButton) self.table = gtk.Table(columns=10, rows=9) self.mainVBox.add(self.table) - + self.mainVBox.show_all() #end def __init__ def displayClicked(self, widget, data=None): - tourneyNo=int(self.entryBox.get_text()) + tourneyNo=int(self.entryTourney.get_text()) siteName=self.siteBox.get_active_text() self.table.destroy() @@ -79,6 +86,36 @@ class GuiTourneyViewer (threading.Thread): self.mainVBox.show_all() #def displayClicked + def displayPlayerClicked(self, widget, data=None): + tourneyNo=int(self.entryTourney.get_text()) + siteName=self.siteBox.get_active_text() + playerName=self.entryPlayer.get_text() + + self.table.destroy() + self.table=gtk.Table(columns=4, rows=5) + self.mainVBox.add(self.table) + + result=self.db.getTourneyPlayerInfo(siteName, tourneyNo, playerName) + x=0 + y=0 + for i in range(1,len(result[0])): + if y==5: + x+=2 + y=0 + + label=gtk.Label(result[0][i]) + self.table.attach(label,x,x+1,y,y+1) + + if result[1][i]==None: + label=gtk.Label("N/A") + else: + label=gtk.Label(result[1][i]) + self.table.attach(label,x+1,x+2,y,y+1) + + y+=1 + self.mainVBox.show_all() + #def displayPlayerClicked + def get_vbox(self): """returns the vbox of this thread""" return self.mainVBox diff --git a/pyfpdb/SQL.py b/pyfpdb/SQL.py index 216d91cc..69d74fbe 100644 --- a/pyfpdb/SQL.py +++ b/pyfpdb/SQL.py @@ -3819,6 +3819,15 @@ class Sql: WHERE s.name=%s AND t.siteTourneyNo=%s """ + self.query['getTourneyPlayerInfo'] = """SELECT tp.* + FROM Tourneys t + INNER JOIN TourneyTypes tt ON (t.tourneyTypeId = tt.id) + INNER JOIN Sites s ON (tt.siteId = s.id) + INNER JOIN TourneysPlayers tp ON (tp.tourneyId = t.id) + INNER JOIN Players p ON (p.id = tp.playerId) + WHERE s.name=%s AND t.siteTourneyNo=%s AND p.name=%s + """ + self.query['insertTourney'] = """INSERT INTO Tourneys (tourneyTypeId, siteTourneyNo, entries, prizepool, startTime, endTime, tourneyName, matrixIdProcessed, From f72b45e8f03e628d43dfdee40a7514905a717049 Mon Sep 17 00:00:00 2001 From: steffen123 Date: Tue, 10 Aug 2010 00:03:24 +0200 Subject: [PATCH 03/10] PP corner case history from ferki --- .../PP_blind_is_in_forced_allin.txt | 63 +++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 pyfpdb/regression-test-files/cash/PartyPoker/PP_blind_is_in_forced_allin.txt diff --git a/pyfpdb/regression-test-files/cash/PartyPoker/PP_blind_is_in_forced_allin.txt b/pyfpdb/regression-test-files/cash/PartyPoker/PP_blind_is_in_forced_allin.txt new file mode 100644 index 00000000..489dbe5e --- /dev/null +++ b/pyfpdb/regression-test-files/cash/PartyPoker/PP_blind_is_in_forced_allin.txt @@ -0,0 +1,63 @@ +Game #9485557849 starts. + +#Game No : 9485557849 +***** Hand History for Game 9485557849 ***** +$0.80 USD NL Texas Hold'em - Saturday, July 31, 13:52:16 EDT 2010 +Table 20BB Min Speed #1770998 (Real Money) +Seat 1 is the button +Total number of players : 4/9 +Seat 3: FErki84 ( $1.64 USD ) +Seat 5: Vandercasses ( $0.01 USD ) +Seat 9: jeremyho888 ( $1.02 USD ) +Seat 1: sergeodem ( $1.20 USD ) +FErki84 posts small blind [$0.01 USD]. +Vandercasses posts big blind [$0.01 USD]. +** Dealing down cards ** +Dealt to FErki84 [ 8h Kc ] +jeremyho888 folds +sergeodem calls [$0.02 USD] +FErki84 calls [$0.01 USD] +** Dealing Flop ** [ Td, 7c, 9h ] +FErki84 checks +sergeodem checks +** Dealing Turn ** [ 3h ] +FErki84 checks +sergeodem checks +** Dealing River ** [ Jc ] +FErki84 bets [$0.04 USD] +sergeodem folds +FErki84 shows [ 8h, Kc ]a straight, Seven to Jack. +Vandercasses doesn't show [ Ts, Jd ]two pairs, Jacks and Tens. +FErki84 wins $0.06 USD from the side pot 1 with a straight, Seven to Jack. +FErki84 wins $0.03 USD from the main pot with a straight, Seven to Jack. +Vandercasses has left the table. + +Game #9498788316 starts. + +#Game No : 9498788316 +***** Hand History for Game 9498788316 ***** +$1.60 USD NL Texas Hold'em - Wednesday, August 04, 15:02:33 EDT 2010 +Table 20BB Min #1847547 (No DP) (Real Money) +Seat 2 is the button +Total number of players : 5/6 +Seat 5: CepguTbIu999 ( $1.60 USD ) +Seat 1: Daytona_955 ( $2.45 USD ) +Seat 4: FErki84 ( $2.18 USD ) +Seat 2: anjl2009 ( $2.80 USD ) +Seat 3: lukeman2 ( $0.01 USD ) +lukeman2 posts small blind [$0.01 USD]. +FErki84 posts big blind [$0.04 USD]. +** Dealing down cards ** +Dealt to FErki84 [ 6s 2c ] +CepguTbIu999 folds +Daytona_955 folds +anjl2009 folds +** Dealing Flop ** [ 9d, Ah, 3h ] +** Dealing Turn ** [ Js ] +** Dealing River ** [ Kc ] +lukeman2 shows [ 5h, 5s ]a pair of Fives. +FErki84 shows [ 6s, 2c ]high card Ace. +FErki84 wins $0.03 USD from the side pot 1 with high card, Ace. +lukeman2 wins $0.02 USD from the main pot with a pair of Fives. +lukeman2 has left the table. + From 8a6fe1588ce77c1642948fd34c5f178f0591c5a1 Mon Sep 17 00:00:00 2001 From: steffen123 Date: Tue, 10 Aug 2010 00:05:13 +0200 Subject: [PATCH 04/10] PP histories by email. note how it skips the lines about hero raising --- .../PartyPoker_sample_HH_by_email.txt | 41 +++++++++++++++++++ .../HH from email/PP_SNG_HH_by_email.txt | 37 +++++++++++++++++ 2 files changed, 78 insertions(+) create mode 100644 pyfpdb/regression-test-files/cash/PartyPoker/history from email/PartyPoker_sample_HH_by_email.txt create mode 100644 pyfpdb/regression-test-files/tour/PartyPoker/HH from email/PP_SNG_HH_by_email.txt diff --git a/pyfpdb/regression-test-files/cash/PartyPoker/history from email/PartyPoker_sample_HH_by_email.txt b/pyfpdb/regression-test-files/cash/PartyPoker/history from email/PartyPoker_sample_HH_by_email.txt new file mode 100644 index 00000000..2267fa45 --- /dev/null +++ b/pyfpdb/regression-test-files/cash/PartyPoker/history from email/PartyPoker_sample_HH_by_email.txt @@ -0,0 +1,41 @@ +***** Hand History For Game 9423586142 ***** +0.01/0.02 Texas Hold'em Game Table (NL) - Mon Jul 12 13:38:32 EDT 2010 +Table 20BB Min Speed #1775757 (Real Money) -- Seat 1 is the button +Total number of players : 9/9 +Seat 1: Player1 ($0.95) +Seat 2: Player2 ($0.57) +Seat 3: Player3 ($0.86) +Seat 4: Player4 ($1.71) +Seat 5: Player5 ($1.76) +Seat 6: Player6 ($0.44) +Seat 7: Player7 ($0.76) +Seat 8: Player8 ($0.68) +Seat 9: Player9 ($0.38) +Player2 posts small blind (0.01) +Player3 posts big blind (0.02) +** Dealing down cards ** +Dealt to Player5 [ Tc, 9d ] +Player5 folds +Player6 calls (0.02) +Player8 folds +Player9 folds +Player1 folds +Player2 calls (0.01) +Player3 raises 0.06 to 0.08 +Player6 calls (0.06) +Player2 folds +** Dealing Flop ** : [ 5s, 7h, 6h ] +Player3 bets (0.13) +Player6 folds +** Summary ** +Main Pot: $0.18 Rake: $0 +Board: [ 5s 7h 6h ] +Player1 balance $0.95, didn't bet (folded) +Player2 balance $0.55, lost $0.02 (folded) +Player3 balance $0.96, bet $0.21, collected $0.31, net +$0.1 +Player4 balance $1.71, sits out +Player5 balance $1.76, didn't bet (folded) +Player6 balance $0.36, lost $0.08 (folded) +Player7 balance $0.76, sits out +Player8 balance $0.68, didn't bet (folded) +Player9 balance $0.38, didn't bet (folded) diff --git a/pyfpdb/regression-test-files/tour/PartyPoker/HH from email/PP_SNG_HH_by_email.txt b/pyfpdb/regression-test-files/tour/PartyPoker/HH from email/PP_SNG_HH_by_email.txt new file mode 100644 index 00000000..e6afb2c8 --- /dev/null +++ b/pyfpdb/regression-test-files/tour/PartyPoker/HH from email/PP_SNG_HH_by_email.txt @@ -0,0 +1,37 @@ +***** Hand History For Game 9336845949 ***** +30/60 Tourney Texas Hold'em Game Table (NL) (STT Tournament #52792286) - Sun Jun 13 12:21:39 EDT 2010 +Table 174827 (Real Money) -- Seat 6 is the button +Total number of players : 6/6 +Seat 1: Player1 (1520) +Seat 2: Player2 (1540) +Seat 3: Player3 (2120) +Seat 4: Player4 (2460) +Seat 5: Player5 (2600) +Seat 6: Player6 (1760) +Player1 posts small blind (30) +Player2 posts big blind (60) +** Dealing down cards ** +Dealt to Player5 [ Jc, Js ] +Player3 folds +Player4 folds +Player6 folds +Player1 calls (210) +Player2 folds +** Dealing Flop ** : [ 4h, 7d, 5c ] +Player1 checks +Player1 calls (450) +** Dealing Turn ** : [ Kd ] +Player1 checks +Player1 calls (830) +Player1 is all-In. +** Dealing River ** : [ Jd ] +Creating Main Pot with 3100 with Player1 +** Summary ** +Main Pot: 3100 +Board: [ 4h 7d 5c Kd Jd ] +Player1 balance 0, lost 1520 [ Ks 6c ] [ a pair of kings -- Ks,Kd,Jd,7d,6c ] +Player2 balance 1480, lost 60 (folded) +Player3 balance 2120, didn't bet (folded) +Player4 balance 2460, didn't bet (folded) +Player5 balance 4180, bet 1520, collected 3100, net +1580 [ Jc Js ] [ three of a kind, jacks -- Kd,Jc,Js,Jd,7d ] +Player6 balance 1760, didn't bet (folded) From 3467f757d37a213c6e80898210ea28a93691d19f Mon Sep 17 00:00:00 2001 From: steffen123 Date: Tue, 10 Aug 2010 00:25:43 +0200 Subject: [PATCH 05/10] refactor a bit in GuiTourneyViewer to reduce code duplication --- pyfpdb/GuiTourneyViewer.py | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/pyfpdb/GuiTourneyViewer.py b/pyfpdb/GuiTourneyViewer.py index 1499e8a6..777c8e9b 100644 --- a/pyfpdb/GuiTourneyViewer.py +++ b/pyfpdb/GuiTourneyViewer.py @@ -58,14 +58,9 @@ class GuiTourneyViewer (threading.Thread): #end def __init__ def displayClicked(self, widget, data=None): - tourneyNo=int(self.entryTourney.get_text()) - siteName=self.siteBox.get_active_text() + self.prepare(10, 9) - self.table.destroy() - self.table=gtk.Table(columns=10, rows=9) - self.mainVBox.add(self.table) - - result=self.db.getTourneyInfo(siteName, tourneyNo) + result=self.db.getTourneyInfo(self.siteName, self.tourneyNo) x=0 y=0 for i in range(1,len(result[0])): @@ -87,15 +82,9 @@ class GuiTourneyViewer (threading.Thread): #def displayClicked def displayPlayerClicked(self, widget, data=None): - tourneyNo=int(self.entryTourney.get_text()) - siteName=self.siteBox.get_active_text() - playerName=self.entryPlayer.get_text() + self.prepare(4, 5) - self.table.destroy() - self.table=gtk.Table(columns=4, rows=5) - self.mainVBox.add(self.table) - - result=self.db.getTourneyPlayerInfo(siteName, tourneyNo, playerName) + result=self.db.getTourneyPlayerInfo(self.siteName, self.tourneyNo, self.playerName) x=0 y=0 for i in range(1,len(result[0])): @@ -120,4 +109,14 @@ class GuiTourneyViewer (threading.Thread): """returns the vbox of this thread""" return self.mainVBox #end def get_vbox + + def prepare(self, columns, rows): + self.tourneyNo=int(self.entryTourney.get_text()) + self.siteName=self.siteBox.get_active_text() + self.playerName=self.entryPlayer.get_text() + + self.table.destroy() + self.table=gtk.Table(columns=columns, rows=rows) + self.mainVBox.add(self.table) + #end def readInfo #end class GuiTourneyViewer From 391c42cdfff874cf9150dac24ddf305ac4c710cc Mon Sep 17 00:00:00 2001 From: steffen123 Date: Tue, 10 Aug 2010 00:35:02 +0200 Subject: [PATCH 06/10] add error handling for invalid entry into tourneNo field --- pyfpdb/GuiTourneyViewer.py | 77 +++++++++++++++++++++----------------- 1 file changed, 42 insertions(+), 35 deletions(-) diff --git a/pyfpdb/GuiTourneyViewer.py b/pyfpdb/GuiTourneyViewer.py index 777c8e9b..6881fac2 100644 --- a/pyfpdb/GuiTourneyViewer.py +++ b/pyfpdb/GuiTourneyViewer.py @@ -58,50 +58,48 @@ class GuiTourneyViewer (threading.Thread): #end def __init__ def displayClicked(self, widget, data=None): - self.prepare(10, 9) - - result=self.db.getTourneyInfo(self.siteName, self.tourneyNo) - x=0 - y=0 - for i in range(1,len(result[0])): - if y==9: - x+=2 - y=0 + if self.prepare(10, 9): + result=self.db.getTourneyInfo(self.siteName, self.tourneyNo) + x=0 + y=0 + for i in range(1,len(result[0])): + if y==9: + x+=2 + y=0 - label=gtk.Label(result[0][i]) - self.table.attach(label,x,x+1,y,y+1) + label=gtk.Label(result[0][i]) + self.table.attach(label,x,x+1,y,y+1) - if result[1][i]==None: - label=gtk.Label("N/A") - else: - label=gtk.Label(result[1][i]) - self.table.attach(label,x+1,x+2,y,y+1) + if result[1][i]==None: + label=gtk.Label("N/A") + else: + label=gtk.Label(result[1][i]) + self.table.attach(label,x+1,x+2,y,y+1) - y+=1 + y+=1 self.mainVBox.show_all() #def displayClicked def displayPlayerClicked(self, widget, data=None): - self.prepare(4, 5) - - result=self.db.getTourneyPlayerInfo(self.siteName, self.tourneyNo, self.playerName) - x=0 - y=0 - for i in range(1,len(result[0])): - if y==5: - x+=2 - y=0 + if self.prepare(4, 5): + result=self.db.getTourneyPlayerInfo(self.siteName, self.tourneyNo, self.playerName) + x=0 + y=0 + for i in range(1,len(result[0])): + if y==5: + x+=2 + y=0 - label=gtk.Label(result[0][i]) - self.table.attach(label,x,x+1,y,y+1) + label=gtk.Label(result[0][i]) + self.table.attach(label,x,x+1,y,y+1) - if result[1][i]==None: - label=gtk.Label("N/A") - else: - label=gtk.Label(result[1][i]) - self.table.attach(label,x+1,x+2,y,y+1) + if result[1][i]==None: + label=gtk.Label("N/A") + else: + label=gtk.Label(result[1][i]) + self.table.attach(label,x+1,x+2,y,y+1) - y+=1 + y+=1 self.mainVBox.show_all() #def displayPlayerClicked @@ -111,12 +109,21 @@ class GuiTourneyViewer (threading.Thread): #end def get_vbox def prepare(self, columns, rows): - self.tourneyNo=int(self.entryTourney.get_text()) + try: self.errorLabel.destroy() + except: pass + + try: + self.tourneyNo=int(self.entryTourney.get_text()) + except ValueError: + self.errorLabel=gtk.Label("invalid entry in tourney number - must enter numbers only") + self.mainVBox.add(self.errorLabel) + return False self.siteName=self.siteBox.get_active_text() self.playerName=self.entryPlayer.get_text() self.table.destroy() self.table=gtk.Table(columns=columns, rows=rows) self.mainVBox.add(self.table) + return True #end def readInfo #end class GuiTourneyViewer From 10fac81ef900d0d354bb6eeb5d5cc4c9b2306252 Mon Sep 17 00:00:00 2001 From: steffen123 Date: Tue, 10 Aug 2010 00:46:55 +0200 Subject: [PATCH 07/10] handle tourney not found --- pyfpdb/GuiTourneyViewer.py | 33 +++++++++++++++++++-------------- 1 file changed, 19 insertions(+), 14 deletions(-) diff --git a/pyfpdb/GuiTourneyViewer.py b/pyfpdb/GuiTourneyViewer.py index 6881fac2..c30cb642 100644 --- a/pyfpdb/GuiTourneyViewer.py +++ b/pyfpdb/GuiTourneyViewer.py @@ -60,23 +60,28 @@ class GuiTourneyViewer (threading.Thread): def displayClicked(self, widget, data=None): if self.prepare(10, 9): result=self.db.getTourneyInfo(self.siteName, self.tourneyNo) - x=0 - y=0 - for i in range(1,len(result[0])): - if y==9: - x+=2 - y=0 + if result[1] == None: + self.table.destroy() + self.errorLabel=gtk.Label("Tournament not found - please ensure you imported it and selected the correct site") + self.mainVBox.add(self.errorLabel) + else: + x=0 + y=0 + for i in range(1,len(result[0])): + if y==9: + x+=2 + y=0 - label=gtk.Label(result[0][i]) - self.table.attach(label,x,x+1,y,y+1) + label=gtk.Label(result[0][i]) + self.table.attach(label,x,x+1,y,y+1) - if result[1][i]==None: - label=gtk.Label("N/A") - else: - label=gtk.Label(result[1][i]) - self.table.attach(label,x+1,x+2,y,y+1) + if result[1][i]==None: + label=gtk.Label("N/A") + else: + label=gtk.Label(result[1][i]) + self.table.attach(label,x+1,x+2,y,y+1) - y+=1 + y+=1 self.mainVBox.show_all() #def displayClicked From 08451c77d5437bb0bdaace275c967cc34178de0f Mon Sep 17 00:00:00 2001 From: steffen123 Date: Tue, 10 Aug 2010 00:49:14 +0200 Subject: [PATCH 08/10] handle player not found --- pyfpdb/GuiTourneyViewer.py | 39 +++++++++++++++++++++----------------- 1 file changed, 22 insertions(+), 17 deletions(-) diff --git a/pyfpdb/GuiTourneyViewer.py b/pyfpdb/GuiTourneyViewer.py index c30cb642..70a8a7d7 100644 --- a/pyfpdb/GuiTourneyViewer.py +++ b/pyfpdb/GuiTourneyViewer.py @@ -88,23 +88,28 @@ class GuiTourneyViewer (threading.Thread): def displayPlayerClicked(self, widget, data=None): if self.prepare(4, 5): result=self.db.getTourneyPlayerInfo(self.siteName, self.tourneyNo, self.playerName) - x=0 - y=0 - for i in range(1,len(result[0])): - if y==5: - x+=2 - y=0 - - label=gtk.Label(result[0][i]) - self.table.attach(label,x,x+1,y,y+1) - - if result[1][i]==None: - label=gtk.Label("N/A") - else: - label=gtk.Label(result[1][i]) - self.table.attach(label,x+1,x+2,y,y+1) - - y+=1 + if result[1] == None: + self.table.destroy() + self.errorLabel=gtk.Label("Player or tourney not found - please ensure you imported it and selected the correct site") + self.mainVBox.add(self.errorLabel) + else: + x=0 + y=0 + for i in range(1,len(result[0])): + if y==5: + x+=2 + y=0 + + label=gtk.Label(result[0][i]) + self.table.attach(label,x,x+1,y,y+1) + + if result[1][i]==None: + label=gtk.Label("N/A") + else: + label=gtk.Label(result[1][i]) + self.table.attach(label,x+1,x+2,y,y+1) + + y+=1 self.mainVBox.show_all() #def displayPlayerClicked From 4fbb26b4fac86ea946c0d205bea133483c2d2122 Mon Sep 17 00:00:00 2001 From: steffen123 Date: Tue, 10 Aug 2010 01:00:35 +0200 Subject: [PATCH 09/10] remove some 100% duplicates --- pyfpdb/SQL.py | 4 ---- 1 file changed, 4 deletions(-) diff --git a/pyfpdb/SQL.py b/pyfpdb/SQL.py index 69d74fbe..5ffb47bc 100644 --- a/pyfpdb/SQL.py +++ b/pyfpdb/SQL.py @@ -1336,8 +1336,6 @@ class Sql: and (p.siteId = %s or %s = -1) """ - self.query['getSiteId'] = """SELECT id from Sites where name = %s""" - self.query['get_stats_from_hand'] = """ SELECT hc.playerId AS player_id, hp.seatNo AS seat, @@ -2010,8 +2008,6 @@ class Sql: self.query['getPlayerIdBySite'] = """SELECT id from Players where name = %s AND siteId = %s""" # used in *Filters: - self.query['getSiteId'] = """SELECT id from Sites where name = %s""" - self.query['getGames'] = """SELECT DISTINCT category from Gametypes""" #self.query['getLimits'] = already defined further up self.query['getLimits2'] = """SELECT DISTINCT type, limitType, bigBlind from Gametypes From c5acd04bb682c168c8cc7d701c63eb8e7af72c01 Mon Sep 17 00:00:00 2001 From: steffen123 Date: Tue, 10 Aug 2010 01:27:25 +0200 Subject: [PATCH 10/10] This makes HUD Cache work again but without tourneytypeid - one of these lines breaks it --- pyfpdb/SQL.py | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/pyfpdb/SQL.py b/pyfpdb/SQL.py index 5ffb47bc..0ee2ad73 100644 --- a/pyfpdb/SQL.py +++ b/pyfpdb/SQL.py @@ -2988,7 +2988,6 @@ class Sql: ,playerId ,activeSeats ,position - ,tourneyTypeId ,styleKey ,HDs ,wonWhenSeenStreet1 @@ -3078,7 +3077,6 @@ class Sql: when hp.position = '9' then 'E' else 'E' end AS hc_position - ,t.tourneyTypeId ,date_format(h.startTime, 'd%y%m%d') ,count(1) ,sum(wonWhenSeenStreet1) @@ -3152,14 +3150,11 @@ class Sql: ,sum(hp.street4Raises) FROM HandsPlayers hp INNER JOIN Hands h ON (h.id = hp.handId) - INNER JOIN TourneysPlayers tp ON (tp.id = hp.tourneysPlayersId) - INNER JOIN Tourneys t ON (t.id = tp.tourneyId) GROUP BY h.gametypeId ,hp.playerId ,h.seats ,hc_position - ,t.tourneyTypeId ,date_format(h.startTime, 'd%y%m%d') """ elif db_server == 'postgresql': @@ -3169,7 +3164,6 @@ class Sql: ,playerId ,activeSeats ,position - ,tourneyTypeId ,styleKey ,HDs ,wonWhenSeenStreet1 @@ -3259,7 +3253,6 @@ class Sql: when hp.position = '9' then 'E' else 'E' end AS hc_position - ,t.tourneyTypeId ,'d' || to_char(h.startTime, 'YYMMDD') ,count(1) ,sum(wonWhenSeenStreet1) @@ -3333,14 +3326,11 @@ class Sql: ,sum(CAST(hp.street4Raises as integer)) FROM HandsPlayers hp INNER JOIN Hands h ON (h.id = hp.handId) - INNER JOIN TourneysPlayers tp ON (tp.id = hp.tourneysPlayersId) - INNER JOIN Tourneys t ON (t.id = tp.tourneyId) GROUP BY h.gametypeId ,hp.playerId ,h.seats ,hc_position - ,t.tourneyTypeId ,to_char(h.startTime, 'YYMMDD') """ else: # assume sqlite @@ -3350,7 +3340,6 @@ class Sql: ,playerId ,activeSeats ,position - ,tourneyTypeId ,styleKey ,HDs ,wonWhenSeenStreet1 @@ -3440,7 +3429,6 @@ class Sql: when hp.position = '9' then 'E' else 'E' end AS hc_position - ,t.tourneyTypeId ,'d' || substr(strftime('%Y%m%d', h.startTime),3,7) ,count(1) ,sum(wonWhenSeenStreet1) @@ -3514,14 +3502,11 @@ class Sql: ,sum(CAST(hp.street4Raises as integer)) FROM HandsPlayers hp INNER JOIN Hands h ON (h.id = hp.handId) - INNER JOIN TourneysPlayers tp ON (tp.id = hp.tourneysPlayersId) - INNER JOIN Tourneys t ON (t.id = tp.tourneyId) GROUP BY h.gametypeId ,hp.playerId ,h.seats ,hc_position - ,t.tourneyTypeId ,'d' || substr(strftime('%Y%m%d', h.startTime),3,7) """