merge from steffen

This commit is contained in:
sqlcoder 2010-08-21 22:43:14 +01:00
commit c8f25ad162
11 changed files with 5562 additions and 1731 deletions

View File

@ -82,7 +82,7 @@ except ImportError:
use_numpy = False
DB_VERSION = 142
DB_VERSION = 143
# Variance created as sqlite has a bunch of undefined aggregate functions.
@ -150,6 +150,8 @@ class Database:
, {'tab':'TourneyTypes', 'col':'siteId', 'drop':0}
, {'tab':'Backings', 'col':'tourneysPlayersId', 'drop':0}
, {'tab':'Backings', 'col':'playerId', 'drop':0}
, {'tab':'RawHands', 'col':'id', 'drop':0}
, {'tab':'RawTourneys', 'col':'id', 'drop':0}
]
, [ # indexes for sqlite (list index 4)
{'tab':'Hands', 'col':'gametypeId', 'drop':0}
@ -165,6 +167,8 @@ class Database:
, {'tab':'TourneyTypes', 'col':'siteId', 'drop':0}
, {'tab':'Backings', 'col':'tourneysPlayersId', 'drop':0}
, {'tab':'Backings', 'col':'playerId', 'drop':0}
, {'tab':'RawHands', 'col':'id', 'drop':0}
, {'tab':'RawTourneys', 'col':'id', 'drop':0}
]
]
@ -306,9 +310,7 @@ class Database:
tables=self.cursor.execute(self.sql.query['list_tables'])
tables=self.cursor.fetchall()
for table in tables:
table=table[0]
for table in (u'Autorates', u'Backings', u'Gametypes', u'Hands', u'HandsActions', u'HandsPlayers', u'HudCache', u'Players', u'RawHands', u'RawTourneys', u'Settings', u'Sites', u'TourneyTypes', u'Tourneys', u'TourneysPlayers'):
print "table:", table
result+="###################\nTable "+table+"\n###################\n"
rows=self.cursor.execute(self.sql.query['get'+table])
@ -1155,6 +1157,8 @@ class Database:
c.execute(self.sql.query['createHandsActionsTable'])
c.execute(self.sql.query['createHudCacheTable'])
c.execute(self.sql.query['createBackingsTable'])
c.execute(self.sql.query['createRawHands'])
c.execute(self.sql.query['createRawTourneys'])
# Create unique indexes:
log.debug("Creating unique indexes")
@ -1765,86 +1769,95 @@ class Database:
#print "DEBUG: %s %s %s" %(hid, pids, pdata)
inserts = []
for p in pdata:
line = [0]*76
line = [0]*85
line[0] = 1 # HDs
if pdata[p]['street0VPI']: line[1] = 1
if pdata[p]['street0Aggr']: line[2] = 1
if pdata[p]['street0_3BChance']: line[3] = 1
if pdata[p]['street0_3BDone']: line[4] = 1
if pdata[p]['street1Seen']: line[5] = 1
if pdata[p]['street2Seen']: line[6] = 1
if pdata[p]['street3Seen']: line[7] = 1
if pdata[p]['street4Seen']: line[8] = 1
if pdata[p]['sawShowdown']: line[9] = 1
if pdata[p]['street1Aggr']: line[10] = 1
if pdata[p]['street2Aggr']: line[11] = 1
if pdata[p]['street3Aggr']: line[12] = 1
if pdata[p]['street4Aggr']: line[13] = 1
if pdata[p]['otherRaisedStreet1']: line[14] = 1
if pdata[p]['otherRaisedStreet2']: line[15] = 1
if pdata[p]['otherRaisedStreet3']: line[16] = 1
if pdata[p]['otherRaisedStreet4']: line[17] = 1
if pdata[p]['foldToOtherRaisedStreet1']: line[18] = 1
if pdata[p]['foldToOtherRaisedStreet2']: line[19] = 1
if pdata[p]['foldToOtherRaisedStreet3']: line[20] = 1
if pdata[p]['foldToOtherRaisedStreet4']: line[21] = 1
line[22] = pdata[p]['wonWhenSeenStreet1']
line[23] = pdata[p]['wonAtSD']
if pdata[p]['raiseFirstInChance']: line[24] = 1
if pdata[p]['raisedFirstIn']: line[25] = 1
if pdata[p]['foldBbToStealChance']: line[26] = 1
if pdata[p]['foldedBbToSteal']: line[27] = 1
if pdata[p]['foldSbToStealChance']: line[28] = 1
if pdata[p]['foldedSbToSteal']: line[29] = 1
if pdata[p]['street1CBChance']: line[30] = 1
if pdata[p]['street1CBDone']: line[31] = 1
if pdata[p]['street2CBChance']: line[32] = 1
if pdata[p]['street2CBDone']: line[33] = 1
if pdata[p]['street3CBChance']: line[34] = 1
if pdata[p]['street3CBDone']: line[35] = 1
if pdata[p]['street4CBChance']: line[36] = 1
if pdata[p]['street4CBDone']: line[37] = 1
if pdata[p]['foldToStreet1CBChance']: line[38] = 1
if pdata[p]['foldToStreet1CBDone']: line[39] = 1
if pdata[p]['foldToStreet2CBChance']: line[40] = 1
if pdata[p]['foldToStreet2CBDone']: line[41] = 1
if pdata[p]['foldToStreet3CBChance']: line[42] = 1
if pdata[p]['foldToStreet3CBDone']: line[43] = 1
if pdata[p]['foldToStreet4CBChance']: line[44] = 1
if pdata[p]['foldToStreet4CBDone']: line[45] = 1
line[46] = pdata[p]['totalProfit']
if pdata[p]['street1CheckCallRaiseChance']: line[47] = 1
if pdata[p]['street1CheckCallRaiseDone']: line[48] = 1
if pdata[p]['street2CheckCallRaiseChance']: line[49] = 1
if pdata[p]['street2CheckCallRaiseDone']: line[50] = 1
if pdata[p]['street3CheckCallRaiseChance']: line[51] = 1
if pdata[p]['street3CheckCallRaiseDone']: line[52] = 1
if pdata[p]['street4CheckCallRaiseChance']: line[53] = 1
if pdata[p]['street4CheckCallRaiseDone']: line[54] = 1
if pdata[p]['street0Calls']: line[55] = 1
if pdata[p]['street1Calls']: line[56] = 1
if pdata[p]['street2Calls']: line[57] = 1
if pdata[p]['street3Calls']: line[58] = 1
if pdata[p]['street4Calls']: line[59] = 1
if pdata[p]['street0Bets']: line[60] = 1
if pdata[p]['street1Bets']: line[61] = 1
if pdata[p]['street2Bets']: line[62] = 1
if pdata[p]['street3Bets']: line[63] = 1
if pdata[p]['street4Bets']: line[64] = 1
if pdata[p]['street0Raises']: line[65] = 1
if pdata[p]['street1Raises']: line[66] = 1
if pdata[p]['street2Raises']: line[67] = 1
if pdata[p]['street3Raises']: line[68] = 1
if pdata[p]['street4Raises']: line[69] = 1
if pdata[p]['street0_4BChance']: line[5] = 1
if pdata[p]['street0_4BDone']: line[6] = 1
if pdata[p]['other3BStreet0']: line[7] = 1
if pdata[p]['other4BStreet0']: line[8] = 1
if pdata[p]['street1Seen']: line[9] = 1
if pdata[p]['street2Seen']: line[10] = 1
if pdata[p]['street3Seen']: line[11] = 1
if pdata[p]['street4Seen']: line[12] = 1
if pdata[p]['sawShowdown']: line[13] = 1
if pdata[p]['street1Aggr']: line[14] = 1
if pdata[p]['street2Aggr']: line[15] = 1
if pdata[p]['street3Aggr']: line[16] = 1
if pdata[p]['street4Aggr']: line[17] = 1
if pdata[p]['otherRaisedStreet0']: line[18] = 1
if pdata[p]['otherRaisedStreet1']: line[19] = 1
if pdata[p]['otherRaisedStreet2']: line[20] = 1
if pdata[p]['otherRaisedStreet3']: line[21] = 1
if pdata[p]['otherRaisedStreet4']: line[22] = 1
if pdata[p]['foldToOtherRaisedStreet0']: line[23] = 1
if pdata[p]['foldToOtherRaisedStreet1']: line[24] = 1
if pdata[p]['foldToOtherRaisedStreet2']: line[25] = 1
if pdata[p]['foldToOtherRaisedStreet3']: line[26] = 1
if pdata[p]['foldToOtherRaisedStreet4']: line[27] = 1
line[28] = pdata[p]['wonWhenSeenStreet1']
line[29] = pdata[p]['wonWhenSeenStreet2']
line[30] = pdata[p]['wonWhenSeenStreet3']
line[31] = pdata[p]['wonWhenSeenStreet4']
line[32] = pdata[p]['wonAtSD']
if pdata[p]['raiseFirstInChance']: line[33] = 1
if pdata[p]['raisedFirstIn']: line[34] = 1
if pdata[p]['foldBbToStealChance']: line[35] = 1
if pdata[p]['foldedBbToSteal']: line[36] = 1
if pdata[p]['foldSbToStealChance']: line[37] = 1
if pdata[p]['foldedSbToSteal']: line[38] = 1
if pdata[p]['street1CBChance']: line[39] = 1
if pdata[p]['street1CBDone']: line[40] = 1
if pdata[p]['street2CBChance']: line[41] = 1
if pdata[p]['street2CBDone']: line[42] = 1
if pdata[p]['street3CBChance']: line[43] = 1
if pdata[p]['street3CBDone']: line[44] = 1
if pdata[p]['street4CBChance']: line[45] = 1
if pdata[p]['street4CBDone']: line[46] = 1
if pdata[p]['foldToStreet1CBChance']: line[47] = 1
if pdata[p]['foldToStreet1CBDone']: line[48] = 1
if pdata[p]['foldToStreet2CBChance']: line[49] = 1
if pdata[p]['foldToStreet2CBDone']: line[50] = 1
if pdata[p]['foldToStreet3CBChance']: line[51] = 1
if pdata[p]['foldToStreet3CBDone']: line[52] = 1
if pdata[p]['foldToStreet4CBChance']: line[53] = 1
if pdata[p]['foldToStreet4CBDone']: line[54] = 1
line[55] = pdata[p]['totalProfit']
if pdata[p]['street1CheckCallRaiseChance']: line[56] = 1
if pdata[p]['street1CheckCallRaiseDone']: line[57] = 1
if pdata[p]['street2CheckCallRaiseChance']: line[58] = 1
if pdata[p]['street2CheckCallRaiseDone']: line[59] = 1
if pdata[p]['street3CheckCallRaiseChance']: line[60] = 1
if pdata[p]['street3CheckCallRaiseDone']: line[61] = 1
if pdata[p]['street4CheckCallRaiseChance']: line[62] = 1
if pdata[p]['street4CheckCallRaiseDone']: line[63] = 1
if pdata[p]['street0Calls']: line[64] = 1
if pdata[p]['street1Calls']: line[65] = 1
if pdata[p]['street2Calls']: line[66] = 1
if pdata[p]['street3Calls']: line[67] = 1
if pdata[p]['street4Calls']: line[68] = 1
if pdata[p]['street0Bets']: line[69] = 1
if pdata[p]['street1Bets']: line[70] = 1
if pdata[p]['street2Bets']: line[71] = 1
if pdata[p]['street3Bets']: line[72] = 1
if pdata[p]['street4Bets']: line[73] = 1
if pdata[p]['street0Raises']: line[74] = 1
if pdata[p]['street1Raises']: line[75] = 1
if pdata[p]['street2Raises']: line[76] = 1
if pdata[p]['street3Raises']: line[77] = 1
if pdata[p]['street4Raises']: line[78] = 1
line[70] = gid # gametypeId
line[71] = pids[p] # playerId
line[72] = len(pids) # activeSeats
line[79] = gid # gametypeId
line[80] = pids[p] # playerId
line[81] = len(pids) # activeSeats
pos = {'B':'B', 'S':'S', 0:'D', 1:'C', 2:'M', 3:'M', 4:'M', 5:'E', 6:'E', 7:'E', 8:'E', 9:'E' }
line[73] = pos[pdata[p]['position']]
line[74] = pdata[p]['tourneyTypeId']
line[75] = styleKey # styleKey
line[82] = pos[pdata[p]['position']]
line[83] = pdata[p]['tourneyTypeId']
line[84] = styleKey # styleKey
inserts.append(line)

