From dd80468f5f969dc1a39be714006612748922628b Mon Sep 17 00:00:00 2001 From: Ray Date: Tue, 9 Jun 2009 14:18:56 -0400 Subject: [PATCH 1/4] Fix a whitespace problem. --- pyfpdb/WinTables.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyfpdb/WinTables.py b/pyfpdb/WinTables.py index 1b064eef..87431dda 100644 --- a/pyfpdb/WinTables.py +++ b/pyfpdb/WinTables.py @@ -62,7 +62,7 @@ class Table(Table_Window): return None (x, y, width, height) = win32gui.GetWindowRect(hwnd) - print "x = %s y = %s width = %s height = %s" % (x, y, width, height) + print "x = %s y = %s width = %s height = %s" % (x, y, width, height) self.x = int(x) + b_width self.y = int(y) + tb_height self.height = int(height) - b_width - tb_height From eea4656f4792f90d9b30baad124d1c2a0075e697 Mon Sep 17 00:00:00 2001 From: Ray Date: Tue, 9 Jun 2009 16:38:26 -0400 Subject: [PATCH 2/4] Should now run on windows--but not work correctly. --- pyfpdb/WinTables.py | 54 ++++++++++++++++++++++----------------------- 1 file changed, 27 insertions(+), 27 deletions(-) diff --git a/pyfpdb/WinTables.py b/pyfpdb/WinTables.py index 87431dda..b867b83d 100644 --- a/pyfpdb/WinTables.py +++ b/pyfpdb/WinTables.py @@ -72,7 +72,8 @@ class Table(Table_Window): self.title = titles[hwnd] self.site = "" self.hud = None - self.number = gtk.gdk.window_foreign_new(long(self.window)) + self.number = hwnd + self.gdkhandle = gtk.gdk.window_foreign_new(long(self.window)) def get_geometry(self): @@ -112,32 +113,31 @@ class Table(Table_Window): win32api.CloseHandle(hToken) return exename + def topify(self, hud): + """Set the specified gtk window to stayontop in MS Windows.""" + + def windowEnumerationHandler(hwnd, resultList): + '''Callback for win32gui.EnumWindows() to generate list of window handles.''' + resultList.append((hwnd, win32gui.GetWindowText(hwnd))) + + unique_name = 'unique name for finding this window' + real_name = hud.main_window.get_title() + hud.main_window.set_title(unique_name) + tl_windows = [] + win32gui.EnumWindows(windowEnumerationHandler, tl_windows) + + for w in tl_windows: + if w[1] == unique_name: + hud.main_window.gdkhandle = gtk.gdk.window_foreign_new(w[0]) + hud.main_window.gdkhandle.set_transient_for(self.gdkhandle) +# +# style = win32gui.GetWindowLong(self.number, win32con.GWL_EXSTYLE) +# style |= win32con.WS_CLIPCHILDREN +# win32gui.SetWindowLong(self.number, win32con.GWL_EXSTYLE, style) + break + + hud.main_window.set_title(real_name) + def win_enum_handler(hwnd, titles): titles[hwnd] = win32gui.GetWindowText(hwnd) -def topify_window(hud, window): - """Set the specified gtk window to stayontop in MS Windows.""" - - def windowEnumerationHandler(hwnd, resultList): - '''Callback for win32gui.EnumWindows() to generate list of window handles.''' - resultList.append((hwnd, win32gui.GetWindowText(hwnd))) - - unique_name = 'unique name for finding this window' - real_name = window.get_title() - window.set_title(unique_name) - tl_windows = [] - win32gui.EnumWindows(windowEnumerationHandler, tl_windows) - - for w in tl_windows: - if w[1] == unique_name: - hud.main_window.parentgdkhandle = gtk.gdk.window_foreign_new(long(hud.table.number)) - hud.main_window.gdkhandle = gtk.gdk.window_foreign_new(w[0]) - hud.main_window.gdkhandle.set_transient_for(hud.main_window.parentgdkhandle) - - style = win32gui.GetWindowLong(self.table.number, win32con.GWL_EXSTYLE) - style |= win32con.WS_CLIPCHILDREN - win32gui.SetWindowLong(hud.table.number, win32con.GWL_EXSTYLE, style) - break - - window.set_title(real_name) - From 9b5f8c53bcc38b22d21efab1436d9896cfbd2134 Mon Sep 17 00:00:00 2001 From: Ray Date: Tue, 9 Jun 2009 19:06:20 -0400 Subject: [PATCH 3/4] Changes to allow importing of razz hands. Tables not fully populated. --- pyfpdb/Hand.py | 3 ++- pyfpdb/fpdb_save_to_db.py | 15 +++++++-------- pyfpdb/fpdb_simple.py | 31 +++++++++++++++++++------------ 3 files changed, 28 insertions(+), 21 deletions(-) diff --git a/pyfpdb/Hand.py b/pyfpdb/Hand.py index c505a68a..38009250 100644 --- a/pyfpdb/Hand.py +++ b/pyfpdb/Hand.py @@ -878,7 +878,8 @@ Add a complete on [street] by [player] to [amountTo] def writeHand(self, fh=sys.__stdout__): # PokerStars format. - print >>fh, _("%s Game #%s: %s ($%s/$%s) - %s" %("PokerStars", self.handid, self.getGameTypeAsString(), self.sb, self.bb, time.strftime('%Y/%m/%d - %H:%M:%S (ET)', self.starttime))) +# print >>fh, _("%s Game #%s: %s ($%s/$%s) - %s" %("PokerStars", self.handid, self.getGameTypeAsString(), self.sb, self.bb, time.strftime('%Y/%m/%d - %H:%M:%S (ET)', self.starttime))) + print >>fh, _("%s Game #%s: %s ($%s/$%s) - %s" %("PokerStars", self.handid, self.getGameTypeAsString(), self.sb, self.bb, datetime.datetime.strftime(self.starttime,'%Y/%m/%d - %H:%M:%S ET'))) print >>fh, _("Table '%s' %d-max Seat #%s is the button" %(self.tablename, self.maxseats, self.buttonpos)) players_who_post_antes = set([x[0] for x in self.actions['ANTES']]) diff --git a/pyfpdb/fpdb_save_to_db.py b/pyfpdb/fpdb_save_to_db.py index 3c99d084..3870a6e9 100644 --- a/pyfpdb/fpdb_save_to_db.py +++ b/pyfpdb/fpdb_save_to_db.py @@ -26,14 +26,13 @@ MYSQL_INNODB = 2 PGSQL = 3 SQLITE = 4 -#fastStoreHudCache = False # set this to True to test the new storeHudCache routine -# -#saveActions = True # set this to False to avoid storing action data -# # Pros: speeds up imports -# # Cons: no action data is saved, so you need to keep the hand histories -# # variance not available on stats page -# # no graphs +fastStoreHudCache = False # set this to True to test the new storeHudCache routine +saveActions = True # set this to False to avoid storing action data + # Pros: speeds up imports + # Cons: no action data is saved, so you need to keep the hand histories + # variance not available on stats page + # : No graphs #stores a stud/razz hand into the database def ring_stud(config, backend, db, cursor, base, category, site_hand_no, gametype_id, hand_start_time ,names, player_ids, start_cashes, antes, card_values, card_suits, winnings, rakes @@ -48,7 +47,7 @@ def ring_stud(config, backend, db, cursor, base, category, site_hand_no, gametyp fpdb_simple.fillCardArrays(len(names), base, category, card_values, card_suits) hands_id = fpdb_simple.storeHands(backend, db, cursor, site_hand_no, gametype_id - ,hand_start_time, names, tableName, maxSeats) + ,hand_start_time, names, tableName, maxSeats, hudImportData) #print "before calling store_hands_players_stud, antes:", antes hands_players_ids = fpdb_simple.store_hands_players_stud(backend, db, cursor, hands_id, player_ids diff --git a/pyfpdb/fpdb_simple.py b/pyfpdb/fpdb_simple.py index 31321aeb..2b6f248b 100644 --- a/pyfpdb/fpdb_simple.py +++ b/pyfpdb/fpdb_simple.py @@ -1318,19 +1318,26 @@ def store_hands_players_stud(backend, conn, cursor, hands_id, player_ids, start_ result=[] #print "before inserts in store_hands_players_stud, antes:", antes for i in xrange(len(player_ids)): + card1 = Card.cardFromValueSuit(card_values[i][0], card_suits[i][0]) + card2 = Card.cardFromValueSuit(card_values[i][1], card_suits[i][1]) + card3 = Card.cardFromValueSuit(card_values[i][2], card_suits[i][2]) + card4 = Card.cardFromValueSuit(card_values[i][3], card_suits[i][3]) + card5 = Card.cardFromValueSuit(card_values[i][4], card_suits[i][4]) + card6 = Card.cardFromValueSuit(card_values[i][5], card_suits[i][5]) + card7 = Card.cardFromValueSuit(card_values[i][6], card_suits[i][6]) + cursor.execute ("""INSERT INTO HandsPlayers -(handId, playerId, startCash, ante, -card1Value, card1Suit, card2Value, card2Suit, -card3Value, card3Suit, card4Value, card4Suit, -card5Value, card5Suit, card6Value, card6Suit, -card7Value, card7Suit, winnings, rake, seatNo) -VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, -%s, %s, %s, %s)""", - (hands_id, player_ids[i], start_cashes[i], antes[i], - card_values[i][0], card_suits[i][0], card_values[i][1], card_suits[i][1], - card_values[i][2], card_suits[i][2], card_values[i][3], card_suits[i][3], - card_values[i][4], card_suits[i][4], card_values[i][5], card_suits[i][5], - card_values[i][6], card_suits[i][6], winnings[i], rakes[i], seatNos[i])) +(handId, playerId, startCash, ante, tourneyTypeId, +card1, card2, +card3, card4, +card5, card6, +card7, winnings, rake, seatNo) +VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)""", + (hands_id, player_ids[i], start_cashes[i], antes[i], 1, + card1, card2, + card3, card4, + card5, card6, + card7, winnings[i], rakes[i], seatNos[i])) #cursor.execute("SELECT id FROM HandsPlayers WHERE handId=%s AND playerId+0=%s", (hands_id, player_ids[i])) #result.append(cursor.fetchall()[0][0]) result.append( getLastInsertId(backend, conn, cursor) ) From 49a04af0c567f31f1d9271719bacfdec38e7faf0 Mon Sep 17 00:00:00 2001 From: Ray Date: Fri, 12 Jun 2009 12:29:17 -0400 Subject: [PATCH 4/4] Add stud8 to PokerStars HH conversion. --- pyfpdb/Hand.py | 6 +++++- pyfpdb/PokerStarsToFpdb.py | 5 +++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/pyfpdb/Hand.py b/pyfpdb/Hand.py index 38009250..2cd05252 100644 --- a/pyfpdb/Hand.py +++ b/pyfpdb/Hand.py @@ -80,6 +80,10 @@ class Hand: self.totalcollected = None self.rake = None + def __str__(self): + str = '' + str = str + "Hand Object for %s at %s" % (self.handid, self.sitename) + return str def insert(self, db): """ Function to insert Hand into database @@ -382,7 +386,7 @@ Map the tuple self.gametype onto the pokerstars string describing it "omahahilo" : "Omaha Hi/Lo", "razz" : "Razz", "studhi" : "7 Card Stud", - "studhilo" : "FIXME", + "studhilo" : "7 Card Stud Hi/Lo", "fivedraw" : "5 Card Draw", "27_1draw" : "FIXME", "27_3draw" : "Triple Draw 2-7 Lowball", diff --git a/pyfpdb/PokerStarsToFpdb.py b/pyfpdb/PokerStarsToFpdb.py index 703dadcf..44bd88a2 100755 --- a/pyfpdb/PokerStarsToFpdb.py +++ b/pyfpdb/PokerStarsToFpdb.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python + #!/usr/bin/env python # -*- coding: utf-8 -*- # # Copyright 2008, Carl Gherardi @@ -26,7 +26,7 @@ from HandHistoryConverter import * class PokerStars(HandHistoryConverter): # Static regexes - re_GameInfo = re.compile("PokerStars Game #(?P[0-9]+):\s+(HORSE)? \(?(?PHold\'em|Razz|7 Card Stud|Omaha|Omaha Hi/Lo|Badugi) (?PNo Limit|Limit|Pot Limit),? \(?(?P\$|)?(?P[.0-9]+)/\$?(?P[.0-9]+)\) - (?P.*$)", re.MULTILINE) + re_GameInfo = re.compile("PokerStars Game #(?P[0-9]+):\s+(HORSE)? \(?(?PHold\'em|Razz|7 Card Stud|7 Card Stud Hi/Lo|Omaha|Omaha Hi/Lo|Badugi) (?PNo Limit|Limit|Pot Limit),? \(?(?P\$|)?(?P[.0-9]+)/\$?(?P[.0-9]+)\) - (?P.*$)", re.MULTILINE) re_SplitHands = re.compile('\n\n+') re_TailSplitHands = re.compile('(\n\n\n+)') re_HandInfo = re.compile("^Table \'(?P[- a-zA-Z]+)\'(?P.+?$)?", re.MULTILINE) @@ -95,6 +95,7 @@ follow : whether to tail -f the input""" 'Omaha Hi/Lo' : ('hold','omahahilo'), 'Razz' : ('stud','razz'), '7 Card Stud' : ('stud','studhi'), + '7 Card Stud Hi/Lo' : ('stud','studhilo'), 'Badugi' : ('draw','badugi') } currencies = { u'€':'EUR', '$':'USD', '':'T$' }