Merge branch 'master' of git://git.assembla.com/fpdboz
Conflicts: pyfpdb/Database.py pyfpdb/fpdb_db.py pyfpdb/fpdb_save_to_db.py
This commit is contained in:
commit
f3103cc82a
|
@ -26,8 +26,8 @@ Create and manage the database objects.
|
||||||
# Standard Library modules
|
# Standard Library modules
|
||||||
import sys
|
import sys
|
||||||
import traceback
|
import traceback
|
||||||
import string
|
|
||||||
from datetime import datetime, date, time, timedelta
|
from datetime import datetime, date, time, timedelta
|
||||||
|
import string
|
||||||
|
|
||||||
# pyGTK modules
|
# pyGTK modules
|
||||||
|
|
||||||
|
@ -85,9 +85,9 @@ class Database:
|
||||||
sys.exit()
|
sys.exit()
|
||||||
|
|
||||||
self.type = db_params['db-type']
|
self.type = db_params['db-type']
|
||||||
self.db_server = c.supported_databases[db_name].db_server
|
self.sql = SQL.Sql(game = game, type = self.type)
|
||||||
self.sql = SQL.Sql(game = game, type = self.type, db_server = self.db_server)
|
self.connection.rollback()
|
||||||
self.connection.rollback()
|
|
||||||
# To add to config:
|
# To add to config:
|
||||||
self.hud_style = 'T' # A=All-time
|
self.hud_style = 'T' # A=All-time
|
||||||
# S=Session
|
# S=Session
|
||||||
|
@ -177,7 +177,7 @@ class Database:
|
||||||
"""Get and return the community cards for the specified hand."""
|
"""Get and return the community cards for the specified hand."""
|
||||||
cards = {}
|
cards = {}
|
||||||
c = self.connection.cursor()
|
c = self.connection.cursor()
|
||||||
c.execute(self.sql.query['get_common_cards'], (hand,))
|
c.execute(self.sql.query['get_common_cards'], [hand])
|
||||||
colnames = [desc[0] for desc in c.description]
|
colnames = [desc[0] for desc in c.description]
|
||||||
for row in c.fetchall():
|
for row in c.fetchall():
|
||||||
s_dict = {}
|
s_dict = {}
|
||||||
|
@ -325,8 +325,9 @@ if __name__=="__main__":
|
||||||
h = db_connection.get_last_hand()
|
h = db_connection.get_last_hand()
|
||||||
print "last hand = ", h
|
print "last hand = ", h
|
||||||
|
|
||||||
hero = db_connection.get_player_id(c, 'Full Tilt Poker', 'PokerAscetic')
|
hero = db_connection.get_player_id(c, 'PokerStars', 'nutOmatic')
|
||||||
print "nutOmatic is id_player = %d" % hero
|
if hero:
|
||||||
|
print "nutOmatic is id_player = %d" % hero
|
||||||
|
|
||||||
stat_dict = db_connection.get_stats_from_hand(h)
|
stat_dict = db_connection.get_stats_from_hand(h)
|
||||||
for p in stat_dict.keys():
|
for p in stat_dict.keys():
|
||||||
|
|
|
@ -158,7 +158,7 @@ or None if we fail to get the info """
|
||||||
# 2008/11/10 3:58:52 ET
|
# 2008/11/10 3:58:52 ET
|
||||||
#TODO: Do conversion from GMT to ET
|
#TODO: Do conversion from GMT to ET
|
||||||
#TODO: Need some date functions to convert to different timezones (Date::Manip for perl rocked for this)
|
#TODO: Need some date functions to convert to different timezones (Date::Manip for perl rocked for this)
|
||||||
hand.starttime = time.strptime(m.group('DATETIME'), "%Y/%m/%d - %H:%M:%S")
|
hand.starttime = datetime.datetime.strptime(m.group('DATETIME'), "%Y/%m/%d - %H:%M:%S")
|
||||||
return
|
return
|
||||||
|
|
||||||
def readPlayerStacks(self, hand):
|
def readPlayerStacks(self, hand):
|
||||||
|
|
|
@ -124,7 +124,7 @@ follow : whether to tail -f the input"""
|
||||||
|
|
||||||
hand.handid = m.group('HID')
|
hand.handid = m.group('HID')
|
||||||
hand.tablename = m.group('TABLE')
|
hand.tablename = m.group('TABLE')
|
||||||
hand.starttime = time.strptime(m.group('DATETIME'), "%H:%M:%S ET - %Y/%m/%d")
|
hand.starttime = datetime.datetime.strptime(m.group('DATETIME'), "%H:%M:%S ET - %Y/%m/%d")
|
||||||
hand.maxseats = 8 # assume 8-max until we see otherwise
|
hand.maxseats = 8 # assume 8-max until we see otherwise
|
||||||
if m.group('TABLEATTRIBUTES'):
|
if m.group('TABLEATTRIBUTES'):
|
||||||
m2 = re.search("(deep )?(\d+)( max)?", m.group('TABLEATTRIBUTES'))
|
m2 = re.search("(deep )?(\d+)( max)?", m.group('TABLEATTRIBUTES'))
|
||||||
|
|
|
@ -172,27 +172,20 @@ class fpdb_db:
|
||||||
raise fpdb_simple.FpdbError("MySQL connection failed")
|
raise fpdb_simple.FpdbError("MySQL connection failed")
|
||||||
elif backend==self.PGSQL:
|
elif backend==self.PGSQL:
|
||||||
import psycopg2
|
import psycopg2
|
||||||
import psycopg2.extensions
|
import psycopg2.extensions
|
||||||
psycopg2.extensions.register_type(psycopg2.extensions.UNICODE)
|
psycopg2.extensions.register_type(psycopg2.extensions.UNICODE)
|
||||||
# If DB connection is made over TCP, then the variables
|
# If DB connection is made over TCP, then the variables
|
||||||
# host, user and password are required
|
# host, user and password are required
|
||||||
# print "host=%s user=%s pass=%s." % (host, user, password)
|
|
||||||
if self.host and self.user and self.password:
|
|
||||||
try:
|
|
||||||
self.db = psycopg2.connect(host = host,
|
|
||||||
user = user,
|
|
||||||
password = password,
|
|
||||||
database = database)
|
|
||||||
except:
|
|
||||||
raise fpdb_simple.FpdbError("PostgreSQL connection failed")
|
|
||||||
# For local domain-socket connections, only DB name is
|
# For local domain-socket connections, only DB name is
|
||||||
# needed, and everything else is in fact undefined and/or
|
# needed, and everything else is in fact undefined and/or
|
||||||
# flat out wrong
|
# flat out wrong
|
||||||
|
if self.host == "localhost" or self.host == "127.0.0.1":
|
||||||
|
self.db = psycopg2.connect(database = database)
|
||||||
else:
|
else:
|
||||||
try:
|
self.db = psycopg2.connect(host = host,
|
||||||
self.db = psycopg2.connect(database = database)
|
user = user,
|
||||||
except:
|
password = password,
|
||||||
raise fpdb_simple.FpdbError("PostgreSQL connection failed")
|
database = database)
|
||||||
else:
|
else:
|
||||||
raise fpdb_simple.FpdbError("unrecognised database backend:"+backend)
|
raise fpdb_simple.FpdbError("unrecognised database backend:"+backend)
|
||||||
self.cursor=self.db.cursor()
|
self.cursor=self.db.cursor()
|
||||||
|
|
|
@ -26,13 +26,14 @@ MYSQL_INNODB = 2
|
||||||
PGSQL = 3
|
PGSQL = 3
|
||||||
SQLITE = 4
|
SQLITE = 4
|
||||||
|
|
||||||
fastStoreHudCache = False # set this to True to test the new storeHudCache routine
|
#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
|
||||||
|
|
||||||
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
|
#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
|
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
|
,names, player_ids, start_cashes, antes, card_values, card_suits, winnings, rakes
|
||||||
|
|
|
@ -16,24 +16,12 @@ def testPokerStarsHHDate():
|
||||||
datetime.datetime(2008,9,7,11,23,14))
|
datetime.datetime(2008,9,7,11,23,14))
|
||||||
)
|
)
|
||||||
|
|
||||||
def testFullTiltHHDate():
|
#def testTableDetection():
|
||||||
sitngo1 = "Full Tilt Poker Game #10311865543: $1 + $0.25 Sit & Go (78057629), Table 1 - 25/50 - No Limit Hold'em - 0:07:45 ET - 2009/01/29"
|
# result = Tables.clean_title("French (deep)")
|
||||||
cash1 = "Full Tilt Poker Game #9403951181: Table CR - tay - $0.05/$0.10 - No Limit Hold'em - 9:40:20 ET - 2008/12/09"
|
# assert result == "French"
|
||||||
cash2 = "Full Tilt Poker Game #9468383505: Table Bike (deep 6) - $0.05/$0.10 - No Limit Hold'em - 5:09:36 ET - 2008/12/13"
|
# result = Tables.clean_title("French (deep) - $0.25/$0.50 - No Limit Hold'em - Logged In As xxxx")
|
||||||
|
# assert result == "French"
|
||||||
result = fpdb_simple.parseHandStartTime(sitngo1,"ftp")
|
#
|
||||||
assert result==datetime.datetime(2009,1,29,05,07,45)
|
# for (header, site, result) in tuples:
|
||||||
result = fpdb_simple.parseHandStartTime(cash1,"ftp")
|
# yield checkDateParse, header, site, result
|
||||||
assert result==datetime.datetime(2008,12,9,14,40,20)
|
|
||||||
result = fpdb_simple.parseHandStartTime(cash2,"ftp")
|
|
||||||
assert result==datetime.datetime(2008,12,13,10,9,36)
|
|
||||||
|
|
||||||
def testTableDetection():
|
|
||||||
result = Tables.clean_title("French (deep)")
|
|
||||||
assert result == "French"
|
|
||||||
result = Tables.clean_title("French (deep) - $0.25/$0.50 - No Limit Hold'em - Logged In As xxxx")
|
|
||||||
assert result == "French"
|
|
||||||
|
|
||||||
for (header, site, result) in tuples:
|
|
||||||
yield checkDateParse, header, site, result
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user