View File

@ -416,7 +416,16 @@ or None if we fail to get the info """
# ['player1name', 'player2name', ...] where player1name is the sb and player2name is bb,
# addtional players are assumed to post a bb oop
def readBlinds(self, hand): abstract
"""Function for reading the various blinds from the hand history.
Pass any small blind to hand.addBlind(<name>, "small blind", <value>)
- unless it is a single dead small blind then use:
hand.addBlind(<name>, 'secondsb', <value>)
Pass any big blind to hand.addBlind(<name>, "big blind", <value>)
Pass any play posting both big and small blinds to hand.addBlind(<name>, 'both', <vale>)
"""
def readAntes(self, hand): abstract
"""Function for reading the antes from the hand history and passing the hand.addAnte"""
def readBringIn(self, hand): abstract
def readButton(self, hand): abstract
def readHeroCards(self, hand): abstract
@ -473,18 +482,6 @@ or None if we fail to get the info """
self.filetype = filetype
self.codepage = codepage
#This function doesn't appear to be used
def splitFileIntoHands(self):
hands = []
self.obs = self.obs.strip()
list = self.re_SplitHands.split(self.obs)
list.pop() #Last entry is empty
for l in list:
# print "'" + l + "'"
hands = hands + [Hand.Hand(self.config, self.sitename, self.gametype, l)]
# TODO: This looks like it could be replaced with a list comp.. ?
return hands
def __listof(self, x):
if isinstance(x, list) or isinstance(x, tuple):
return x

