p132 - fixed tv to new importer. added CliFpdb as initial CLI importer interface. fixed fpdb.printEmailError

This commit is contained in:
steffen123 2008-10-10 04:14:26 +01:00
parent acb4160969
commit 4cc0eb539e
5 changed files with 156 additions and 9 deletions

83
pyfpdb/CliFpdb.py Executable file
View File

@ -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 os
import sys
import fpdb_simple
from optparse import OptionParser
try:
import MySQLdb
except:
diaSQLLibMissing = gtk.Dialog(title="Fatal Error - SQL interface library missing", parent=None, flags=0, buttons=(gtk.STOCK_QUIT,gtk.RESPONSE_OK))
print "Please note that the CLI importer only works with MySQL, if you use PostgreSQL this error is expected."
import fpdb_import
import fpdb_db
# def __init__(self, db, settings, debug=True):
# """Constructor for table_viewer"""
# self.debug=debug
# #print "start of table_viewer constructor"
# self.db=db
# self.cursor=db.cursor
# self.settings=settings
if __name__ == "__main__":
failOnError=False
quiet=False
#process CLI parameters
parser = OptionParser()
parser.add_option("-c", "--handCount", default="0", type="int",
help="Number of hands to import (default 0 means unlimited)")
parser.add_option("-d", "--database", default="fpdb", help="The MySQL database to use (default fpdb)")
parser.add_option("-e", "--errorFile", default="failed.txt",
help="File to store failed hands into. (default: failed.txt) Not implemented.")
parser.add_option("-f", "--inputFile", "--file", "--inputfile", default="stdin",
help="The file you want to import (remember to use quotes if necessary)")
parser.add_option("-m", "--minPrint", "--status", default="50", type="int",
help="How often to print a one-line status report (0 means never, default is 50)")
parser.add_option("-p", "--password", help="The password for the MySQL user")
parser.add_option("-q", "--quiet", action="store_true",
help="If this is passed it doesn't print a total at the end nor the opening line. Note that this purposely does NOT change --minPrint")
parser.add_option("-s", "--server", default="localhost",
help="Hostname/IP of the MySQL server (default localhost)")
parser.add_option("-u", "--user", default="fpdb", help="The MySQL username (default fpdb)")
parser.add_option("-x", "--failOnError", action="store_true",
help="If this option is passed it quits when it encounters any error")
(options, sys.argv) = parser.parse_args()
settings={'imp-callFpdbHud':False, 'db-backend':2}
#self.inputFile=options.inputFile
#self.server=options.server
#self.database=options.database
#self.user=options.user
#self.password=options.password
#self.quiet=False
#self.failOnError=False
#self.minPrint=0
#self.handCount=0
importer = fpdb_import.Importer()
importer.import_file_dict(options, settings)

View File

@ -257,7 +257,7 @@ class GuiTableViewer (threading.Thread):
self.handCount=0 self.handCount=0
self.importer = fpdb_import.Importer() self.importer = fpdb_import.Importer()
self.last_read_hand_id=importer.import_file_dict(self, self.settings) self.last_read_hand_id=self.importer.import_file_dict(self, self.settings)
#end def table_viewer.import_clicked #end def table_viewer.import_clicked
def all_clicked(self, widget, data): def all_clicked(self, widget, data):

View File

@ -36,7 +36,6 @@ import os
import datetime import datetime
import fpdb_simple import fpdb_simple
import fpdb_parse_logic import fpdb_parse_logic
from optparse import OptionParser
from time import time from time import time
class Importer: class Importer:
@ -72,6 +71,7 @@ class Importer:
self.callHud = value self.callHud = value
def import_file_dict(self, options, settings): def import_file_dict(self, options, settings):
self.options=options
starttime = time() starttime = time()
last_read_hand=0 last_read_hand=0
if (options.inputFile=="stdin"): if (options.inputFile=="stdin"):
@ -136,7 +136,8 @@ class Importer:
if not isTourney: if not isTourney:
fpdb_simple.filterAnteBlindFold(site,hand) fpdb_simple.filterAnteBlindFold(site,hand)
hand=fpdb_simple.filterCrap(site, hand, isTourney) hand=fpdb_simple.filterCrap(site, hand, isTourney)
self.hand=hand
try: try:
handsId=fpdb_parse_logic.mainParser(self.db, self.cursor, site, category, hand) handsId=fpdb_parse_logic.mainParser(self.db, self.cursor, site, category, hand)
self.db.commit() self.db.commit()
@ -203,9 +204,9 @@ class Importer:
def printEmailErrorMessage(self, errors, filename, line): def printEmailErrorMessage(self, errors, filename, line):
print "Error No.",errors,", please send the hand causing this to steffen@sycamoretest.info so I can fix it." print "Error No.",errors,", please send the hand causing this to steffen@sycamoretest.info so I can fix it."
print "Filename:",options.inputFile print "Filename:", self.options.inputFile
print "Here is the first line so you can identify it. Please mention that the error was a ValueError:" print "Here is the first line so you can identify it. Please mention that the error was a ValueError:"
print hand[0] print self.hand[0]
if __name__ == "__main__": if __name__ == "__main__":

View File

