Merge branch 'master' into stats

This commit is contained in:
Worros 2009-12-17 13:33:39 +08:00
commit 209c4f94fa
7 changed files with 33 additions and 16 deletions

View File

@ -1867,8 +1867,10 @@ class Database:
,(name, site_id))
#Get last id might be faster here.
#c.execute ("SELECT id FROM Players WHERE name=%s", (name,))
tmp = [self.get_last_insert_id(c)]
return tmp[0]
result = self.get_last_insert_id(c)
else:
result = tmp[1]
return result
def insertGameTypes(self, row):
c = self.get_cursor()

View File

@ -17,6 +17,7 @@
#fpdb modules
import Card
from decimal import Decimal
DEBUG = False
@ -43,9 +44,9 @@ class DerivedStats():
self.handsplayers[player[1]]['totalProfit'] = 0
self.handsplayers[player[1]]['street4Seen'] = False
self.handsplayers[player[1]]['street4Aggr'] = False
self.handsplayers[player[1]]['wonWhenSeenStreet1'] = False
self.handsplayers[player[1]]['wonWhenSeenStreet1'] = 0.0
self.handsplayers[player[1]]['sawShowdown'] = False
self.handsplayers[player[1]]['wonAtSD'] = False
self.handsplayers[player[1]]['wonAtSD'] = 0.0
for i in range(5):
self.handsplayers[player[1]]['street%dCalls' % i] = 0
self.handsplayers[player[1]]['street%dBets' % i] = 0
@ -135,7 +136,7 @@ class DerivedStats():
#hand.players = [[seat, name, chips],[seat, name, chips]]
for player in hand.players:
self.handsplayers[player[1]]['seatNo'] = player[0]
self.handsplayers[player[1]]['startCash'] = player[2]
self.handsplayers[player[1]]['startCash'] = int(100 * Decimal(player[2]))
for i, street in enumerate(hand.actionStreets[2:]):
self.seen(self.hand, i+1)
@ -155,9 +156,9 @@ class DerivedStats():
# Should be fine for split-pots, but won't be accurate for multi-way pots
self.handsplayers[player]['rake'] = int(100* hand.rake)/len(hand.collectees)
if self.handsplayers[player]['street1Seen'] == True:
self.handsplayers[player]['wonWhenSeenStreet1'] = True
self.handsplayers[player]['wonWhenSeenStreet1'] = 1.0
if self.handsplayers[player]['sawShowdown'] == True:
self.handsplayers[player]['wonAtSD'] = True
self.handsplayers[player]['wonAtSD'] = 1.0
for player in hand.pot.committed:
self.handsplayers[player]['totalProfit'] = int(self.handsplayers[player]['winnings'] - (100*hand.pot.committed[player]))

View File

@ -479,7 +479,8 @@ class Filters(threading.Thread):
self.cursor.execute(self.sql.query['getLimits2'])
# selects limitType, bigBlind
result = self.db.cursor.fetchall()
fl, nl = False, False
found = {'nl':False, 'fl':False, 'ring':False, 'tour':False}
if len(result) >= 1:
hbox = gtk.HBox(True, 0)
vbox1.pack_start(hbox, False, False, 0)
@ -487,7 +488,6 @@ class Filters(threading.Thread):
hbox.pack_start(vbox2, False, False, 0)
vbox3 = gtk.VBox(False, 0)
hbox.pack_start(vbox3, False, False, 0)
found = {'nl':False, 'fl':False, 'ring':False, 'tour':False}
for i, line in enumerate(result):
if "UseType" in self.display:
if line[0] != self.display["UseType"]:

View File

@ -387,6 +387,18 @@ Left-Drag to Move"
<location seat="8" x="0" y="181"> </location>
<location seat="9" x="70" y="53"> </location>
</layout>
<layout fav_seat="6" height="547" max="10" width="794">
<location seat="1" x="698" y="69"> </location>
<location seat="2" x="716" y="243"> </location>
<location seat="3" x="699" y="301"> </location>
<location seat="4" x="456" y="391"> </location>
<location seat="5" x="338" y="369"> </location>
<location seat="6" x="98" y="363"> </location>
<location seat="7" x="15" y="242"> </location>
<location seat="8" x="11" y="55"> </location>
<location seat="9" x="341" y="30"> </location>
<location seat="10" x="562" y="8"> </location>
</layout>
</site>

View File

@ -2789,8 +2789,6 @@ class Sql:
,hp.tourneyTypeId
,date_format(h.handStart, 'd%y%m%d')
"""
#>>>>>>> 28ca49d592c8e706ad6ee58dd26655bcc33fc5fb:pyfpdb/SQL.py
#"""
elif db_server == 'postgresql':
self.query['rebuildHudCache'] = """
INSERT INTO HudCache

View File

@ -158,7 +158,7 @@ class fpdb_db:
if not os.path.isdir(Configuration.DIR_DATABASES) and not database == ":memory:":
print "Creating directory: '%s'" % (Configuration.DIR_DATABASES)
os.mkdir(Configuration.DIR_DATABASES)
database = os.path.join(Configuration.DIR_DATABASE, database)
database = os.path.join(Configuration.DIR_DATABASES, database)
self.db = sqlite3.connect(database, detect_types=sqlite3.PARSE_DECLTYPES )
sqlite3.register_converter("bool", lambda x: bool(int(x)))
sqlite3.register_adapter(bool, lambda x: "1" if x else "0")

View File

@ -432,16 +432,20 @@ class Importer:
#This code doesn't do anything yet
handlist = hhc.getProcessedHands()
self.pos_in_file[file] = hhc.getLastCharacterRead()
to_hud = []
for hand in handlist:
#try, except duplicates here?
hand.prepInsert(self.database)
hand.insert(self.database)
if self.callHud and hand.dbid_hands != 0:
#print "DEBUG: call to HUD: handsId: %s" % hand.dbid_hands
#pipe the Hands.id out to the HUD
print "fpdb_import: sending hand to hud", handsId, "pipe =", self.caller.pipe_to_hud
#self.caller.pipe_to_hud.stdin.write("%s" % (hand.dbid_hands) + os.linesep)
to_hud.append(hand.dbid_hands)
self.database.commit()
#pipe the Hands.id out to the HUD
for hid in to_hud:
print "fpdb_import: sending hand to hud", hand.dbid_hands, "pipe =", self.caller.pipe_to_hud
self.caller.pipe_to_hud.stdin.write("%s" % (hid) + os.linesep)
errors = getattr(hhc, 'numErrors')
stored = getattr(hhc, 'numHands')