View File

@ -525,7 +525,10 @@ class Hud:
def debug_stat_windows(self, *args):
# print self.table, "\n", self.main_window.window.get_transient_for()
for w in self.stat_windows:
print self.stat_windows[w].window.window.get_transient_for()
try:
print self.stat_windows[w].window.window.get_transient_for()
except AttributeError:
print "this window doesnt have get_transient_for"
def save_layout(self, *args):
new_layout = [(0, 0)] * self.max

View File

@ -66,8 +66,7 @@ def run(config, db):
#print "response to fetch subject:",response
if response!="OK":
raise error #TODO: show error message
if headerData[1].find("Subject: PokerStars Tournament History Request - Last x")!=1:
neededMessages.append(("PS", messageNumber))
neededMessages.append(("PS", messageNumber))
if (len(neededMessages)==0):
raise error #TODO: show error message

View File

@ -50,7 +50,7 @@ class OnGame(HandHistoryConverter):
'LS' : "\$|\xe2\x82\xac|" # legal currency symbols - Euro(cp1252, utf-8)
}
limits = { 'NO LIMIT':'nl', 'LIMIT':'fl'}
limits = { 'NO_LIMIT':'nl', 'LIMIT':'fl'}
games = { # base, category
"TEXAS_HOLDEM" : ('hold','holdem'),

View File

@ -108,6 +108,51 @@ class Sql:
self.query['createSettingsTable'] = """CREATE TABLE Settings
(version INTEGER NOT NULL) """
################################
# Create RawHands (this table is all but identical with RawTourneys)
################################
if db_server == 'mysql':
self.query['createRawHands'] = """CREATE TABLE RawHands (
id BIGINT UNSIGNED AUTO_INCREMENT NOT NULL, PRIMARY KEY (id),
handId BIGINT NOT NULL,
rawHand TEXT NOT NULL,
complain BOOLEAN NOT NULL DEFAULT FALSE)
ENGINE=INNODB"""
elif db_server == 'postgresql':
self.query['createRawHands'] = """CREATE TABLE RawHands (
id BIGSERIAL, PRIMARY KEY (id),
handId BIGINT NOT NULL,
rawHand TEXT NOT NULL,
complain BOOLEAN NOT NULL DEFAULT FALSE)"""
elif db_server == 'sqlite':
self.query['createRawHands'] = """CREATE TABLE RawHands (
id INTEGER PRIMARY KEY,
handId BIGINT NOT NULL,
rawHand TEXT NOT NULL,
complain BOOLEAN NOT NULL DEFAULT FALSE)"""
################################
# Create RawTourneys (this table is all but identical with RawHands)
################################
if db_server == 'mysql':
self.query['createRawTourneys'] = """CREATE TABLE RawTourneys (
id BIGINT UNSIGNED AUTO_INCREMENT NOT NULL, PRIMARY KEY (id),
tourneyId BIGINT NOT NULL,
rawTourney TEXT NOT NULL,
complain BOOLEAN NOT NULL DEFAULT FALSE)
ENGINE=INNODB"""
elif db_server == 'postgresql':
self.query['createRawTourneys'] = """CREATE TABLE RawTourneys (
id BIGSERIAL, PRIMARY KEY (id),
tourneyId BIGINT NOT NULL,
rawTourney TEXT NOT NULL,
complain BOOLEAN NOT NULL DEFAULT FALSE)"""
elif db_server == 'sqlite':
self.query['createRawTourneys'] = """CREATE TABLE RawTourneys (
id INTEGER PRIMARY KEY,
tourneyId BIGINT NOT NULL,
rawTourney TEXT NOT NULL,
complain BOOLEAN NOT NULL DEFAULT FALSE)"""
################################
# Create Sites
@ -3753,6 +3798,10 @@ class Sql:
street0Aggr=street0Aggr+%s,
street0_3BChance=street0_3BChance+%s,
street0_3BDone=street0_3BDone+%s,
street0_4BChance=street0_4BChance+%s,
street0_4BDone=street0_4BDone+%s,
other3BStreet0=other3BStreet0+%s,
other4BStreet0=other4BStreet0+%s,
street1Seen=street1Seen+%s,
street2Seen=street2Seen+%s,
street3Seen=street3Seen+%s,
@ -4182,7 +4231,7 @@ class Sql:
################################
# queries for dumpDatabase
################################
for table in (u'Autorates', u'Backings', u'Gametypes', u'Hands', u'HandsActions', u'HandsPlayers', u'HudCache', u'Players', u'Settings', u'Sites', u'TourneyTypes', u'Tourneys', u'TourneysPlayers'):
for table in (u'Autorates', u'Backings', u'Gametypes', u'Hands', u'HandsActions', u'HandsPlayers', u'HudCache', u'Players', u'RawHands', u'RawTourneys', u'Settings', u'Sites', u'TourneyTypes', u'Tourneys', u'TourneysPlayers'):
self.query['get'+table] = u"SELECT * FROM "+table
################################

View File

@ -1093,6 +1093,7 @@ You can find the full license texts in agpl-3.0.txt, gpl-2.0.txt, gpl-3.0.txt an
self.status_bar = None
self.quitting = False
self.visible = False
self.window = gtk.Window(gtk.WINDOW_TOPLEVEL)
self.window.connect("delete_event", self.delete_event)
self.window.connect("destroy", self.destroy)
@ -1130,6 +1131,7 @@ You can find the full license texts in agpl-3.0.txt, gpl-2.0.txt, gpl-3.0.txt an
self.tab_main_help(None, None)
self.window.show()
self.visible = True # Flip on
self.load_profile(create_db = True)
if not options.errorsToConsole:
@ -1165,21 +1167,31 @@ You can find the full license texts in agpl-3.0.txt, gpl-2.0.txt, gpl-3.0.txt an
self.window.connect('window-state-event', self.window_state_event_cb)
sys.stderr.write(_("fpdb starting ..."))
def __iconify(self):
self.visible = False
self.window.set_skip_taskbar_hint(True)
self.window.set_skip_pager_hint(True)
def __deiconify(self):
self.visible = True
self.window.set_skip_taskbar_hint(False)
self.window.set_skip_pager_hint(False)
def window_state_event_cb(self, window, event):
# Deal with iconification first
if event.changed_mask & gtk.gdk.WINDOW_STATE_ICONIFIED:
# -20 = GWL_EXSTYLE can't find it in the pywin32 libs
#bits = win32api.GetWindowLong(self.window.window.handle, -20)
#bits = bits ^ (win32con.WS_EX_TOOLWINDOW | win32con.WS_EX_APPWINDOW)
#win32api.SetWindowLong(self.window.window.handle, -20, bits)
if event.new_window_state & gtk.gdk.WINDOW_STATE_ICONIFIED:
self.window.hide()
self.window.set_skip_taskbar_hint(True)
self.window.set_skip_pager_hint(True)
self.__iconify()
else:
self.window.set_skip_taskbar_hint(False)
self.window.set_skip_pager_hint(False)
self.__deiconify()
if not event.new_window_state & gtk.gdk.WINDOW_STATE_WITHDRAWN:
return True
# And then the tray icon click
if event.new_window_state & gtk.gdk.WINDOW_STATE_WITHDRAWN:
self.__iconify()
else:
self.__deiconify()
# Tell GTK not to propagate this signal any further
return True
@ -1197,11 +1209,9 @@ You can find the full license texts in agpl-3.0.txt, gpl-2.0.txt, gpl-3.0.txt an
def statusicon_activate(self, widget, data = None):
# Let's allow the tray icon to toggle window visibility, the way
# most other apps work
shown = self.window.get_property('visible')
if shown:
if self.visible:
self.window.hide()
else:
self.window.show()
self.window.present()
def info_box(self, str1, str2):