Merge branch 'master' of git://git.assembla.com/free_poker_tools.git
This commit is contained in:
commit
98e376a956
|
@ -106,8 +106,23 @@ def valueSuitFromCard(card):
|
||||||
, '2s', '3s', '4s', '5s', '6s', '7s', '8s', '9s', 'Ts', 'Js', 'Qs', 'Ks', 'As'
|
, '2s', '3s', '4s', '5s', '6s', '7s', '8s', '9s', 'Ts', 'Js', 'Qs', 'Ks', 'As'
|
||||||
][card] )
|
][card] )
|
||||||
|
|
||||||
|
def encodeCard(cardString):
|
||||||
|
"""Take a card string (Ah) and convert it to the db card code (1)."""
|
||||||
|
try:
|
||||||
|
return {'2h': 1, '3h': 2, '4h': 3, '5h': 4, '6h': 5, '7h': 6, '8h': 7, '9h': 8, 'Th': 9, 'Jh': 10, 'Qh': 11, 'Kh': 12, 'Ah': 13,
|
||||||
|
'2d': 14, '3d': 15, '4d': 16, '5d': 17, '6d': 18, '7d': 19, '8d': 20, '9d': 21, 'Td': 22, 'Jd': 23, 'Qd': 24, 'Kd': 25, 'Ad': 26,
|
||||||
|
'2c': 27, '3c': 28, '4c': 29, '5c': 30, '6c': 31, '7c': 32, '8c': 33, '9c': 34, 'Tc': 35, 'Jc': 36, 'Qc': 27, 'Kc': 38, 'Ac': 39,
|
||||||
|
'2s': 40, '3s': 41, '4s': 42, '5s': 43, '6s': 44, '7s': 45, '8s': 46, '9s': 47, 'Ts': 48, 'Js': 49, 'Qs': 50, 'Ks': 51, 'As': 52,
|
||||||
|
' ': 0
|
||||||
|
}[cardString]
|
||||||
|
except:
|
||||||
|
return 0 # everthing that isn't known is a unknown!
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
print "fpdb card encoding(same as pokersource)"
|
||||||
for i in xrange(1, 14):
|
for i in xrange(1, 14):
|
||||||
print "card %2d = %s card %2d = %s card %2d = %s card %2d = %s" % \
|
print "card %2d = %s card %2d = %s card %2d = %s card %2d = %s" % \
|
||||||
(i, valueSuitFromCard(i), i+13, valueSuitFromCard(i+13), i+26, valueSuitFromCard(i+26), i+39, valueSuitFromCard(i+39))
|
(i, valueSuitFromCard(i), i+13, valueSuitFromCard(i+13), i+26, valueSuitFromCard(i+26), i+39, valueSuitFromCard(i+39))
|
||||||
|
|
||||||
|
print
|
||||||
|
print encodeCard('7c')
|
|
@ -64,11 +64,15 @@ class Database:
|
||||||
, [ # indexes for mysql (list index 2)
|
, [ # indexes for mysql (list index 2)
|
||||||
{'tab':'Players', 'col':'name', 'drop':0}
|
{'tab':'Players', 'col':'name', 'drop':0}
|
||||||
, {'tab':'Hands', 'col':'siteHandNo', 'drop':0}
|
, {'tab':'Hands', 'col':'siteHandNo', 'drop':0}
|
||||||
|
, {'tab':'Hands', 'col':'gametypeId', 'drop':0} # mct 22/3/09
|
||||||
|
, {'tab':'HandsPlayers', 'col':'handId', 'drop':0} # not needed, handled by fk
|
||||||
|
, {'tab':'HandsPlayers', 'col':'playerId', 'drop':0} # not needed, handled by fk
|
||||||
|
, {'tab':'HandsPlayers', 'col':'tourneysTypeId', 'drop':0}
|
||||||
|
, {'tab':'HandsPlayers', 'col':'tourneysPlayersId', 'drop':0}
|
||||||
, {'tab':'Tourneys', 'col':'siteTourneyNo', 'drop':0}
|
, {'tab':'Tourneys', 'col':'siteTourneyNo', 'drop':0}
|
||||||
]
|
]
|
||||||
, [ # indexes for postgres (list index 3)
|
, [ # indexes for postgres (list index 3)
|
||||||
{'tab':'Boardcards', 'col':'handId', 'drop':0}
|
{'tab':'Gametypes', 'col':'siteId', 'drop':0}
|
||||||
, {'tab':'Gametypes', 'col':'siteId', 'drop':0}
|
|
||||||
, {'tab':'Hands', 'col':'gametypeId', 'drop':0} # mct 22/3/09
|
, {'tab':'Hands', 'col':'gametypeId', 'drop':0} # mct 22/3/09
|
||||||
, {'tab':'Hands', 'col':'siteHandNo', 'drop':0}
|
, {'tab':'Hands', 'col':'siteHandNo', 'drop':0}
|
||||||
, {'tab':'HandsActions', 'col':'handsPlayerId', 'drop':0}
|
, {'tab':'HandsActions', 'col':'handsPlayerId', 'drop':0}
|
||||||
|
@ -589,16 +593,17 @@ class Database:
|
||||||
"""Drop some indexes/foreign keys to prepare for bulk import.
|
"""Drop some indexes/foreign keys to prepare for bulk import.
|
||||||
Currently keeping the standalone indexes as needed to import quickly"""
|
Currently keeping the standalone indexes as needed to import quickly"""
|
||||||
stime = time()
|
stime = time()
|
||||||
|
c = self.get_cursor()
|
||||||
|
# sc: don't think autocommit=0 is needed, should already be in that mode
|
||||||
if self.backend == self.MYSQL_INNODB:
|
if self.backend == self.MYSQL_INNODB:
|
||||||
self.get_cursor().execute("SET foreign_key_checks=0")
|
c.execute("SET foreign_key_checks=0")
|
||||||
self.get_cursor().execute("SET autocommit=0")
|
c.execute("SET autocommit=0")
|
||||||
return
|
return
|
||||||
if self.backend == self.PGSQL:
|
if self.backend == self.PGSQL:
|
||||||
self.connection.set_isolation_level(0) # allow table/index operations to work
|
self.connection.set_isolation_level(0) # allow table/index operations to work
|
||||||
for fk in self.foreignKeys[self.backend]:
|
for fk in self.foreignKeys[self.backend]:
|
||||||
if fk['drop'] == 1:
|
if fk['drop'] == 1:
|
||||||
if self.backend == self.MYSQL_INNODB:
|
if self.backend == self.MYSQL_INNODB:
|
||||||
c = self.get_cursor()
|
|
||||||
c.execute("SELECT constraint_name " +
|
c.execute("SELECT constraint_name " +
|
||||||
"FROM information_schema.KEY_COLUMN_USAGE " +
|
"FROM information_schema.KEY_COLUMN_USAGE " +
|
||||||
#"WHERE REFERENCED_TABLE_SCHEMA = 'fpdb'
|
#"WHERE REFERENCED_TABLE_SCHEMA = 'fpdb'
|
||||||
|
@ -608,13 +613,13 @@ class Database:
|
||||||
"AND referenced_column_name = %s ",
|
"AND referenced_column_name = %s ",
|
||||||
(fk['fktab'], fk['fkcol'], fk['rtab'], fk['rcol']) )
|
(fk['fktab'], fk['fkcol'], fk['rtab'], fk['rcol']) )
|
||||||
cons = c.fetchone()
|
cons = c.fetchone()
|
||||||
#print "preparebulk: cons=", cons
|
print "preparebulk find fk: cons=", cons
|
||||||
if cons:
|
if cons:
|
||||||
print "dropping mysql fk", cons[0], fk['fktab'], fk['fkcol']
|
print "dropping mysql fk", cons[0], fk['fktab'], fk['fkcol']
|
||||||
try:
|
try:
|
||||||
c.execute("alter table " + fk['fktab'] + " drop foreign key " + cons[0])
|
c.execute("alter table " + fk['fktab'] + " drop foreign key " + cons[0])
|
||||||
except:
|
except:
|
||||||
pass
|
print " drop failed: " + str(sys.exc_info())
|
||||||
elif self.backend == self.PGSQL:
|
elif self.backend == self.PGSQL:
|
||||||
# DON'T FORGET TO RECREATE THEM!!
|
# DON'T FORGET TO RECREATE THEM!!
|
||||||
print "dropping pg fk", fk['fktab'], fk['fkcol']
|
print "dropping pg fk", fk['fktab'], fk['fkcol']
|
||||||
|
@ -640,16 +645,18 @@ class Database:
|
||||||
print "Only MySQL and Postgres supported so far"
|
print "Only MySQL and Postgres supported so far"
|
||||||
return -1
|
return -1
|
||||||
|
|
||||||
for idx in indexes[self.backend]:
|
for idx in self.indexes[self.backend]:
|
||||||
if idx['drop'] == 1:
|
if idx['drop'] == 1:
|
||||||
if self.backend == self.MYSQL_INNODB:
|
if self.backend == self.MYSQL_INNODB:
|
||||||
print "dropping mysql index ", idx['tab'], idx['col']
|
print "dropping mysql index ", idx['tab'], idx['col']
|
||||||
try:
|
try:
|
||||||
# apparently nowait is not implemented in mysql so this just hands if there are locks
|
# apparently nowait is not implemented in mysql so this just hangs if there are locks
|
||||||
# preventing the index drop :-(
|
# preventing the index drop :-(
|
||||||
c.execute( "alter table %s drop index %s", (idx['tab'],idx['col']) )
|
c.execute( "alter table %s drop index %s;", (idx['tab'],idx['col']) )
|
||||||
except:
|
except:
|
||||||
pass
|
print " drop index failed: " + str(sys.exc_info())
|
||||||
|
# ALTER TABLE `fpdb`.`handsplayers` DROP INDEX `playerId`;
|
||||||
|
# using: 'HandsPlayers' drop index 'playerId'
|
||||||
elif self.backend == self.PGSQL:
|
elif self.backend == self.PGSQL:
|
||||||
# DON'T FORGET TO RECREATE THEM!!
|
# DON'T FORGET TO RECREATE THEM!!
|
||||||
print "dropping pg index ", idx['tab'], idx['col']
|
print "dropping pg index ", idx['tab'], idx['col']
|
||||||
|
@ -684,8 +691,8 @@ class Database:
|
||||||
"""Re-create any dropped indexes/foreign keys after bulk import"""
|
"""Re-create any dropped indexes/foreign keys after bulk import"""
|
||||||
stime = time()
|
stime = time()
|
||||||
|
|
||||||
if self.backend == self.MYSQL_INNODB:
|
|
||||||
c = self.get_cursor()
|
c = self.get_cursor()
|
||||||
|
if self.backend == self.MYSQL_INNODB:
|
||||||
c.execute("SET foreign_key_checks=1")
|
c.execute("SET foreign_key_checks=1")
|
||||||
c.execute("SET autocommit=1")
|
c.execute("SET autocommit=1")
|
||||||
return
|
return
|
||||||
|
@ -714,7 +721,7 @@ class Database:
|
||||||
+ fk['fkcol'] + ") references " + fk['rtab'] + "("
|
+ fk['fkcol'] + ") references " + fk['rtab'] + "("
|
||||||
+ fk['rcol'] + ")")
|
+ fk['rcol'] + ")")
|
||||||
except:
|
except:
|
||||||
pass
|
print " create fk failed: " + str(sys.exc_info())
|
||||||
elif self.backend == self.PGSQL:
|
elif self.backend == self.PGSQL:
|
||||||
print "creating fk ", fk['fktab'], fk['fkcol'], "->", fk['rtab'], fk['rcol']
|
print "creating fk ", fk['fktab'], fk['fkcol'], "->", fk['rtab'], fk['rcol']
|
||||||
try:
|
try:
|
||||||
|
@ -723,12 +730,12 @@ class Database:
|
||||||
+ " foreign key (" + fk['fkcol']
|
+ " foreign key (" + fk['fkcol']
|
||||||
+ ") references " + fk['rtab'] + "(" + fk['rcol'] + ")")
|
+ ") references " + fk['rtab'] + "(" + fk['rcol'] + ")")
|
||||||
except:
|
except:
|
||||||
pass
|
print " create fk failed: " + str(sys.exc_info())
|
||||||
else:
|
else:
|
||||||
print "Only MySQL and Postgres supported so far"
|
print "Only MySQL and Postgres supported so far"
|
||||||
return -1
|
return -1
|
||||||
|
|
||||||
for idx in indexes[self.backend]:
|
for idx in self.indexes[self.backend]:
|
||||||
if idx['drop'] == 1:
|
if idx['drop'] == 1:
|
||||||
if self.backend == self.MYSQL_INNODB:
|
if self.backend == self.MYSQL_INNODB:
|
||||||
print "creating mysql index ", idx['tab'], idx['col']
|
print "creating mysql index ", idx['tab'], idx['col']
|
||||||
|
@ -736,7 +743,7 @@ class Database:
|
||||||
c.execute( "alter table %s add index %s(%s)"
|
c.execute( "alter table %s add index %s(%s)"
|
||||||
, (idx['tab'],idx['col'],idx['col']) )
|
, (idx['tab'],idx['col'],idx['col']) )
|
||||||
except:
|
except:
|
||||||
pass
|
print " create fk failed: " + str(sys.exc_info())
|
||||||
elif self.backend == self.PGSQL:
|
elif self.backend == self.PGSQL:
|
||||||
# pass
|
# pass
|
||||||
# mod to use tab_col for index name?
|
# mod to use tab_col for index name?
|
||||||
|
@ -746,8 +753,7 @@ class Database:
|
||||||
c.execute( "create index %s_%s_idx on %s(%s)"
|
c.execute( "create index %s_%s_idx on %s(%s)"
|
||||||
% (idx['tab'], idx['col'], idx['tab'], idx['col']) )
|
% (idx['tab'], idx['col'], idx['tab'], idx['col']) )
|
||||||
except:
|
except:
|
||||||
print " ERROR! :-("
|
print " create index failed: " + str(sys.exc_info())
|
||||||
pass
|
|
||||||
else:
|
else:
|
||||||
print "Only MySQL and Postgres supported so far"
|
print "Only MySQL and Postgres supported so far"
|
||||||
return -1
|
return -1
|
||||||
|
@ -823,12 +829,12 @@ class Database:
|
||||||
"""Drops the fpdb tables from the current db"""
|
"""Drops the fpdb tables from the current db"""
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
c = self.get_cursor()
|
||||||
if(self.get_backend_name() == 'MySQL InnoDB'):
|
if(self.get_backend_name() == 'MySQL InnoDB'):
|
||||||
#Databases with FOREIGN KEY support need this switched of before you can drop tables
|
#Databases with FOREIGN KEY support need this switched of before you can drop tables
|
||||||
self.drop_referential_integrity()
|
self.drop_referential_integrity()
|
||||||
|
|
||||||
# Query the DB to see what tables exist
|
# Query the DB to see what tables exist
|
||||||
c = self.get_cursor()
|
|
||||||
c.execute(self.sql.query['list_tables'])
|
c.execute(self.sql.query['list_tables'])
|
||||||
for table in c:
|
for table in c:
|
||||||
c.execute(self.sql.query['drop_table'] + table[0])
|
c.execute(self.sql.query['drop_table'] + table[0])
|
||||||
|
@ -974,6 +980,62 @@ class Database:
|
||||||
#end def lock_for_insert
|
#end def lock_for_insert
|
||||||
|
|
||||||
|
|
||||||
|
def store_the_hand(self, h):
|
||||||
|
"""Take a HandToWrite object and store it in the db"""
|
||||||
|
|
||||||
|
# Following code writes hands to database and commits (or rolls back if there is an error)
|
||||||
|
try:
|
||||||
|
result = None
|
||||||
|
if h.isTourney:
|
||||||
|
ranks = map(lambda x: 0, h.names) # create an array of 0's equal to the length of names
|
||||||
|
payin_amounts = fpdb_simple.calcPayin(len(h.names), h.buyin, h.fee)
|
||||||
|
|
||||||
|
if h.base == "hold":
|
||||||
|
result = self.tourney_holdem_omaha(
|
||||||
|
h.config, h.settings, h.base, h.category, h.siteTourneyNo, h.buyin
|
||||||
|
, h.fee, h.knockout, h.entries, h.prizepool, h.tourneyStartTime
|
||||||
|
, h.payin_amounts, h.ranks, h.tourneyTypeId, h.siteID, h.siteHandNo
|
||||||
|
, h.gametypeID, h.handStartTime, h.names, h.playerIDs, h.startCashes
|
||||||
|
, h.positions, h.cardValues, h.cardSuits, h.boardValues, h.boardSuits
|
||||||
|
, h.winnings, h.rakes, h.actionTypes, h.allIns, h.actionAmounts
|
||||||
|
, h.actionNos, h.hudImportData, h.maxSeats, h.tableName, h.seatNos)
|
||||||
|
elif h.base == "stud":
|
||||||
|
result = self.tourney_stud(
|
||||||
|
h.config, h.settings, h.base, h.category, h.siteTourneyNo
|
||||||
|
, h.buyin, h.fee, h.knockout, h.entries, h.prizepool, h.tourneyStartTime
|
||||||
|
, h.payin_amounts, h.ranks, h.tourneyTypeId, h.siteID, h.siteHandNo
|
||||||
|
, h.gametypeID, h.handStartTime, h.names, h.playerIDs, h.startCashes
|
||||||
|
, h.antes, h.cardValues, h.cardSuits, h.winnings, h.rakes, h.actionTypes
|
||||||
|
, h.allIns, h.actionAmounts, h.actionNos, h.hudImportData, h.maxSeats
|
||||||
|
, h.tableName, h.seatNos)
|
||||||
|
else:
|
||||||
|
raise fpself.simple.Fpself.rror("unrecognised category")
|
||||||
|
else:
|
||||||
|
if h.base == "hold":
|
||||||
|
result = self.ring_holdem_omaha(
|
||||||
|
h.config, h.settings, h.base, h.category, h.siteHandNo
|
||||||
|
, h.gametypeID, h.handStartTime, h.names, h.playerIDs
|
||||||
|
, h.startCashes, h.positions, h.cardValues, h.cardSuits
|
||||||
|
, h.boardValues, h.boardSuits, h.winnings, h.rakes
|
||||||
|
, h.actionTypes, h.allIns, h.actionAmounts, h.actionNos
|
||||||
|
, h.hudImportData, h.maxSeats, h.tableName, h.seatNos)
|
||||||
|
elif h.base == "stud":
|
||||||
|
result = self.ring_stud(
|
||||||
|
h.config, h.settings, h.base, h.category, h.siteHandNo, h.gametypeID
|
||||||
|
, h.handStartTime, h.names, h.playerIDs, h.startCashes, h.antes
|
||||||
|
, h.cardValues, h.cardSuits, h.winnings, h.rakes, h.actionTypes, h.allIns
|
||||||
|
, h.actionAmounts, h.actionNos, h.hudImportData, h.maxSeats, h.tableName
|
||||||
|
, h.seatNos)
|
||||||
|
else:
|
||||||
|
raise fpself.simple.Fpself.rror ("unrecognised category")
|
||||||
|
self.commit()
|
||||||
|
except:
|
||||||
|
print "Error storing hand: " + str(sys.exc_value)
|
||||||
|
self.rollback()
|
||||||
|
|
||||||
|
return result
|
||||||
|
#end def store_the_hand
|
||||||
|
|
||||||
def storeHands(self, backend, site_hand_no, gametype_id
|
def storeHands(self, backend, site_hand_no, gametype_id
|
||||||
,hand_start_time, names, tableName, maxSeats, hudCache
|
,hand_start_time, names, tableName, maxSeats, hudCache
|
||||||
,board_values, board_suits):
|
,board_values, board_suits):
|
||||||
|
@ -1514,6 +1576,157 @@ class Database:
|
||||||
#end def store_tourneys_players
|
#end def store_tourneys_players
|
||||||
|
|
||||||
|
|
||||||
|
# Class used to hold all the data needed to write a hand to the db
|
||||||
|
# mainParser() in fpdb_parse_logic.py creates one of these and then passes it to
|
||||||
|
|
||||||
|
class HandToWrite:
|
||||||
|
|
||||||
|
def __init__(self, finished = False): # db_name and game not used any more
|
||||||
|
try:
|
||||||
|
self.finished = finished
|
||||||
|
self.config = None
|
||||||
|
self.settings = None
|
||||||
|
self.base = None
|
||||||
|
self.category = None
|
||||||
|
self.siteTourneyNo = None
|
||||||
|
self.buyin = None
|
||||||
|
self.fee = None
|
||||||
|
self.knockout = None
|
||||||
|
self.entries = None
|
||||||
|
self.prizepool = None
|
||||||
|
self.tourneyStartTime = None
|
||||||
|
self.isTourney = None
|
||||||
|
self.tourneyTypeId = None
|
||||||
|
self.siteID = None
|
||||||
|
self.siteHandNo = None
|
||||||
|
self.gametypeID = None
|
||||||
|
self.handStartTime = None
|
||||||
|
self.names = None
|
||||||
|
self.playerIDs = None
|
||||||
|
self.startCashes = None
|
||||||
|
self.positions = None
|
||||||
|
self.antes = None
|
||||||
|
self.cardValues = None
|
||||||
|
self.cardSuits = None
|
||||||
|
self.boardValues = None
|
||||||
|
self.boardSuits = None
|
||||||
|
self.winnings = None
|
||||||
|
self.rakes = None
|
||||||
|
self.actionTypes = None
|
||||||
|
self.allIns = None
|
||||||
|
self.actionAmounts = None
|
||||||
|
self.actionNos = None
|
||||||
|
self.hudImportData = None
|
||||||
|
self.maxSeats = None
|
||||||
|
self.tableName = None
|
||||||
|
self.seatNos = None
|
||||||
|
except:
|
||||||
|
print "htw.init error: " + str(sys.exc_info())
|
||||||
|
raise
|
||||||
|
# end def __init__
|
||||||
|
|
||||||
|
def set_all( self, config, settings, base, category, siteTourneyNo, buyin
|
||||||
|
, fee, knockout, entries, prizepool, tourneyStartTime
|
||||||
|
, isTourney, tourneyTypeId, siteID, siteHandNo
|
||||||
|
, gametypeID, handStartTime, names, playerIDs, startCashes
|
||||||
|
, positions, antes, cardValues, cardSuits, boardValues, boardSuits
|
||||||
|
, winnings, rakes, actionTypes, allIns, actionAmounts
|
||||||
|
, actionNos, hudImportData, maxSeats, tableName, seatNos):
|
||||||
|
|
||||||
|
try:
|
||||||
|
self.config = config
|
||||||
|
self.settings = settings
|
||||||
|
self.base = base
|
||||||
|
self.category = category
|
||||||
|
self.siteTourneyNo = siteTourneyNo
|
||||||
|
self.buyin = buyin
|
||||||
|
self.fee = fee
|
||||||
|
self.knockout = knockout
|
||||||
|
self.entries = entries
|
||||||
|
self.prizepool = prizepool
|
||||||
|
self.tourneyStartTime = tourneyStartTime
|
||||||
|
self.isTourney = isTourney
|
||||||
|
self.tourneyTypeId = tourneyTypeId
|
||||||
|
self.siteID = siteID
|
||||||
|
self.siteHandNo = siteHandNo
|
||||||
|
self.gametypeID = gametypeID
|
||||||
|
self.handStartTime = handStartTime
|
||||||
|
self.names = names
|
||||||
|
self.playerIDs = playerIDs
|
||||||
|
self.startCashes = startCashes
|
||||||
|
self.positions = positions
|
||||||
|
self.antes = antes
|
||||||
|
self.cardValues = cardValues
|
||||||
|
self.cardSuits = cardSuits
|
||||||
|
self.boardValues = boardValues
|
||||||
|
self.boardSuits = boardSuits
|
||||||
|
self.winnings = winnings
|
||||||
|
self.rakes = rakes
|
||||||
|
self.actionTypes = actionTypes
|
||||||
|
self.allIns = allIns
|
||||||
|
self.actionAmounts = actionAmounts
|
||||||
|
self.actionNos = actionNos
|
||||||
|
self.hudImportData = hudImportData
|
||||||
|
self.maxSeats = maxSeats
|
||||||
|
self.tableName = tableName
|
||||||
|
self.seatNos = seatNos
|
||||||
|
except:
|
||||||
|
print "htw.set_all error: " + str(sys.exc_info())
|
||||||
|
raise
|
||||||
|
# end def set_hand
|
||||||
|
|
||||||
|
def set_ring_holdem_omaha( self, config, settings, base, category, siteHandNo
|
||||||
|
, gametypeID, handStartTime, names, playerIDs
|
||||||
|
, startCashes, positions, cardValues, cardSuits
|
||||||
|
, boardValues, boardSuits, winnings, rakes
|
||||||
|
, actionTypes, allIns, actionAmounts, actionNos
|
||||||
|
, hudImportData, maxSeats, tableName, seatNos ):
|
||||||
|
self.config = config
|
||||||
|
self.settings = settings
|
||||||
|
self.base = base
|
||||||
|
self.category = category
|
||||||
|
self.siteHandNo = siteHandNo
|
||||||
|
self.gametypeID = gametypeID
|
||||||
|
self.handStartTime = handStartTime
|
||||||
|
self.names = names
|
||||||
|
self.playerIDs = playerIDs
|
||||||
|
self.startCashes = startCashes
|
||||||
|
self.positions = positions
|
||||||
|
self.cardValues = cardValues
|
||||||
|
self.cardSuits = cardSuits
|
||||||
|
self.boardValues = boardValues
|
||||||
|
self.boardSuits = boardSuits
|
||||||
|
self.winnings = winnings
|
||||||
|
self.rakes = rakes
|
||||||
|
self.actionTypes = actionTypes
|
||||||
|
self.allIns = allIns
|
||||||
|
self.actionAmounts = actionAmounts
|
||||||
|
self.actionNos = actionNos
|
||||||
|
self.hudImportData = hudImportData
|
||||||
|
self.maxSeats = maxSeats
|
||||||
|
self.tableName = tableName
|
||||||
|
self.seatNos = seatNos
|
||||||
|
# end def set_ring_holdem_omaha
|
||||||
|
|
||||||
|
def send_ring_holdem_omaha(self, db):
|
||||||
|
result = db.ring_holdem_omaha(
|
||||||
|
self.config, self.settings, self.base, self.category, self.siteHandNo
|
||||||
|
, self.gametypeID, self.handStartTime, self.names, self.playerIDs
|
||||||
|
, self.startCashes, self.positions, self.cardValues, self.cardSuits
|
||||||
|
, self.boardValues, self.boardSuits, self.winnings, self.rakes
|
||||||
|
, self.actionTypes, self.allIns, self.actionAmounts, self.actionNos
|
||||||
|
, self.hudImportData, self.maxSeats, self.tableName, self.seatNos)
|
||||||
|
# end def send_ring_holdem_omaha
|
||||||
|
|
||||||
|
def get_finished(self):
|
||||||
|
return( self.finished )
|
||||||
|
# end def get_finished
|
||||||
|
|
||||||
|
def get_siteHandNo(self):
|
||||||
|
return( self.siteHandNo )
|
||||||
|
# end def get_siteHandNo
|
||||||
|
|
||||||
|
|
||||||
if __name__=="__main__":
|
if __name__=="__main__":
|
||||||
c = Configuration.Config()
|
c = Configuration.Config()
|
||||||
|
|
||||||
|
|
|
@ -34,6 +34,7 @@ import Configuration
|
||||||
|
|
||||||
class GuiBulkImport():
|
class GuiBulkImport():
|
||||||
|
|
||||||
|
# not used
|
||||||
def import_dir(self):
|
def import_dir(self):
|
||||||
"""imports a directory, non-recursive. todo: move this to fpdb_import so CLI can use it"""
|
"""imports a directory, non-recursive. todo: move this to fpdb_import so CLI can use it"""
|
||||||
|
|
||||||
|
@ -80,7 +81,7 @@ class GuiBulkImport():
|
||||||
ttime = time() - starttime
|
ttime = time() - starttime
|
||||||
if ttime == 0:
|
if ttime == 0:
|
||||||
ttime = 1
|
ttime = 1
|
||||||
print 'GuiBulkImport.import_dir done: Stored: %d \tDuplicates: %d \tPartial: %d \tErrors: %d in %s seconds - %d/sec'\
|
print 'GuiBulkImport.load done: Stored: %d \tDuplicates: %d \tPartial: %d \tErrors: %d in %s seconds - %d/sec'\
|
||||||
% (stored, dups, partial, errs, ttime, stored / ttime)
|
% (stored, dups, partial, errs, ttime, stored / ttime)
|
||||||
self.importer.clearFileList()
|
self.importer.clearFileList()
|
||||||
|
|
||||||
|
@ -96,10 +97,10 @@ class GuiBulkImport():
|
||||||
"""returns the vbox of this thread"""
|
"""returns the vbox of this thread"""
|
||||||
return self.vbox
|
return self.vbox
|
||||||
|
|
||||||
def __init__(self, settings, config):
|
def __init__(self, settings, config, sql = None):
|
||||||
self.settings = settings
|
self.settings = settings
|
||||||
self.config = config
|
self.config = config
|
||||||
self.importer = fpdb_import.Importer(self, self.settings, config)
|
self.importer = fpdb_import.Importer(self, self.settings, config, sql)
|
||||||
|
|
||||||
self.vbox = gtk.VBox(False, 0)
|
self.vbox = gtk.VBox(False, 0)
|
||||||
self.vbox.show()
|
self.vbox.show()
|
||||||
|
|
|
@ -235,12 +235,8 @@ class Hud:
|
||||||
# does the user have a fav_seat?
|
# does the user have a fav_seat?
|
||||||
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:
|
||||||
try:
|
try:
|
||||||
sys.stderr.write("site = %s, max = %d, fav seat = %d\n" % (self.table.site, self.max, config.supported_sites[self.table.site].layout[self.max].fav_seat))
|
|
||||||
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
|
||||||
sys.stderr.write("found fav seat = %d\n" % fav_seat)
|
|
||||||
# actual_seat = self.db_connection.get_actual_seat(hand, config.supported_sites[self.table.site].screen_name)
|
|
||||||
actual_seat = self.get_actual_seat(config.supported_sites[self.table.site].screen_name)
|
actual_seat = self.get_actual_seat(config.supported_sites[self.table.site].screen_name)
|
||||||
sys.stderr.write("found actual seat = %d\n" % actual_seat)
|
|
||||||
for i in xrange(0, self.max + 1):
|
for i in xrange(0, self.max + 1):
|
||||||
j = actual_seat + i
|
j = actual_seat + i
|
||||||
if j > self.max:
|
if j > self.max:
|
||||||
|
@ -273,7 +269,6 @@ class Hud:
|
||||||
self.cards = cards
|
self.cards = cards
|
||||||
sys.stderr.write("------------------------------------------------------------\nCreating hud from hand %s\n" % hand)
|
sys.stderr.write("------------------------------------------------------------\nCreating hud from hand %s\n" % hand)
|
||||||
adj = self.adj_seats(hand, config)
|
adj = self.adj_seats(hand, config)
|
||||||
sys.stderr.write("adj = %s\n" % adj)
|
|
||||||
loc = self.config.get_locations(self.table.site, self.max)
|
loc = self.config.get_locations(self.table.site, self.max)
|
||||||
|
|
||||||
# create the stat windows
|
# create the stat windows
|
||||||
|
@ -282,7 +277,6 @@ class Hud:
|
||||||
if i in self.stat_windows:
|
if i in self.stat_windows:
|
||||||
self.stat_windows[i].relocate(x, y)
|
self.stat_windows[i].relocate(x, y)
|
||||||
else:
|
else:
|
||||||
sys.stderr.write("actual seat = %d, x = %d, y= %d\n" % (i, x, y))
|
|
||||||
self.stat_windows[i] = Stat_Window(game = config.supported_games[self.poker_game],
|
self.stat_windows[i] = Stat_Window(game = config.supported_games[self.poker_game],
|
||||||
parent = self,
|
parent = self,
|
||||||
table = self.table,
|
table = self.table,
|
||||||
|
|
|
@ -294,6 +294,7 @@ class Stud_cards:
|
||||||
def update_gui(self, new_hand_id):
|
def update_gui(self, new_hand_id):
|
||||||
self.clear()
|
self.clear()
|
||||||
for c, cards in self.parent.hud.cards.iteritems():
|
for c, cards in self.parent.hud.cards.iteritems():
|
||||||
|
if c == 'common': continue
|
||||||
self.grid_contents[(1, c - 1)].set_text(self.get_screen_name(c))
|
self.grid_contents[(1, c - 1)].set_text(self.get_screen_name(c))
|
||||||
for i in ((0, cards[0]), (1, cards[1]), (2, cards[2]), (3, cards[3]),
|
for i in ((0, cards[0]), (1, cards[1]), (2, cards[2]), (3, cards[3]),
|
||||||
(4, cards[4]), (5, cards[5]), (6, cards[6])):
|
(4, cards[4]), (5, cards[5]), (6, cards[6])):
|
||||||
|
@ -462,7 +463,6 @@ class Flop_Mucked(Aux_Seats):
|
||||||
if n_cards > 0 and i != 'common':
|
if n_cards > 0 and i != 'common':
|
||||||
n_sd = n_sd + 1
|
n_sd = n_sd + 1
|
||||||
if n_sd < 2:
|
if n_sd < 2:
|
||||||
print "skipping, n_sd =", n_sd
|
|
||||||
return
|
return
|
||||||
|
|
||||||
super(Flop_Mucked, self).update_gui(new_hand_id)
|
super(Flop_Mucked, self).update_gui(new_hand_id)
|
||||||
|
|
|
@ -165,9 +165,10 @@ class Sql:
|
||||||
################################
|
################################
|
||||||
# List tables
|
# List tables
|
||||||
################################
|
################################
|
||||||
|
print "db_server =", db_server
|
||||||
if db_server == 'mysql':
|
if db_server == 'mysql':
|
||||||
self.query['list_tables'] = """SHOW TABLES"""
|
self.query['list_tables'] = """SHOW TABLES"""
|
||||||
elif db_server == 'postgres': # what is the correct value here?
|
elif db_server == 'postgresql': # what is the correct value here?
|
||||||
self.query['list_tables'] = """SELECT table_name FROM information_schema.tables WHERE table_schema = 'public'"""
|
self.query['list_tables'] = """SELECT table_name FROM information_schema.tables WHERE table_schema = 'public'"""
|
||||||
elif db_server == 'sqlite': # what is the correct value here?
|
elif db_server == 'sqlite': # what is the correct value here?
|
||||||
self.query['list_tables'] = """SELECT name FROM sqlite_master
|
self.query['list_tables'] = """SELECT name FROM sqlite_master
|
||||||
|
@ -188,7 +189,7 @@ class Sql:
|
||||||
self.query['createSettingsTable'] = """CREATE TABLE Settings (
|
self.query['createSettingsTable'] = """CREATE TABLE Settings (
|
||||||
version SMALLINT NOT NULL)
|
version SMALLINT NOT NULL)
|
||||||
ENGINE=INNODB"""
|
ENGINE=INNODB"""
|
||||||
elif db_server == 'postgres': # what is the correct value here?
|
elif db_server == 'postgresql': # what is the correct value here?
|
||||||
self.query['createSettingsTable'] = """CREATE TABLE Settings (version SMALLINT)"""
|
self.query['createSettingsTable'] = """CREATE TABLE Settings (version SMALLINT)"""
|
||||||
|
|
||||||
elif db_server == 'sqlite': # what is the correct value here?
|
elif db_server == 'sqlite': # what is the correct value here?
|
||||||
|
@ -206,7 +207,7 @@ class Sql:
|
||||||
name varchar(32) NOT NULL,
|
name varchar(32) NOT NULL,
|
||||||
currency char(3) NOT NULL)
|
currency char(3) NOT NULL)
|
||||||
ENGINE=INNODB"""
|
ENGINE=INNODB"""
|
||||||
elif db_server == 'postgres': # what is the correct value here?
|
elif db_server == 'postgresql': # what is the correct value here?
|
||||||
self.query['createSitesTable'] = """CREATE TABLE Sites (
|
self.query['createSitesTable'] = """CREATE TABLE Sites (
|
||||||
id SERIAL, PRIMARY KEY (id),
|
id SERIAL, PRIMARY KEY (id),
|
||||||
name varchar(32),
|
name varchar(32),
|
||||||
|
@ -236,7 +237,7 @@ class Sql:
|
||||||
smallBet int NOT NULL,
|
smallBet int NOT NULL,
|
||||||
bigBet int NOT NULL)
|
bigBet int NOT NULL)
|
||||||
ENGINE=INNODB"""
|
ENGINE=INNODB"""
|
||||||
elif db_server == 'postgres': # what is the correct value here?
|
elif db_server == 'postgresql': # what is the correct value here?
|
||||||
self.query['createGametypesTable'] = """CREATE TABLE Gametypes (
|
self.query['createGametypesTable'] = """CREATE TABLE Gametypes (
|
||||||
id SERIAL, PRIMARY KEY (id),
|
id SERIAL, PRIMARY KEY (id),
|
||||||
siteId INTEGER, FOREIGN KEY (siteId) REFERENCES Sites(id),
|
siteId INTEGER, FOREIGN KEY (siteId) REFERENCES Sites(id),
|
||||||
|
@ -277,7 +278,7 @@ class Sql:
|
||||||
comment text,
|
comment text,
|
||||||
commentTs DATETIME)
|
commentTs DATETIME)
|
||||||
ENGINE=INNODB"""
|
ENGINE=INNODB"""
|
||||||
elif db_server == 'postgres': # what is the correct value here?
|
elif db_server == 'postgresql': # what is the correct value here?
|
||||||
self.query['createPlayersTable'] = """CREATE TABLE Players (
|
self.query['createPlayersTable'] = """CREATE TABLE Players (
|
||||||
id SERIAL, PRIMARY KEY (id),
|
id SERIAL, PRIMARY KEY (id),
|
||||||
name VARCHAR(32),
|
name VARCHAR(32),
|
||||||
|
@ -308,7 +309,7 @@ class Sql:
|
||||||
ratingTime DATETIME NOT NULL,
|
ratingTime DATETIME NOT NULL,
|
||||||
handCount int NOT NULL)
|
handCount int NOT NULL)
|
||||||
ENGINE=INNODB"""
|
ENGINE=INNODB"""
|
||||||
elif db_server == 'postgres': # what is the correct value here?
|
elif db_server == 'postgresql': # what is the correct value here?
|
||||||
self.query['createAutoratesTable'] = """CREATE TABLE Autorates (
|
self.query['createAutoratesTable'] = """CREATE TABLE Autorates (
|
||||||
id BIGSERIAL, PRIMARY KEY (id),
|
id BIGSERIAL, PRIMARY KEY (id),
|
||||||
playerId INT, FOREIGN KEY (playerId) REFERENCES Players(id),
|
playerId INT, FOREIGN KEY (playerId) REFERENCES Players(id),
|
||||||
|
@ -360,7 +361,7 @@ class Sql:
|
||||||
comment TEXT,
|
comment TEXT,
|
||||||
commentTs DATETIME)
|
commentTs DATETIME)
|
||||||
ENGINE=INNODB"""
|
ENGINE=INNODB"""
|
||||||
elif db_server == 'postgres': # what is the correct value here?
|
elif db_server == 'postgresql': # what is the correct value here?
|
||||||
self.query['createHandsTable'] = """CREATE TABLE Hands (
|
self.query['createHandsTable'] = """CREATE TABLE Hands (
|
||||||
id BIGSERIAL, PRIMARY KEY (id),
|
id BIGSERIAL, PRIMARY KEY (id),
|
||||||
tableName VARCHAR(20) NOT NULL,
|
tableName VARCHAR(20) NOT NULL,
|
||||||
|
@ -422,7 +423,7 @@ class Sql:
|
||||||
knockout INT NOT NULL,
|
knockout INT NOT NULL,
|
||||||
rebuyOrAddon BOOLEAN NOT NULL)
|
rebuyOrAddon BOOLEAN NOT NULL)
|
||||||
ENGINE=INNODB"""
|
ENGINE=INNODB"""
|
||||||
elif db_server == 'postgres': # what is the correct value here?
|
elif db_server == 'postgresql': # what is the correct value here?
|
||||||
self.query['createTourneyTypesTable'] = """CREATE TABLE TourneyTypes (
|
self.query['createTourneyTypesTable'] = """CREATE TABLE TourneyTypes (
|
||||||
id SERIAL, PRIMARY KEY (id),
|
id SERIAL, PRIMARY KEY (id),
|
||||||
siteId INT, FOREIGN KEY (siteId) REFERENCES Sites(id),
|
siteId INT, FOREIGN KEY (siteId) REFERENCES Sites(id),
|
||||||
|
@ -449,7 +450,7 @@ class Sql:
|
||||||
comment TEXT,
|
comment TEXT,
|
||||||
commentTs DATETIME)
|
commentTs DATETIME)
|
||||||
ENGINE=INNODB"""
|
ENGINE=INNODB"""
|
||||||
elif db_server == 'postgres': # what is the correct value here?
|
elif db_server == 'postgresql': # what is the correct value here?
|
||||||
self.query['createTourneysTable'] = """CREATE TABLE Tourneys (
|
self.query['createTourneysTable'] = """CREATE TABLE Tourneys (
|
||||||
id SERIAL, PRIMARY KEY (id),
|
id SERIAL, PRIMARY KEY (id),
|
||||||
tourneyTypeId INT, FOREIGN KEY (tourneyTypeId) REFERENCES TourneyTypes(id),
|
tourneyTypeId INT, FOREIGN KEY (tourneyTypeId) REFERENCES TourneyTypes(id),
|
||||||
|
@ -591,7 +592,7 @@ class Sql:
|
||||||
|
|
||||||
FOREIGN KEY (tourneysPlayersId) REFERENCES TourneysPlayers(id))
|
FOREIGN KEY (tourneysPlayersId) REFERENCES TourneysPlayers(id))
|
||||||
ENGINE=INNODB"""
|
ENGINE=INNODB"""
|
||||||
elif db_server == 'postgres': # what is the correct value here?
|
elif db_server == 'postgresql': # what is the correct value here?
|
||||||
self.query['createHandsPlayersTable'] = """CREATE TABLE HandsPlayers (
|
self.query['createHandsPlayersTable'] = """CREATE TABLE HandsPlayers (
|
||||||
id BIGSERIAL, PRIMARY KEY (id),
|
id BIGSERIAL, PRIMARY KEY (id),
|
||||||
handId BIGINT NOT NULL, FOREIGN KEY (handId) REFERENCES Hands(id),
|
handId BIGINT NOT NULL, FOREIGN KEY (handId) REFERENCES Hands(id),
|
||||||
|
@ -727,7 +728,7 @@ class Sql:
|
||||||
comment TEXT,
|
comment TEXT,
|
||||||
commentTs DATETIME)
|
commentTs DATETIME)
|
||||||
ENGINE=INNODB"""
|
ENGINE=INNODB"""
|
||||||
elif db_server == 'postgres': # what is the correct value here?
|
elif db_server == 'postgresql': # what is the correct value here?
|
||||||
self.query['createTourneysPlayersTable'] = """CREATE TABLE TourneysPlayers (
|
self.query['createTourneysPlayersTable'] = """CREATE TABLE TourneysPlayers (
|
||||||
id BIGSERIAL, PRIMARY KEY (id),
|
id BIGSERIAL, PRIMARY KEY (id),
|
||||||
tourneyId INT, FOREIGN KEY (tourneyId) REFERENCES Tourneys(id),
|
tourneyId INT, FOREIGN KEY (tourneyId) REFERENCES Tourneys(id),
|
||||||
|
@ -757,7 +758,7 @@ class Sql:
|
||||||
comment TEXT,
|
comment TEXT,
|
||||||
commentTs DATETIME)
|
commentTs DATETIME)
|
||||||
ENGINE=INNODB"""
|
ENGINE=INNODB"""
|
||||||
elif db_server == 'postgres': # what is the correct value here?
|
elif db_server == 'postgresql': # what is the correct value here?
|
||||||
self.query['createHandsActionsTable'] = """CREATE TABLE HandsActions (
|
self.query['createHandsActionsTable'] = """CREATE TABLE HandsActions (
|
||||||
id BIGSERIAL, PRIMARY KEY (id),
|
id BIGSERIAL, PRIMARY KEY (id),
|
||||||
handsPlayerId BIGINT, FOREIGN KEY (handsPlayerId) REFERENCES HandsPlayers(id),
|
handsPlayerId BIGINT, FOREIGN KEY (handsPlayerId) REFERENCES HandsPlayers(id),
|
||||||
|
@ -877,7 +878,7 @@ class Sql:
|
||||||
street4Raises INT)
|
street4Raises INT)
|
||||||
|
|
||||||
ENGINE=INNODB"""
|
ENGINE=INNODB"""
|
||||||
elif db_server == 'postgres': # what is the correct value here?
|
elif db_server == 'postgresql': # what is the correct value here?
|
||||||
self.query['createHudCacheTable'] = """CREATE TABLE HudCache (
|
self.query['createHudCacheTable'] = """CREATE TABLE HudCache (
|
||||||
id BIGSERIAL, PRIMARY KEY (id),
|
id BIGSERIAL, PRIMARY KEY (id),
|
||||||
gametypeId INT, FOREIGN KEY (gametypeId) REFERENCES Gametypes(id),
|
gametypeId INT, FOREIGN KEY (gametypeId) REFERENCES Gametypes(id),
|
||||||
|
@ -981,21 +982,21 @@ class Sql:
|
||||||
|
|
||||||
if db_server == 'mysql':
|
if db_server == 'mysql':
|
||||||
self.query['addTourneyIndex'] = """ALTER TABLE Tourneys ADD INDEX siteTourneyNo(siteTourneyNo)"""
|
self.query['addTourneyIndex'] = """ALTER TABLE Tourneys ADD INDEX siteTourneyNo(siteTourneyNo)"""
|
||||||
elif db_server == 'postgres': # what is the correct value here?
|
elif db_server == 'postgresql': # what is the correct value here?
|
||||||
self.query['addTourneyIndex'] = """CREATE INDEX siteTourneyNo ON Tourneys (siteTourneyNo)"""
|
self.query['addTourneyIndex'] = """CREATE INDEX siteTourneyNo ON Tourneys (siteTourneyNo)"""
|
||||||
elif db_server == 'sqlite': # what is the correct value here?
|
elif db_server == 'sqlite': # what is the correct value here?
|
||||||
self.query['addHandsIndex'] = """ """
|
self.query['addHandsIndex'] = """ """
|
||||||
|
|
||||||
if db_server == 'mysql':
|
if db_server == 'mysql':
|
||||||
self.query['addHandsIndex'] = """ALTER TABLE Hands ADD INDEX siteHandNo(siteHandNo)"""
|
self.query['addHandsIndex'] = """ALTER TABLE Hands ADD INDEX siteHandNo(siteHandNo)"""
|
||||||
elif db_server == 'postgres': # what is the correct value here?
|
elif db_server == 'postgresql': # what is the correct value here?
|
||||||
self.query['addHandsIndex'] = """CREATE INDEX siteHandNo ON Hands (siteHandNo)"""
|
self.query['addHandsIndex'] = """CREATE INDEX siteHandNo ON Hands (siteHandNo)"""
|
||||||
elif db_server == 'sqlite': # what is the correct value here?
|
elif db_server == 'sqlite': # what is the correct value here?
|
||||||
self.query['addHandsIndex'] = """ """
|
self.query['addHandsIndex'] = """ """
|
||||||
|
|
||||||
if db_server == 'mysql':
|
if db_server == 'mysql':
|
||||||
self.query['addPlayersIndex'] = """ALTER TABLE Players ADD INDEX name(name)"""
|
self.query['addPlayersIndex'] = """ALTER TABLE Players ADD INDEX name(name)"""
|
||||||
elif db_server == 'postgres': # what is the correct value here?
|
elif db_server == 'postgresql': # what is the correct value here?
|
||||||
self.query['addPlayersIndex'] = """CREATE INDEX name ON Players (name)"""
|
self.query['addPlayersIndex'] = """CREATE INDEX name ON Players (name)"""
|
||||||
elif db_server == 'sqlite': # what is the correct value here?
|
elif db_server == 'sqlite': # what is the correct value here?
|
||||||
self.query['addPlayersIndex'] = """ """
|
self.query['addPlayersIndex'] = """ """
|
||||||
|
|
|
@ -430,7 +430,6 @@ class fpdb:
|
||||||
self.status_bar.set_text("Status: Connected to %s database named %s on host %s" % (self.db.get_backend_name(),self.db.fdb.database, self.db.fdb.host))
|
self.status_bar.set_text("Status: Connected to %s database named %s on host %s" % (self.db.get_backend_name(),self.db.fdb.database, self.db.fdb.host))
|
||||||
|
|
||||||
# Database connected to successfully, load queries to pass on to other classes
|
# Database connected to successfully, load queries to pass on to other classes
|
||||||
self.querydict = FpdbSQLQueries.FpdbSQLQueries(self.db.get_backend_name())
|
|
||||||
self.db.connection.rollback()
|
self.db.connection.rollback()
|
||||||
#end def load_profile
|
#end def load_profile
|
||||||
|
|
||||||
|
@ -477,7 +476,7 @@ class fpdb:
|
||||||
def tab_bulk_import(self, widget, data=None):
|
def tab_bulk_import(self, widget, data=None):
|
||||||
"""opens a tab for bulk importing"""
|
"""opens a tab for bulk importing"""
|
||||||
#print "start of tab_bulk_import"
|
#print "start of tab_bulk_import"
|
||||||
new_import_thread=GuiBulkImport.GuiBulkImport(self.settings, self.config)
|
new_import_thread = GuiBulkImport.GuiBulkImport(self.settings, self.config, self.sql)
|
||||||
self.threads.append(new_import_thread)
|
self.threads.append(new_import_thread)
|
||||||
bulk_tab=new_import_thread.get_vbox()
|
bulk_tab=new_import_thread.get_vbox()
|
||||||
self.add_and_display_tab(bulk_tab, "Bulk Import")
|
self.add_and_display_tab(bulk_tab, "Bulk Import")
|
||||||
|
|
|
@ -54,11 +54,13 @@ except:
|
||||||
|
|
||||||
class Importer:
|
class Importer:
|
||||||
|
|
||||||
def __init__(self, caller, settings, config):
|
def __init__(self, caller, settings, config, sql = None):
|
||||||
"""Constructor"""
|
"""Constructor"""
|
||||||
self.settings = settings
|
self.settings = settings
|
||||||
self.caller = caller
|
self.caller = caller
|
||||||
self.config = config
|
self.config = config
|
||||||
|
self.sql = sql
|
||||||
|
|
||||||
self.database = None # database will be the main db interface eventually
|
self.database = None # database will be the main db interface eventually
|
||||||
self.filelist = {}
|
self.filelist = {}
|
||||||
self.dirlist = {}
|
self.dirlist = {}
|
||||||
|
@ -76,7 +78,7 @@ class Importer:
|
||||||
self.settings.setdefault("minPrint", 30)
|
self.settings.setdefault("minPrint", 30)
|
||||||
self.settings.setdefault("handCount", 0)
|
self.settings.setdefault("handCount", 0)
|
||||||
|
|
||||||
self.database = Database.Database(self.config) # includes .connection and .sql variables
|
self.database = Database.Database(self.config, sql = self.sql) # includes .connection and .sql variables
|
||||||
|
|
||||||
self.NEWIMPORT = False
|
self.NEWIMPORT = False
|
||||||
self.allow_hudcache_rebuild = False
|
self.allow_hudcache_rebuild = False
|
||||||
|
|
|
@ -15,15 +15,20 @@
|
||||||
#In the "official" distribution you can find the license in
|
#In the "official" distribution you can find the license in
|
||||||
#agpl-3.0.txt in the docs folder of the package.
|
#agpl-3.0.txt in the docs folder of the package.
|
||||||
|
|
||||||
#methods that are specific to holdem but not trivial
|
#parses an in-memory fpdb hand history and calls db routine to store it
|
||||||
|
|
||||||
|
import sys
|
||||||
|
|
||||||
import fpdb_simple
|
import fpdb_simple
|
||||||
import Database
|
import Database
|
||||||
from time import time, strftime
|
from time import time, strftime
|
||||||
|
|
||||||
|
|
||||||
#parses a holdem hand
|
#parses a holdem hand
|
||||||
def mainParser(settings, siteID, category, hand, config, db = None):
|
def mainParser(settings, siteID, category, hand, config, db = None):
|
||||||
|
#print "mainparser"
|
||||||
# fdb is not used now - to be removed ...
|
# fdb is not used now - to be removed ...
|
||||||
|
|
||||||
t0 = time()
|
t0 = time()
|
||||||
#print "mainparser"
|
#print "mainparser"
|
||||||
backend = settings['db-backend']
|
backend = settings['db-backend']
|
||||||
|
@ -51,7 +56,6 @@ def mainParser(settings, siteID, category, hand, config, db = None):
|
||||||
if line[-2:] == "$0": continue
|
if line[-2:] == "$0": continue
|
||||||
smallBlindLine = i
|
smallBlindLine = i
|
||||||
break
|
break
|
||||||
#print "small blind line:",smallBlindLine
|
|
||||||
|
|
||||||
gametypeID = fpdb_simple.recogniseGametypeID(backend, db, db.get_cursor(), hand[0], hand[smallBlindLine], siteID, category, isTourney)
|
gametypeID = fpdb_simple.recogniseGametypeID(backend, db, db.get_cursor(), hand[0], hand[smallBlindLine], siteID, category, isTourney)
|
||||||
if isTourney:
|
if isTourney:
|
||||||
|
@ -65,6 +69,17 @@ def mainParser(settings, siteID, category, hand, config, db = None):
|
||||||
rebuyOrAddon = fpdb_simple.isRebuyOrAddon(hand[0])
|
rebuyOrAddon = fpdb_simple.isRebuyOrAddon(hand[0])
|
||||||
|
|
||||||
tourneyTypeId = fpdb_simple.recogniseTourneyTypeId(db.get_cursor(), siteID, buyin, fee, knockout, rebuyOrAddon)
|
tourneyTypeId = fpdb_simple.recogniseTourneyTypeId(db.get_cursor(), siteID, buyin, fee, knockout, rebuyOrAddon)
|
||||||
|
else:
|
||||||
|
siteTourneyNo = -1
|
||||||
|
buyin = -1
|
||||||
|
fee = -1
|
||||||
|
entries = -1
|
||||||
|
prizepool = -1
|
||||||
|
knockout = 0
|
||||||
|
tourneyStartTime= None
|
||||||
|
rebuyOrAddon = -1
|
||||||
|
|
||||||
|
tourneyTypeId = 1
|
||||||
|
|
||||||
fpdb_simple.isAlreadyInDB(db.get_cursor(), gametypeID, siteHandNo)
|
fpdb_simple.isAlreadyInDB(db.get_cursor(), gametypeID, siteHandNo)
|
||||||
|
|
||||||
|
@ -145,63 +160,25 @@ def mainParser(settings, siteID, category, hand, config, db = None):
|
||||||
, allIns, actionTypeByNo, winnings, totalWinnings, None
|
, allIns, actionTypeByNo, winnings, totalWinnings, None
|
||||||
, actionTypes, actionAmounts, antes)
|
, actionTypes, actionAmounts, antes)
|
||||||
|
|
||||||
|
|
||||||
#print "parse: hand data prepared" # only reads up to here apart from inserting new players
|
#print "parse: hand data prepared" # only reads up to here apart from inserting new players
|
||||||
try:
|
try:
|
||||||
db.commit() # need to commit new players as different db connection used
|
db.commit() # need to commit new players as different db connection used
|
||||||
# for other writes. maybe this will change maybe not ...
|
# for other writes. maybe this will change maybe not ...
|
||||||
except:
|
except:
|
||||||
print "parse: error during rollback: " + str(sys.exc_value)
|
print "parse: error during commit: " + str(sys.exc_value)
|
||||||
|
|
||||||
|
|
||||||
# Following code writes hands to database and commits (or rolls back if there is an error)
|
# save data structures in a HandToWrite instance and then insert into database:
|
||||||
try:
|
htw = Database.HandToWrite()
|
||||||
if isTourney:
|
htw.set_all( config, settings, base, category, siteTourneyNo, buyin
|
||||||
ranks = map(lambda x: 0, names) # create an array of 0's equal to the length of names
|
|
||||||
payin_amounts = fpdb_simple.calcPayin(len(names), buyin, fee)
|
|
||||||
|
|
||||||
if base == "hold":
|
|
||||||
result = db.tourney_holdem_omaha(
|
|
||||||
config, settings, base, category, siteTourneyNo, buyin
|
|
||||||
, fee, knockout, entries, prizepool, tourneyStartTime
|
, fee, knockout, entries, prizepool, tourneyStartTime
|
||||||
, payin_amounts, ranks, tourneyTypeId, siteID, siteHandNo
|
, isTourney, tourneyTypeId, siteID, siteHandNo
|
||||||
, gametypeID, handStartTime, names, playerIDs, startCashes
|
, gametypeID, handStartTime, names, playerIDs, startCashes
|
||||||
, positions, cardValues, cardSuits, boardValues, boardSuits
|
, positions, antes, cardValues, cardSuits, boardValues, boardSuits
|
||||||
, winnings, rakes, actionTypes, allIns, actionAmounts
|
, winnings, rakes, actionTypes, allIns, actionAmounts
|
||||||
, actionNos, hudImportData, maxSeats, tableName, seatNos)
|
, actionNos, hudImportData, maxSeats, tableName, seatNos)
|
||||||
elif base == "stud":
|
result = db.store_the_hand(htw)
|
||||||
result = db.tourney_stud(
|
|
||||||
config, settings, base, category, siteTourneyNo
|
|
||||||
, buyin, fee, knockout, entries, prizepool, tourneyStartTime
|
|
||||||
, payin_amounts, ranks, tourneyTypeId, siteID, siteHandNo
|
|
||||||
, gametypeID, handStartTime, names, playerIDs, startCashes
|
|
||||||
, antes, cardValues, cardSuits, winnings, rakes, actionTypes
|
|
||||||
, allIns, actionAmounts, actionNos, hudImportData, maxSeats
|
|
||||||
, tableName, seatNos)
|
|
||||||
else:
|
|
||||||
raise fpdb_simple.FpdbError("unrecognised category")
|
|
||||||
else:
|
|
||||||
if base == "hold":
|
|
||||||
result = db.ring_holdem_omaha(
|
|
||||||
config, settings, base, category, siteHandNo
|
|
||||||
, gametypeID, handStartTime, names, playerIDs
|
|
||||||
, startCashes, positions, cardValues, cardSuits
|
|
||||||
, boardValues, boardSuits, winnings, rakes
|
|
||||||
, actionTypes, allIns, actionAmounts, actionNos
|
|
||||||
, hudImportData, maxSeats, tableName, seatNos)
|
|
||||||
elif base == "stud":
|
|
||||||
result = db.ring_stud(
|
|
||||||
config, settings, base, category, siteHandNo, gametypeID
|
|
||||||
, handStartTime, names, playerIDs, startCashes, antes
|
|
||||||
, cardValues, cardSuits, winnings, rakes, actionTypes, allIns
|
|
||||||
, actionAmounts, actionNos, hudImportData, maxSeats, tableName
|
|
||||||
, seatNos)
|
|
||||||
else:
|
|
||||||
raise fpdb_simple.FpdbError ("unrecognised category")
|
|
||||||
db.commit()
|
|
||||||
except:
|
|
||||||
print "Error storing hand: " + str(sys.exc_value)
|
|
||||||
db.rollback()
|
|
||||||
t9 = time()
|
t9 = time()
|
||||||
#print "parse and save=(%4.3f)" % (t9-t0)
|
#print "parse and save=(%4.3f)" % (t9-t0)
|
||||||
return result
|
return result
|
||||||
|
|
Loading…
Reference in New Issue
Block a user