@ -65,3 +65,66 @@ Seat 8: willowdale showed [3s 4d 5s 4s Ad 5h 2c] and won ($1.02) with HI: a stra
PokerStars Game #20711747191: Razz Limit ($1/$2) - 2008/09/26 14:36:50 ET
Table 'Siwa III' 8-max
Seat 2: dainmat ($63.15 in chips)
Seat 3: fnJ's ($30.75 in chips)
Seat 4: ambythegreat ($24.90 in chips)
Seat 5: jt studd ($39.90 in chips)
Seat 6: KyleHruby ($11.55 in chips)
Seat 7: nutOmatic ($71.30 in chips)
dainmat: posts the ante $0.10
fnJ's: posts the ante $0.10
ambythegreat: posts the ante $0.10
jt studd: posts the ante $0.10
KyleHruby: posts the ante $0.10
nutOmatic: posts the ante $0.10
*** 3rd STREET ***
Dealt to dainmat [Ts]
Dealt to fnJ's [3s]
Dealt to ambythegreat [5h]
Dealt to jt studd [Ad]
Dealt to KyleHruby [As]
Dealt to nutOmatic [6d Kd Th]
dainmat: brings in for $0.50
fnJ's: calls $0.50
ambythegreat: raises $0.50 to $1
garnishgut joins the table at seat #1
jt studd: folds
KyleHruby: folds
nutOmatic: folds
dainmat: folds
fnJ's: calls $0.50
*** 4th STREET ***
Dealt to fnJ's [3s] [6h]
Dealt to ambythegreat [5h] [4c]
ambythegreat: bets $1
fnJ's: calls $1
*** 5th STREET ***
Dealt to fnJ's [3s 6h] [2h]
Dealt to ambythegreat [5h 4c] [Kh]
fnJ's: bets $2
ambythegreat: calls $2
*** 6th STREET ***
Dealt to fnJ's [3s 6h 2h] [2c]
Dealt to ambythegreat [5h 4c Kh] [5s]
fnJ's: bets $2
ambythegreat: calls $2
*** RIVER ***
fnJ's: bets $2
ambythegreat: calls $2
*** SHOW DOWN ***
fnJ's: shows [9d 5c 3s 6h 2h 2c 4h] (Lo: 6,5,4,3,2)
ambythegreat: mucks hand
fnJ's collected $16.35 from pot
*** SUMMARY ***
Total pot $17.10 | Rake $0.75
Seat 2: dainmat folded on the 3rd Street
Seat 3: fnJ's showed [9d 5c 3s 6h 2h 2c 4h] and won ($16.35) with Lo: 6,5,4,3,2
Seat 4: ambythegreat mucked [6s 7h 5h 4c Kh 5s Jc]
Seat 5: jt studd folded on the 3rd Street (didn't bet)
Seat 6: KyleHruby folded on the 3rd Street (didn't bet)
Seat 7: nutOmatic folded on the 3rd Street (didn't bet)

View File

@ -18,8 +18,8 @@
echo "Please note for this to work you need to work on an empty database, otherwise some info (the id fields) will be off" echo "Please note for this to work you need to work on an empty database, otherwise some info (the id fields) will be off"
rm *.found.txt rm *.found.txt
../pyfpdb/fpdb_import.py -p$1 --file=ps-lhe-ring-3hands.txt -x ../pyfpdb/CliFpdb.py -p$1 --file=ps-lhe-ring-3hands.txt -x
../pyfpdb/fpdb_import.py -p$1 --file=ps-lhe-ring-3hands.txt -x ../pyfpdb/CliFpdb.py -p$1 --file=ps-lhe-ring-3hands.txt -x
echo "it should've reported first that it stored 3, then that it had 3 duplicates" echo "it should've reported first that it stored 3, then that it had 3 duplicates"
@ -31,12 +31,12 @@ echo "it should've reported first that it stored 3, then that it had 3 duplicate
./PrintPlayerHudData.py -p$1 -nPlayer_5 -oB > ps-flags-B-1hands.found.txt && colordiff ps-flags-B-1hands.found.txt ps-flags-B-1hands.expected.txt ./PrintPlayerHudData.py -p$1 -nPlayer_5 -oB > ps-flags-B-1hands.found.txt && colordiff ps-flags-B-1hands.found.txt ps-flags-B-1hands.expected.txt
../pyfpdb/fpdb_import.py -p$1 --file=ps-lhe-ring-call-3B-preflop-cb-no2b.txt -x ../pyfpdb/CliFpdb.py -p$1 --file=ps-lhe-ring-call-3B-preflop-cb-no2b.txt -x
echo "it should've now reported another successful store of 1 hand" echo "it should've now reported another successful store of 1 hand"
./PrintPlayerHudData.py -p$1 -nplayer3 -oE -e10 -b50 > ps-flags-CBflop.found.txt && colordiff ps-flags-CBflop.found.txt ps-flags-CBflop.expected.txt ./PrintPlayerHudData.py -p$1 -nplayer3 -oE -e10 -b50 > ps-flags-CBflop.found.txt && colordiff ps-flags-CBflop.found.txt ps-flags-CBflop.expected.txt
../pyfpdb/fpdb_import.py -p$1 --file=ps-studhilo-ring-showdown.txt -x ../pyfpdb/CliFpdb.py -p$1 --file=ps-studhilo-ring-showdown.txt -x
echo "it should've now reported another successful store of 1 hand" echo "it should've now reported another successful store of 1 hand"
./PrintHand.py -p$1 --hand=15043388146 > ps.15043388146.found.txt && colordiff ps.15043388146.found.txt ps.15043388146.expected.txt ./PrintHand.py -p$1 --hand=15043388146 > ps.15043388146.found.txt && colordiff ps.15043388146.found.txt ps.15043388146.expected.txt
./PrintPlayerHudData.py -p$1 -nbr1an -o0 -e6 -b20 -cstudhilo> ps-flags-studhilo.found.txt && colordiff ps-flags-studhilo.found.txt ps-flags-studhilo.expected.txt ./PrintPlayerHudData.py -p$1 -nbr1an -o0 -e6 -b20 -cstudhilo> ps-flags-studhilo.found.txt && colordiff ps-flags-studhilo.found.txt ps-flags-studhilo.expected.txt