git1 - initial git commit. note that right now nothing works due to reworking things
This commit is contained in:
Executable
+38
@@ -0,0 +1,38 @@
|
||||
#!/usr/bin/python
|
||||
|
||||
#Copyright 2008 Steffen Jobbagy-Felso
|
||||
#This program is free software: you can redistribute it and/or modify
|
||||
#it under the terms of the GNU Affero General Public License as published by
|
||||
#the Free Software Foundation, version 3 of the License.
|
||||
#
|
||||
#This program is distributed in the hope that it will be useful,
|
||||
#but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
#GNU General Public License for more details.
|
||||
#
|
||||
#You should have received a copy of the GNU Affero General Public License
|
||||
#along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#In the "official" distribution you can find the license in
|
||||
#agpl-3.0.txt in the docs folder of the package.
|
||||
|
||||
import sys
|
||||
import MySQLdb
|
||||
|
||||
db = MySQLdb.connect("localhost", "fpdb", sys.argv[1], "fpdb")
|
||||
cursor = db.cursor()
|
||||
print "Connected to MySQL on localhost. Printing dev-supplied base data:"
|
||||
|
||||
cursor.execute("SELECT * FROM sites")
|
||||
print "Sites"
|
||||
print "====="
|
||||
print cursor.fetchall()
|
||||
|
||||
cursor.execute("SELECT * FROM gametypes")
|
||||
print "Gametypes"
|
||||
print "========="
|
||||
result=cursor.fetchall()
|
||||
for i in range (len(result)):
|
||||
print result[i]
|
||||
|
||||
cursor.close()
|
||||
db.close()
|
||||
@@ -0,0 +1,79 @@
|
||||
#!/usr/bin/python
|
||||
|
||||
#Copyright 2008 Steffen Jobbagy-Felso
|
||||
#This program is free software: you can redistribute it and/or modify
|
||||
#it under the terms of the GNU Affero General Public License as published by
|
||||
#the Free Software Foundation, version 3 of the License.
|
||||
#
|
||||
#This program is distributed in the hope that it will be useful,
|
||||
#but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
#GNU General Public License for more details.
|
||||
#
|
||||
#You should have received a copy of the GNU Affero General Public License
|
||||
#along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#In the "official" distribution you can find the license in
|
||||
#agpl-3.0.txt in the docs folder of the package.
|
||||
|
||||
import sys
|
||||
|
||||
def cards2String(arr):
|
||||
if (len(arr)%2!=0):
|
||||
print "TODO: raise error, cards2String failed, uneven length of arr"
|
||||
sys.exit(1)
|
||||
result = ""
|
||||
for i in range (len(arr)/2):
|
||||
if arr[i*2]==0:
|
||||
result+="??"
|
||||
else:
|
||||
if arr[i*2]==14:
|
||||
result+="A"
|
||||
elif arr[i*2]==13:
|
||||
result+="K"
|
||||
elif arr[i*2]==12:
|
||||
result+="Q"
|
||||
elif arr[i*2]==11:
|
||||
result+="J"
|
||||
elif arr[i*2]==10:
|
||||
result+="T"
|
||||
elif (arr[i*2]>=2 and arr[i*2]<=9):
|
||||
result+=str(arr[i*2])
|
||||
else:
|
||||
print "TODO: raise error, cards2String failed, arr[i*2]:",arr[i*2]
|
||||
sys.exit(1)
|
||||
result+=arr[i*2+1]
|
||||
result+=" "
|
||||
return result[:-1]
|
||||
|
||||
def id_to_player_name(cursor, id):
|
||||
cursor.execute("SELECT name FROM players WHERE id=%s", (id, ))
|
||||
return cursor.fetchone()[0]
|
||||
|
||||
def position2String(pos):
|
||||
if pos=="B":
|
||||
return "BB"
|
||||
elif pos=="S":
|
||||
return "SB"
|
||||
elif pos=="0":
|
||||
return "Btn"
|
||||
else:
|
||||
return (pos+" off Btn")
|
||||
|
||||
def street_int2String(category, street):
|
||||
if (category=="holdem" or category=="omahahi" or category=="omahahilo"):
|
||||
if street==0:
|
||||
return "Preflop"
|
||||
elif street==1:
|
||||
return "Flop"
|
||||
elif street==2:
|
||||
return "Turn"
|
||||
elif street==3:
|
||||
return "River"
|
||||
else:
|
||||
print "TODO: raise error, fpdb_util_lib.py street_int2String invalid street no"
|
||||
sys.exit(1)
|
||||
elif (category=="razz" or category=="studhi" or category=="studhilo"):
|
||||
return str(street)
|
||||
else:
|
||||
print "TODO: raise error, fpdb_util_lib.py street_int2String invalid category"
|
||||
sys.exit(1)
|
||||
Executable
+83
@@ -0,0 +1,83 @@
|
||||
#!/usr/bin/python
|
||||
|
||||
#Copyright 2008 Steffen Jobbagy-Felso
|
||||
#This program is free software: you can redistribute it and/or modify
|
||||
#it under the terms of the GNU Affero General Public License as published by
|
||||
#the Free Software Foundation, version 3 of the License.
|
||||
#
|
||||
#This program is distributed in the hope that it will be useful,
|
||||
#but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
#GNU General Public License for more details.
|
||||
#
|
||||
#You should have received a copy of the GNU Affero General Public License
|
||||
#along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#In the "official" distribution you can find the license in
|
||||
#agpl-3.0.txt in the docs folder of the package.
|
||||
|
||||
import sys
|
||||
import MySQLdb
|
||||
|
||||
db = MySQLdb.connect("localhost", "fpdb", sys.argv[1], "fpdb")
|
||||
cursor = db.cursor()
|
||||
print "Connected to MySQL on localhost. Printing summary stats:"
|
||||
|
||||
cursor.execute("SELECT id FROM players")
|
||||
print "Players:",cursor.rowcount
|
||||
cursor.execute("SELECT id FROM autorates")
|
||||
print "Autorates:",cursor.rowcount
|
||||
|
||||
cursor.execute("SELECT id FROM sites")
|
||||
print "Sites:",cursor.rowcount
|
||||
cursor.execute("SELECT id FROM gametypes")
|
||||
print "Gametypes:",cursor.rowcount
|
||||
|
||||
cursor.execute("SELECT id FROM hands")
|
||||
print "Total Hands:",cursor.rowcount
|
||||
cursor.execute("SELECT hands.id FROM hands INNER JOIN gametypes ON hands.gametype_id = gametypes.id WHERE gametypes.type='ring'")
|
||||
print "Hands, Ring:",cursor.rowcount
|
||||
cursor.execute("SELECT hands.id FROM hands INNER JOIN gametypes ON hands.gametype_id = gametypes.id WHERE gametypes.type='stt'")
|
||||
print "Hands, STT:",cursor.rowcount
|
||||
cursor.execute("SELECT hands.id FROM hands INNER JOIN gametypes ON hands.gametype_id = gametypes.id WHERE gametypes.type='mtt'")
|
||||
print "Hands, MTT:",cursor.rowcount
|
||||
|
||||
print ""
|
||||
print "Hands per category and type"
|
||||
cursor.execute("SELECT hands.id FROM hands INNER JOIN gametypes ON hands.gametype_id = gametypes.id WHERE gametypes.limit_type='cn'")
|
||||
print "Hands, Cap No Limit:",cursor.rowcount
|
||||
cursor.execute("SELECT hands.id FROM hands INNER JOIN gametypes ON hands.gametype_id = gametypes.id WHERE gametypes.limit_type='cp'")
|
||||
print "Hands, Cap Pot Limit:",cursor.rowcount
|
||||
cursor.execute("SELECT hands.id FROM hands INNER JOIN gametypes ON hands.gametype_id = gametypes.id WHERE gametypes.category='holdem' AND gametypes.limit_type='nl'")
|
||||
print "Hands, Holdem No Limit:",cursor.rowcount
|
||||
cursor.execute("SELECT hands.id FROM hands INNER JOIN gametypes ON hands.gametype_id = gametypes.id WHERE gametypes.category='holdem' AND gametypes.limit_type='pl'")
|
||||
print "Hands, Holdem Pot Limit:",cursor.rowcount
|
||||
cursor.execute("SELECT hands.id FROM hands INNER JOIN gametypes ON hands.gametype_id = gametypes.id WHERE gametypes.category='holdem' AND gametypes.limit_type='fl'")
|
||||
print "Hands, Holdem Fixed Limit:",cursor.rowcount
|
||||
cursor.execute("SELECT hands.id FROM hands INNER JOIN gametypes ON hands.gametype_id = gametypes.id WHERE gametypes.category='omahahi' AND gametypes.limit_type='nl'")
|
||||
print "Hands, Omaha Hi No Limit:",cursor.rowcount
|
||||
cursor.execute("SELECT hands.id FROM hands INNER JOIN gametypes ON hands.gametype_id = gametypes.id WHERE gametypes.category='omahahi' AND gametypes.limit_type='pl'")
|
||||
print "Hands, Omaha Hi Pot Limit:",cursor.rowcount
|
||||
cursor.execute("SELECT hands.id FROM hands INNER JOIN gametypes ON hands.gametype_id = gametypes.id WHERE gametypes.category='omahahi' AND gametypes.limit_type='fl'")
|
||||
print "Hands, Omaha Hi Fixed Limit:",cursor.rowcount
|
||||
cursor.execute("SELECT hands.id FROM hands INNER JOIN gametypes ON hands.gametype_id = gametypes.id WHERE gametypes.category='omahahilo' AND gametypes.limit_type='nl'")
|
||||
print "Hands, Omaha Hi/Lo No Limit:",cursor.rowcount
|
||||
cursor.execute("SELECT hands.id FROM hands INNER JOIN gametypes ON hands.gametype_id = gametypes.id WHERE gametypes.category='omahahilo' AND gametypes.limit_type='pl'")
|
||||
print "Hands, Omaha Hi/Lo Pot Limit:",cursor.rowcount
|
||||
cursor.execute("SELECT hands.id FROM hands INNER JOIN gametypes ON hands.gametype_id = gametypes.id WHERE gametypes.category='omahahilo' AND gametypes.limit_type='fl'")
|
||||
print "Hands, Omaha Hi/Lo Fixed Limit:",cursor.rowcount
|
||||
cursor.execute("SELECT hands.id FROM hands INNER JOIN gametypes ON hands.gametype_id = gametypes.id WHERE gametypes.category='razz'")
|
||||
print "Hands, Razz:",cursor.rowcount
|
||||
cursor.execute("SELECT hands.id FROM hands INNER JOIN gametypes ON hands.gametype_id = gametypes.id WHERE gametypes.category='studhi'")
|
||||
print "Hands, Stud Hi:",cursor.rowcount
|
||||
cursor.execute("SELECT hands.id FROM hands INNER JOIN gametypes ON hands.gametype_id = gametypes.id WHERE gametypes.category='studhilo'")
|
||||
print "Hands, Stud Hi/Lo:",cursor.rowcount
|
||||
print ""
|
||||
cursor.execute("SELECT id FROM board_cards")
|
||||
print "Board_cards:",cursor.rowcount
|
||||
cursor.execute("SELECT id FROM hands_players")
|
||||
print "Hands_players:",cursor.rowcount
|
||||
cursor.execute("SELECT id FROM hands_actions")
|
||||
print "Hands_actions:",cursor.rowcount
|
||||
|
||||
cursor.close()
|
||||
db.close()
|
||||
Executable
+169
@@ -0,0 +1,169 @@
|
||||
#!/usr/bin/python
|
||||
|
||||
#Copyright 2008 Steffen Jobbagy-Felso
|
||||
#This program is free software: you can redistribute it and/or modify
|
||||
#it under the terms of the GNU Affero General Public License as published by
|
||||
#the Free Software Foundation, version 3 of the License.
|
||||
#
|
||||
#This program is distributed in the hope that it will be useful,
|
||||
#but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
#GNU General Public License for more details.
|
||||
#
|
||||
#You should have received a copy of the GNU Affero General Public License
|
||||
#along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#In the "official" distribution you can find the license in
|
||||
#agpl-3.0.txt in the docs folder of the package.
|
||||
|
||||
#This is intended mostly for regression testing
|
||||
|
||||
import sys
|
||||
import MySQLdb
|
||||
from optparse import OptionParser
|
||||
import fpdb_util_lib as ful
|
||||
|
||||
parser = OptionParser()
|
||||
parser.add_option("-n", "--hand_number", "--hand", type="int",
|
||||
help="Number of the hand to print")
|
||||
parser.add_option("-p", "--password", help="The password for the MySQL user")
|
||||
parser.add_option("-s", "--site", default="PokerStars",
|
||||
help="Name of the site (as written in the history files)")
|
||||
|
||||
(options, sys.argv) = parser.parse_args()
|
||||
|
||||
if options.hand_number==None or options.site==None:
|
||||
print "please supply a hand number and site name. TODO: make this work"
|
||||
|
||||
db = MySQLdb.connect("localhost", "fpdb", options.password, "fpdb")
|
||||
cursor = db.cursor()
|
||||
print "Connected to MySQL on localhost. Print Hand Utility"
|
||||
|
||||
cursor.execute("SELECT id FROM sites WHERE name=%s", (options.site,))
|
||||
site_id=cursor.fetchone()[0]
|
||||
print "options.site:",options.site,"site_id:",site_id
|
||||
|
||||
cursor.execute("""SELECT hands.* FROM hands INNER JOIN gametypes
|
||||
ON hands.gametype_id = gametypes.id WHERE gametypes.site_id=%s AND hands.site_hand_no=%s""",
|
||||
(site_id, options.hand_number))
|
||||
hands_result=cursor.fetchone()
|
||||
gametype_id=hands_result[2]
|
||||
site_hand_no=options.hand_number
|
||||
hand_id=hands_result[0]
|
||||
hand_start=hands_result[3]
|
||||
seat_count=hands_result[4]
|
||||
|
||||
|
||||
print ""
|
||||
print "From Table gametypes"
|
||||
print "===================="
|
||||
|
||||
cursor.execute("""SELECT type, category, limit_type FROM gametypes WHERE id=%s""",
|
||||
(gametype_id, ))
|
||||
type_etc=cursor.fetchone()
|
||||
type=type_etc[0]
|
||||
category=type_etc[1]
|
||||
limit_type=type_etc[2]
|
||||
print "type:", type, " category:", category, " limit_type:", limit_type
|
||||
|
||||
gt_string=""
|
||||
do_bets=False
|
||||
if (category=="holdem" or category=="omahahi" or category=="omahahilo"):
|
||||
cursor.execute("SELECT small_blind FROM gametypes WHERE id=%s", (gametype_id, ))
|
||||
sb=cursor.fetchone()[0]
|
||||
cursor.execute("SELECT big_blind FROM gametypes WHERE id=%s", (gametype_id, ))
|
||||
bb=cursor.fetchone()[0]
|
||||
gt_string=("sb: "+str(sb)+" bb: "+str(bb))
|
||||
if (limit_type=="fl"):
|
||||
do_bets=True
|
||||
elif (category=="razz" or category=="studhi" or category=="studhilo"):
|
||||
do_bets=True
|
||||
|
||||
if do_bets:
|
||||
cursor.execute("SELECT small_bet FROM gametypes WHERE id=%s", (gametype_id, ))
|
||||
sbet=cursor.fetchone()[0]
|
||||
cursor.execute("SELECT big_bet FROM gametypes WHERE id=%s", (gametype_id, ))
|
||||
bbet=cursor.fetchone()[0]
|
||||
gt_string+=(" sbet: "+str(sbet)+" bbet: "+str(bbet))
|
||||
print gt_string
|
||||
|
||||
if type=="ring":
|
||||
pass
|
||||
elif type=="tour":
|
||||
#cursor.execute("SELECT tourneys_players_id FROM hands
|
||||
cursor.execute("""SELECT DISTINCT tourneys_players.id
|
||||
FROM hands JOIN hands_players ON hands_players.hand_id=hands.id
|
||||
JOIN tourneys_players ON hands_players.tourneys_players_id=tourneys_players.id
|
||||
WHERE hands.id=%s""", (hand_id,))
|
||||
hands_players_ids=cursor.fetchall()
|
||||
print "dbg hands_players_ids:",hands_players_ids
|
||||
|
||||
print ""
|
||||
print "From Table tourneys"
|
||||
print "==================="
|
||||
print "TODO"
|
||||
|
||||
|
||||
print ""
|
||||
print "From Table tourneys_players"
|
||||
print "==========================="
|
||||
print "TODO"
|
||||
else:
|
||||
print "invalid type:",type
|
||||
sys.exit(1)
|
||||
|
||||
|
||||
print ""
|
||||
print "From Table hands"
|
||||
print "================"
|
||||
|
||||
print "site_hand_no:",site_hand_no,"hand_start:",hand_start,"seat_count:",seat_count
|
||||
#,"hand_id:",hand_id,"gametype_id:",gametype_id
|
||||
|
||||
if (category=="holdem" or category=="omahahi" or category=="omahahilo"):
|
||||
cursor.execute("""SELECT * FROM board_cards WHERE hand_id=%s""",(hand_id, ))
|
||||
bc=cursor.fetchone()
|
||||
print "Board cards:", ful.cards2String(bc[2:])
|
||||
|
||||
|
||||
print ""
|
||||
print "From Table hands_players"
|
||||
print "========================"
|
||||
cursor.execute("""SELECT * FROM hands_players WHERE hand_id=%s""",(hand_id, ))
|
||||
hands_players=cursor.fetchall()
|
||||
player_names=[]
|
||||
for i in range (len(hands_players)):
|
||||
line=hands_players[i][2:]
|
||||
player_names.append(ful.id_to_player_name(cursor, line[0]))
|
||||
printstr="player_name:"+player_names[i]+" player_startcash:"+str(line[1])
|
||||
if (category=="holdem" or category=="omahahi" or category=="omahahilo"):
|
||||
printstr+=" position:"+ful.position2String(line[2])+" cards:"
|
||||
if (category=="holdem"):
|
||||
printstr+=ful.cards2String(line[4:8])
|
||||
else:
|
||||
printstr+=ful.cards2String(line[4:12])
|
||||
elif (category=="razz" or category=="studhi" or category=="studhilo"):
|
||||
printstr+=" ante:"+str(line[3])+" cards:"
|
||||
printstr+=ful.cards2String(line[4:18])
|
||||
else:
|
||||
print "TODO: raise error, print_hand.py"
|
||||
sys.exit(1)
|
||||
printstr+=" winnings:"+str(line[18])+" rake:"+str(line[19])
|
||||
print printstr
|
||||
|
||||
|
||||
print ""
|
||||
print "From Table hands_actions"
|
||||
print "========================"
|
||||
for i in range (len(hands_players)):
|
||||
cursor.execute("""SELECT * FROM hands_actions WHERE hand_player_id=%s""",(hands_players[i][0], ))
|
||||
hands_actions=cursor.fetchall()
|
||||
for j in range (len(hands_actions)):
|
||||
line=hands_actions[j][2:]
|
||||
printstr="player_name:"+player_names[i]+" actionCount:"+str(j)
|
||||
printstr+=" street:"+ful.street_int2String(category, line[0])+" streetActionNo:"+str(line[1])+" action:"+line[2]
|
||||
printstr+=" amount:"+str(line[3])
|
||||
print printstr
|
||||
|
||||
cursor.close()
|
||||
db.close()
|
||||
sys.exit(0)
|
||||
Executable
+40
@@ -0,0 +1,40 @@
|
||||
#!/bin/sh
|
||||
|
||||
#Copyright 2008 Steffen Jobbagy-Felso
|
||||
#This program is free software: you can redistribute it and/or modify
|
||||
#it under the terms of the GNU Affero General Public License as published by
|
||||
#the Free Software Foundation, version 3 of the License.
|
||||
#
|
||||
#This program is distributed in the hope that it will be useful,
|
||||
#but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
#GNU General Public License for more details.
|
||||
#
|
||||
#You should have received a copy of the GNU Affero General Public License
|
||||
#along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#In the "official" distribution you can find the license in
|
||||
#agpl-3.0.txt in the docs folder of the package.
|
||||
|
||||
rm ../testdata/*.found.txt
|
||||
../fpdb-python/fpdb_import.py -p$1 --file=../testdata/ps-holdem-ring-001to003.txt -x
|
||||
../fpdb-python/fpdb_import.py -p$1 --file=../testdata/ps-holdem-ring-001to003.txt -x
|
||||
../fpdb-python/fpdb_import.py -p$1 --file=../testdata/ftp-stud-hilo-ring-001.txt -x
|
||||
../fpdb-python/fpdb_import.py -p$1 --file=../testdata/ftp-omaha-hi-pl-ring-001-005.txt -x
|
||||
|
||||
echo "it should've reported first that it stored 3, then that it had 3 duplicates,"
|
||||
echo " then 1 stored, then 5 stored"
|
||||
|
||||
./print_hand.py -p$1 --hand=14519394979 > ../testdata/ps.14519394979.found.txt && colordiff ../testdata/ps.14519394979.found.txt ../testdata/ps.14519394979.expected.txt
|
||||
./print_hand.py -p$1 --hand=14519420999 > ../testdata/ps.14519420999.found.txt && colordiff ../testdata/ps.14519420999.found.txt ../testdata/ps.14519420999.expected.txt
|
||||
./print_hand.py -p$1 --hand=14519433154 > ../testdata/ps.14519433154.found.txt && colordiff ../testdata/ps.14519433154.found.txt ../testdata/ps.14519433154.expected.txt
|
||||
|
||||
./print_hand.py -p$1 --site="Full Tilt Poker" --hand=6367428246 > ../testdata/ftp.6367428246.found.txt && colordiff ../testdata/ftp.6367428246.found.txt ../testdata/ftp.6367428246.expected.txt
|
||||
|
||||
./print_hand.py -p$1 --site="Full Tilt Poker" --hand=6929537410 > ../testdata/ftp.6929537410.found.txt && colordiff ../testdata/ftp.6929537410.found.txt ../testdata/ftp.6929537410.expected.txt
|
||||
./print_hand.py -p$1 --site="Full Tilt Poker" --hand=6929553738 > ../testdata/ftp.6929553738.found.txt && colordiff ../testdata/ftp.6929553738.found.txt ../testdata/ftp.6929553738.expected.txt
|
||||
#./print_hand.py -p$1 --site="Full Tilt Poker" --hand=6929572212 > ../testdata/ftp.6929572212.found.txt && colordiff ../testdata/ftp.6929572212.found.txt ../testdata/ftp.6929572212.expected.txt
|
||||
#./print_hand.py -p$1 --site="Full Tilt Poker" --hand=6929576743 > ../testdata/ftp.6929576743.found.txt && colordiff ../testdata/ftp.6929576743.found.txt ../testdata/ftp.6929576743.expected.txt
|
||||
#./print_hand.py -p$1 --site="Full Tilt Poker" --hand=6929587483 > ../testdata/ftp.6929587483.found.txt && colordiff ../testdata/ftp.6929587483.found.txt ../testdata/ftp.6929587483.expected.txt
|
||||
|
||||
echo "if everything was printed as expected this worked"
|
||||
echo "todo: this doesnt verify correct gametype detection"
|
||||
Reference in New Issue
Block a user