pull from Ray (I think this was release 0.11)
|
@ -1,37 +0,0 @@
|
||||||
#!/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 regression-test/*.found.txt
|
|
||||||
rm regression-test/*.pyc
|
|
||||||
rm pyfpdb/*.pyc
|
|
||||||
|
|
||||||
mkdir fpdb-$1
|
|
||||||
cp -R docs fpdb-$1/
|
|
||||||
cp -R packaging fpdb-$1/
|
|
||||||
cp -R pyfpdb fpdb-$1/
|
|
||||||
rm fpdb-$1/pyfpdb/HUD_config.*
|
|
||||||
cp pyfpdb/HUD_config.xml.example fpdb-$1/pyfpdb/HUD_config.xml
|
|
||||||
cp -R regression-test fpdb-$1/
|
|
||||||
cp -R utils fpdb-$1/
|
|
||||||
|
|
||||||
cd fpdb-$1
|
|
||||||
zip -r releases/fpdb-1.0_$1.zip *
|
|
||||||
tar -cf - * | bzip2 >> releases/fpdb-1.0_$1.tar.bz2
|
|
||||||
cd ..
|
|
||||||
rm -r fpdb-$1
|
|
||||||
|
|
||||||
echo "Please ensure the files are named fpdb-1.0_alpha*_p*.*"
|
|
|
@ -1,47 +0,0 @@
|
||||||
HUD/table viewer
|
|
||||||
================
|
|
||||||
A3-7=3rd-7th street Complete/Raise percentage
|
|
||||||
AF=Flop Bet/Raise percentage
|
|
||||||
AT=River Bet/Raise percentage
|
|
||||||
AR=Turn Bet/Raise percentage
|
|
||||||
F3-7=3rd-7th street Fold percentage
|
|
||||||
FB=like FSB but for big blinds only
|
|
||||||
FF=Flop Fold percentage
|
|
||||||
FR=River Fold percentage
|
|
||||||
FSB=Fold to steal - combined of small and big blind (FSB means Fold Small Big). E.g. if a player faced a steal attempt in the SB 7 times and
|
|
||||||
FS=like FSB but for small blinds only.
|
|
||||||
FT=Turn Fold percentage
|
|
||||||
HD=Hands
|
|
||||||
PF3B4B=Pre Flop 3Bet or 4Bet
|
|
||||||
PFR=Pre Flop Raise
|
|
||||||
Postf A=Postflop (ie. flop+turn+river) Aggression%
|
|
||||||
Postf F=Postflop Fold %
|
|
||||||
SD/F=Showdown/Flop=WtSD=How often player went to showdown when he saw the flop
|
|
||||||
ST=Steal chance (nobody had entered the pot before the player in question, and the player is in cutoff, button or SB position)
|
|
||||||
W$wsF=Won $ when he saw flop
|
|
||||||
W$@SD=Won $ at showdown
|
|
||||||
VPI3=Voluntary Put In on 3rd Street (ie. call+complete+raise)
|
|
||||||
VPIP=Voluntary Put In Preflop (ie. call+raise)
|
|
||||||
|
|
||||||
Other
|
|
||||||
=====
|
|
||||||
CLI=Command Line Interface (Shell, Terminal, "DOS-window")
|
|
||||||
FTP=Full Tilt Poker
|
|
||||||
GUI=Graphical User Interface (normal interface with buttons and menus)
|
|
||||||
HUD=Heads-Up Display (shows stats directly in the poker software)
|
|
||||||
PS=PokerStars
|
|
||||||
MTT=Multi Table Tournament
|
|
||||||
SnG=Sit and Go
|
|
||||||
|
|
||||||
License
|
|
||||||
=======
|
|
||||||
Trademarks of third parties have been used under Fair Use or similar laws.
|
|
||||||
|
|
||||||
Copyright 2008 Steffen Jobbagy-Felso
|
|
||||||
Permission is granted to copy, distribute and/or modify this
|
|
||||||
document under the terms of the GNU Free Documentation License,
|
|
||||||
Version 1.2 as published by the Free Software Foundation; with
|
|
||||||
no Invariant Sections, no Front-Cover Texts, and with no Back-Cover
|
|
||||||
Texts. A copy of the license can be found in fdl-1.2.txt
|
|
||||||
|
|
||||||
The program itself is licensed under AGPLv3, see agpl-3.0.txt
|
|
|
@ -1,75 +0,0 @@
|
||||||
benchmarks
|
|
||||||
==========
|
|
||||||
All measurements on my Athlon64@1.1GHz, 1 GB RAM, RAID5, Hardened Gentoo Linux 2.6.23
|
|
||||||
From svn47 all measurements on my Athlon64 X2@1GHz, 2GB RAM
|
|
||||||
All measurements were ran several times in a row, unless otherwise noted the computer was mostly idle
|
|
||||||
svn12/15 were with PostgreSQL, svn23 onwards with MySQL
|
|
||||||
All import measurements were taken immediately after reseting the tables
|
|
||||||
|
|
||||||
svn12, whilst compiling open office in the background
|
|
||||||
=====
|
|
||||||
reseting tables (incl filling default data): 0.5-0.6s
|
|
||||||
importing one hand from a file: 0.5-0.7s
|
|
||||||
|
|
||||||
svn15
|
|
||||||
=====
|
|
||||||
reseting tables (incl filling default data): 0.35-0.4s
|
|
||||||
importing one FTP hand from a file: 0.2-0.3s or 12-18k/hr
|
|
||||||
importing 51 FTP hands: 2.8-2.9s or 63-66k/hr
|
|
||||||
The large speedup will be partially due to not compiling in the background, and
|
|
||||||
partially due to less connecting/disconnecting the DB I'd imagine.
|
|
||||||
I'm VERY happy with this performance, but large gains could probably be made by
|
|
||||||
making the importer just a bit more sensible.
|
|
||||||
|
|
||||||
svn23
|
|
||||||
=====
|
|
||||||
reseting tables (incl filling default data): 0.3-0.35s
|
|
||||||
importing 75 PS hands: 3.2s or 84k/hr
|
|
||||||
importing 180 FTP hands: 7.7-7.9s 82k/hr
|
|
||||||
This is the rewrite in import_FTP_and_PS.py, svn12/15 are with import_file.py
|
|
||||||
Nice, it's substantially faster inspite of supporting PS and FTP (ish) rather
|
|
||||||
than just FTP and handling more special cases.
|
|
||||||
|
|
||||||
svn24
|
|
||||||
=====
|
|
||||||
importing 75 PS hands: 3.2-3.3s or 82k/hr
|
|
||||||
importing 507 FTP hands: 23.5-23.8s or 77k/hr
|
|
||||||
importing 947 FTP hands: 76.2-72.7s or 44k/hr
|
|
||||||
As you can see FTP has gotten about 6% slower on 500 hands - but the much expanded handling
|
|
||||||
of new cases (particularly the ante folding will be ALOT of extra string
|
|
||||||
comparisons) easily explains that. In fact I expected a much bigger impact.
|
|
||||||
(I suspect this is due to the parsing pausing whilst my shell catches up)
|
|
||||||
|
|
||||||
svn47
|
|
||||||
=====
|
|
||||||
It significantly slows down as the database gets larger, after a few thousand
|
|
||||||
hands it got to just one hand per second and slower. However, around 90% of the
|
|
||||||
CPU load was MySQL. Any tips are most welcome..
|
|
||||||
|
|
||||||
svn52 (whilst watching movie in a small window)
|
|
||||||
=====
|
|
||||||
Importing 2500 hands (mixed sites+types): 6m15s or 31k/hr (ran twice)
|
|
||||||
Of these 230 were skipped as duplicate or partial so counting 2270 hands
|
|
||||||
|
|
||||||
svn53 (whilst watching movie in a small window)
|
|
||||||
=====
|
|
||||||
Importing the 2270 hands from svn52: 1m50 or 74k/hr (82 if counting dupes/partial)
|
|
||||||
Importing my 35661 (plus 427 dupe/part) hands: 51m51s or 41k/hr (ran once)
|
|
||||||
|
|
||||||
The dbsize still has a significant impact, but with these sizes certainly it's
|
|
||||||
just not a problem. If anyone runs a larger database let me know how long it takes.
|
|
||||||
Thanks bwarycha for the tip with the foreign keys!
|
|
||||||
|
|
||||||
|
|
||||||
License
|
|
||||||
=======
|
|
||||||
Trademarks of third parties have been used under Fair Use or similar laws.
|
|
||||||
|
|
||||||
Copyright 2008 Steffen Jobbagy-Felso
|
|
||||||
Permission is granted to copy, distribute and/or modify this
|
|
||||||
document under the terms of the GNU Free Documentation License,
|
|
||||||
Version 1.2 as published by the Free Software Foundation; with
|
|
||||||
no Invariant Sections, no Front-Cover Texts, and with no Back-Cover
|
|
||||||
Texts. A copy of the license can be found in fdl-1.2.txt
|
|
||||||
|
|
||||||
The program itself is licensed under AGPLv3, see agpl-3.0.txt
|
|
|
@ -1,27 +0,0 @@
|
||||||
This is just a loose collection of things so far, but might as well make a start :)
|
|
||||||
|
|
||||||
A word on wrapping: Please avoid making manual line breaks, the computer can and therefore should do it. Whether people use a phone or a 40" super-uber-HD screen, they should be allowed to use as much of it as they wish/can. Incidentially, if anyone knows how to activate line wrap in Eclipse I'd really appreciate if you let me know.
|
|
||||||
|
|
||||||
Comments (or prints) with todo are things that are missing, bugs, or just messy code.
|
|
||||||
|
|
||||||
After every def (ie. at the end of the method) there should be a comment including the name, e.g.
|
|
||||||
#def end of parseActionLine
|
|
||||||
|
|
||||||
If you don't mind make names in java style, ie.:
|
|
||||||
Classes, files or tables like this: MyClassName
|
|
||||||
Methods and variables like this: myMethodName
|
|
||||||
|
|
||||||
I'll eventually change all my code to that style, too.
|
|
||||||
|
|
||||||
License
|
|
||||||
=======
|
|
||||||
Trademarks of third parties have been used under Fair Use or similar laws.
|
|
||||||
|
|
||||||
Copyright 2008 Steffen Jobbagy-Felso
|
|
||||||
Permission is granted to copy, distribute and/or modify this
|
|
||||||
document under the terms of the GNU Free Documentation License,
|
|
||||||
Version 1.2 as published by the Free Software Foundation; with
|
|
||||||
no Invariant Sections, no Front-Cover Texts, and with no Back-Cover
|
|
||||||
Texts. A copy of the license can be found in fdl-1.2.txt
|
|
||||||
|
|
||||||
The program itself is licensed under AGPLv3, see agpl-3.0.txt
|
|
|
@ -1,22 +0,0 @@
|
||||||
stats to add
|
|
||||||
============
|
|
||||||
*CC,TotalColdCalls,TimesFacingRaisePreflop
|
|
||||||
**Folded to 3-Bet,FoldedToThreeBetPreflop,FacedThreeBetPreflop
|
|
||||||
Called 3-Bet,CalledThreeBetPreflop,FacedThreeBetPreflop
|
|
||||||
*Winning %,wonhand,TotalHands
|
|
||||||
**Flop Aggression Factor,timesaggressiveflop,timescalledflop
|
|
||||||
**Turn Aggression Factor,timesaggressiveturn,timescalledturn
|
|
||||||
**River Aggression Factor,timesaggressiveriver,timescalledriver
|
|
||||||
scoopedPot (useful for hi/lo split games)
|
|
||||||
|
|
||||||
couldSqueeze, didSqueeze, facedSqueeze, calledSqueeze -> if (player raises from EP) and (someone after him calls) and (someone after that goes all in)
|
|
||||||
Donk Bet Turn,DidDonkBetTurn,CouldDonkBetTurn -> EP raises, LP reraises, EP calls. If EP bets out after the flop, it is considered a donk bet
|
|
||||||
Float Turn,DidFloatTurn,CouldFloatTurn ->
|
|
||||||
|
|
||||||
other
|
|
||||||
=====
|
|
||||||
look at PT3 and HM tables see if i forgot anything
|
|
||||||
store all-in somewhere
|
|
||||||
add somewhere: mixed flag to denote that the game is part of a mixed game rotation
|
|
||||||
|
|
||||||
add tables for single draw (5card draw, 2-7 single draw, badugi) and tripple draw (2-7 tripple draw)
|
|
|
@ -1,46 +0,0 @@
|
||||||
Last checked: 1 Sep, p74
|
|
||||||
|
|
||||||
These instructions are for any Ubuntu Linux, but except for the name of the package management software it should be identical on other Linux distributions.
|
|
||||||
|
|
||||||
Using the package manager (I think it's called synaptics) install the dependencies: mysql, python, mysql-python, pygtk
|
|
||||||
I don't use ubuntu but I'd imagine it will at some point prompt you for a MySQL root password enter one and when it's done installing everything open a shell/terminal and type this:
|
|
||||||
mysql --user=root --password=YourMysqlRootPassword
|
|
||||||
It should say something like this:
|
|
||||||
|
|
||||||
Welcome to the MySQL monitor. Commands end with ; or \g.
|
|
||||||
Your MySQL connection id is 4
|
|
||||||
Server version: 5.0.60-log Ubuntu Linux mysql-5.0.60-r1
|
|
||||||
|
|
||||||
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
|
|
||||||
|
|
||||||
mysql>
|
|
||||||
|
|
||||||
Now type this:
|
|
||||||
CREATE DATABASE fpdb;
|
|
||||||
|
|
||||||
Next you need to create a user. Type this (replacing newPassword with the password you want the fpdb user to have - this can, but for security shouldn't, be the same as the root mysql password):
|
|
||||||
GRANT ALL PRIVILEGES ON fpdb.* TO 'fpdb'@'localhost' IDENTIFIED BY 'newPassword' WITH GRANT OPTION;
|
|
||||||
|
|
||||||
Then download one of the alpha2 archives from the sourceforge page at https://sourceforge.net/projects/fpdb/ and unpack it into a folder of your choice.
|
|
||||||
|
|
||||||
Next create a directory called .fpdb (the . at the beginning is important) in your home directory, e.g. /home/steffen/.fpdb
|
|
||||||
Then copy the default.conf file from the docs directory of the archive into this new folder.
|
|
||||||
Finally edit default.conf with any texteditor and enter the fpdb password you entered above (in the GRANT ALL... command).
|
|
||||||
|
|
||||||
This should be it, try double clicking pyfpdb/fpdb.py or open it from a shell with python /path/to/fpdb/pyfpdb/fpdb.py
|
|
||||||
|
|
||||||
Now see readme-user.txt for usage instructions.
|
|
||||||
|
|
||||||
|
|
||||||
License
|
|
||||||
=======
|
|
||||||
Trademarks of third parties have been used under Fair Use or similar laws.
|
|
||||||
|
|
||||||
Copyright 2008 Steffen Jobbagy-Felso
|
|
||||||
Permission is granted to copy, distribute and/or modify this
|
|
||||||
document under the terms of the GNU Free Documentation License,
|
|
||||||
Version 1.2 as published by the Free Software Foundation; with
|
|
||||||
no Invariant Sections, no Front-Cover Texts, and with no Back-Cover
|
|
||||||
Texts. A copy of the license can be found in fdl-1.2.txt
|
|
||||||
|
|
||||||
The program itself is licensed under AGPLv3, see agpl-3.0.txt
|
|
|
@ -1,58 +0,0 @@
|
||||||
Everything is subject to change and the order does not indicate priority. Patches for any of these or other features are very welcome, see readme-overview.txt for contacts.
|
|
||||||
Please also see db-todo.txt
|
|
||||||
|
|
||||||
before beta
|
|
||||||
===========
|
|
||||||
change to savannah?
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Any comment or print with "todo" in it in the sourcecode except what is marked todo in the menu
|
|
||||||
make a quick benchmark of mysql and postgresql: import of my whole db, some tableviewer refreshes with and without updated file
|
|
||||||
Make tab and enter work as sensible in GUIs and implement Ctrl+Q, Ctrl+X and Alt+F4 for close.
|
|
||||||
use profile file for bulk import and table viewer settings and pathes
|
|
||||||
check that we read sitout correctly in: Full Tilt Poker Game #6150325318: Table Bogside
|
|
||||||
verify at least 2 or 3 sng hands
|
|
||||||
|
|
||||||
no rush but before 1.0RC
|
|
||||||
========================
|
|
||||||
improve handling of dead hand before BB, see git101/7bd1631
|
|
||||||
make DB version error offer reimport, recreation and continue.
|
|
||||||
In many places there are unnecessary database accesses or it regenerates information it already had before or just generally does things in obscenely inefficient ways. Optimise this
|
|
||||||
multi-select in bulk importer
|
|
||||||
cut down action_types array size to appropriate length
|
|
||||||
make the gui display errors
|
|
||||||
log file
|
|
||||||
move directory import code from gui to backend
|
|
||||||
convert fpdb_import to not require passing "self", generally clean the parameter passing
|
|
||||||
Doesn't handle Daylight Saving Time (I don't think at least)
|
|
||||||
ensure that refresh still takes no more than 10 seks on my P3M-800 (a quick run on git15 indicates this is ok now), or 5 with remote DB
|
|
||||||
select range of stakes and sng/mtt values and types for hud
|
|
||||||
recognise somewhere if a file is still active and if so keep it open and only read new hands rather than detecting dupes
|
|
||||||
return full ftp functionality
|
|
||||||
|
|
||||||
can wait till 1.x
|
|
||||||
=================
|
|
||||||
in all importer: stop doing if site=="ftp", make class constants for site_id instead
|
|
||||||
It treats fold due to disconnect as voluntary fold which is not ideal
|
|
||||||
aliases
|
|
||||||
repair hands where the seat lines are missing, happens when observing at FTP
|
|
||||||
flags for storing the reason for winning (best hi, tie for best low, etc.) to DB. not sure actually if this is such a good idea remember that there can be multiple reasons for the same player in the same hand
|
|
||||||
benchmark properly on mysql innodb, postgresql, more?
|
|
||||||
rename things like this: ClassName.methodName and variableName. update codingstyle
|
|
||||||
CLI (not ncurses, normal CLI) equivalent for fpdb.py
|
|
||||||
optimise/simplify storing by creating the SQL statements depending on hand rather than calling different methods
|
|
||||||
make range of activeSeats configurable for tv/hud
|
|
||||||
|
|
||||||
License
|
|
||||||
=======
|
|
||||||
Trademarks of third parties have been used under Fair Use or similar laws.
|
|
||||||
|
|
||||||
Copyright 2008 Steffen Jobbagy-Felso
|
|
||||||
Permission is granted to copy, distribute and/or modify this
|
|
||||||
document under the terms of the GNU Free Documentation License,
|
|
||||||
Version 1.2 as published by the Free Software Foundation; with
|
|
||||||
no Invariant Sections, no Front-Cover Texts, and with no Back-Cover
|
|
||||||
Texts. A copy of the license can be found in fdl-1.2.txt
|
|
||||||
|
|
||||||
The program itself is licensed under AGPLv3, see agpl-3.0.txt
|
|
|
@ -1,67 +0,0 @@
|
||||||
Hi,
|
|
||||||
This document is to serve as a little overview (later: full technical doc) for current and prospective developers with:
|
|
||||||
a) introduction into the code structure
|
|
||||||
b) organisational/legal things
|
|
||||||
|
|
||||||
What to do?
|
|
||||||
===========
|
|
||||||
- Anything you want.
|
|
||||||
- The most useful (because it's the most boring) would be to update print_hand.py, update the expected files (testdata/*.found.txt) and create more .found.txt to ensure import processing is running correctly.
|
|
||||||
- There's a list of various bugs, deficiencies and important missing features in known_bugs_and_planned_features.txt.
|
|
||||||
- In the main GUI there's various menu points marked with todo - all of these will have to be done eventually.
|
|
||||||
|
|
||||||
If you want to take a look at coding-style.txt.
|
|
||||||
Ideally use git (see git-instructions.txt for some commands) and let me know where to pull from, alternatively feel free to send patches or even just changed file in whatever code layout or naming convention you like best. I will, of course, still give you full credit.
|
|
||||||
|
|
||||||
Contact/Communication
|
|
||||||
=====================
|
|
||||||
If you start working on something please open a bug or feature request at sf to avoid someone else from doing the same
|
|
||||||
Please see readme-overview
|
|
||||||
|
|
||||||
Dependencies
|
|
||||||
============
|
|
||||||
Please let me know before you add any new dependencies and ensure that they are source-compatible between *nix and Windows
|
|
||||||
|
|
||||||
Code/File/Class Structure
|
|
||||||
=========================
|
|
||||||
Basically the code runs like this
|
|
||||||
|
|
||||||
fpdb.py -> bulk importer tab (import_threaded.py) -> fpdb_import.py -> fpdb_parse_logic.py -> fpdb_save_to_db.py
|
|
||||||
or
|
|
||||||
fpdb.py -> table viewer tab (table_viewer.py) (todo: -> libTableViewer)
|
|
||||||
|
|
||||||
All files call the simple methods that I just collected in fpdb_simple.py, to abstract the other files off the nitty gritty details as I was learning python.
|
|
||||||
I'm currently working on (amongst other things) integrating everything into the fpdb.py GUI with a view to allow easy creation of a CLI client, too.
|
|
||||||
|
|
||||||
Also see filelist.txt.
|
|
||||||
|
|
||||||
How to Commit
|
|
||||||
=============
|
|
||||||
Please make sure you read and accept the copyright policy as stated in this file. Then see git-instructions.txt. Don't get me wrong, I hate all this legalese, but unfortunately it's kinda necessary.
|
|
||||||
|
|
||||||
Copyright/Licensing
|
|
||||||
===================
|
|
||||||
Copyright by default is handled on a per-file basis. If you send in a patch or make a commit to an existing file it is done on the understanding that you transfer all rights (as far as legally possible in your jurisdiction) to the current copyright holder of that file, unless otherwise stated. If you create a new file please ensure to include a copyright and license statement.
|
|
||||||
|
|
||||||
The licenses used by this project are the AGPL3 for code and FDL1.2 for documentation. See readme-overview.txt for reasons and if you wish to use fpdb with different licensing.
|
|
||||||
|
|
||||||
Preferred File Formats
|
|
||||||
======================
|
|
||||||
Preferred: Where possible simple text-based formats, e.g. plain text (with Unix end of line char) or (X)HTML. Preferred picture format is PNG. IE-compability for HTML files is optional as IE was never meant to be a real web browser, if it were they would've implemented web standards.
|
|
||||||
|
|
||||||
Also good: Other free and open formats, e.g. ODF.
|
|
||||||
|
|
||||||
Not good: Any format that doesn't have full documentation freely and publicly available with a proper license for anyone to implement it. Sadly, Microsoft has chosen not fulfil these requirements for ISO MS OOXML to become a truly open standard.
|
|
||||||
|
|
||||||
License (of this file)
|
|
||||||
=======
|
|
||||||
Trademarks of third parties have been used under Fair Use or similar laws.
|
|
||||||
|
|
||||||
Copyright 2008 Steffen Jobbagy-Felso
|
|
||||||
Permission is granted to copy, distribute and/or modify this
|
|
||||||
document under the terms of the GNU Free Documentation License,
|
|
||||||
Version 1.2 as published by the Free Software Foundation; with
|
|
||||||
no Invariant Sections, no Front-Cover Texts, and with no Back-Cover
|
|
||||||
Texts. A copy of the license can be found in fdl-1.2.txt
|
|
||||||
|
|
||||||
The program itself is licensed under AGPLv3, see agpl-3.0.txt
|
|
|
@ -1,86 +0,0 @@
|
||||||
Summary
|
|
||||||
=======
|
|
||||||
A database program to track your online poker games, the behaviour of the other players and your winnings/losses. Supports Holdem, Omaha, Stud and Razz for cash games as well as SnG and MTT tournaments with more possibly coming in the future. Some of this is not yet working though, please see status.txt and known-bugs-and-planned-features.txt
|
|
||||||
|
|
||||||
Contact
|
|
||||||
=======
|
|
||||||
Please note that this project has two hostings: one at assembla.com which holds are version control "central tree" (irrelevant for users) and everything else at http://sourceforge.net/projects/fpdb/.
|
|
||||||
|
|
||||||
The best means of contact are the sourceforge page: Use the bug, feature request or patch functions or just post in the forum.
|
|
||||||
|
|
||||||
Alternatively feel free to contact me directly:
|
|
||||||
|
|
||||||
mail: steffen(at)sycamoretest.info
|
|
||||||
jabber/xmpp/Google Talk: as above
|
|
||||||
ICQ: 7806355
|
|
||||||
MSN: steffenjf@gmx.de (don't email that)
|
|
||||||
|
|
||||||
But you could send all my hand histories to yourself!
|
|
||||||
=====================================================
|
|
||||||
At the end of the day this comes down to a question of trust, but unlike Windows and the poker client software you don't have to trust fpdb blindly. You can:
|
|
||||||
- Verify the source code yourself.
|
|
||||||
- Convince or pay someone to verify the source code for you.
|
|
||||||
- Use a personal firewall to completely block fpdb from the Internet
|
|
||||||
- (for the uber-paranoid) Get yourself the free virtualisation software VirtualBox, set up a VM (virtual machine) to run fpdb but run the poker software on your real PC. Then cut the VM off the Internet, fpdb doesn't need it. If you have a PC made in the last few years this should run fast enough as well. Note that most Windows licenses do NOT permit you to use two Windows installations at once, even if they are on the same PC.
|
|
||||||
|
|
||||||
Installing
|
|
||||||
==========
|
|
||||||
See the install-*.txt for your operating system. If your OS is missing or if you have problems let me know (contacts are further below). In particular I'd be happy to provide packages for GNU/Linux and *BSD distributions.
|
|
||||||
|
|
||||||
Using it
|
|
||||||
========
|
|
||||||
See readme-user.txt
|
|
||||||
If you have a problem, request or question see the contacts section below
|
|
||||||
|
|
||||||
Changing it
|
|
||||||
===========
|
|
||||||
See readme-dev.txt
|
|
||||||
|
|
||||||
Requirements
|
|
||||||
============
|
|
||||||
Software requirements are listed in requirements.txt
|
|
||||||
As for hardware, my main test machine is a Pentium 3-M 800 with 256 RAM and Gentoo GNU/Linux
|
|
||||||
(running the poker client through what most people will call emulation). So this
|
|
||||||
program will have to work on that. If you run an even more ancient machine and
|
|
||||||
its too slow let me know and I'll see what I can do :)
|
|
||||||
|
|
||||||
Why Free Software?
|
|
||||||
==================
|
|
||||||
This program is released under the terms of the free/libre software license AGPL3 as released by the FSF. The AGPL3 protects your rights and those of the wider community. As Richard Stallman, one of the founders of the free software movement, put it: "Free software is a matter of liberty, not price. To understand the concept, you should think of free as in free speech, not as in free beer." (well, it is both really, like the right to vote used to be free)
|
|
||||||
|
|
||||||
For example, a "pirated" copy of proprietary software X is free of charge, but you don't actually have a legal right to use it, you don't have any possibility to fix its bugs and you certainly don't have any legal right to share it with your friends. You also won't be able to get support, often not even security fixes. Actually, even if you pay hundreds of pounds for your program they deny your right to fix their errors for them. Imagine buying a car where you're not permitted (under threat of jail) to replace broken parts..
|
|
||||||
|
|
||||||
With free/libre software (also known as open source software, or short FOSS or FLOSS) on the other hand you get all these freedoms:
|
|
||||||
(note: the legally binding terms are in the license text, this is merely an amateur summary so normal people don't have to read pages of legalese)
|
|
||||||
|
|
||||||
Freedom 0: The freedom to use: To run the program, for any purpose. Free of Charge.
|
|
||||||
Freedom 1: The freedom to study and help yourself. This freedom guarantees your right to study and learn from the source code of the program, and to fix it if it is broken. If you're not a programmer yourself the developers will generally be happy to fix it for you, often even for free. Failing that you can always pay someone from the money you saved on not having to pay for it.
|
|
||||||
Freedom 2: The freedom to be a decent human being and help your neighbour: I don't threaten you with lawsuits or jail time if you share with your friends and neighbours, subject to the very modest restrictions of the AGPL3.
|
|
||||||
Freedom 3: The freedom to improve the program and release your improvements to the public (or parts thereof) so that the whole community benefits. Note that you are PERMITTED, but not REQUIRED to distribute your changes. If you do distribute your changes you must do so under the terms of the AGPL3 however.
|
|
||||||
|
|
||||||
Note that this is the license - I retain full copyright over my code, including the right to change the license for future versions. I do not intend to do this however. In any case, any version I released under AGPL3 remains available under that license forever, or more accurately until my copyright expires at which point it goes into the public domain.
|
|
||||||
|
|
||||||
I reject the concept of software patents as a crime and under the European Patent Agreement software patents - even if you mislabel them as "computer-implemented inventions" or whatever - are explicitly prohibited.
|
|
||||||
|
|
||||||
Can I get/use this under a different license?
|
|
||||||
=============================================
|
|
||||||
The short answer: Maybe.
|
|
||||||
The long one: As detailed, I fully support what the FSF does and aims to achieve with the GPL. However, I realise that many free software developers don't object to closed source, some don't even object to closed source profiteering of their charity, and I don't think I have any right to go and tell them they're wrong.
|
|
||||||
So if anyone wishes to use all or part of my code in another free software/open source project with an AGPL3-incompatible license such as BSD then let me know and we'll figure out a solution that makes everyone happy.
|
|
||||||
If you wish to use all or part of this in closed source let me know how much if anything that is worth to you and I'm sure we'll be able to reach an agreement. Note that you are NOT permitted to just use fpdb code in closed source development whether in-house or by an independent software developer, you will NEED an additionally agreement with me to get fpdb under different licensing conditions.
|
|
||||||
|
|
||||||
|
|
||||||
License of this Document
|
|
||||||
========================
|
|
||||||
The views expressed in this document are those of Steffen Jobbagy-Felso, other members of the fpdb team and external contributors may or may not agree.
|
|
||||||
|
|
||||||
Trademarks of third parties have been used under Fair Use or similar laws.
|
|
||||||
|
|
||||||
Copyright 2008 Steffen Jobbagy-Felso
|
|
||||||
Permission is granted to copy, distribute and/or modify this
|
|
||||||
document under the terms of the GNU Free Documentation License,
|
|
||||||
Version 1.2 as published by the Free Software Foundation; with
|
|
||||||
no Invariant Sections, no Front-Cover Texts, and with no Back-Cover
|
|
||||||
Texts. A copy of the license can be found in fdl-1.2.txt
|
|
||||||
|
|
||||||
The program itself is licensed under AGPLv3, see agpl-3.0.txt
|
|
|
@ -1,43 +0,0 @@
|
||||||
Before you do this make sure you setup the dependencies, the database, user, tables and config file.
|
|
||||||
|
|
||||||
Running it
|
|
||||||
==========
|
|
||||||
If you have python setup properly you can execute it by double clicking pyfpdb/fpdb.py.
|
|
||||||
|
|
||||||
Note however that all error messages are currently only printed if you call it from a shell. It'll be much easier to diagnose possible problems (which are likely in alpha stage) if you run it from a shell. In Windows XP it seems to automatically open a shell window with the fpdb window where you can see the command line output.
|
|
||||||
|
|
||||||
In Linux/MacOS/*BSD, e.g. if its in /home/sycamore/fpdb/, do this:
|
|
||||||
cd /home/sycamore/fpdb/pyfpdb
|
|
||||||
python fpdb.py
|
|
||||||
|
|
||||||
|
|
||||||
That will start the main GUI.
|
|
||||||
|
|
||||||
Have a look at the menus, the stuff that is marked todo is not yet implemented.
|
|
||||||
|
|
||||||
The main things are the bulk importer and the table viewer. To use the importer open it from the menu (import files and directories). You can set a few options at the bottom, then select a folder or single file in the main are and click Import. Please report any errors by one of the contacts listed in readme-overview.txt.
|
|
||||||
Currently this will block the interface, but you can open another instance of this program e.g. if you wanna play whilst a big import is running.
|
|
||||||
|
|
||||||
Please check the output at the shell for errors, if there are any please get in touch by one of the methods listed in readme-overview.txt
|
|
||||||
|
|
||||||
Table Viewer (tv)
|
|
||||||
=================
|
|
||||||
To use the table viewer open it from the menu, select the hand history file of the table you're at, and click the Import&Read&Refresh button. The abbreviations there are explained in abbreviations.txt, but feel free to ask. Note that most poker software will only create the file once the first hand you payed to play is finished.
|
|
||||||
In each column there is either just the number (hand count for current stake, range of seats and type of game) or a percentage and the number of hands that this percentage is based on. For example, in W$@SD (won $ at shodown) the number in brackets is how many showdowns that player has seen.
|
|
||||||
|
|
||||||
Reimporting
|
|
||||||
===========
|
|
||||||
Currently on most updates a reimport of the whole database is required. To do this open fpdb, click the menu Database and select Create/Recreate tables. Then import all your history files again.
|
|
||||||
|
|
||||||
License
|
|
||||||
=======
|
|
||||||
Trademarks of third parties have been used under Fair Use or similar laws.
|
|
||||||
|
|
||||||
Copyright 2008 Steffen Jobbagy-Felso
|
|
||||||
Permission is granted to copy, distribute and/or modify this
|
|
||||||
document under the terms of the GNU Free Documentation License,
|
|
||||||
Version 1.2 as published by the Free Software Foundation; with
|
|
||||||
no Invariant Sections, no Front-Cover Texts, and with no Back-Cover
|
|
||||||
Texts. A copy of the license can be found in fdl-1.2.txt
|
|
||||||
|
|
||||||
The program itself is licensed under AGPLv3, see agpl-3.0.txt
|
|
64
docs/readme.txt
Normal file
|
@ -0,0 +1,64 @@
|
||||||
|
README.txt
|
||||||
|
updated 26 March 2009, REB
|
||||||
|
|
||||||
|
fpdb - Free Poker Database
|
||||||
|
|
||||||
|
The most accurate and up-to-date information on fpdb will be found in the wiki:
|
||||||
|
http://fpdb.wiki.sourceforge.net/
|
||||||
|
|
||||||
|
Other resources are:
|
||||||
|
Mailing list: http://sourceforge.net/mailarchive/forum.php?forum_name=fpdb-main
|
||||||
|
Chat room(irc): #fpdb on freenode.net
|
||||||
|
|
||||||
|
fpdb is a free program for use with on line poker. It provides:
|
||||||
|
Tracking of your results and statistics.
|
||||||
|
Tracking of opponents' results statistics.
|
||||||
|
Win/loss graphing
|
||||||
|
Heads Up Display (HUD) with a variety of statistics
|
||||||
|
Display of mucked cards in the HUD
|
||||||
|
|
||||||
|
fpdb supports:
|
||||||
|
Sites:
|
||||||
|
PokerStars
|
||||||
|
Full Tilt Poker
|
||||||
|
Everleaf Network
|
||||||
|
Other sites are under development and are easily added
|
||||||
|
|
||||||
|
Games:
|
||||||
|
Holdem
|
||||||
|
Omaha (incl Hi/low)
|
||||||
|
7 Card Stud (incl Hi/low)
|
||||||
|
Razz
|
||||||
|
Draw support is under development
|
||||||
|
Mixed Games -- HUD under development
|
||||||
|
|
||||||
|
Operating Systems:
|
||||||
|
Linux and other Unix-like, using X
|
||||||
|
Windows
|
||||||
|
Mac OS/X -- no support for HUD
|
||||||
|
|
||||||
|
Databases:
|
||||||
|
MySQL
|
||||||
|
PostgreSQL
|
||||||
|
SQLite under development
|
||||||
|
|
||||||
|
Downloads:
|
||||||
|
Releases: http://sourceforge.net/project/showfiles.php?group_id=226872
|
||||||
|
Development code via git: http://www.assembla.com/spaces/free_poker_tools/trac_git_tool
|
||||||
|
|
||||||
|
Developers:
|
||||||
|
At least 7 people have contributed code or patches. Others are welcome.
|
||||||
|
|
||||||
|
License
|
||||||
|
=======
|
||||||
|
Trademarks of third parties have been used under Fair Use or similar laws.
|
||||||
|
|
||||||
|
Copyright 2008 Steffen Jobbagy-Felso
|
||||||
|
Copyright 2009 Ray E. Barker
|
||||||
|
Permission is granted to copy, distribute and/or modify this
|
||||||
|
document under the terms of the GNU Free Documentation License,
|
||||||
|
Version 1.2 as published by the Free Software Foundation; with
|
||||||
|
no Invariant Sections, no Front-Cover Texts, and with no Back-Cover
|
||||||
|
Texts. A copy of the license can be found in fdl-1.2.txt
|
||||||
|
|
||||||
|
fpdb itself is licensed under AGPLv3, see agpl-3.0.txt.
|
|
@ -1,76 +0,0 @@
|
||||||
For all support please note that the tables WILL be changed, almost certainly without keeping backwards compatibility. Therefore you should keep your history files after import so you can re-import when necessary. Should you lose history files and need a "database updater" let me know.
|
|
||||||
|
|
||||||
If support for another site/game would encourage you to help with this software please let me know at steffen@sycamoretest.info.
|
|
||||||
|
|
||||||
IMPORTANT: There appears to be a bug in at least up to git34 in reading WtSD/W$wsF/W$SD
|
|
||||||
|
|
||||||
Holdem/Omaha ring games on PokerStars
|
|
||||||
======================================
|
|
||||||
Works, quite well tested, works in table viewer and is useful now. Functionality is quite limited so far though. This includes the holdem/omaha parts of HORSE, HOSE and any other mixed game
|
|
||||||
|
|
||||||
Stud/Razz ring games on PokerStars
|
|
||||||
==================================
|
|
||||||
Broken - used to work, hardly tested. Needs to be updated to new infrastructure using a HudData table rather than hands_players_flags. Will fix this shortly.
|
|
||||||
|
|
||||||
Tournaments/SnGs
|
|
||||||
================
|
|
||||||
Broken - used to work, hardly tested. Needs to be updated to new infrastructure.. Will probably fix this shortly
|
|
||||||
|
|
||||||
Full Tilt Poker
|
|
||||||
===============
|
|
||||||
Might work - used to work and was very well test. It should import them (except HudData), but I believe the table viewer won't work. Would be easy to fix I think, volunteers welcome. This used to work in a pre-alpha but basically was left behind during updates to the other stuff.
|
|
||||||
|
|
||||||
Other Sites
|
|
||||||
===========
|
|
||||||
Patches/Volunteers welcome. Should be quite easy.
|
|
||||||
|
|
||||||
GUI
|
|
||||||
===
|
|
||||||
Alpha - the infrastructure stands and is fast enough, now "just" need to add more functionality.
|
|
||||||
|
|
||||||
HUD
|
|
||||||
===
|
|
||||||
Not started - volunteers welcome. I found a *nix utility based on xlib that does half the work for this (most of the other half is already in the table viewer), see http://www.roard.com/docs/cookbook/cbsu19.html. There's also a python implementation of xlib which should run even on Windows.
|
|
||||||
|
|
||||||
Packaging
|
|
||||||
=========
|
|
||||||
Gentoo GNU/Linux: I'll make ebuilds, if you want one now let me know.
|
|
||||||
Other free/libre systems (e.g. other GNU/Linux-Distros, *BSD, and I'd love to help in getting this to work on any Hurd based system): Let me know what you use (Distribution, version and CPU type) and I'll make a package.
|
|
||||||
Windows/MacOSX: Manual installation of dependencies for now, integrated installer would be nice - volunteers welcome, but I'll do it eventually in any case.
|
|
||||||
|
|
||||||
Regression Testing
|
|
||||||
==================
|
|
||||||
The query scripts are done-ish, need to verify more data so it can be used in automated regression testing.
|
|
||||||
|
|
||||||
Database Backends
|
|
||||||
=================
|
|
||||||
- MySQL InnoDB is the default
|
|
||||||
- PostgreSQL should work but I haven't tried it. If it doesn't please let me know.
|
|
||||||
- MySQL ISAM won't be supported since it is not transactional
|
|
||||||
|
|
||||||
Legal
|
|
||||||
=====
|
|
||||||
General: This will offer more or less the same kind of functionality as HM and PT so there shouldn't be any problem on any site that allows tracking.
|
|
||||||
PS: I have asked them and they said that due to the fast changing nature
|
|
||||||
of pre-release software they don't review that. However, looking at their
|
|
||||||
posted guidelines we're fine
|
|
||||||
FTP: I sent them an email and what I described there was ok for them.
|
|
||||||
I will write them again for "certification" on release of 1.0
|
|
||||||
|
|
||||||
To avoid any misunderstandings, PS and FTP obviously do not sponsor, endorse, or support fpdb. They allow using it, that's all. Any problems with fpdb should be reported to us, not the poker site.
|
|
||||||
|
|
||||||
A note on viewing/tracking mucked hands. Many people will say this is cheating. I agree. However, I don't make the rules on these sites. The sites that store mucked hands into the history file clearly think that being able to see other people's mucked hands is ok. This software - like HM and PT - merely takes info provided by the poker site and makes it more easily accessible.
|
|
||||||
Apparently PS has now turned this off :)
|
|
||||||
|
|
||||||
License
|
|
||||||
=======
|
|
||||||
Trademarks of third parties have been used under Fair Use or similar laws.
|
|
||||||
|
|
||||||
Copyright 2008 Steffen Jobbagy-Felso
|
|
||||||
Permission is granted to copy, distribute and/or modify this
|
|
||||||
document under the terms of the GNU Free Documentation License,
|
|
||||||
Version 1.2 as published by the Free Software Foundation; with
|
|
||||||
no Invariant Sections, no Front-Cover Texts, and with no Back-Cover
|
|
||||||
Texts. A copy of the license can be found in fdl-1.2.txt
|
|
||||||
|
|
||||||
The program itself is licensed under AGPLv3, see agpl-3.0.txt
|
|
|
@ -1,7 +1,7 @@
|
||||||
# Copyright 1999-2008 Gentoo Foundation
|
# Copyright 1999-2008 Gentoo Foundation
|
||||||
# Gentoo had nothing to do with the production of this ebuild, but I'm pre-emptively transferring all copyrights (as far as legally possible under my local jurisdiction) to them.
|
# Gentoo had nothing to do with the production of this ebuild, but I'm pre-emptively transferring all copyrights (as far as legally possible under my local jurisdiction) to them.
|
||||||
# Distributed under the terms of the GNU General Public License v2
|
# Distributed under the terms of the GNU General Public License v2
|
||||||
# $Header: /var/cvsroot/gentoo-x86/games-util/fpdb/fpdb-1.0_alpha8_p137.ebuild,v 1.0 2008/10/17 steffen@sycamoretest.info Exp $
|
# $Header: /var/cvsroot/gentoo-x86/games-util/fpdb/fpdb-0.10.ebuild,v 1.0 2009/1/30 steffen@sycamoretest.info Exp $
|
||||||
|
|
||||||
NEED_PYTHON=2.3
|
NEED_PYTHON=2.3
|
||||||
|
|
|
@ -1,62 +0,0 @@
|
||||||
# Copyright 1999-2008 Gentoo Foundation
|
|
||||||
# Gentoo had nothing to do with the production of this ebuild, but I'm pre-emptively transferring all copyrights (as far as legally possible under my local jurisdiction) to them.
|
|
||||||
# Distributed under the terms of the GNU General Public License v2
|
|
||||||
# $Header: /var/cvsroot/gentoo-x86/games-util/fpdb/fpdb-1.0_alpha8_p137.ebuild,v 1.0 2008/10/17 steffen@sycamoretest.info Exp $
|
|
||||||
|
|
||||||
NEED_PYTHON=2.3
|
|
||||||
|
|
||||||
#inherit distutils
|
|
||||||
|
|
||||||
MY_P="fpdb-${PV}"
|
|
||||||
DESCRIPTION="A database program to track your online poker games"
|
|
||||||
HOMEPAGE="https://sourceforge.net/projects/fpdb/"
|
|
||||||
SRC_URI="mirror://sourceforge/fpdb/${MY_P}.tar.bz2"
|
|
||||||
|
|
||||||
LICENSE="AGPL-3"
|
|
||||||
SLOT="0"
|
|
||||||
KEYWORDS="~amd64 ~x86"
|
|
||||||
#note: this should work on other architectures too, please send me your experiences
|
|
||||||
IUSE=""
|
|
||||||
|
|
||||||
RDEPEND="virtual/mysql
|
|
||||||
dev-python/mysql-python
|
|
||||||
>=x11-libs/gtk+-2.10
|
|
||||||
dev-python/pygtk
|
|
||||||
dev-python/numpy
|
|
||||||
dev-python/matplotlib"
|
|
||||||
|
|
||||||
DEPEND="${RDEPEND}"
|
|
||||||
|
|
||||||
src_install() {
|
|
||||||
DIRINST="${D}usr/share/games/fpdb/"
|
|
||||||
mkdir -p "${DIRINST}"
|
|
||||||
cp -R * "${DIRINST}" || die
|
|
||||||
|
|
||||||
DIRBIN="${D}usr/games/bin/"
|
|
||||||
mkdir -p "${DIRBIN}"
|
|
||||||
#echo "pathes"
|
|
||||||
#echo "${DIRINST}pyfpdb/fpdb.py"
|
|
||||||
#echo "${DIRBIN}fpdb.py"
|
|
||||||
#echo
|
|
||||||
echo "cd /usr/share/games/fpdb/pyfpdb/ && python fpdb.py" > "${DIRBIN}fpdb" || die
|
|
||||||
chmod 755 "${DIRBIN}fpdb" || die
|
|
||||||
}
|
|
||||||
|
|
||||||
#src_test() {
|
|
||||||
#}
|
|
||||||
|
|
||||||
pkg_postinst() {
|
|
||||||
elog "Fpdb has been installed and can be called by executing /usr/games/bin/fpdb"
|
|
||||||
elog "You need to perform a couple more steps manually."
|
|
||||||
elog "Please also make sure you followed instructions from previous emerges, in particular make sure you configured mysql and set a root pw for it"
|
|
||||||
elog "Now run this command to connect to MySQL: mysql --user=root --password=yourPassword"
|
|
||||||
elog "In the mysql command line interface you need to type these two lines (make sure you get the ; at the end)"
|
|
||||||
elog "In the second line replace \"newPassword\" with a password of your choice"
|
|
||||||
elog "CREATE DATABASE fpdb;"
|
|
||||||
elog "GRANT ALL PRIVILEGES ON fpdb.* TO 'fpdb'@'localhost' IDENTIFIED BY 'newPassword' WITH GRANT OPTION;"
|
|
||||||
elog "Finally copy the default config file from ${DIRINST}docs/default.conf to ~/.fpdb/ for every user that is to use fpdb."
|
|
||||||
elog "You will need to edit the default.conf, in particular you need to replace the password with what you entered in the \"GRANT ALL...\""
|
|
||||||
elog "Finally run the GUI and click the menu database -> recreate tables"
|
|
||||||
elog "That's it! See our webpage at http://fpdb.sourceforge.net for more documentation"
|
|
||||||
elog " "
|
|
||||||
}
|
|
241
pyfpdb/BetfairToFpdb.py
Executable file
|
@ -0,0 +1,241 @@
|
||||||
|
#!/usr/bin/env python
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
#
|
||||||
|
# Copyright 2008, Carl Gherardi
|
||||||
|
#
|
||||||
|
# This program is free software; you can redistribute it and/or modify
|
||||||
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
# the Free Software Foundation; either version 2 of the License, or
|
||||||
|
# (at your option) any later version.
|
||||||
|
#
|
||||||
|
# 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 General Public License
|
||||||
|
# along with this program; if not, write to the Free Software
|
||||||
|
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
########################################################################
|
||||||
|
|
||||||
|
import sys
|
||||||
|
import logging
|
||||||
|
from HandHistoryConverter import *
|
||||||
|
|
||||||
|
# Betfair HH format
|
||||||
|
|
||||||
|
class Betfair(HandHistoryConverter):
|
||||||
|
|
||||||
|
# Static regexes
|
||||||
|
re_GameInfo = re.compile("^(?P<LIMIT>NL|PL|) (?P<CURRENCY>\$|)?(?P<SB>[.0-9]+)/\$?(?P<BB>[.0-9]+) (?P<GAME>(Texas Hold\'em|Omaha Hi|Razz))", re.MULTILINE)
|
||||||
|
re_SplitHands = re.compile(r'\n\n+')
|
||||||
|
re_HandInfo = re.compile("\*\*\*\*\* Betfair Poker Hand History for Game (?P<HID>[0-9]+) \*\*\*\*\*\n(?P<LIMIT>NL|PL|) (?P<CURRENCY>\$|)?(?P<SB>[.0-9]+)/\$?(?P<BB>[.0-9]+) (?P<GAMETYPE>(Texas Hold\'em|Omaha Hi|Razz)) - (?P<DATETIME>[a-zA-Z]+, [a-zA-Z]+ \d+, \d\d:\d\d:\d\d GMT \d\d\d\d)\nTable (?P<TABLE>[ a-zA-Z0-9]+) \d-max \(Real Money\)\nSeat (?P<BUTTON>[0-9]+)", re.MULTILINE)
|
||||||
|
re_Button = re.compile(ur"^Seat (?P<BUTTON>\d+) is the button", re.MULTILINE)
|
||||||
|
re_PlayerInfo = re.compile("Seat (?P<SEAT>[0-9]+): (?P<PNAME>.*)\s\(\s(\$(?P<CASH>[.0-9]+)) \)")
|
||||||
|
re_Board = re.compile(ur"\[ (?P<CARDS>.+) \]")
|
||||||
|
|
||||||
|
def __init__(self, in_path = '-', out_path = '-', follow = False, autostart=True):
|
||||||
|
"""\
|
||||||
|
in_path (default '-' = sys.stdin)
|
||||||
|
out_path (default '-' = sys.stdout)
|
||||||
|
follow : whether to tail -f the input"""
|
||||||
|
HandHistoryConverter.__init__(self, in_path, out_path, sitename="Betfair", follow=follow) # Call super class init.
|
||||||
|
logging.info("Initialising Betfair converter class")
|
||||||
|
self.filetype = "text"
|
||||||
|
self.codepage = "cp1252"
|
||||||
|
if autostart:
|
||||||
|
self.start()
|
||||||
|
|
||||||
|
|
||||||
|
def compilePlayerRegexs(self, hand):
|
||||||
|
players = set([player[1] for player in hand.players])
|
||||||
|
if not players <= self.compiledPlayers: # x <= y means 'x is subset of y'
|
||||||
|
# we need to recompile the player regexs.
|
||||||
|
self.compiledPlayers = players
|
||||||
|
player_re = "(?P<PNAME>" + "|".join(map(re.escape, players)) + ")"
|
||||||
|
logging.debug("player_re: " + player_re)
|
||||||
|
self.re_PostSB = re.compile("^%s posts small blind \[\$?(?P<SB>[.0-9]+)" % player_re, re.MULTILINE)
|
||||||
|
self.re_PostBB = re.compile("^%s posts big blind \[\$?(?P<BB>[.0-9]+)" % player_re, re.MULTILINE)
|
||||||
|
self.re_Antes = re.compile("^%s antes asdf sadf sadf" % player_re, re.MULTILINE)
|
||||||
|
self.re_BringIn = re.compile("^%s antes asdf sadf sadf" % player_re, re.MULTILINE)
|
||||||
|
self.re_PostBoth = re.compile("^%s posts small \& big blinds \[\$?(?P<SBBB>[.0-9]+)" % player_re, re.MULTILINE)
|
||||||
|
self.re_HeroCards = re.compile("^Dealt to %s \[ (?P<CARDS>.*) \]" % player_re, re.MULTILINE)
|
||||||
|
self.re_Action = re.compile("^%s (?P<ATYPE>bets|checks|raises to|raises|calls|folds)(\s\[\$(?P<BET>[.\d]+)\])?" % player_re, re.MULTILINE)
|
||||||
|
self.re_ShowdownAction = re.compile("^%s shows \[ (?P<CARDS>.*) \]" % player_re, re.MULTILINE)
|
||||||
|
self.re_CollectPot = re.compile("^%s wins \$(?P<POT>[.\d]+) (.*?\[ (?P<CARDS>.*?) \])?" % player_re, re.MULTILINE)
|
||||||
|
self.re_SitsOut = re.compile("^%s sits out" % player_re, re.MULTILINE)
|
||||||
|
self.re_ShownCards = re.compile(r"%s (?P<SEAT>[0-9]+) (?P<CARDS>adsfasdf)" % player_re, re.MULTILINE)
|
||||||
|
|
||||||
|
def readSupportedGames(self):
|
||||||
|
return [["ring", "hold", "nl"]
|
||||||
|
]
|
||||||
|
|
||||||
|
def determineGameType(self, handText):
|
||||||
|
info = {'type':'ring'}
|
||||||
|
|
||||||
|
m = self.re_GameInfo.search(handText)
|
||||||
|
if not m:
|
||||||
|
logging.info('GameInfo regex did not match')
|
||||||
|
return None
|
||||||
|
|
||||||
|
mg = m.groupdict()
|
||||||
|
|
||||||
|
# translations from captured groups to our info strings
|
||||||
|
limits = { 'NL':'nl', 'PL':'pl', 'Limit':'fl' }
|
||||||
|
games = { # base, category
|
||||||
|
"Texas Hold'em" : ('hold','holdem'),
|
||||||
|
'Omaha Hi' : ('hold','omahahi'),
|
||||||
|
'Razz' : ('stud','razz'),
|
||||||
|
'7 Card Stud' : ('stud','studhi')
|
||||||
|
}
|
||||||
|
currencies = { u' €':'EUR', '$':'USD', '':'T$' }
|
||||||
|
if 'LIMIT' in mg:
|
||||||
|
info['limitType'] = limits[mg['LIMIT']]
|
||||||
|
if 'GAME' in mg:
|
||||||
|
(info['base'], info['category']) = games[mg['GAME']]
|
||||||
|
if 'SB' in mg:
|
||||||
|
info['sb'] = mg['SB']
|
||||||
|
if 'BB' in mg:
|
||||||
|
info['bb'] = mg['BB']
|
||||||
|
if 'CURRENCY' in mg:
|
||||||
|
info['currency'] = currencies[mg['CURRENCY']]
|
||||||
|
# NB: SB, BB must be interpreted as blinds or bets depending on limit type.
|
||||||
|
|
||||||
|
return info
|
||||||
|
|
||||||
|
def readHandInfo(self, hand):
|
||||||
|
m = self.re_HandInfo.search(hand.handText)
|
||||||
|
if(m == None):
|
||||||
|
logging.info("Didn't match re_HandInfo")
|
||||||
|
logging.info(hand.handText)
|
||||||
|
return None
|
||||||
|
logging.debug("HID %s, Table %s" % (m.group('HID'), m.group('TABLE')))
|
||||||
|
hand.handid = m.group('HID')
|
||||||
|
hand.tablename = m.group('TABLE')
|
||||||
|
hand.starttime = time.strptime(m.group('DATETIME'), "%A, %B %d, %H:%M:%S GMT %Y")
|
||||||
|
#hand.buttonpos = int(m.group('BUTTON'))
|
||||||
|
|
||||||
|
def readPlayerStacks(self, hand):
|
||||||
|
m = self.re_PlayerInfo.finditer(hand.handText)
|
||||||
|
for a in m:
|
||||||
|
hand.addPlayer(int(a.group('SEAT')), a.group('PNAME'), a.group('CASH'))
|
||||||
|
|
||||||
|
#Shouldn't really dip into the Hand object, but i've no idea how to tell the length of iter m
|
||||||
|
if len(hand.players) < 2:
|
||||||
|
logging.info("readPlayerStacks: Less than 2 players found in a hand")
|
||||||
|
|
||||||
|
def markStreets(self, hand):
|
||||||
|
m = re.search(r"\*\* Dealing down cards \*\*(?P<PREFLOP>.+(?=\*\* Dealing Flop \*\*)|.+)"
|
||||||
|
r"(\*\* Dealing Flop \*\*(?P<FLOP> \[ \S\S, \S\S, \S\S \].+(?=\*\* Dealing Turn \*\*)|.+))?"
|
||||||
|
r"(\*\* Dealing Turn \*\*(?P<TURN> \[ \S\S \].+(?=\*\* Dealing River \*\*)|.+))?"
|
||||||
|
r"(\*\* Dealing River \*\*(?P<RIVER> \[ \S\S \].+))?", hand.handText,re.DOTALL)
|
||||||
|
|
||||||
|
hand.addStreets(m)
|
||||||
|
|
||||||
|
|
||||||
|
def readCommunityCards(self, hand, street): # street has been matched by markStreets, so exists in this hand
|
||||||
|
if street in ('FLOP','TURN','RIVER'): # a list of streets which get dealt community cards (i.e. all but PREFLOP)
|
||||||
|
m = self.re_Board.search(hand.streets[street])
|
||||||
|
hand.setCommunityCards(street, m.group('CARDS').split(', '))
|
||||||
|
|
||||||
|
def readBlinds(self, hand):
|
||||||
|
try:
|
||||||
|
m = self.re_PostSB.search(hand.handText)
|
||||||
|
hand.addBlind(m.group('PNAME'), 'small blind', m.group('SB'))
|
||||||
|
except: # no small blind
|
||||||
|
hand.addBlind(None, None, None)
|
||||||
|
for a in self.re_PostBB.finditer(hand.handText):
|
||||||
|
hand.addBlind(a.group('PNAME'), 'big blind', a.group('BB'))
|
||||||
|
for a in self.re_PostBoth.finditer(hand.handText):
|
||||||
|
hand.addBlind(a.group('PNAME'), 'small & big blinds', a.group('SBBB'))
|
||||||
|
|
||||||
|
def readAntes(self, hand):
|
||||||
|
logging.debug("reading antes")
|
||||||
|
for player in m:
|
||||||
|
logging.debug("hand.addAnte(%s,%s)" %(player.group('PNAME'), player.group('ANTE')))
|
||||||
|
hand.addAnte(player.group('PNAME'), player.group('ANTE'))
|
||||||
|
|
||||||
|
def readBringIn(self, hand):
|
||||||
|
m = self.re_BringIn.search(hand.handText,re.DOTALL)
|
||||||
|
if m:
|
||||||
|
logging.debug("Player bringing in: %s for %s" %(m.group('PNAME'), m.group('BRINGIN')))
|
||||||
|
hand.addBringIn(m.group('PNAME'), m.group('BRINGIN'))
|
||||||
|
else:
|
||||||
|
logging.warning("No bringin found")
|
||||||
|
|
||||||
|
def readButton(self, hand):
|
||||||
|
hand.buttonpos = int(self.re_Button.search(hand.handText).group('BUTTON'))
|
||||||
|
|
||||||
|
def readHeroCards(self, hand):
|
||||||
|
m = self.re_HeroCards.search(hand.handText)
|
||||||
|
if(m == None):
|
||||||
|
#Not involved in hand
|
||||||
|
hand.involved = False
|
||||||
|
else:
|
||||||
|
hand.hero = m.group('PNAME')
|
||||||
|
# "2c, qh" -> set(["2c","qc"])
|
||||||
|
# Also works with Omaha hands.
|
||||||
|
cards = m.group('CARDS')
|
||||||
|
cards = [c.strip() for c in cards.split(',')]
|
||||||
|
hand.addHoleCards(cards, m.group('PNAME'))
|
||||||
|
|
||||||
|
def readStudPlayerCards(self, hand, street):
|
||||||
|
# balh blah blah
|
||||||
|
pass
|
||||||
|
|
||||||
|
def readAction(self, hand, street):
|
||||||
|
m = self.re_Action.finditer(hand.streets[street])
|
||||||
|
for action in m:
|
||||||
|
if action.group('ATYPE') == 'raises to':
|
||||||
|
hand.addRaiseTo( street, action.group('PNAME'), action.group('BET') )
|
||||||
|
# elif action.group('ATYPE') == ' completes it to':
|
||||||
|
# hand.addComplete( street, action.group('PNAME'), action.group('BET') )
|
||||||
|
elif action.group('ATYPE') == 'calls':
|
||||||
|
hand.addCall( street, action.group('PNAME'), action.group('BET') )
|
||||||
|
elif action.group('ATYPE') == 'bets':
|
||||||
|
hand.addBet( street, action.group('PNAME'), action.group('BET') )
|
||||||
|
elif action.group('ATYPE') == 'folds':
|
||||||
|
hand.addFold( street, action.group('PNAME'))
|
||||||
|
elif action.group('ATYPE') == 'checks':
|
||||||
|
hand.addCheck( street, action.group('PNAME'))
|
||||||
|
else:
|
||||||
|
print "DEBUG: unimplemented readAction: '%s' '%s'" %(action.group('PNAME'),action.group('ATYPE'),)
|
||||||
|
|
||||||
|
|
||||||
|
def readShowdownActions(self, hand):
|
||||||
|
for shows in self.re_ShowdownAction.finditer(hand.handText):
|
||||||
|
cards = shows.group('CARDS')
|
||||||
|
cards = cards.split(', ')
|
||||||
|
hand.addShownCards(cards, shows.group('PNAME'))
|
||||||
|
|
||||||
|
def readCollectPot(self,hand):
|
||||||
|
for m in self.re_CollectPot.finditer(hand.handText):
|
||||||
|
hand.addCollectPot(player=m.group('PNAME'),pot=m.group('POT'))
|
||||||
|
|
||||||
|
def readShownCards(self,hand):
|
||||||
|
for m in self.re_ShownCards.finditer(hand.handText):
|
||||||
|
if m.group('CARDS') is not None:
|
||||||
|
cards = m.group('CARDS')
|
||||||
|
cards = cards.split(', ')
|
||||||
|
hand.addShownCards(cards=None, player=m.group('PNAME'), holeandboard=cards)
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
parser = OptionParser()
|
||||||
|
parser.add_option("-i", "--input", dest="ipath", help="parse input hand history", default="regression-test-files/betfair/befair.02.04.txt")
|
||||||
|
parser.add_option("-o", "--output", dest="opath", help="output translation to", default="-")
|
||||||
|
parser.add_option("-f", "--follow", dest="follow", help="follow (tail -f) the input", action="store_true", default=False)
|
||||||
|
parser.add_option("-q", "--quiet",
|
||||||
|
action="store_const", const=logging.CRITICAL, dest="verbosity", default=logging.INFO)
|
||||||
|
parser.add_option("-v", "--verbose",
|
||||||
|
action="store_const", const=logging.INFO, dest="verbosity")
|
||||||
|
parser.add_option("--vv",
|
||||||
|
action="store_const", const=logging.DEBUG, dest="verbosity")
|
||||||
|
|
||||||
|
(options, args) = parser.parse_args()
|
||||||
|
|
||||||
|
LOG_FILENAME = './logging.out'
|
||||||
|
logging.basicConfig(filename=LOG_FILENAME,level=options.verbosity)
|
||||||
|
|
||||||
|
e = Betfair(in_path = options.ipath, out_path = options.opath, follow = options.follow)
|
||||||
|
|
BIN
pyfpdb/Cards0-HMHUD.png
Normal file
After Width: | Height: | Size: 76 KiB |
|
@ -3,7 +3,7 @@
|
||||||
|
|
||||||
Handles HUD configuration files.
|
Handles HUD configuration files.
|
||||||
"""
|
"""
|
||||||
# Copyright 2008, Ray E. Barker
|
# Copyright 2008, 2009, Ray E. Barker
|
||||||
|
|
||||||
#
|
#
|
||||||
# This program is free software; you can redistribute it and/or modify
|
# This program is free software; you can redistribute it and/or modify
|
||||||
|
@ -32,14 +32,39 @@ import shutil
|
||||||
import xml.dom.minidom
|
import xml.dom.minidom
|
||||||
from xml.dom.minidom import Node
|
from xml.dom.minidom import Node
|
||||||
|
|
||||||
|
def fix_tf(x, default = True):
|
||||||
|
# The xml parser doesn't translate "True" to True. Therefore, we never get
|
||||||
|
# True or False from the parser only "True" or "False". So translate the
|
||||||
|
# string to the python boolean representation.
|
||||||
|
if x == "1" or x == 1 or string.lower(x) == "true" or string.lower(x) == "t":
|
||||||
|
return True
|
||||||
|
if x == "0" or x == 0 or string.lower(x) == "false" or string.lower(x) == "f":
|
||||||
|
return False
|
||||||
|
return default
|
||||||
|
|
||||||
class Layout:
|
class Layout:
|
||||||
def __init__(self, max):
|
def __init__(self, node):
|
||||||
self.max = int(max)
|
|
||||||
|
self.max = int( node.getAttribute('max') )
|
||||||
|
if node.hasAttribute('fav_seat'): self.fav_seat = int( node.getAttribute('fav_seat') )
|
||||||
|
self.width = int( node.getAttribute('width') )
|
||||||
|
self.height = int( node.getAttribute('height') )
|
||||||
|
|
||||||
self.location = []
|
self.location = []
|
||||||
for i in range(self.max + 1): self.location.append(None)
|
self.location = map(lambda x: None, range(self.max+1)) # fill array with max seats+1 empty entries
|
||||||
|
|
||||||
|
for location_node in node.getElementsByTagName('location'):
|
||||||
|
if location_node.getAttribute('seat') != "":
|
||||||
|
self.location[int( location_node.getAttribute('seat') )] = (int( location_node.getAttribute('x') ), int( location_node.getAttribute('y')))
|
||||||
|
elif location_node.getAttribute('common') != "":
|
||||||
|
self.common = (int( location_node.getAttribute('x') ), int( location_node.getAttribute('y')))
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
temp = " Layout = %d max, width= %d, height = %d, fav_seat = %d\n" % (self.max, self.width, self.height, self.fav_seat)
|
temp = " Layout = %d max, width= %d, height = %d" % (self.max, self.width, self.height)
|
||||||
|
if hasattr(self, 'fav_seat'): temp = temp + ", fav_seat = %d\n" % self.fav_seat
|
||||||
|
else: temp = temp + "\n"
|
||||||
|
if hasattr(self, "common"):
|
||||||
|
temp = temp + " Common = (%d, %d)\n" % (self.common[0], self.common[1])
|
||||||
temp = temp + " Locations = "
|
temp = temp + " Locations = "
|
||||||
for i in range(1, len(self.location)):
|
for i in range(1, len(self.location)):
|
||||||
temp = temp + "(%d,%d)" % self.location[i]
|
temp = temp + "(%d,%d)" % self.location[i]
|
||||||
|
@ -58,22 +83,15 @@ class Site:
|
||||||
self.hudbgcolor = node.getAttribute("bgcolor")
|
self.hudbgcolor = node.getAttribute("bgcolor")
|
||||||
self.hudfgcolor = node.getAttribute("fgcolor")
|
self.hudfgcolor = node.getAttribute("fgcolor")
|
||||||
self.converter = node.getAttribute("converter")
|
self.converter = node.getAttribute("converter")
|
||||||
self.enabled = node.getAttribute("enabled")
|
|
||||||
self.aux_window = node.getAttribute("aux_window")
|
self.aux_window = node.getAttribute("aux_window")
|
||||||
self.font = node.getAttribute("font")
|
self.font = node.getAttribute("font")
|
||||||
self.font_size = node.getAttribute("font_size")
|
self.font_size = node.getAttribute("font_size")
|
||||||
|
self.use_frames = node.getAttribute("use_frames")
|
||||||
|
self.enabled = fix_tf(node.getAttribute("enabled"), default = True)
|
||||||
self.layout = {}
|
self.layout = {}
|
||||||
|
|
||||||
for layout_node in node.getElementsByTagName('layout'):
|
for layout_node in node.getElementsByTagName('layout'):
|
||||||
max = int( layout_node.getAttribute('max') )
|
lo = Layout(layout_node)
|
||||||
lo = Layout(max)
|
|
||||||
lo.fav_seat = int( layout_node.getAttribute('fav_seat') )
|
|
||||||
lo.width = int( layout_node.getAttribute('width') )
|
|
||||||
lo.height = int( layout_node.getAttribute('height') )
|
|
||||||
|
|
||||||
for location_node in layout_node.getElementsByTagName('location'):
|
|
||||||
lo.location[int( location_node.getAttribute('seat') )] = (int( location_node.getAttribute('x') ), int( location_node.getAttribute('y')))
|
|
||||||
|
|
||||||
self.layout[lo.max] = lo
|
self.layout[lo.max] = lo
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
|
@ -104,7 +122,12 @@ class Game:
|
||||||
self.db = node.getAttribute("db")
|
self.db = node.getAttribute("db")
|
||||||
self.rows = int( node.getAttribute("rows") )
|
self.rows = int( node.getAttribute("rows") )
|
||||||
self.cols = int( node.getAttribute("cols") )
|
self.cols = int( node.getAttribute("cols") )
|
||||||
self.aux = node.getAttribute("aux")
|
|
||||||
|
aux_text = node.getAttribute("aux")
|
||||||
|
aux_list = aux_text.split(',')
|
||||||
|
for i in range(0, len(aux_list)):
|
||||||
|
aux_list[i] = aux_list[i].strip()
|
||||||
|
self.aux = aux_list
|
||||||
|
|
||||||
self.stats = {}
|
self.stats = {}
|
||||||
for stat_node in node.getElementsByTagName('stat'):
|
for stat_node in node.getElementsByTagName('stat'):
|
||||||
|
@ -155,21 +178,23 @@ class Aux_window:
|
||||||
def __init__(self, node):
|
def __init__(self, node):
|
||||||
for (name, value) in node.attributes.items():
|
for (name, value) in node.attributes.items():
|
||||||
setattr(self, name, value)
|
setattr(self, name, value)
|
||||||
# self.name = node.getAttribute("mw_name")
|
|
||||||
# self.cards = node.getAttribute("deck")
|
self.layout = {}
|
||||||
# self.card_wd = node.getAttribute("card_wd")
|
for layout_node in node.getElementsByTagName('layout'):
|
||||||
# self.card_ht = node.getAttribute("card_ht")
|
lo = Layout(layout_node)
|
||||||
# self.rows = node.getAttribute("rows")
|
self.layout[lo.max] = lo
|
||||||
# self.cols = node.getAttribute("cols")
|
|
||||||
# self.format = node.getAttribute("stud")
|
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
temp = 'Aux = ' + self.name + "\n"
|
temp = 'Aux = ' + self.name + "\n"
|
||||||
for key in dir(self):
|
for key in dir(self):
|
||||||
if key.startswith('__'): continue
|
if key.startswith('__'): continue
|
||||||
|
if key == 'layout': continue
|
||||||
value = getattr(self, key)
|
value = getattr(self, key)
|
||||||
if callable(value): continue
|
if callable(value): continue
|
||||||
temp = temp + ' ' + key + " = " + value + "\n"
|
temp = temp + ' ' + key + " = " + value + "\n"
|
||||||
|
|
||||||
|
for layout in self.layout:
|
||||||
|
temp = temp + "%s" % self.layout[layout]
|
||||||
return temp
|
return temp
|
||||||
|
|
||||||
class Popup:
|
class Popup:
|
||||||
|
@ -189,10 +214,13 @@ class Import:
|
||||||
def __init__(self, node):
|
def __init__(self, node):
|
||||||
self.interval = node.getAttribute("interval")
|
self.interval = node.getAttribute("interval")
|
||||||
self.callFpdbHud = node.getAttribute("callFpdbHud")
|
self.callFpdbHud = node.getAttribute("callFpdbHud")
|
||||||
self.hhArchiveBase = node.getAttribute("hhArchiveBase")
|
self.hhArchiveBase = node.getAttribute("hhArchiveBase")
|
||||||
|
self.saveActions = fix_tf(node.getAttribute("saveActions"), True)
|
||||||
|
self.fastStoreHudCache = fix_tf(node.getAttribute("fastStoreHudCache"), False)
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return " interval = %s\n callFpdbHud = %s\n hhArchiveBase = %s" % (self.interval, self.callFpdbHud, self.hhArchiveBase)
|
return " interval = %s\n callFpdbHud = %s\n hhArchiveBase = %s\n saveActions = %s\n fastStoreHudCache = %s\n" \
|
||||||
|
% (self.interval, self.callFpdbHud, self.hhArchiveBase, self.saveActions, self.fastStoreHudCache)
|
||||||
|
|
||||||
class Tv:
|
class Tv:
|
||||||
def __init__(self, node):
|
def __init__(self, node):
|
||||||
|
@ -205,13 +233,14 @@ class Tv:
|
||||||
(self.combinedStealFold, self.combined2B3B, self.combinedPostflop) )
|
(self.combinedStealFold, self.combined2B3B, self.combinedPostflop) )
|
||||||
|
|
||||||
class Config:
|
class Config:
|
||||||
def __init__(self, file = None):
|
def __init__(self, file = None, dbname = 'fpdb'):
|
||||||
|
|
||||||
# "file" is a path to an xml file with the fpdb/HUD configuration
|
# "file" is a path to an xml file with the fpdb/HUD configuration
|
||||||
# we check the existence of "file" and try to recover if it doesn't exist
|
# we check the existence of "file" and try to recover if it doesn't exist
|
||||||
|
self.dbname = dbname
|
||||||
|
|
||||||
self.default_config_path = self.get_default_config_path()
|
self.default_config_path = self.get_default_config_path()
|
||||||
if not file == None: # configuration file path has been passed
|
if file != None: # configuration file path has been passed
|
||||||
if not os.path.exists(file):
|
if not os.path.exists(file):
|
||||||
print "Configuration file %s not found. Using defaults." % (file)
|
print "Configuration file %s not found. Using defaults." % (file)
|
||||||
sys.stderr.write("Configuration file %s not found. Using defaults." % (file))
|
sys.stderr.write("Configuration file %s not found. Using defaults." % (file))
|
||||||
|
@ -222,7 +251,7 @@ class Config:
|
||||||
|
|
||||||
if file == None: # no config file in the normal places
|
if file == None: # no config file in the normal places
|
||||||
file = self.find_example_config() #Look for an example file to edit
|
file = self.find_example_config() #Look for an example file to edit
|
||||||
if not file == None:
|
if file != None:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
if file == None: # that didn't work either, just die
|
if file == None: # that didn't work either, just die
|
||||||
|
@ -283,7 +312,7 @@ class Config:
|
||||||
tv = Tv(node = tv_node)
|
tv = Tv(node = tv_node)
|
||||||
self.tv = tv
|
self.tv = tv
|
||||||
|
|
||||||
db = self.get_db_parameters('fpdb')
|
db = self.get_db_parameters()
|
||||||
if db['db-password'] == 'YOUR MYSQL PASSWORD':
|
if db['db-password'] == 'YOUR MYSQL PASSWORD':
|
||||||
df_file = self.find_default_conf()
|
df_file = self.find_default_conf()
|
||||||
if df_file == None: # this is bad
|
if df_file == None: # this is bad
|
||||||
|
@ -357,6 +386,11 @@ class Config:
|
||||||
if site_node.getAttribute("site_name") == site:
|
if site_node.getAttribute("site_name") == site:
|
||||||
return site_node
|
return site_node
|
||||||
|
|
||||||
|
def get_aux_node(self, aux):
|
||||||
|
for aux_node in self.doc.getElementsByTagName("aw"):
|
||||||
|
if aux_node.getAttribute("name") == aux:
|
||||||
|
return aux_node
|
||||||
|
|
||||||
def get_db_node(self, db_name):
|
def get_db_node(self, db_name):
|
||||||
for db_node in self.doc.getElementsByTagName("database"):
|
for db_node in self.doc.getElementsByTagName("database"):
|
||||||
if db_node.getAttribute("db_name") == db_name:
|
if db_node.getAttribute("db_name") == db_name:
|
||||||
|
@ -371,12 +405,17 @@ class Config:
|
||||||
return layout_node
|
return layout_node
|
||||||
|
|
||||||
def get_location_node(self, layout_node, seat):
|
def get_location_node(self, layout_node, seat):
|
||||||
for location_node in layout_node.getElementsByTagName("location"):
|
if seat == "common":
|
||||||
if int( location_node.getAttribute("seat") ) == int( seat ):
|
for location_node in layout_node.getElementsByTagName("location"):
|
||||||
return location_node
|
if location_node.hasAttribute("common"):
|
||||||
|
return location_node
|
||||||
|
else:
|
||||||
|
for location_node in layout_node.getElementsByTagName("location"):
|
||||||
|
if int( location_node.getAttribute("seat") ) == int( seat ):
|
||||||
|
return location_node
|
||||||
|
|
||||||
def save(self, file = None):
|
def save(self, file = None):
|
||||||
if not file == None:
|
if file != None:
|
||||||
f = open(file, 'w')
|
f = open(file, 'w')
|
||||||
self.doc.writexml(f)
|
self.doc.writexml(f)
|
||||||
f.close()
|
f.close()
|
||||||
|
@ -397,63 +436,92 @@ class Config:
|
||||||
location_node.setAttribute("y", str( locations[i-1][1] ))
|
location_node.setAttribute("y", str( locations[i-1][1] ))
|
||||||
self.supported_sites[site_name].layout[max].location[i] = ( locations[i-1][0], locations[i-1][1] )
|
self.supported_sites[site_name].layout[max].location[i] = ( locations[i-1][0], locations[i-1][1] )
|
||||||
|
|
||||||
def get_db_parameters(self, name = None):
|
def edit_aux_layout(self, aux_name, max, width = None, height = None, locations = None):
|
||||||
if name == None: name = 'fpdb'
|
aux_node = self.get_aux_node(aux_name)
|
||||||
|
layout_node = self.get_layout_node(aux_node, max)
|
||||||
|
if layout_node == None:
|
||||||
|
print "aux node not found"
|
||||||
|
return
|
||||||
|
print "editing locations =", locations
|
||||||
|
for (i, pos) in locations.iteritems():
|
||||||
|
location_node = self.get_location_node(layout_node, i)
|
||||||
|
location_node.setAttribute("x", str( locations[i][0] ))
|
||||||
|
location_node.setAttribute("y", str( locations[i][1] ))
|
||||||
|
if i == "common":
|
||||||
|
self.aux_windows[aux_name].layout[max].common = ( locations[i][0], locations[i][1] )
|
||||||
|
else:
|
||||||
|
self.aux_windows[aux_name].layout[max].location[i] = ( locations[i][0], locations[i][1] )
|
||||||
|
|
||||||
|
def get_db_parameters(self):
|
||||||
db = {}
|
db = {}
|
||||||
try:
|
name = self.dbname
|
||||||
db['db-databaseName'] = name
|
try: db['db-databaseName'] = name
|
||||||
db['db-host'] = self.supported_databases[name].db_ip
|
except: pass
|
||||||
db['db-user'] = self.supported_databases[name].db_user
|
|
||||||
db['db-password'] = self.supported_databases[name].db_pass
|
try: db['db-host'] = self.supported_databases[name].db_ip
|
||||||
db['db-server'] = self.supported_databases[name].db_server
|
except: pass
|
||||||
if string.lower(self.supported_databases[name].db_server) == 'mysql':
|
|
||||||
db['db-backend'] = 2
|
try: db['db-user'] = self.supported_databases[name].db_user
|
||||||
elif string.lower(self.supported_databases[name].db_server) == 'postgresql':
|
except: pass
|
||||||
db['db-backend'] = 3
|
|
||||||
else: db['db-backend'] = None # this is big trouble
|
try: db['db-password'] = self.supported_databases[name].db_pass
|
||||||
except:
|
except: pass
|
||||||
pass
|
|
||||||
|
try: db['db-server'] = self.supported_databases[name].db_server
|
||||||
|
except: pass
|
||||||
|
|
||||||
|
if string.lower(self.supported_databases[name].db_server) == 'mysql':
|
||||||
|
db['db-backend'] = 2
|
||||||
|
elif string.lower(self.supported_databases[name].db_server) == 'postgresql':
|
||||||
|
db['db-backend'] = 3
|
||||||
|
else: db['db-backend'] = None # this is big trouble
|
||||||
return db
|
return db
|
||||||
|
|
||||||
def set_db_parameters(self, db_name = 'fpdb', db_ip = None, db_user = None,
|
def set_db_parameters(self, db_name = 'fpdb', db_ip = None, db_user = None,
|
||||||
db_pass = None, db_server = None, db_type = None):
|
db_pass = None, db_server = None, db_type = None):
|
||||||
db_node = self.get_db_node(db_name)
|
db_node = self.get_db_node(db_name)
|
||||||
if not db_node == None:
|
if db_node != None:
|
||||||
if not db_ip == None: db_node.setAttribute("db_ip", db_ip)
|
if db_ip != None: db_node.setAttribute("db_ip", db_ip)
|
||||||
if not db_user == None: db_node.setAttribute("db_user", db_user)
|
if db_user != None: db_node.setAttribute("db_user", db_user)
|
||||||
if not db_pass == None: db_node.setAttribute("db_pass", db_pass)
|
if db_pass != None: db_node.setAttribute("db_pass", db_pass)
|
||||||
if not db_server == None: db_node.setAttribute("db_server", db_server)
|
if db_server != None: db_node.setAttribute("db_server", db_server)
|
||||||
if not db_type == None: db_node.setAttribute("db_type", db_type)
|
if db_type != None: db_node.setAttribute("db_type", db_type)
|
||||||
if self.supported_databases.has_key(db_name):
|
if self.supported_databases.has_key(db_name):
|
||||||
if not db_ip == None: self.supported_databases[db_name].dp_ip = db_ip
|
if db_ip != None: self.supported_databases[db_name].dp_ip = db_ip
|
||||||
if not db_user == None: self.supported_databases[db_name].dp_user = db_user
|
if db_user != None: self.supported_databases[db_name].dp_user = db_user
|
||||||
if not db_pass == None: self.supported_databases[db_name].dp_pass = db_pass
|
if db_pass != None: self.supported_databases[db_name].dp_pass = db_pass
|
||||||
if not db_server == None: self.supported_databases[db_name].dp_server = db_server
|
if db_server != None: self.supported_databases[db_name].dp_server = db_server
|
||||||
if not db_type == None: self.supported_databases[db_name].dp_type = db_type
|
if db_type != None: self.supported_databases[db_name].dp_type = db_type
|
||||||
return
|
return
|
||||||
|
|
||||||
def get_tv_parameters(self):
|
def get_tv_parameters(self):
|
||||||
tv = {}
|
tv = {}
|
||||||
try:
|
try: tv['combinedStealFold'] = self.tv.combinedStealFold
|
||||||
tv['combinedStealFold'] = self.tv.combinedStealFold
|
except: tv['combinedStealFold'] = True
|
||||||
tv['combined2B3B'] = self.tv.combined2B3B
|
|
||||||
tv['combinedPostflop'] = self.tv.combinedPostflop
|
try: tv['combined2B3B'] = self.tv.combined2B3B
|
||||||
except: # Default tv parameters
|
except: tv['combined2B3B'] = True
|
||||||
tv['combinedStealFold'] = True
|
|
||||||
tv['combined2B3B'] = True
|
try: tv['combinedPostflop'] = self.tv.combinedPostflop
|
||||||
tv['combinedPostflop'] = True
|
except: tv['combinedPostflop'] = True
|
||||||
return tv
|
return tv
|
||||||
|
|
||||||
def get_import_parameters(self):
|
def get_import_parameters(self):
|
||||||
imp = {}
|
imp = {}
|
||||||
try:
|
try: imp['callFpdbHud'] = self.imp.callFpdbHud
|
||||||
imp['callFpdbHud'] = self.imp.callFpdbHud
|
except: imp['callFpdbHud'] = True
|
||||||
imp['interval'] = self.imp.interval
|
|
||||||
imp['hhArchiveBase'] = self.imp.hhArchiveBase
|
try: imp['interval'] = self.imp.interval
|
||||||
except: # Default params
|
except: imp['interval'] = 10
|
||||||
imp['callFpdbHud'] = True
|
|
||||||
imp['interval'] = 10
|
try: imp['hhArchiveBase'] = self.imp.hhArchiveBase
|
||||||
imp['hhArchiveBase'] = "~/.fpdb/HandHistories/"
|
except: imp['hhArchiveBase'] = "~/.fpdb/HandHistories/"
|
||||||
|
|
||||||
|
try: imp['saveActions'] = self.imp.saveActions
|
||||||
|
except: imp['saveActions'] = True
|
||||||
|
|
||||||
|
try: imp['fastStoreHudCache'] = self.imp.fastStoreHudCache
|
||||||
|
except: imp['fastStoreHudCache'] = True
|
||||||
return imp
|
return imp
|
||||||
|
|
||||||
def get_default_paths(self, site = "PokerStars"):
|
def get_default_paths(self, site = "PokerStars"):
|
||||||
|
@ -466,6 +534,9 @@ class Config:
|
||||||
paths['bulkImport-defaultPath'] = "default"
|
paths['bulkImport-defaultPath'] = "default"
|
||||||
return paths
|
return paths
|
||||||
|
|
||||||
|
def get_frames(self, site = "PokerStars"):
|
||||||
|
return self.supported_sites[site].use_frames == True
|
||||||
|
|
||||||
def get_default_colors(self, site = "PokerStars"):
|
def get_default_colors(self, site = "PokerStars"):
|
||||||
colors = {}
|
colors = {}
|
||||||
if self.supported_sites[site].hudopacity == "":
|
if self.supported_sites[site].hudopacity == "":
|
||||||
|
@ -505,14 +576,27 @@ class Config:
|
||||||
( 0, 280), (121, 280), ( 46, 30) )
|
( 0, 280), (121, 280), ( 46, 30) )
|
||||||
return locations
|
return locations
|
||||||
|
|
||||||
def get_supported_sites(self):
|
def get_aux_locations(self, aux = "mucked", max = "9"):
|
||||||
|
|
||||||
|
try:
|
||||||
|
locations = self.aux_windows[aux].layout[max].location
|
||||||
|
except:
|
||||||
|
locations = ( ( 0, 0), (684, 61), (689, 239), (692, 346),
|
||||||
|
(586, 393), (421, 440), (267, 440), ( 0, 361),
|
||||||
|
( 0, 280), (121, 280), ( 46, 30) )
|
||||||
|
return locations
|
||||||
|
|
||||||
|
def get_supported_sites(self, all = False):
|
||||||
"""Returns the list of supported sites."""
|
"""Returns the list of supported sites."""
|
||||||
return self.supported_sites.keys()
|
the_sites = []
|
||||||
|
for site in self.supported_sites.keys():
|
||||||
|
params = self.get_site_parameters(site)
|
||||||
|
if all or params['enabled']:
|
||||||
|
the_sites.append(site)
|
||||||
|
return the_sites
|
||||||
|
|
||||||
def get_site_parameters(self, site):
|
def get_site_parameters(self, site):
|
||||||
"""Returns a dict of the site parameters for the specified site"""
|
"""Returns a dict of the site parameters for the specified site"""
|
||||||
if not self.supported_sites.has_key(site):
|
|
||||||
return None
|
|
||||||
parms = {}
|
parms = {}
|
||||||
parms["converter"] = self.supported_sites[site].converter
|
parms["converter"] = self.supported_sites[site].converter
|
||||||
parms["decoder"] = self.supported_sites[site].decoder
|
parms["decoder"] = self.supported_sites[site].decoder
|
||||||
|
@ -524,10 +608,10 @@ class Config:
|
||||||
parms["table_finder"] = self.supported_sites[site].table_finder
|
parms["table_finder"] = self.supported_sites[site].table_finder
|
||||||
parms["HH_path"] = self.supported_sites[site].HH_path
|
parms["HH_path"] = self.supported_sites[site].HH_path
|
||||||
parms["site_name"] = self.supported_sites[site].site_name
|
parms["site_name"] = self.supported_sites[site].site_name
|
||||||
parms["enabled"] = self.supported_sites[site].enabled
|
|
||||||
parms["aux_window"] = self.supported_sites[site].aux_window
|
parms["aux_window"] = self.supported_sites[site].aux_window
|
||||||
parms["font"] = self.supported_sites[site].font
|
parms["font"] = self.supported_sites[site].font
|
||||||
parms["font_size"] = self.supported_sites[site].font_size
|
parms["font_size"] = self.supported_sites[site].font_size
|
||||||
|
parms["enabled"] = self.supported_sites[site].enabled
|
||||||
return parms
|
return parms
|
||||||
|
|
||||||
def set_site_parameters(self, site_name, converter = None, decoder = None,
|
def set_site_parameters(self, site_name, converter = None, decoder = None,
|
||||||
|
@ -538,31 +622,19 @@ class Config:
|
||||||
font = None, font_size = None):
|
font = None, font_size = None):
|
||||||
"""Sets the specified site parameters for the specified site."""
|
"""Sets the specified site parameters for the specified site."""
|
||||||
site_node = self.get_site_node(site_name)
|
site_node = self.get_site_node(site_name)
|
||||||
if not db_node == None:
|
if db_node != None:
|
||||||
if not converter == None: site_node.setAttribute("converter", converter)
|
if converter != None: site_node.setAttribute("converter", converter)
|
||||||
if not decoder == None: site_node.setAttribute("decoder", decoder)
|
if decoder != None: site_node.setAttribute("decoder", decoder)
|
||||||
if not hudbgcolor == None: site_node.setAttribute("hudbgcolor", hudbgcolor)
|
if hudbgcolor != None: site_node.setAttribute("hudbgcolor", hudbgcolor)
|
||||||
if not hudfgcolor == None: site_node.setAttribute("hudfgcolor", hudfgcolor)
|
if hudfgcolor != None: site_node.setAttribute("hudfgcolor", hudfgcolor)
|
||||||
if not hudopacity == None: site_node.setAttribute("hudopacity", hudopacity)
|
if hudopacity != None: site_node.setAttribute("hudopacity", hudopacity)
|
||||||
if not screen_name == None: site_node.setAttribute("screen_name", screen_name)
|
if screen_name != None: site_node.setAttribute("screen_name", screen_name)
|
||||||
if not site_path == None: site_node.setAttribute("site_path", site_path)
|
if site_path != None: site_node.setAttribute("site_path", site_path)
|
||||||
if not table_finder == None: site_node.setAttribute("table_finder", table_finder)
|
if table_finder != None: site_node.setAttribute("table_finder", table_finder)
|
||||||
if not HH_path == None: site_node.setAttribute("HH_path", HH_path)
|
if HH_path != None: site_node.setAttribute("HH_path", HH_path)
|
||||||
if not enabled == None: site_node.setAttribute("enabled", enabled)
|
if enabled != None: site_node.setAttribute("enabled", enabled)
|
||||||
if not font == None: site_node.setAttribute("font", font)
|
if font != None: site_node.setAttribute("font", font)
|
||||||
if not font_size == None: site_node.setAttribute("font_size", font_size)
|
if font_size != None: site_node.setAttribute("font_size", font_size)
|
||||||
|
|
||||||
# if self.supported_databases.has_key(db_name):
|
|
||||||
# if not converter == None: self.supported_sites[site].converter = converter
|
|
||||||
# if not decoder == None: self.supported_sites[site].decoder = decoder
|
|
||||||
# if not hudbgcolor == None: self.supported_sites[site].hudbgcolor = hudbgcolor
|
|
||||||
# if not hudfgcolor == None: self.supported_sites[site].hudfgcolor = hudfgcolor
|
|
||||||
# if not hudopacity == None: self.supported_sites[site].hudopacity = hudopacity
|
|
||||||
# if not screen_name == None: self.supported_sites[site].screen_name = screen_name
|
|
||||||
# if not site_path == None: self.supported_sites[site].site_path = site_path
|
|
||||||
# if not table_finder == None: self.supported_sites[site].table_finder = table_finder
|
|
||||||
# if not HH_path == None: self.supported_sites[site].HH_path = HH_path
|
|
||||||
# if not enabled == None: self.supported_sites[site].enabled = enabled
|
|
||||||
return
|
return
|
||||||
|
|
||||||
def get_aux_windows(self):
|
def get_aux_windows(self):
|
||||||
|
@ -605,7 +677,7 @@ class Config:
|
||||||
|
|
||||||
def execution_path(self, filename):
|
def execution_path(self, filename):
|
||||||
"""Join the fpdb path to filename."""
|
"""Join the fpdb path to filename."""
|
||||||
return os.path.join(os.path.dirname(inspect.getfile(sys._getframe(1))), filename)
|
return os.path.join(os.path.dirname(inspect.getfile(sys._getframe(0))), filename)
|
||||||
|
|
||||||
if __name__== "__main__":
|
if __name__== "__main__":
|
||||||
c = Config()
|
c = Config()
|
||||||
|
@ -657,6 +729,11 @@ if __name__== "__main__":
|
||||||
for mw in c.get_aux_windows():
|
for mw in c.get_aux_windows():
|
||||||
print c.get_aux_parameters(mw)
|
print c.get_aux_parameters(mw)
|
||||||
|
|
||||||
|
print "mucked locations =", c.get_aux_locations('mucked', 9)
|
||||||
|
# c.edit_aux_layout('mucked', 9, locations = [(487, 113), (555, 469), (572, 276), (522, 345),
|
||||||
|
# (333, 354), (217, 341), (150, 273), (150, 169), (230, 115)])
|
||||||
|
# print "mucked locations =", c.get_aux_locations('mucked', 9)
|
||||||
|
|
||||||
for site in c.supported_sites.keys():
|
for site in c.supported_sites.keys():
|
||||||
print "site = ", site,
|
print "site = ", site,
|
||||||
print c.get_site_parameters(site)
|
print c.get_site_parameters(site)
|
||||||
|
|
|
@ -116,31 +116,53 @@ class Database:
|
||||||
row = c.fetchone()
|
row = c.fetchone()
|
||||||
return row[0]
|
return row[0]
|
||||||
|
|
||||||
# def get_cards(self, hand):
|
|
||||||
# this version is for the PTrackSv2 db
|
|
||||||
# c = self.connection.cursor()
|
|
||||||
# c.execute(self.sql.query['get_cards'], hand)
|
|
||||||
# colnames = [desc[0] for desc in c.description]
|
|
||||||
# cards = {}
|
|
||||||
# for row in c.fetchall():
|
|
||||||
# s_dict = {}
|
|
||||||
# for name, val in zip(colnames, row):
|
|
||||||
# s_dict[name] = val
|
|
||||||
# cards[s_dict['seat_number']] = s_dict
|
|
||||||
# return (cards)
|
|
||||||
|
|
||||||
def get_cards(self, hand):
|
def get_cards(self, hand):
|
||||||
# this version is for the fpdb db
|
"""Get and return the cards for each player in the hand."""
|
||||||
|
cards = {} # dict of cards, the key is the seat number example: {1: 'AcQd9hTs5d'}
|
||||||
c = self.connection.cursor()
|
c = self.connection.cursor()
|
||||||
c.execute(self.sql.query['get_cards'], hand)
|
c.execute(self.sql.query['get_cards'], hand)
|
||||||
colnames = [desc[0] for desc in c.description]
|
colnames = [desc[0] for desc in c.description]
|
||||||
cards = {}
|
|
||||||
for row in c.fetchall():
|
for row in c.fetchall():
|
||||||
s_dict = {}
|
s_dict = {}
|
||||||
for name, val in zip(colnames, row):
|
for name, val in zip(colnames, row):
|
||||||
s_dict[name] = val
|
s_dict[name] = val
|
||||||
cards[s_dict['seat_number']] = s_dict
|
cards[s_dict['seat_number']] = (self.convert_cards(s_dict))
|
||||||
return (cards)
|
return cards
|
||||||
|
|
||||||
|
def get_common_cards(self, hand):
|
||||||
|
"""Get and return the community cards for the specified hand."""
|
||||||
|
cards = {}
|
||||||
|
c = self.connection.cursor()
|
||||||
|
c.execute(self.sql.query['get_common_cards'], hand)
|
||||||
|
colnames = [desc[0] for desc in c.description]
|
||||||
|
for row in c.fetchall():
|
||||||
|
s_dict = {}
|
||||||
|
for name, val in zip(colnames, row):
|
||||||
|
s_dict[name] = val
|
||||||
|
cards['common'] = (self.convert_cards(s_dict))
|
||||||
|
return cards
|
||||||
|
|
||||||
|
def convert_cards(self, d):
|
||||||
|
ranks = ('', '', '2', '3', '4', '5', '6', '7', '8', '9', 'T', 'J', 'Q', 'K', 'A')
|
||||||
|
cards = ""
|
||||||
|
for i in xrange(1, 8):
|
||||||
|
# key = 'card' + str(i) + 'Value'
|
||||||
|
# if not d.has_key(key): continue
|
||||||
|
# if d[key] == None:
|
||||||
|
# break
|
||||||
|
# elif d[key] == 0:
|
||||||
|
# cards += "xx"
|
||||||
|
# else:
|
||||||
|
# cards += ranks[d['card' + str(i) + 'Value']] + d['card' +str(i) + 'Suit']
|
||||||
|
cv = "card%dValue" % i
|
||||||
|
if cv not in d or d[cv] == None:
|
||||||
|
break
|
||||||
|
elif d[cv] == 0:
|
||||||
|
cards += "xx"
|
||||||
|
else:
|
||||||
|
cs = "card%dSuit" % i
|
||||||
|
cards = "%s%s%s" % (cards, ranks[d[cv]], d[cs])
|
||||||
|
return cards
|
||||||
|
|
||||||
def get_action_from_hand(self, hand_no):
|
def get_action_from_hand(self, hand_no):
|
||||||
action = [ [], [], [], [], [] ]
|
action = [ [], [], [], [], [] ]
|
||||||
|
@ -165,19 +187,11 @@ class Database:
|
||||||
c = self.connection.cursor()
|
c = self.connection.cursor()
|
||||||
|
|
||||||
if aggregate:
|
if aggregate:
|
||||||
query = 'get_stats_from_hand'
|
|
||||||
subs = (hand, hand)
|
|
||||||
else:
|
|
||||||
query = 'get_stats_from_hand_aggregated'
|
query = 'get_stats_from_hand_aggregated'
|
||||||
subs = (hand, hand, hand)
|
subs = (hand, hand, hand)
|
||||||
|
else:
|
||||||
# get the players in the hand and their seats
|
query = 'get_stats_from_hand'
|
||||||
c.execute(self.sql.query['get_players_from_hand'], (hand, ))
|
subs = (hand, hand)
|
||||||
names = {}
|
|
||||||
seats = {}
|
|
||||||
for row in c.fetchall():
|
|
||||||
names[row[0]] = row[2]
|
|
||||||
seats[row[0]] = row[1]
|
|
||||||
|
|
||||||
# now get the stats
|
# now get the stats
|
||||||
c.execute(self.sql.query[query], subs)
|
c.execute(self.sql.query[query], subs)
|
||||||
|
@ -187,9 +201,6 @@ class Database:
|
||||||
t_dict = {}
|
t_dict = {}
|
||||||
for name, val in zip(colnames, row):
|
for name, val in zip(colnames, row):
|
||||||
t_dict[name.lower()] = val
|
t_dict[name.lower()] = val
|
||||||
# print t_dict
|
|
||||||
t_dict['screen_name'] = names[t_dict['player_id']]
|
|
||||||
t_dict['seat'] = seats[t_dict['player_id']]
|
|
||||||
stat_dict[t_dict['player_id']] = t_dict
|
stat_dict[t_dict['player_id']] = t_dict
|
||||||
return stat_dict
|
return stat_dict
|
||||||
|
|
||||||
|
@ -225,6 +236,7 @@ if __name__=="__main__":
|
||||||
for p in stat_dict.keys():
|
for p in stat_dict.keys():
|
||||||
print p, " ", stat_dict[p]
|
print p, " ", stat_dict[p]
|
||||||
|
|
||||||
|
print "cards =", db_connection.get_cards(73525)
|
||||||
db_connection.close_connection
|
db_connection.close_connection
|
||||||
|
|
||||||
print "press enter to continue"
|
print "press enter to continue"
|
||||||
|
|
91
pyfpdb/DerivedStats.py
Normal file
|
@ -0,0 +1,91 @@
|
||||||
|
#!/usr/bin/python
|
||||||
|
|
||||||
|
#Copyright 2008 Carl Gherardi
|
||||||
|
#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.
|
||||||
|
|
||||||
|
class DerivedStats():
|
||||||
|
def __init__(self, hand):
|
||||||
|
self.hand = hand
|
||||||
|
|
||||||
|
self.activeSeats = 0
|
||||||
|
self.position = 0
|
||||||
|
self.tourneyTypeId = 0
|
||||||
|
|
||||||
|
self.HDs = 0
|
||||||
|
self.street0VPI = 0
|
||||||
|
self.street0Aggr = 0
|
||||||
|
self.street0_3B4BChance = 0
|
||||||
|
self.street0_3B4BDone = 0
|
||||||
|
|
||||||
|
self.street1Seen = 0
|
||||||
|
self.street2Seen = 0
|
||||||
|
self.street3Seen = 0
|
||||||
|
self.street4Seen = 0
|
||||||
|
self.sawShowdown = 0
|
||||||
|
|
||||||
|
self.street1Aggr = 0
|
||||||
|
self.street2Aggr = 0
|
||||||
|
self.street3Aggr = 0
|
||||||
|
self.street4Aggr = 0
|
||||||
|
|
||||||
|
self.otherRaisedStreet1 = 0
|
||||||
|
self.otherRaisedStreet2 = 0
|
||||||
|
self.otherRaisedStreet3 = 0
|
||||||
|
self.otherRaisedStreet4 = 0
|
||||||
|
self.foldToOtherRaisedStreet1 = 0
|
||||||
|
self.foldToOtherRaisedStreet2 = 0
|
||||||
|
self.foldToOtherRaisedStreet3 = 0
|
||||||
|
self.foldToOtherRaisedStreet4 = 0
|
||||||
|
self.wonWhenSeenStreet1 = 0
|
||||||
|
self.wonAtSD = 0
|
||||||
|
|
||||||
|
self.stealAttemptChance = 0
|
||||||
|
self.stealAttempted = 0
|
||||||
|
self.foldBbToStealChance = 0
|
||||||
|
self.foldedBbToSteal = 0
|
||||||
|
self.foldSbToStealChance = 0
|
||||||
|
self.foldedSbToSteal = 0
|
||||||
|
|
||||||
|
self.street1CBChance = 0
|
||||||
|
self.street1CBDone = 0
|
||||||
|
self.street2CBChance = 0
|
||||||
|
self.street2CBDone = 0
|
||||||
|
self.street3CBChance = 0
|
||||||
|
self.street3CBDone = 0
|
||||||
|
self.street4CBChance = 0
|
||||||
|
self.street4CBDone = 0
|
||||||
|
|
||||||
|
self.foldToStreet1CBChance = 0
|
||||||
|
self.foldToStreet1CBDone = 0
|
||||||
|
self.foldToStreet2CBChance = 0
|
||||||
|
self.foldToStreet2CBDone = 0
|
||||||
|
self.foldToStreet3CBChance = 0
|
||||||
|
self.foldToStreet3CBDone = 0
|
||||||
|
self.foldToStreet4CBChance = 0
|
||||||
|
self.foldToStreet4CBDone = 0
|
||||||
|
|
||||||
|
self.totalProfit = 0
|
||||||
|
|
||||||
|
self.street1CheckCallRaiseChance = 0
|
||||||
|
self.street1CheckCallRaiseDone = 0
|
||||||
|
self.street2CheckCallRaiseChance = 0
|
||||||
|
self.street2CheckCallRaiseDone = 0
|
||||||
|
self.street3CheckCallRaiseChance = 0
|
||||||
|
self.street3CheckCallRaiseDone = 0
|
||||||
|
self.street4CheckCallRaiseChance = 0
|
||||||
|
self.street4CheckCallRaiseDone = 0
|
||||||
|
|
||||||
|
def getStats():
|
||||||
|
pass
|
|
@ -1,4 +1,6 @@
|
||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
#
|
||||||
# Copyright 2008, Carl Gherardi
|
# Copyright 2008, Carl Gherardi
|
||||||
#
|
#
|
||||||
# This program is free software; you can redistribute it and/or modify
|
# This program is free software; you can redistribute it and/or modify
|
||||||
|
@ -17,158 +19,239 @@
|
||||||
########################################################################
|
########################################################################
|
||||||
|
|
||||||
import sys
|
import sys
|
||||||
import Configuration
|
import logging
|
||||||
from HandHistoryConverter import *
|
from HandHistoryConverter import *
|
||||||
|
|
||||||
# Everleaf HH format
|
# Class for converting Everleaf HH format.
|
||||||
|
|
||||||
# Everleaf Gaming Game #55208539
|
|
||||||
# ***** Hand history for game #55208539 *****
|
|
||||||
# Blinds $0.50/$1 NL Hold'em - 2008/09/01 - 13:35:01
|
|
||||||
# Table Speed Kuala
|
|
||||||
# Seat 1 is the button
|
|
||||||
# Total number of players: 9
|
|
||||||
# Seat 1: BadBeatBox ( $ 98.97 USD )
|
|
||||||
# Seat 3: EricBlade ( $ 73.96 USD )
|
|
||||||
# Seat 4: randy888 ( $ 196.50 USD )
|
|
||||||
# Seat 5: BaronSengir ( $ 182.80 USD )
|
|
||||||
# Seat 6: dogge ( $ 186.06 USD )
|
|
||||||
# Seat 7: wings ( $ 50 USD )
|
|
||||||
# Seat 8: schoffeltje ( $ 282.05 USD )
|
|
||||||
# Seat 9: harrydebeng ( $ 109.45 USD )
|
|
||||||
# Seat 10: smaragdar ( $ 96.50 USD )
|
|
||||||
# EricBlade: posts small blind [$ 0.50 USD]
|
|
||||||
# randy888: posts big blind [$ 1 USD]
|
|
||||||
# wings: posts big blind [$ 1 USD]
|
|
||||||
# ** Dealing down cards **
|
|
||||||
# Dealt to EricBlade [ qc, 3c ]
|
|
||||||
# BaronSengir folds
|
|
||||||
# dogge folds
|
|
||||||
# wings raises [$ 2.50 USD]
|
|
||||||
# schoffeltje folds
|
|
||||||
# harrydebeng calls [$ 3.50 USD]
|
|
||||||
# smaragdar raises [$ 15.50 USD]
|
|
||||||
# BadBeatBox folds
|
|
||||||
# EricBlade folds
|
|
||||||
# randy888 folds
|
|
||||||
# wings calls [$ 12 USD]
|
|
||||||
# harrydebeng folds
|
|
||||||
# ** Dealing Flop ** [ qs, 3d, 8h ]
|
|
||||||
# wings: bets [$ 34.50 USD]
|
|
||||||
# smaragdar calls [$ 34.50 USD]
|
|
||||||
# ** Dealing Turn ** [ 2d ]
|
|
||||||
# ** Dealing River ** [ 6c ]
|
|
||||||
# dogge shows [ 9h, 9c ]a pair of nines
|
|
||||||
# spicybum shows [ 5d, 6d ]a straight, eight high
|
|
||||||
# harrydebeng does not show cards
|
|
||||||
# smaragdar wins $ 102 USD from main pot with a pair of aces [ ad, ah, qs, 8h, 6c ]
|
|
||||||
|
|
||||||
class Everleaf(HandHistoryConverter):
|
class Everleaf(HandHistoryConverter):
|
||||||
def __init__(self, config, file):
|
|
||||||
print "Initialising Everleaf converter class"
|
# Static regexes
|
||||||
HandHistoryConverter.__init__(self, config, file, sitename="Everleaf") # Call super class init.
|
re_SplitHands = re.compile(r"(\n\n\n+)")
|
||||||
self.sitename = "Everleaf"
|
re_GameInfo = re.compile(ur"^(Blinds )?(?P<CURRENCY>\$| €|)(?P<SB>[.0-9]+)/(?:\$| €)?(?P<BB>[.0-9]+) (?P<LIMIT>NL|PL|) ?(?P<GAME>(Hold\'em|Omaha|7 Card Stud))", re.MULTILINE)
|
||||||
self.setFileType("text", "cp1252")
|
#re.compile(ur"^(Blinds )?(?P<CURRENCY>\$| €|)(?P<SB>[.0-9]+)/(?:\$| €)?(?P<BB>[.0-9]+) (?P<LIMIT>NL|PL|) (?P<GAME>(Hold\'em|Omaha|7 Card Stud))", re.MULTILINE)
|
||||||
self.rexx.setGameInfoRegex('.*Blinds \$?(?P<SB>[.0-9]+)/\$?(?P<BB>[.0-9]+)')
|
re_HandInfo = re.compile(ur".*#(?P<HID>[0-9]+)\n.*\n(Blinds )?(?:\$| €|)(?P<SB>[.0-9]+)/(?:\$| €|)(?P<BB>[.0-9]+) (?P<GAMETYPE>.*) - (?P<DATETIME>\d\d\d\d/\d\d/\d\d - \d\d:\d\d:\d\d)\nTable (?P<TABLE>.+$)", re.MULTILINE)
|
||||||
self.rexx.setSplitHandRegex('\n\n+')
|
re_Button = re.compile(ur"^Seat (?P<BUTTON>\d+) is the button", re.MULTILINE)
|
||||||
self.rexx.setHandInfoRegex('.*#(?P<HID>[0-9]+)\n.*\nBlinds \$?(?P<SB>[.0-9]+)/\$?(?P<BB>[.0-9]+) (?P<GAMETYPE>.*) - (?P<DATETIME>\d\d\d\d/\d\d/\d\d - \d\d:\d\d:\d\d)\nTable (?P<TABLE>[ a-zA-Z]+)\nSeat (?P<BUTTON>[0-9]+)')
|
re_PlayerInfo = re.compile(ur"^Seat (?P<SEAT>[0-9]+): (?P<PNAME>.*) \(\s+((?:\$| €|) (?P<CASH>[.0-9]+) (USD|EUR|)|new player|All-in) \)", re.MULTILINE)
|
||||||
self.rexx.setPlayerInfoRegex('Seat (?P<SEAT>[0-9]+): (?P<PNAME>.*) \(\s+(\$ (?P<CASH>[.0-9]+) USD|€ (?P<CASH>[.0-9]+) EUR|new player|All-in) \)')
|
re_Board = re.compile(ur"\[ (?P<CARDS>.+) \]")
|
||||||
self.rexx.setPostSbRegex('.*\n(?P<PNAME>.*): posts small blind \[\$? (?P<SB>[.0-9]+)')
|
|
||||||
self.rexx.setPostBbRegex('.*\n(?P<PNAME>.*): posts big blind \[\$? (?P<BB>[.0-9]+)')
|
|
||||||
self.rexx.setPostBothRegex('.*\n(?P<PNAME>.*): posts small \& big blinds \[\$? (?P<SBBB>[.0-9]+)')
|
def __init__(self, in_path = '-', out_path = '-', follow = False, autostart=True, debugging=False):
|
||||||
self.rexx.setHeroCardsRegex('.*\nDealt\sto\s(?P<PNAME>.*)\s\[ (?P<CARDS>.*) \]')
|
"""\
|
||||||
self.rexx.setActionStepRegex('.*\n(?P<PNAME>.*)(?P<ATYPE>: bets| checks| raises| calls| folds)(\s\[\$ (?P<BET>[.\d]+) (USD|EUR)\])?')
|
in_path (default '-' = sys.stdin)
|
||||||
self.rexx.setShowdownActionRegex('.*\n(?P<PNAME>.*) shows \[ (?P<CARDS>.*) \]')
|
out_path (default '-' = sys.stdout)
|
||||||
self.rexx.setCollectPotRegex('.*\n(?P<PNAME>.*) wins \$ (?P<POT>[.\d]+) (USD|EUR)(.*?\[ (?P<CARDS>.*?) \])?')
|
follow : whether to tail -f the input
|
||||||
#self.rexx.setCollectPotRegex('.*\n(?P<PNAME>.*) wins \$ (?P<POT>[.\d]+) USD(.*\[ (?P<CARDS>) \S\S, \S\S, \S\S, \S\S, \S\S \])?')
|
autostart: whether to run the thread (or you can call start() yourself)
|
||||||
self.rexx.sits_out_re = re.compile('(?P<PNAME>.*) sits out')
|
debugging: if False, pass on partially supported game types. If true, have a go and error..."""
|
||||||
self.rexx.compileRegexes()
|
print "DEBUG: XXXXXXXXXXXXXXX"
|
||||||
|
HandHistoryConverter.__init__(self, in_path, out_path, sitename="Everleaf", follow=follow)
|
||||||
|
logging.info("Initialising Everleaf converter class")
|
||||||
|
self.filetype = "text"
|
||||||
|
self.codepage = "cp1252"
|
||||||
|
self.debugging = debugging
|
||||||
|
if autostart:
|
||||||
|
self.start()
|
||||||
|
# otherwise you need to call start yourself.
|
||||||
|
|
||||||
|
def compilePlayerRegexs(self, hand):
|
||||||
|
players = set([player[1] for player in hand.players])
|
||||||
|
if not players <= self.compiledPlayers: # x <= y means 'x is subset of y'
|
||||||
|
# we need to recompile the player regexs.
|
||||||
|
self.compiledPlayers = players
|
||||||
|
player_re = "(?P<PNAME>" + "|".join(map(re.escape, players)) + ")"
|
||||||
|
logging.debug("player_re: "+ player_re)
|
||||||
|
self.re_PostSB = re.compile(ur"^%s: posts small blind \[(?:\$| €|) (?P<SB>[.0-9]+)" % player_re, re.MULTILINE)
|
||||||
|
self.re_PostBB = re.compile(ur"^%s: posts big blind \[(?:\$| €|) (?P<BB>[.0-9]+)" % player_re, re.MULTILINE)
|
||||||
|
self.re_PostBoth = re.compile(ur"^%s: posts both blinds \[(?:\$| €|) (?P<SBBB>[.0-9]+)" % player_re, re.MULTILINE)
|
||||||
|
self.re_Antes = re.compile(ur"^%s: posts ante \[(?:\$| €|) (?P<ANTE>[.0-9]+)" % player_re, re.MULTILINE)
|
||||||
|
self.re_BringIn = re.compile(ur"^%s posts bring-in (?:\$| €|)(?P<BRINGIN>[.0-9]+)\." % player_re, re.MULTILINE)
|
||||||
|
self.re_HeroCards = re.compile(ur"^Dealt to %s \[ (?P<CARDS>.*) \]" % player_re, re.MULTILINE)
|
||||||
|
self.re_Action = re.compile(ur"^%s(?P<ATYPE>: bets| checks| raises| calls| folds)(\s\[(?:\$| €|) (?P<BET>[.\d]+) (USD|EUR|)\])?" % player_re, re.MULTILINE)
|
||||||
|
#self.re_Action = re.compile(ur"^%s(?P<ATYPE>: bets| checks| raises| calls| folds| complete to)(\s\[?(?:\$| €|) ?(?P<BET>\d+\.?\d*)\.?\s?(USD|EUR|)\]?)?" % player_re, re.MULTILINE)
|
||||||
|
self.re_ShowdownAction = re.compile(ur"^%s shows \[ (?P<CARDS>.*) \]" % player_re, re.MULTILINE)
|
||||||
|
self.re_CollectPot = re.compile(ur"^%s wins (?:\$| €|) (?P<POT>[.\d]+) (USD|EUR|chips)(.*?\[ (?P<CARDS>.*?) \])?" % player_re, re.MULTILINE)
|
||||||
|
self.re_SitsOut = re.compile(ur"^%s sits out" % player_re, re.MULTILINE)
|
||||||
|
|
||||||
def readSupportedGames(self):
|
def readSupportedGames(self):
|
||||||
pass
|
return [["ring", "hold", "nl"],
|
||||||
|
["ring", "hold", "pl"],
|
||||||
|
["ring", "hold", "fl"],
|
||||||
|
["ring", "studhi", "fl"],
|
||||||
|
["ring", "omahahi", "pl"]
|
||||||
|
]
|
||||||
|
|
||||||
def determineGameType(self):
|
def determineGameType(self, handText):
|
||||||
# Cheating with this regex, only support nlhe at the moment
|
"""return dict with keys/values:
|
||||||
gametype = ["ring", "hold", "nl"]
|
'type' in ('ring', 'tour')
|
||||||
|
'limitType' in ('nl', 'cn', 'pl', 'cp', 'fl')
|
||||||
|
'base' in ('hold', 'stud', 'draw')
|
||||||
|
'category' in ('holdem', 'omahahi', omahahilo', 'razz', 'studhi', 'studhilo', 'fivedraw', '27_1draw', '27_3draw', 'badugi')
|
||||||
|
'hilo' in ('h','l','s')
|
||||||
|
'smallBlind' int?
|
||||||
|
'bigBlind' int?
|
||||||
|
'smallBet'
|
||||||
|
'bigBet'
|
||||||
|
'currency' in ('USD', 'EUR', 'T$', <countrycode>)
|
||||||
|
or None if we fail to get the info """
|
||||||
|
#(TODO: which parts are optional/required?)
|
||||||
|
|
||||||
m = self.rexx.game_info_re.search(self.obs)
|
# Blinds $0.50/$1 PL Omaha - 2008/12/07 - 21:59:48
|
||||||
gametype = gametype + [m.group('SB')]
|
# Blinds $0.05/$0.10 NL Hold'em - 2009/02/21 - 11:21:57
|
||||||
gametype = gametype + [m.group('BB')]
|
# $0.25/$0.50 7 Card Stud - 2008/12/05 - 21:43:59
|
||||||
|
|
||||||
|
# Tourney:
|
||||||
|
# Everleaf Gaming Game #75065769
|
||||||
|
# ***** Hand history for game #75065769 *****
|
||||||
|
# Blinds 10/20 NL Hold'em - 2009/02/25 - 17:30:32
|
||||||
|
# Table 2
|
||||||
|
info = {'type':'ring'}
|
||||||
|
|
||||||
|
m = self.re_GameInfo.search(handText)
|
||||||
|
if not m:
|
||||||
|
return None
|
||||||
|
|
||||||
|
mg = m.groupdict()
|
||||||
|
|
||||||
|
# translations from captured groups to our info strings
|
||||||
|
limits = { 'NL':'nl', 'PL':'pl', '':'fl' }
|
||||||
|
games = { # base, category
|
||||||
|
"Hold'em" : ('hold','holdem'),
|
||||||
|
'Omaha' : ('hold','omahahi'),
|
||||||
|
'Razz' : ('stud','razz'),
|
||||||
|
'7 Card Stud' : ('stud','studhi')
|
||||||
|
}
|
||||||
|
currencies = { u' €':'EUR', '$':'USD', '':'T$' }
|
||||||
|
if 'LIMIT' in mg:
|
||||||
|
info['limitType'] = limits[mg['LIMIT']]
|
||||||
|
if 'GAME' in mg:
|
||||||
|
(info['base'], info['category']) = games[mg['GAME']]
|
||||||
|
if 'SB' in mg:
|
||||||
|
info['sb'] = mg['SB']
|
||||||
|
if 'BB' in mg:
|
||||||
|
info['bb'] = mg['BB']
|
||||||
|
if 'CURRENCY' in mg:
|
||||||
|
info['currency'] = currencies[mg['CURRENCY']]
|
||||||
|
if info['currency'] == 'T$':
|
||||||
|
info['type'] = 'tour'
|
||||||
|
# NB: SB, BB must be interpreted as blinds or bets depending on limit type.
|
||||||
|
|
||||||
|
return info
|
||||||
|
|
||||||
return gametype
|
|
||||||
|
|
||||||
def readHandInfo(self, hand):
|
def readHandInfo(self, hand):
|
||||||
m = self.rexx.hand_info_re.search(hand.string)
|
m = self.re_HandInfo.search(hand.handText)
|
||||||
hand.handid = m.group('HID')
|
if(m == None):
|
||||||
|
logging.info("Didn't match re_HandInfo")
|
||||||
|
logging.info(hand.handText)
|
||||||
|
return None
|
||||||
|
logging.debug("HID %s, Table %s" % (m.group('HID'), m.group('TABLE')))
|
||||||
|
hand.handid = m.group('HID')
|
||||||
hand.tablename = m.group('TABLE')
|
hand.tablename = m.group('TABLE')
|
||||||
# These work, but the info is already in the Hand class - should be used for tourneys though.
|
hand.maxseats = 6 # assume 6-max unless we have proof it's a larger/smaller game, since everleaf doesn't give seat max info
|
||||||
# m.group('SB')
|
|
||||||
# m.group('BB')
|
|
||||||
# m.group('GAMETYPE')
|
|
||||||
|
|
||||||
# Believe Everleaf time is GMT/UTC, no transation necessary
|
# Believe Everleaf time is GMT/UTC, no transation necessary
|
||||||
# Stars format (Nov 10 2008): 2008/11/07 12:38:49 CET [2008/11/07 7:38:49 ET]
|
# Stars format (Nov 10 2008): 2008/11/07 12:38:49 CET [2008/11/07 7:38:49 ET]
|
||||||
# or : 2008/11/07 12:38:49 ET
|
# or : 2008/11/07 12:38:49 ET
|
||||||
# Not getting it in my HH files yet, so using
|
# Not getting it in my HH files yet, so using
|
||||||
# 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 = time.strptime(m.group('DATETIME'), "%Y/%m/%d - %H:%M:%S")
|
||||||
hand.buttonpos = int(m.group('BUTTON'))
|
return
|
||||||
|
|
||||||
def readPlayerStacks(self, hand):
|
def readPlayerStacks(self, hand):
|
||||||
m = self.rexx.player_info_re.finditer(hand.string)
|
m = self.re_PlayerInfo.finditer(hand.handText)
|
||||||
players = []
|
|
||||||
for a in m:
|
for a in m:
|
||||||
hand.addPlayer(int(a.group('SEAT')), a.group('PNAME'), a.group('CASH'))
|
seatnum = int(a.group('SEAT'))
|
||||||
|
hand.addPlayer(seatnum, a.group('PNAME'), a.group('CASH'))
|
||||||
|
if seatnum > 6:
|
||||||
|
hand.maxseats = 10 # everleaf currently does 2/6/10 games, so if seats > 6 are in use, it must be 10-max.
|
||||||
|
# TODO: implement lookup list by table-name to determine maxes, then fall back to 6 default/10 here, if there's no entry in the list?
|
||||||
|
|
||||||
|
|
||||||
def markStreets(self, hand):
|
def markStreets(self, hand):
|
||||||
# PREFLOP = ** Dealing down cards **
|
# PREFLOP = ** Dealing down cards **
|
||||||
# This re fails if, say, river is missing; then we don't get the ** that starts the river.
|
# This re fails if, say, river is missing; then we don't get the ** that starts the river.
|
||||||
#m = re.search('(\*\* Dealing down cards \*\*\n)(?P<PREFLOP>.*?\n\*\*)?( Dealing Flop \*\* \[ (?P<FLOP1>\S\S), (?P<FLOP2>\S\S), (?P<FLOP3>\S\S) \])?(?P<FLOP>.*?\*\*)?( Dealing Turn \*\* \[ (?P<TURN1>\S\S) \])?(?P<TURN>.*?\*\*)?( Dealing River \*\* \[ (?P<RIVER1>\S\S) \])?(?P<RIVER>.*)', hand.string,re.DOTALL)
|
#m = re.search('(\*\* Dealing down cards \*\*\n)(?P<PREFLOP>.*?\n\*\*)?( Dealing Flop \*\* \[ (?P<FLOP1>\S\S), (?P<FLOP2>\S\S), (?P<FLOP3>\S\S) \])?(?P<FLOP>.*?\*\*)?( Dealing Turn \*\* \[ (?P<TURN1>\S\S) \])?(?P<TURN>.*?\*\*)?( Dealing River \*\* \[ (?P<RIVER1>\S\S) \])?(?P<RIVER>.*)', hand.handText,re.DOTALL)
|
||||||
|
if hand.gametype['base'] == 'hold':
|
||||||
m = re.search(r"\*\* Dealing down cards \*\*(?P<PREFLOP>.+(?=\*\* Dealing Flop \*\*)|.+)"
|
m = re.search(r"\*\* Dealing down cards \*\*(?P<PREFLOP>.+(?=\*\* Dealing Flop \*\*)|.+)"
|
||||||
r"(\*\* Dealing Flop \*\*(?P<FLOP> \[ \S\S, \S\S, \S\S \].+(?=\*\* Dealing Turn \*\*)|.+))?"
|
r"(\*\* Dealing Flop \*\*(?P<FLOP> \[ \S\S, \S\S, \S\S \].+(?=\*\* Dealing Turn \*\*)|.+))?"
|
||||||
r"(\*\* Dealing Turn \*\*(?P<TURN> \[ \S\S \].+(?=\*\* Dealing River \*\*)|.+))?"
|
r"(\*\* Dealing Turn \*\*(?P<TURN> \[ \S\S \].+(?=\*\* Dealing River \*\*)|.+))?"
|
||||||
r"(\*\* Dealing River \*\*(?P<RIVER> \[ \S\S \].+))?", hand.string,re.DOTALL)
|
r"(\*\* Dealing River \*\*(?P<RIVER> \[ \S\S \].+))?", hand.handText,re.DOTALL)
|
||||||
|
elif hand.gametype['base'] == 'stud':
|
||||||
|
m = re.search(r"(?P<ANTES>.+(?=\*\* Dealing down cards \*\*)|.+)"
|
||||||
|
r"(\*\* Dealing down cards \*\*(?P<THIRD>.+(?=\*\*\*\* dealing 4th street \*\*\*\*)|.+))?"
|
||||||
|
r"(\*\*\*\* dealing 4th street \*\*\*\*(?P<FOURTH>.+(?=\*\*\*\* dealing 5th street \*\*\*\*)|.+))?"
|
||||||
|
r"(\*\*\*\* dealing 5th street \*\*\*\*(?P<FIFTH>.+(?=\*\*\*\* dealing 6th street \*\*\*\*)|.+))?"
|
||||||
|
r"(\*\*\*\* dealing 6th street \*\*\*\*(?P<SIXTH>.+(?=\*\*\*\* dealing river \*\*\*\*)|.+))?"
|
||||||
|
r"(\*\*\*\* dealing river \*\*\*\*(?P<SEVENTH>.+))?", hand.handText,re.DOTALL)
|
||||||
hand.addStreets(m)
|
hand.addStreets(m)
|
||||||
|
|
||||||
|
|
||||||
def readCommunityCards(self, hand, street): # street has been matched by markStreets, so exists in this hand
|
def readCommunityCards(self, hand, street): # street has been matched by markStreets, so exists in this hand
|
||||||
self.rexx.board_re = re.compile(r"\[ (?P<CARDS>.+) \]")
|
# If this has been called, street is a street which gets dealt community cards by type hand
|
||||||
print hand.streets.group(street)
|
# but it might be worth checking somehow.
|
||||||
if street in ('FLOP','TURN','RIVER'): # a list of streets which get dealt community cards (i.e. all but PREFLOP)
|
# if street in ('FLOP','TURN','RIVER'): # a list of streets which get dealt community cards (i.e. all but PREFLOP)
|
||||||
m = self.rexx.board_re.search(hand.streets.group(street))
|
logging.debug("readCommunityCards (%s)" % street)
|
||||||
hand.setCommunityCards(street, m.group('CARDS').split(', '))
|
m = self.re_Board.search(hand.streets[street])
|
||||||
|
cards = m.group('CARDS')
|
||||||
|
cards = [card.strip() for card in cards.split(',')]
|
||||||
|
hand.setCommunityCards(street=street, cards=cards)
|
||||||
|
|
||||||
|
def readAntes(self, hand):
|
||||||
|
logging.debug("reading antes")
|
||||||
|
m = self.re_Antes.finditer(hand.handText)
|
||||||
|
for player in m:
|
||||||
|
logging.debug("hand.addAnte(%s,%s)" %(player.group('PNAME'), player.group('ANTE')))
|
||||||
|
hand.addAnte(player.group('PNAME'), player.group('ANTE'))
|
||||||
|
|
||||||
|
def readBringIn(self, hand):
|
||||||
|
m = self.re_BringIn.search(hand.handText,re.DOTALL)
|
||||||
|
if m:
|
||||||
|
logging.debug("Player bringing in: %s for %s" %(m.group('PNAME'), m.group('BRINGIN')))
|
||||||
|
hand.addBringIn(m.group('PNAME'), m.group('BRINGIN'))
|
||||||
|
else:
|
||||||
|
logging.warning("No bringin found.")
|
||||||
|
|
||||||
def readBlinds(self, hand):
|
def readBlinds(self, hand):
|
||||||
try:
|
m = self.re_PostSB.search(hand.handText)
|
||||||
m = self.rexx.small_blind_re.search(hand.string)
|
if m is not None:
|
||||||
hand.addBlind(m.group('PNAME'), 'small blind', m.group('SB'))
|
hand.addBlind(m.group('PNAME'), 'small blind', m.group('SB'))
|
||||||
except: # no small blind
|
else:
|
||||||
|
logging.debug("No small blind")
|
||||||
hand.addBlind(None, None, None)
|
hand.addBlind(None, None, None)
|
||||||
for a in self.rexx.big_blind_re.finditer(hand.string):
|
for a in self.re_PostBB.finditer(hand.handText):
|
||||||
hand.addBlind(a.group('PNAME'), 'big blind', a.group('BB'))
|
hand.addBlind(a.group('PNAME'), 'big blind', a.group('BB'))
|
||||||
for a in self.rexx.both_blinds_re.finditer(hand.string):
|
for a in self.re_PostBoth.finditer(hand.handText):
|
||||||
hand.addBlind(a.group('PNAME'), 'small & big blinds', a.group('SBBB'))
|
hand.addBlind(a.group('PNAME'), 'both', a.group('SBBB'))
|
||||||
|
|
||||||
|
def readButton(self, hand):
|
||||||
|
hand.buttonpos = int(self.re_Button.search(hand.handText).group('BUTTON'))
|
||||||
|
|
||||||
def readHeroCards(self, hand):
|
def readHeroCards(self, hand):
|
||||||
m = self.rexx.hero_cards_re.search(hand.string)
|
m = self.re_HeroCards.search(hand.handText)
|
||||||
if(m == None):
|
if m:
|
||||||
#Not involved in hand
|
|
||||||
hand.involved = False
|
|
||||||
else:
|
|
||||||
hand.hero = m.group('PNAME')
|
hand.hero = m.group('PNAME')
|
||||||
# "2c, qh" -> set(["2c","qc"])
|
# "2c, qh" -> ["2c","qc"]
|
||||||
# Also works with Omaha hands.
|
# Also works with Omaha hands.
|
||||||
cards = m.group('CARDS')
|
cards = m.group('CARDS')
|
||||||
cards = set(cards.split(', '))
|
cards = [card.strip() for card in cards.split(',')]
|
||||||
hand.addHoleCards(cards, m.group('PNAME'))
|
hand.addHoleCards(cards, m.group('PNAME'))
|
||||||
|
else:
|
||||||
|
#Not involved in hand
|
||||||
|
hand.involved = False
|
||||||
|
|
||||||
|
def readStudPlayerCards(self, hand, street):
|
||||||
|
# lol. see Plymouth.txt
|
||||||
|
logging.warning("Everleaf readStudPlayerCards is only a stub.")
|
||||||
|
#~ if street in ('THIRD', 'FOURTH', 'FIFTH', 'SIXTH'):
|
||||||
|
#~ hand.addPlayerCards(player = player.group('PNAME'), street = street, closed = [], open = [])
|
||||||
|
|
||||||
|
|
||||||
def readAction(self, hand, street):
|
def readAction(self, hand, street):
|
||||||
m = self.rexx.action_re.finditer(hand.streets.group(street))
|
logging.debug("readAction (%s)" % street)
|
||||||
|
m = self.re_Action.finditer(hand.streets[street])
|
||||||
for action in m:
|
for action in m:
|
||||||
|
logging.debug("%s %s" % (action.group('ATYPE'), action.groupdict()))
|
||||||
if action.group('ATYPE') == ' raises':
|
if action.group('ATYPE') == ' raises':
|
||||||
hand.addCallandRaise( street, action.group('PNAME'), action.group('BET') )
|
hand.addCallandRaise( street, action.group('PNAME'), action.group('BET') )
|
||||||
elif action.group('ATYPE') == ' calls':
|
elif action.group('ATYPE') == ' calls':
|
||||||
|
@ -179,35 +262,54 @@ class Everleaf(HandHistoryConverter):
|
||||||
hand.addFold( street, action.group('PNAME'))
|
hand.addFold( street, action.group('PNAME'))
|
||||||
elif action.group('ATYPE') == ' checks':
|
elif action.group('ATYPE') == ' checks':
|
||||||
hand.addCheck( street, action.group('PNAME'))
|
hand.addCheck( street, action.group('PNAME'))
|
||||||
|
elif action.group('ATYPE') == ' complete to':
|
||||||
|
hand.addComplete( street, action.group('PNAME'), action.group('BET'))
|
||||||
else:
|
else:
|
||||||
print "DEBUG: unimplemented readAction: %s %s" %(action.group('PNAME'),action.group('ATYPE'),)
|
logging.debug("Unimplemented readAction: %s %s" %(action.group('PNAME'),action.group('ATYPE'),))
|
||||||
|
|
||||||
|
|
||||||
def readShowdownActions(self, hand):
|
def readShowdownActions(self, hand):
|
||||||
for shows in self.rexx.showdown_action_re.finditer(hand.string):
|
"""Reads lines where holecards are reported in a showdown"""
|
||||||
|
logging.debug("readShowdownActions")
|
||||||
|
for shows in self.re_ShowdownAction.finditer(hand.handText):
|
||||||
cards = shows.group('CARDS')
|
cards = shows.group('CARDS')
|
||||||
cards = set(cards.split(', '))
|
cards = cards.split(', ')
|
||||||
|
logging.debug("readShowdownActions %s %s" %(cards, shows.group('PNAME')))
|
||||||
hand.addShownCards(cards, shows.group('PNAME'))
|
hand.addShownCards(cards, shows.group('PNAME'))
|
||||||
|
|
||||||
|
|
||||||
def readCollectPot(self,hand):
|
def readCollectPot(self,hand):
|
||||||
for m in self.rexx.collect_pot_re.finditer(hand.string):
|
for m in self.re_CollectPot.finditer(hand.handText):
|
||||||
hand.addCollectPot(player=m.group('PNAME'),pot=m.group('POT'))
|
hand.addCollectPot(player=m.group('PNAME'),pot=m.group('POT'))
|
||||||
|
|
||||||
def readShownCards(self,hand):
|
def readShownCards(self,hand):
|
||||||
for m in self.rexx.collect_pot_re.finditer(hand.string):
|
"""Reads lines where hole & board cards are mixed to form a hand (summary lines)"""
|
||||||
|
for m in self.re_CollectPot.finditer(hand.handText):
|
||||||
if m.group('CARDS') is not None:
|
if m.group('CARDS') is not None:
|
||||||
cards = m.group('CARDS')
|
cards = m.group('CARDS')
|
||||||
cards = set(cards.split(', '))
|
cards = cards.split(', ')
|
||||||
|
player = m.group('PNAME')
|
||||||
|
logging.debug("readShownCards %s cards=%s" % (player, cards))
|
||||||
hand.addShownCards(cards=None, player=m.group('PNAME'), holeandboard=cards)
|
hand.addShownCards(cards=None, player=m.group('PNAME'), holeandboard=cards)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
c = Configuration.Config()
|
parser = OptionParser()
|
||||||
if len(sys.argv) == 1:
|
parser.add_option("-i", "--input", dest="ipath", help="parse input hand history", default="-")
|
||||||
testfile = "regression-test-files/everleaf/Speed_Kuala_full.txt"
|
parser.add_option("-o", "--output", dest="opath", help="output translation to", default="-")
|
||||||
else:
|
parser.add_option("-f", "--follow", dest="follow", help="follow (tail -f) the input", action="store_true", default=False)
|
||||||
testfile = sys.argv[1]
|
parser.add_option("-q", "--quiet",
|
||||||
e = Everleaf(c, testfile)
|
action="store_const", const=logging.CRITICAL, dest="verbosity", default=logging.INFO)
|
||||||
e.processFile()
|
parser.add_option("-v", "--verbose",
|
||||||
print str(e)
|
action="store_const", const=logging.INFO, dest="verbosity")
|
||||||
|
parser.add_option("--vv",
|
||||||
|
action="store_const", const=logging.DEBUG, dest="verbosity")
|
||||||
|
|
||||||
|
(options, args) = parser.parse_args()
|
||||||
|
|
||||||
|
LOG_FILENAME = './logging.out'
|
||||||
|
logging.basicConfig(filename=LOG_FILENAME,level=options.verbosity)
|
||||||
|
|
||||||
|
e = Everleaf(in_path = options.ipath, out_path = options.opath, follow = options.follow, autostart=True, debugging=True)
|
||||||
|
|
||||||
|
|
1
pyfpdb/Exceptions.py
Normal file
|
@ -0,0 +1 @@
|
||||||
|
class FpdbParseError(Exception): pass
|
|
@ -599,37 +599,6 @@ class FpdbSQLQueries:
|
||||||
################################
|
################################
|
||||||
|
|
||||||
|
|
||||||
# Returns all cash game handIds and the money won(winnings is the final pot)
|
|
||||||
# by the playerId for a single site.
|
|
||||||
if(self.dbname == 'MySQL InnoDB') or (self.dbname == 'PostgreSQL'):
|
|
||||||
self.query['getRingWinningsAllGamesPlayerIdSite'] = """SELECT handId, winnings FROM HandsPlayers
|
|
||||||
INNER JOIN Players ON HandsPlayers.playerId = Players.id
|
|
||||||
INNER JOIN Hands ON Hands.id = HandsPlayers.handId
|
|
||||||
WHERE Players.name = %s AND Players.siteId = %s AND (tourneysPlayersId IS NULL)
|
|
||||||
ORDER BY handStart"""
|
|
||||||
elif(self.dbname == 'SQLite'):
|
|
||||||
#Probably doesn't work.
|
|
||||||
self.query['getRingWinningsAllGamesPlayerIdSite'] = """SELECT handId, winnings FROM HandsPlayers
|
|
||||||
INNER JOIN Players ON HandsPlayers.playerId = Players.id
|
|
||||||
INNER JOIN Hands ON Hands.id = HandsPlayers.handId
|
|
||||||
WHERE Players.name = %s AND Players.siteId = %s AND (tourneysPlayersId IS NULL)
|
|
||||||
ORDER BY handStart"""
|
|
||||||
|
|
||||||
# Returns the profit for a given ring game handId, Total pot - money invested by playerId
|
|
||||||
if(self.dbname == 'MySQL InnoDB') or (self.dbname == 'PostgreSQL'):
|
|
||||||
self.query['getRingProfitFromHandId'] = """SELECT SUM(amount) FROM HandsActions
|
|
||||||
INNER JOIN HandsPlayers ON HandsActions.handPlayerId = HandsPlayers.id
|
|
||||||
INNER JOIN Players ON HandsPlayers.playerId = Players.id
|
|
||||||
WHERE Players.name = %s AND HandsPlayers.handId = %s
|
|
||||||
AND Players.siteId = %s AND (tourneysPlayersId IS NULL)"""
|
|
||||||
elif(self.dbname == 'SQLite'):
|
|
||||||
#Probably doesn't work.
|
|
||||||
self.query['getRingProfitFromHandId'] = """SELECT SUM(amount) FROM HandsActions
|
|
||||||
INNER JOIN HandsPlayers ON HandsActions.handPlayerId = HandsPlayers.id
|
|
||||||
INNER JOIN Players ON HandsPlayers.playerId = Players.id
|
|
||||||
WHERE Players.name = %s AND HandsPlayers.handId = %s
|
|
||||||
AND Players.siteId = %s AND (tourneysPlayersId IS NULL)"""
|
|
||||||
|
|
||||||
if(self.dbname == 'MySQL InnoDB') or (self.dbname == 'PostgreSQL'):
|
if(self.dbname == 'MySQL InnoDB') or (self.dbname == 'PostgreSQL'):
|
||||||
self.query['getPlayerId'] = """SELECT id from Players where name = %s"""
|
self.query['getPlayerId'] = """SELECT id from Players where name = %s"""
|
||||||
elif(self.dbname == 'SQLite'):
|
elif(self.dbname == 'SQLite'):
|
||||||
|
@ -1054,6 +1023,137 @@ class FpdbSQLQueries:
|
||||||
elif(self.dbname == 'SQLite'):
|
elif(self.dbname == 'SQLite'):
|
||||||
self.query['playerStatsByPosition'] = """ """
|
self.query['playerStatsByPosition'] = """ """
|
||||||
|
|
||||||
|
if(self.dbname == 'MySQL InnoDB'):
|
||||||
|
self.query['playerStatsByPositionAndHoleCards'] = """
|
||||||
|
SELECT
|
||||||
|
concat(upper(stats.limitType), ' '
|
||||||
|
,concat(upper(substring(stats.category,1,1)),substring(stats.category,2) ), ' '
|
||||||
|
,stats.name, ' $'
|
||||||
|
,cast(trim(leading ' ' from
|
||||||
|
case when stats.bigBlind < 100 then format(stats.bigBlind/100.0,2)
|
||||||
|
else format(stats.bigBlind/100.0,0)
|
||||||
|
end ) as char)
|
||||||
|
) AS Game
|
||||||
|
,case when stats.PlPosition = -2 then 'BB'
|
||||||
|
when stats.PlPosition = -1 then 'SB'
|
||||||
|
when stats.PlPosition = 0 then 'Btn'
|
||||||
|
when stats.PlPosition = 1 then 'CO'
|
||||||
|
when stats.PlPosition = 2 then 'MP'
|
||||||
|
when stats.PlPosition = 5 then 'EP'
|
||||||
|
else '??'
|
||||||
|
end AS PlPosition
|
||||||
|
/*,stats.n*/,hprof2.n
|
||||||
|
/*,stats.vpip*/,0
|
||||||
|
/*,stats.pfr*/,0
|
||||||
|
/*,stats.saw_f*/,0
|
||||||
|
/*,stats.sawsd*/,0
|
||||||
|
/*,stats.wtsdwsf*/,0
|
||||||
|
/*,stats.wmsd*/,0
|
||||||
|
/*,stats.FlAFq*/,0
|
||||||
|
/*,stats.TuAFq*/,0
|
||||||
|
/*,stats.RvAFq*/,0
|
||||||
|
/*,stats.PoFAFq*/,0
|
||||||
|
/* if you have handsactions data the next 3 fields should give same answer as
|
||||||
|
following 3 commented out fields */
|
||||||
|
/*,stats.Net
|
||||||
|
,stats.BBper100
|
||||||
|
,stats.Profitperhand*/
|
||||||
|
,format(hprof2.sum_profit/100.0,2) AS Net
|
||||||
|
/*,format((hprof2.sum_profit/(stats.bigBlind+0.0)) / (stats.n/100.0),2)*/,0
|
||||||
|
AS BBlPer100
|
||||||
|
,hprof2.profitperhand AS Profitperhand
|
||||||
|
,format(hprof2.variance,2) AS Variance
|
||||||
|
FROM
|
||||||
|
(select /* stats from hudcache */
|
||||||
|
gt.base
|
||||||
|
,gt.category
|
||||||
|
,upper(gt.limitType) as limitType
|
||||||
|
,s.name
|
||||||
|
,gt.bigBlind
|
||||||
|
,hc.gametypeId
|
||||||
|
,case when hc.position = 'B' then -2
|
||||||
|
when hc.position = 'S' then -1
|
||||||
|
when hc.position = 'D' then 0
|
||||||
|
when hc.position = 'C' then 1
|
||||||
|
when hc.position = 'M' then 2
|
||||||
|
when hc.position = 'E' then 5
|
||||||
|
else 9
|
||||||
|
end as PlPosition
|
||||||
|
,sum(HDs) AS n
|
||||||
|
,format(100.0*sum(street0VPI)/sum(HDs),1) AS vpip
|
||||||
|
,format(100.0*sum(street0Aggr)/sum(HDs),1) AS pfr
|
||||||
|
,format(100.0*sum(street1Seen)/sum(HDs),1) AS saw_f
|
||||||
|
,format(100.0*sum(sawShowdown)/sum(HDs),1) AS sawsd
|
||||||
|
,case when sum(street1Seen) = 0 then 'oo'
|
||||||
|
else format(100.0*sum(sawShowdown)/sum(street1Seen),1)
|
||||||
|
end AS wtsdwsf
|
||||||
|
,case when sum(sawShowdown) = 0 then 'oo'
|
||||||
|
end AS wtsdwsf
|
||||||
|
,case when sum(sawShowdown) = 0 then 'oo'
|
||||||
|
else format(100.0*sum(wonAtSD)/sum(sawShowdown),1)
|
||||||
|
end AS wmsd
|
||||||
|
,case when sum(street1Seen) = 0 then 'oo'
|
||||||
|
else format(100.0*sum(street1Aggr)/sum(street1Seen),1)
|
||||||
|
end AS FlAFq
|
||||||
|
,case when sum(street2Seen) = 0 then 'oo'
|
||||||
|
else format(100.0*sum(street2Aggr)/sum(street2Seen),1)
|
||||||
|
end AS TuAFq
|
||||||
|
,case when sum(street3Seen) = 0 then 'oo'
|
||||||
|
else format(100.0*sum(street3Aggr)/sum(street3Seen),1)
|
||||||
|
end AS RvAFq
|
||||||
|
,case when sum(street1Seen)+sum(street2Seen)+sum(street3Seen) = 0 then 'oo'
|
||||||
|
else format(100.0*(sum(street1Aggr)+sum(street2Aggr)+sum(street3Aggr))
|
||||||
|
/(sum(street1Seen)+sum(street2Seen)+sum(street3Seen)),1)
|
||||||
|
end AS PoFAFq
|
||||||
|
,format(sum(totalProfit)/100.0,2) AS Net
|
||||||
|
,format((sum(totalProfit)/(gt.bigBlind+0.0)) / (sum(HDs)/100.0),2)
|
||||||
|
AS BBper100
|
||||||
|
,format( (sum(totalProfit)/100.0) / sum(HDs), 4) AS Profitperhand
|
||||||
|
from Gametypes gt
|
||||||
|
inner join Sites s on s.Id = gt.siteId
|
||||||
|
inner join HudCache hc on hc.gameTypeId = gt.Id
|
||||||
|
where hc.playerId in <player_test>
|
||||||
|
# use <gametype_test> here ?
|
||||||
|
group by gt.base
|
||||||
|
,gt.category
|
||||||
|
,upper(gt.limitType)
|
||||||
|
,s.name
|
||||||
|
,gt.bigBlind
|
||||||
|
,hc.gametypeId
|
||||||
|
,PlPosition
|
||||||
|
) stats
|
||||||
|
inner join
|
||||||
|
( select # profit from handsplayers/handsactions
|
||||||
|
hprof.gameTypeId,
|
||||||
|
case when hprof.position = 'B' then -2
|
||||||
|
when hprof.position = 'S' then -1
|
||||||
|
when hprof.position in ('3','4') then 2
|
||||||
|
when hprof.position in ('6','7') then 5
|
||||||
|
else hprof.position
|
||||||
|
end as PlPosition,
|
||||||
|
sum(hprof.profit) as sum_profit,
|
||||||
|
avg(hprof.profit/100.0) as profitperhand,
|
||||||
|
variance(hprof.profit/100.0) as variance,
|
||||||
|
count(*) as n
|
||||||
|
from
|
||||||
|
(select hp.handId, h.gameTypeId, hp.position, hp.winnings, SUM(ha.amount)
|
||||||
|
costs, hp.winnings - SUM(ha.amount) profit
|
||||||
|
from HandsPlayers hp
|
||||||
|
inner join Hands h ON h.id = hp.handId
|
||||||
|
left join HandsActions ha ON ha.handPlayerId = hp.id
|
||||||
|
where hp.playerId in <player_test>
|
||||||
|
# use <gametype_test> here ?
|
||||||
|
and hp.tourneysPlayersId IS NULL
|
||||||
|
and ((hp.card1Value = <first_card> and hp.card2Value = <second_card>) or (hp.card1Value = <second_card> and hp.card2Value = <first_card>))
|
||||||
|
group by hp.handId, h.gameTypeId, hp.position, hp.winnings
|
||||||
|
) hprof
|
||||||
|
group by hprof.gameTypeId, PlPosition
|
||||||
|
) hprof2
|
||||||
|
on ( hprof2.gameTypeId = stats.gameTypeId
|
||||||
|
and hprof2.PlPosition = stats.PlPosition)
|
||||||
|
order by stats.category, stats.limittype, stats.bigBlind, cast(stats.PlPosition as signed)
|
||||||
|
"""
|
||||||
|
|
||||||
if __name__== "__main__":
|
if __name__== "__main__":
|
||||||
from optparse import OptionParser
|
from optparse import OptionParser
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
#
|
||||||
# Copyright 2008, Carl Gherardi
|
# Copyright 2008, Carl Gherardi
|
||||||
#
|
#
|
||||||
# This program is free software; you can redistribute it and/or modify
|
# This program is free software; you can redistribute it and/or modify
|
||||||
|
@ -17,102 +19,117 @@
|
||||||
########################################################################
|
########################################################################
|
||||||
|
|
||||||
import sys
|
import sys
|
||||||
import Configuration
|
import logging
|
||||||
from HandHistoryConverter import *
|
from HandHistoryConverter import *
|
||||||
|
|
||||||
# FullTilt HH Format
|
# Fulltilt HH Format converter
|
||||||
|
|
||||||
#Full Tilt Poker Game #9403951181: Table CR - tay - $0.05/$0.10 - No Limit Hold'em - 9:40:20 ET - 2008/12/09
|
class Fulltilt(HandHistoryConverter):
|
||||||
#Seat 1: rigoise ($15.95)
|
|
||||||
#Seat 2: K2dream ($6.70)
|
# Static regexes
|
||||||
#Seat 4: ravens2216 ($10)
|
re_GameInfo = re.compile('- (?P<CURRENCY>\$|)?(?P<SB>[.0-9]+)/\$?(?P<BB>[.0-9]+) (Ante \$(?P<ANTE>[.0-9]+) )?- (?P<LIMIT>(No Limit|Pot Limit|Limit))? (?P<GAME>(Hold\'em|Omaha Hi|Razz))')
|
||||||
#Seat 5: rizkouner ($4)
|
re_SplitHands = re.compile(r"(\n\n+)")
|
||||||
#Seat 6: Sorrowful ($8.35)
|
re_HandInfo = re.compile('.*#(?P<HID>[0-9]+): Table (?P<TABLE>[- a-zA-Z]+) (\((?P<TABLEATTRIBUTES>.+)\) )?- \$?(?P<SB>[.0-9]+)/\$?(?P<BB>[.0-9]+) (Ante \$(?P<ANTE>[.0-9]+) )?- (?P<GAMETYPE>[a-zA-Z\' ]+) - (?P<DATETIME>.*)')
|
||||||
#rigoise posts the small blind of $0.05
|
re_Button = re.compile('^The button is in seat #(?P<BUTTON>\d+)', re.MULTILINE)
|
||||||
#K2dream posts the big blind of $0.10
|
re_PlayerInfo = re.compile('Seat (?P<SEAT>[0-9]+): (?P<PNAME>.*) \(\$(?P<CASH>[.0-9]+)\)\n')
|
||||||
#5 seconds left to act
|
re_Board = re.compile(r"\[(?P<CARDS>.+)\]")
|
||||||
#rizkouner posts $0.10
|
|
||||||
#The button is in seat #6
|
def __init__(self, in_path = '-', out_path = '-', follow = False, autostart=True):
|
||||||
#*** HOLE CARDS ***
|
"""\
|
||||||
#Dealt to Sorrowful [8h Qc]
|
in_path (default '-' = sys.stdin)
|
||||||
#ravens2216 folds
|
out_path (default '-' = sys.stdout)
|
||||||
#rizkouner checks
|
follow : whether to tail -f the input"""
|
||||||
#Sorrowful has 15 seconds left to act
|
HandHistoryConverter.__init__(self, in_path, out_path, sitename="Fulltilt", follow=follow)
|
||||||
#Sorrowful folds
|
logging.info("Initialising Fulltilt converter class")
|
||||||
#rigoise folds
|
self.filetype = "text"
|
||||||
#K2dream checks
|
self.codepage = "cp1252"
|
||||||
#*** FLOP *** [9d Kc 5c]
|
if autostart:
|
||||||
#K2dream checks
|
self.start()
|
||||||
#rizkouner checks
|
|
||||||
#*** TURN *** [9d Kc 5c] [5h]
|
|
||||||
#K2dream has 15 seconds left to act
|
def compilePlayerRegexs(self, hand):
|
||||||
#K2dream bets $0.20
|
players = set([player[1] for player in hand.players])
|
||||||
#rizkouner calls $0.20
|
if not players <= self.compiledPlayers: # x <= y means 'x is subset of y'
|
||||||
#*** RIVER *** [9d Kc 5c 5h] [6h]
|
# we need to recompile the player regexs.
|
||||||
#K2dream checks
|
self.compiledPlayers = players
|
||||||
#rizkouner has 15 seconds left to act
|
player_re = "(?P<PNAME>" + "|".join(map(re.escape, players)) + ")"
|
||||||
#rizkouner bets $0.20
|
logging.debug("player_re: " + player_re)
|
||||||
#K2dream folds
|
self.re_PostSB = re.compile(r"^%s posts the small blind of \$?(?P<SB>[.0-9]+)" % player_re, re.MULTILINE)
|
||||||
#Uncalled bet of $0.20 returned to rizkouner
|
self.re_PostBB = re.compile(r"^%s posts (the big blind of )?\$?(?P<BB>[.0-9]+)" % player_re, re.MULTILINE)
|
||||||
#rizkouner mucks
|
self.re_Antes = re.compile(r"^%s antes \$?(?P<ANTE>[.0-9]+)" % player_re, re.MULTILINE)
|
||||||
#rizkouner wins the pot ($0.60)
|
self.re_BringIn = re.compile(r"^%s brings in for \$?(?P<BRINGIN>[.0-9]+)" % player_re, re.MULTILINE)
|
||||||
#*** SUMMARY ***
|
self.re_PostBoth = re.compile(r"^%s posts small \& big blinds \[\$? (?P<SBBB>[.0-9]+)" % player_re, re.MULTILINE)
|
||||||
#Total pot $0.65 | Rake $0.05
|
self.re_HeroCards = re.compile(r"^Dealt to %s(?: \[(?P<OLDCARDS>.+?)\])?( \[(?P<NEWCARDS>.+?)\])" % player_re, re.MULTILINE)
|
||||||
#Board: [9d Kc 5c 5h 6h]
|
self.re_Action = re.compile(r"^%s(?P<ATYPE> bets| checks| raises to| completes it to| calls| folds)(\s\$(?P<BET>[.\d]+))?" % player_re, re.MULTILINE)
|
||||||
#Seat 1: rigoise (small blind) folded before the Flop
|
self.re_ShowdownAction = re.compile(r"^%s shows \[(?P<CARDS>.*)\]" % player_re, re.MULTILINE)
|
||||||
#Seat 2: K2dream (big blind) folded on the River
|
self.re_CollectPot = re.compile(r"^Seat (?P<SEAT>[0-9]+): %s (\(button\) |\(small blind\) |\(big blind\) )?(collected|showed \[.*\] and won) \(\$(?P<POT>[.\d]+)\)(, mucked| with.*)" % player_re, re.MULTILINE)
|
||||||
#Seat 4: ravens2216 didn't bet (folded)
|
self.re_SitsOut = re.compile(r"^%s sits out" % player_re, re.MULTILINE)
|
||||||
#Seat 5: rizkouner collected ($0.60), mucked
|
self.re_ShownCards = re.compile(r"^Seat (?P<SEAT>[0-9]+): %s \(.*\) showed \[(?P<CARDS>.*)\].*" % player_re, re.MULTILINE)
|
||||||
#Seat 6: Sorrowful (button) didn't bet (folded)
|
|
||||||
#Seat N: rizkouner (button) showed [Jh Ah] and won ($0.70) with a pair of Threes
|
|
||||||
|
|
||||||
class FullTilt(HandHistoryConverter):
|
|
||||||
def __init__(self, config, file):
|
|
||||||
print "Initialising FullTilt converter class"
|
|
||||||
HandHistoryConverter.__init__(self, config, file, sitename="FullTilt") # Call super class init.
|
|
||||||
self.sitename = "FullTilt"
|
|
||||||
self.setFileType("text", "cp1252")
|
|
||||||
self.rexx.setGameInfoRegex('- \$?(?P<SB>[.0-9]+)/\$?(?P<BB>[.0-9]+) -')
|
|
||||||
self.rexx.setSplitHandRegex('\n\n+')
|
|
||||||
self.rexx.setHandInfoRegex('.*#(?P<HID>[0-9]+): Table (?P<TABLE>[- a-zA-Z]+) (\((?P<TABLEATTRIBUTES>.+)\) )?- \$?(?P<SB>[.0-9]+)/\$?(?P<BB>[.0-9]+) - (?P<GAMETYPE>[a-zA-Z\' ]+) - (?P<DATETIME>.*)')
|
|
||||||
# self.rexx.setHandInfoRegex('.*#(?P<HID>[0-9]+): Table (?P<TABLE>[ a-zA-Z]+) - \$?(?P<SB>[.0-9]+)/\$?(?P<BB>[.0-9]+) - (?P<GAMETYPE>.*) - (?P<HR>[0-9]+):(?P<MIN>[0-9]+) ET - (?P<YEAR>[0-9]+)/(?P<MON>[0-9]+)/(?P<DAY>[0-9]+)Table (?P<TABLE>[ a-zA-Z]+)\nSeat (?P<BUTTON>[0-9]+)')
|
|
||||||
self.rexx.button_re = re.compile('The button is in seat #(?P<BUTTON>\d+)')
|
|
||||||
self.rexx.setPlayerInfoRegex('Seat (?P<SEAT>[0-9]+): (?P<PNAME>.*) \(\$(?P<CASH>[.0-9]+)\)\n')
|
|
||||||
self.rexx.setPostSbRegex('.*\n(?P<PNAME>.*) posts the small blind of \$?(?P<SB>[.0-9]+)')
|
|
||||||
self.rexx.setPostBbRegex('.*\n(?P<PNAME>.*) posts (the big blind of )?\$?(?P<BB>[.0-9]+)')
|
|
||||||
self.rexx.setPostBothRegex('.*\n(?P<PNAME>.*) posts small \& big blinds \[\$? (?P<SBBB>[.0-9]+)')
|
|
||||||
self.rexx.setHeroCardsRegex('.*\nDealt\sto\s(?P<PNAME>.*)\s\[(?P<CARDS>.*)\]')
|
|
||||||
self.rexx.setActionStepRegex('.*\n(?P<PNAME>.*)(?P<ATYPE> bets| checks| raises to| calls| folds)(\s\$(?P<BET>[.\d]+))?')
|
|
||||||
self.rexx.setShowdownActionRegex('.*\n(?P<PNAME>.*) shows \[(?P<CARDS>.*)\]')
|
|
||||||
self.rexx.setCollectPotRegex(r"Seat (?P<SEAT>[0-9]+): (?P<PNAME>.*?) (\(button\) |\(small blind\) |\(big blind\) )?(collected|showed \[.*\] and won) \(\$(?P<POT>[.\d]+)\)(, mucked| with.*)")
|
|
||||||
self.rexx.shown_cards_re = re.compile('Seat (?P<SEAT>[0-9]+): (?P<PNAME>.*) \(.*\) showed \[(?P<CARDS>.*)\].*')
|
|
||||||
self.rexx.sits_out_re = re.compile('(?P<PNAME>.*) sits out')
|
|
||||||
self.rexx.compileRegexes()
|
|
||||||
|
|
||||||
def readSupportedGames(self):
|
def readSupportedGames(self):
|
||||||
pass
|
return [["ring", "hold", "nl"],
|
||||||
|
["ring", "hold", "pl"],
|
||||||
|
["ring", "hold", "fl"],
|
||||||
|
["ring", "stud", "fl"],
|
||||||
|
["ring", "omaha", "pl"]
|
||||||
|
]
|
||||||
|
|
||||||
def determineGameType(self):
|
def determineGameType(self, handText):
|
||||||
# Cheating with this regex, only support nlhe at the moment
|
# Full Tilt Poker Game #10777181585: Table Deerfly (deep 6) - $0.01/$0.02 - Pot Limit Omaha Hi - 2:24:44 ET - 2009/02/22
|
||||||
gametype = ["ring", "hold", "nl"]
|
# Full Tilt Poker Game #10773265574: Table Butte (6 max) - $0.01/$0.02 - Pot Limit Hold'em - 21:33:46 ET - 2009/02/21
|
||||||
|
# Full Tilt Poker Game #9403951181: Table CR - tay - $0.05/$0.10 - No Limit Hold'em - 9:40:20 ET - 2008/12/09
|
||||||
|
# Full Tilt Poker Game #10809877615: Table Danville - $0.50/$1 Ante $0.10 - Limit Razz - 21:47:27 ET - 2009/02/23
|
||||||
|
info = {'type':'ring'}
|
||||||
|
|
||||||
m = self.rexx.game_info_re.search(self.obs)
|
m = self.re_GameInfo.search(handText)
|
||||||
gametype = gametype + [m.group('SB')]
|
if not m:
|
||||||
gametype = gametype + [m.group('BB')]
|
return None
|
||||||
|
|
||||||
return gametype
|
mg = m.groupdict()
|
||||||
|
|
||||||
|
# translations from captured groups to our info strings
|
||||||
|
limits = { 'No Limit':'nl', 'Pot Limit':'pl', 'Limit':'fl' }
|
||||||
|
games = { # base, category
|
||||||
|
"Hold'em" : ('hold','holdem'),
|
||||||
|
'Omaha Hi' : ('hold','omahahi'),
|
||||||
|
'Razz' : ('stud','razz'),
|
||||||
|
'7 Card Stud' : ('stud','studhi')
|
||||||
|
}
|
||||||
|
currencies = { u' €':'EUR', '$':'USD', '':'T$' }
|
||||||
|
if 'LIMIT' in mg:
|
||||||
|
info['limitType'] = limits[mg['LIMIT']]
|
||||||
|
if 'GAME' in mg:
|
||||||
|
(info['base'], info['category']) = games[mg['GAME']]
|
||||||
|
if 'SB' in mg:
|
||||||
|
info['sb'] = mg['SB']
|
||||||
|
if 'BB' in mg:
|
||||||
|
info['bb'] = mg['BB']
|
||||||
|
if 'CURRENCY' in mg:
|
||||||
|
info['currency'] = currencies[mg['CURRENCY']]
|
||||||
|
# NB: SB, BB must be interpreted as blinds or bets depending on limit type.
|
||||||
|
|
||||||
|
return info
|
||||||
|
|
||||||
def readHandInfo(self, hand):
|
def readHandInfo(self, hand):
|
||||||
m = self.rexx.hand_info_re.search(hand.string,re.DOTALL)
|
m = self.re_HandInfo.search(hand.handText,re.DOTALL)
|
||||||
#print m.groups()
|
|
||||||
|
if(m == None):
|
||||||
|
logging.info("Didn't match re_HandInfo")
|
||||||
|
logging.info(hand.handText)
|
||||||
|
return None
|
||||||
|
|
||||||
hand.handid = m.group('HID')
|
hand.handid = m.group('HID')
|
||||||
hand.tablename = m.group('TABLE')
|
hand.tablename = m.group('TABLE')
|
||||||
hand.buttonpos = int(self.rexx.button_re.search(hand.string).group('BUTTON'))
|
|
||||||
hand.starttime = time.strptime(m.group('DATETIME'), "%H:%M:%S ET - %Y/%m/%d")
|
hand.starttime = time.strptime(m.group('DATETIME'), "%H:%M:%S ET - %Y/%m/%d")
|
||||||
|
hand.maxseats = 8 # assume 8-max until we see otherwise
|
||||||
|
if m.group('TABLEATTRIBUTES'):
|
||||||
|
m2 = re.search("(deep )?(\d+)( max)?", m.group('TABLEATTRIBUTES'))
|
||||||
|
hand.maxseats = int(m2.group(2))
|
||||||
# These work, but the info is already in the Hand class - should be used for tourneys though.
|
# These work, but the info is already in the Hand class - should be used for tourneys though.
|
||||||
# m.group('SB')
|
# m.group('SB')
|
||||||
# m.group('BB')
|
# m.group('BB')
|
||||||
# m.group('GAMETYPE')
|
# m.group('GAMETYPE')
|
||||||
|
|
||||||
# Stars format (Nov 10 2008): 2008/11/07 12:38:49 CET [2008/11/07 7:38:49 ET]
|
# Stars format (Nov 10 2008): 2008/11/07 12:38:49 CET [2008/11/07 7:38:49 ET]
|
||||||
# or : 2008/11/07 12:38:49 ET
|
# or : 2008/11/07 12:38:49 ET
|
||||||
|
@ -125,43 +142,66 @@ class FullTilt(HandHistoryConverter):
|
||||||
#FIXME: hand.buttonpos = int(m.group('BUTTON'))
|
#FIXME: hand.buttonpos = int(m.group('BUTTON'))
|
||||||
|
|
||||||
def readPlayerStacks(self, hand):
|
def readPlayerStacks(self, hand):
|
||||||
m = self.rexx.player_info_re.finditer(hand.string)
|
m = self.re_PlayerInfo.finditer(hand.handText)
|
||||||
players = []
|
players = []
|
||||||
for a in m:
|
for a in m:
|
||||||
hand.addPlayer(int(a.group('SEAT')), a.group('PNAME'), a.group('CASH'))
|
hand.addPlayer(int(a.group('SEAT')), a.group('PNAME'), a.group('CASH'))
|
||||||
|
|
||||||
def markStreets(self, hand):
|
def markStreets(self, hand):
|
||||||
# PREFLOP = ** Dealing down cards **
|
# PREFLOP = ** Dealing down cards **
|
||||||
# This re fails if, say, river is missing; then we don't get the ** that starts the river.
|
|
||||||
|
|
||||||
m = re.search(r"\*\*\* HOLE CARDS \*\*\*(?P<PREFLOP>.+(?=\*\*\* FLOP \*\*\*)|.+)"
|
if hand.gametype['base'] == 'hold':
|
||||||
|
m = re.search(r"\*\*\* HOLE CARDS \*\*\*(?P<PREFLOP>.+(?=\*\*\* FLOP \*\*\*)|.+)"
|
||||||
r"(\*\*\* FLOP \*\*\*(?P<FLOP> \[\S\S \S\S \S\S\].+(?=\*\*\* TURN \*\*\*)|.+))?"
|
r"(\*\*\* FLOP \*\*\*(?P<FLOP> \[\S\S \S\S \S\S\].+(?=\*\*\* TURN \*\*\*)|.+))?"
|
||||||
r"(\*\*\* TURN \*\*\* \[\S\S \S\S \S\S] (?P<TURN>\[\S\S\].+(?=\*\*\* RIVER \*\*\*)|.+))?"
|
r"(\*\*\* TURN \*\*\* \[\S\S \S\S \S\S] (?P<TURN>\[\S\S\].+(?=\*\*\* RIVER \*\*\*)|.+))?"
|
||||||
r"(\*\*\* RIVER \*\*\* \[\S\S \S\S \S\S \S\S] (?P<RIVER>\[\S\S\].+))?", hand.string,re.DOTALL)
|
r"(\*\*\* RIVER \*\*\* \[\S\S \S\S \S\S \S\S] (?P<RIVER>\[\S\S\].+))?", hand.handText,re.DOTALL)
|
||||||
|
elif hand.gametype['base'] == "stud": # or should this be gametype['category'] == 'razz'
|
||||||
|
m = re.search(r"(?P<ANTES>.+(?=\*\*\* 3RD STREET \*\*\*)|.+)"
|
||||||
|
r"(\*\*\* 3RD STREET \*\*\*(?P<THIRD>.+(?=\*\*\* 4TH STREET \*\*\*)|.+))?"
|
||||||
|
r"(\*\*\* 4TH STREET \*\*\*(?P<FOURTH>.+(?=\*\*\* 5TH STREET \*\*\*)|.+))?"
|
||||||
|
r"(\*\*\* 5TH STREET \*\*\*(?P<FIFTH>.+(?=\*\*\* 6TH STREET \*\*\*)|.+))?"
|
||||||
|
r"(\*\*\* 6TH STREET \*\*\*(?P<SIXTH>.+(?=\*\*\* 7TH STREET \*\*\*)|.+))?"
|
||||||
|
r"(\*\*\* 7TH STREET \*\*\*(?P<SEVENTH>.+))?", hand.handText,re.DOTALL)
|
||||||
hand.addStreets(m)
|
hand.addStreets(m)
|
||||||
|
|
||||||
def readCommunityCards(self, hand, street): # street has been matched by markStreets, so exists in this hand
|
def readCommunityCards(self, hand, street): # street has been matched by markStreets, so exists in this hand
|
||||||
if street in ('FLOP','TURN','RIVER'): # a list of streets which get dealt community cards (i.e. all but PREFLOP)
|
if street in ('FLOP','TURN','RIVER'): # a list of streets which get dealt community cards (i.e. all but PREFLOP)
|
||||||
self.rexx.board_re = re.compile(r"\[(?P<CARDS>.+)\]")
|
|
||||||
#print "DEBUG readCommunityCards:", street, hand.streets.group(street)
|
#print "DEBUG readCommunityCards:", street, hand.streets.group(street)
|
||||||
m = self.rexx.board_re.search(hand.streets.group(street))
|
m = self.re_Board.search(hand.streets[street])
|
||||||
hand.setCommunityCards(street, m.group('CARDS').split(' '))
|
hand.setCommunityCards(street, m.group('CARDS').split(' '))
|
||||||
|
|
||||||
|
|
||||||
def readBlinds(self, hand):
|
def readBlinds(self, hand):
|
||||||
try:
|
try:
|
||||||
m = self.rexx.small_blind_re.search(hand.string)
|
m = self.re_PostSB.search(hand.handText)
|
||||||
hand.addBlind(m.group('PNAME'), 'small blind', m.group('SB'))
|
hand.addBlind(m.group('PNAME'), 'small blind', m.group('SB'))
|
||||||
except: # no small blind
|
except: # no small blind
|
||||||
hand.addBlind(None, None, None)
|
hand.addBlind(None, None, None)
|
||||||
for a in self.rexx.big_blind_re.finditer(hand.string):
|
for a in self.re_PostBB.finditer(hand.handText):
|
||||||
hand.addBlind(a.group('PNAME'), 'big blind', a.group('BB'))
|
hand.addBlind(a.group('PNAME'), 'big blind', a.group('BB'))
|
||||||
for a in self.rexx.both_blinds_re.finditer(hand.string):
|
for a in self.re_PostBoth.finditer(hand.handText):
|
||||||
hand.addBlind(a.group('PNAME'), 'small & big blinds', a.group('SBBB'))
|
hand.addBlind(a.group('PNAME'), 'small & big blinds', a.group('SBBB'))
|
||||||
|
|
||||||
|
def readAntes(self, hand):
|
||||||
|
logging.debug("reading antes")
|
||||||
|
m = self.re_Antes.finditer(hand.handText)
|
||||||
|
for player in m:
|
||||||
|
logging.debug("hand.addAnte(%s,%s)" %(player.group('PNAME'), player.group('ANTE')))
|
||||||
|
hand.addAnte(player.group('PNAME'), player.group('ANTE'))
|
||||||
|
|
||||||
|
def readBringIn(self, hand):
|
||||||
|
m = self.re_BringIn.search(hand.handText,re.DOTALL)
|
||||||
|
if m:
|
||||||
|
logging.debug("Player bringing in: %s for %s" %(m.group('PNAME'), m.group('BRINGIN')))
|
||||||
|
hand.addBringIn(m.group('PNAME'), m.group('BRINGIN'))
|
||||||
|
else:
|
||||||
|
logging.warning("No bringin found")
|
||||||
|
|
||||||
|
def readButton(self, hand):
|
||||||
|
hand.buttonpos = int(self.re_Button.search(hand.handText).group('BUTTON'))
|
||||||
|
|
||||||
def readHeroCards(self, hand):
|
def readHeroCards(self, hand):
|
||||||
m = self.rexx.hero_cards_re.search(hand.string)
|
m = self.re_HeroCards.search(hand.handText)
|
||||||
if(m == None):
|
if(m == None):
|
||||||
#Not involved in hand
|
#Not involved in hand
|
||||||
hand.involved = False
|
hand.involved = False
|
||||||
|
@ -169,15 +209,73 @@ class FullTilt(HandHistoryConverter):
|
||||||
hand.hero = m.group('PNAME')
|
hand.hero = m.group('PNAME')
|
||||||
# "2c, qh" -> set(["2c","qc"])
|
# "2c, qh" -> set(["2c","qc"])
|
||||||
# Also works with Omaha hands.
|
# Also works with Omaha hands.
|
||||||
cards = m.group('CARDS')
|
cards = m.group('NEWCARDS')
|
||||||
cards = set(cards.split(' '))
|
cards = [c.strip() for c in cards.split(' ')]
|
||||||
hand.addHoleCards(cards, m.group('PNAME'))
|
hand.addHoleCards(cards, m.group('PNAME'))
|
||||||
|
|
||||||
|
def readStudPlayerCards(self, hand, street):
|
||||||
|
# This could be the most tricky one to get right.
|
||||||
|
# It looks for cards dealt in 'street',
|
||||||
|
# which may or may not be in the section of the hand designated 'street' by markStreets earlier.
|
||||||
|
# Here's an example at FTP of what 'THIRD' and 'FOURTH' look like to hero PokerAscetic
|
||||||
|
#
|
||||||
|
#"*** 3RD STREET ***
|
||||||
|
#Dealt to BFK23 [Th]
|
||||||
|
#Dealt to cutiepr1nnymaid [8c]
|
||||||
|
#Dealt to PokerAscetic [7c 8s] [3h]
|
||||||
|
#..."
|
||||||
|
#
|
||||||
|
#"*** 4TH STREET ***
|
||||||
|
#Dealt to cutiepr1nnymaid [8c] [2s]
|
||||||
|
#Dealt to PokerAscetic [7c 8s 3h] [5s]
|
||||||
|
#..."
|
||||||
|
#Note that hero's first two holecards are only reported at 3rd street as 'old' cards.
|
||||||
|
logging.debug("readStudPlayerCards")
|
||||||
|
m = self.re_HeroCards.finditer(hand.streets[street])
|
||||||
|
for player in m:
|
||||||
|
logging.debug(player.groupdict())
|
||||||
|
(pname, oldcards, newcards) = (player.group('PNAME'), player.group('OLDCARDS'), player.group('NEWCARDS'))
|
||||||
|
if oldcards:
|
||||||
|
oldcards = [c.strip() for c in oldcards.split(' ')]
|
||||||
|
if newcards:
|
||||||
|
newcards = [c.strip() for c in newcards.split(' ')]
|
||||||
|
# options here:
|
||||||
|
# (1) we trust the hand will know what to do -- probably check that the old cards match what it already knows, and add the newcards to this street.
|
||||||
|
# (2) we're the experts at this particular history format and we know how we're going to be called (once for each street in Hand.streetList)
|
||||||
|
# so call addPlayerCards with the appropriate information.
|
||||||
|
# I favour (2) here but I'm afraid it is rather stud7-specific.
|
||||||
|
# in the following, the final list of cards will be in 'newcards' whilst if the first list exists (most of the time it does) it will be in 'oldcards'
|
||||||
|
if street=='ANTES':
|
||||||
|
return
|
||||||
|
elif street=='THIRD':
|
||||||
|
# we'll have observed hero holecards in CARDS and thirdstreet open cards in 'NEWCARDS'
|
||||||
|
# hero: [xx][o]
|
||||||
|
# others: [o]
|
||||||
|
hand.addPlayerCards(player = player.group('PNAME'), street = street, closed = oldcards, open = newcards)
|
||||||
|
elif street in ('FOURTH', 'FIFTH', 'SIXTH'):
|
||||||
|
# 4th:
|
||||||
|
# hero: [xxo] [o]
|
||||||
|
# others: [o] [o]
|
||||||
|
# 5th:
|
||||||
|
# hero: [xxoo] [o]
|
||||||
|
# others: [oo] [o]
|
||||||
|
# 6th:
|
||||||
|
# hero: [xxooo] [o]
|
||||||
|
# others: [ooo] [o]
|
||||||
|
hand.addPlayerCards(player = player.group('PNAME'), street = street, open = newcards)
|
||||||
|
# we may additionally want to check the earlier streets tally with what we have but lets trust it for now.
|
||||||
|
elif street=='SEVENTH' and newcards:
|
||||||
|
# hero: [xxoooo] [x]
|
||||||
|
# others: not reported.
|
||||||
|
hand.addPlayerCards(player = player.group('PNAME'), street = street, closed = newcards)
|
||||||
|
|
||||||
def readAction(self, hand, street):
|
def readAction(self, hand, street):
|
||||||
m = self.rexx.action_re.finditer(hand.streets.group(street))
|
m = self.re_Action.finditer(hand.streets[street])
|
||||||
for action in m:
|
for action in m:
|
||||||
if action.group('ATYPE') == ' raises to':
|
if action.group('ATYPE') == ' raises to':
|
||||||
hand.addRaiseTo( street, action.group('PNAME'), action.group('BET') )
|
hand.addRaiseTo( street, action.group('PNAME'), action.group('BET') )
|
||||||
|
elif action.group('ATYPE') == ' completes it to':
|
||||||
|
hand.addComplete( street, action.group('PNAME'), action.group('BET') )
|
||||||
elif action.group('ATYPE') == ' calls':
|
elif action.group('ATYPE') == ' calls':
|
||||||
hand.addCall( street, action.group('PNAME'), action.group('BET') )
|
hand.addCall( street, action.group('PNAME'), action.group('BET') )
|
||||||
elif action.group('ATYPE') == ' bets':
|
elif action.group('ATYPE') == ' bets':
|
||||||
|
@ -187,34 +285,42 @@ class FullTilt(HandHistoryConverter):
|
||||||
elif action.group('ATYPE') == ' checks':
|
elif action.group('ATYPE') == ' checks':
|
||||||
hand.addCheck( street, action.group('PNAME'))
|
hand.addCheck( street, action.group('PNAME'))
|
||||||
else:
|
else:
|
||||||
print "DEBUG: unimplemented readAction: %s %s" %(action.group('PNAME'),action.group('ATYPE'),)
|
print "DEBUG: unimplemented readAction: '%s' '%s'" %(action.group('PNAME'),action.group('ATYPE'),)
|
||||||
|
|
||||||
|
|
||||||
def readShowdownActions(self, hand):
|
def readShowdownActions(self, hand):
|
||||||
for shows in self.rexx.showdown_action_re.finditer(hand.string):
|
for shows in self.re_ShowdownAction.finditer(hand.handText):
|
||||||
cards = shows.group('CARDS')
|
cards = shows.group('CARDS')
|
||||||
cards = set(cards.split(' '))
|
cards = cards.split(' ')
|
||||||
hand.addShownCards(cards, shows.group('PNAME'))
|
hand.addShownCards(cards, shows.group('PNAME'))
|
||||||
|
|
||||||
def readCollectPot(self,hand):
|
def readCollectPot(self,hand):
|
||||||
for m in self.rexx.collect_pot_re.finditer(hand.string):
|
for m in self.re_CollectPot.finditer(hand.handText):
|
||||||
hand.addCollectPot(player=m.group('PNAME'),pot=m.group('POT'))
|
hand.addCollectPot(player=m.group('PNAME'),pot=m.group('POT'))
|
||||||
|
|
||||||
def readShownCards(self,hand):
|
def readShownCards(self,hand):
|
||||||
for m in self.rexx.shown_cards_re.finditer(hand.string):
|
for m in self.re_ShownCards.finditer(hand.handText):
|
||||||
if m.group('CARDS') is not None:
|
if m.group('CARDS') is not None:
|
||||||
cards = m.group('CARDS')
|
cards = m.group('CARDS')
|
||||||
cards = set(cards.split(' '))
|
cards = cards.split(' ')
|
||||||
hand.addShownCards(cards=cards, player=m.group('PNAME'))
|
hand.addShownCards(cards=cards, player=m.group('PNAME'))
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
c = Configuration.Config()
|
parser = OptionParser()
|
||||||
if len(sys.argv) == 1:
|
parser.add_option("-i", "--input", dest="ipath", help="parse input hand history", default="regression-test-files/fulltilt/razz/FT20090223 Danville - $0.50-$1 Ante $0.10 - Limit Razz.txt")
|
||||||
testfile = "regression-test-files/FT20081209 CR - tay - $0.05-$0.10 - No Limit Hold'em.txt"
|
parser.add_option("-o", "--output", dest="opath", help="output translation to", default="-")
|
||||||
else:
|
parser.add_option("-f", "--follow", dest="follow", help="follow (tail -f) the input", action="store_true", default=False)
|
||||||
testfile = sys.argv[1]
|
parser.add_option("-q", "--quiet",
|
||||||
print "Converting: ", testfile
|
action="store_const", const=logging.CRITICAL, dest="verbosity", default=logging.INFO)
|
||||||
e = FullTilt(c, testfile)
|
parser.add_option("-v", "--verbose",
|
||||||
e.processFile()
|
action="store_const", const=logging.INFO, dest="verbosity")
|
||||||
print str(e)
|
parser.add_option("--vv",
|
||||||
|
action="store_const", const=logging.DEBUG, dest="verbosity")
|
||||||
|
|
||||||
|
(options, args) = parser.parse_args()
|
||||||
|
|
||||||
|
LOG_FILENAME = './logging.out'
|
||||||
|
logging.basicConfig(filename=LOG_FILENAME,level=options.verbosity)
|
||||||
|
|
||||||
|
e = Fulltilt(in_path = options.ipath, out_path = options.opath, follow = options.follow)
|
||||||
|
|
69
pyfpdb/GuiAutoImport.py
Normal file → Executable file
|
@ -26,7 +26,8 @@ import os
|
||||||
import sys
|
import sys
|
||||||
import time
|
import time
|
||||||
import fpdb_import
|
import fpdb_import
|
||||||
|
from optparse import OptionParser
|
||||||
|
import Configuration
|
||||||
|
|
||||||
class GuiAutoImport (threading.Thread):
|
class GuiAutoImport (threading.Thread):
|
||||||
def __init__(self, settings, config):
|
def __init__(self, settings, config):
|
||||||
|
@ -44,7 +45,7 @@ class GuiAutoImport (threading.Thread):
|
||||||
|
|
||||||
self.importer = fpdb_import.Importer(self,self.settings, self.config)
|
self.importer = fpdb_import.Importer(self,self.settings, self.config)
|
||||||
self.importer.setCallHud(True)
|
self.importer.setCallHud(True)
|
||||||
self.importer.setMinPrint(30)
|
self.importer.setMinPrint(settings['minPrint'])
|
||||||
self.importer.setQuiet(False)
|
self.importer.setQuiet(False)
|
||||||
self.importer.setFailOnError(False)
|
self.importer.setFailOnError(False)
|
||||||
self.importer.setHandCount(0)
|
self.importer.setHandCount(0)
|
||||||
|
@ -106,7 +107,8 @@ class GuiAutoImport (threading.Thread):
|
||||||
"""Callback for timer to do an import iteration."""
|
"""Callback for timer to do an import iteration."""
|
||||||
if self.doAutoImportBool:
|
if self.doAutoImportBool:
|
||||||
self.importer.runUpdated()
|
self.importer.runUpdated()
|
||||||
print "GuiAutoImport.import_dir done"
|
sys.stdout.write(".")
|
||||||
|
sys.stdout.flush()
|
||||||
return True
|
return True
|
||||||
else:
|
else:
|
||||||
return False
|
return False
|
||||||
|
@ -128,12 +130,13 @@ class GuiAutoImport (threading.Thread):
|
||||||
widget.set_label(u'Stop Autoimport')
|
widget.set_label(u'Stop Autoimport')
|
||||||
if self.pipe_to_hud is None:
|
if self.pipe_to_hud is None:
|
||||||
if os.name == 'nt':
|
if os.name == 'nt':
|
||||||
command = "python HUD_run_me.py" + " %s" % (self.database)
|
command = "python HUD_main.py" + " %s" % (self.database)
|
||||||
bs = 0 # windows is not happy with line buffing here
|
bs = 0 # windows is not happy with line buffing here
|
||||||
self.pipe_to_hud = subprocess.Popen(command, bufsize = bs, stdin = subprocess.PIPE,
|
self.pipe_to_hud = subprocess.Popen(command, bufsize = bs, stdin = subprocess.PIPE,
|
||||||
universal_newlines=True)
|
universal_newlines=True)
|
||||||
else:
|
else:
|
||||||
command = self.config.execution_path('HUD_run_me.py')
|
command = os.path.join(sys.path[0], 'HUD_main.py')
|
||||||
|
#command = self.config.execution_path('HUD_main.py') # Hi Ray. Sorry about this, kludging.
|
||||||
bs = 1
|
bs = 1
|
||||||
self.pipe_to_hud = subprocess.Popen((command, self.database), bufsize = bs, stdin = subprocess.PIPE,
|
self.pipe_to_hud = subprocess.Popen((command, self.database), bufsize = bs, stdin = subprocess.PIPE,
|
||||||
universal_newlines=True)
|
universal_newlines=True)
|
||||||
|
@ -199,13 +202,14 @@ class GuiAutoImport (threading.Thread):
|
||||||
filter.show()
|
filter.show()
|
||||||
|
|
||||||
def addSites(self, vbox):
|
def addSites(self, vbox):
|
||||||
for site in self.config.supported_sites.keys():
|
the_sites = self.config.get_supported_sites()
|
||||||
|
for site in the_sites:
|
||||||
pathHBox = gtk.HBox(False, 0)
|
pathHBox = gtk.HBox(False, 0)
|
||||||
vbox.pack_start(pathHBox, False, True, 0)
|
vbox.pack_start(pathHBox, False, True, 0)
|
||||||
pathHBox.show()
|
pathHBox.show()
|
||||||
|
|
||||||
paths = self.config.get_default_paths(site)
|
|
||||||
params = self.config.get_site_parameters(site)
|
params = self.config.get_site_parameters(site)
|
||||||
|
paths = self.config.get_default_paths(site)
|
||||||
self.createSiteLine(pathHBox, site, False, paths['hud-defaultPath'], params['converter'], params['enabled'])
|
self.createSiteLine(pathHBox, site, False, paths['hud-defaultPath'], params['converter'], params['enabled'])
|
||||||
self.input_settings[site] = [paths['hud-defaultPath']] + [params['converter']]
|
self.input_settings[site] = [paths['hud-defaultPath']] + [params['converter']]
|
||||||
|
|
||||||
|
@ -213,18 +217,41 @@ if __name__== "__main__":
|
||||||
def destroy(*args): # call back for terminating the main eventloop
|
def destroy(*args): # call back for terminating the main eventloop
|
||||||
gtk.main_quit()
|
gtk.main_quit()
|
||||||
|
|
||||||
settings = {}
|
# settings = {}
|
||||||
settings['db-host'] = "192.168.1.100"
|
# settings['db-host'] = "192.168.1.100"
|
||||||
settings['db-user'] = "mythtv"
|
# settings['db-user'] = "mythtv"
|
||||||
settings['db-password'] = "mythtv"
|
# settings['db-password'] = "mythtv"
|
||||||
settings['db-databaseName'] = "fpdb"
|
# settings['db-databaseName'] = "fpdb"
|
||||||
settings['hud-defaultInterval'] = 10
|
# settings['hud-defaultInterval'] = 10
|
||||||
settings['hud-defaultPath'] = 'C:/Program Files/PokerStars/HandHistory/nutOmatic'
|
# settings['hud-defaultPath'] = 'C:/Program Files/PokerStars/HandHistory/nutOmatic'
|
||||||
settings['callFpdbHud'] = True
|
# settings['callFpdbHud'] = True
|
||||||
|
|
||||||
|
parser = OptionParser()
|
||||||
|
parser.add_option("-q", "--quiet", action="store_false", dest="gui", default=True, help="don't start gui")
|
||||||
|
parser.add_option("-m", "--minPrint", "--status", dest="minPrint", default="0", type="int",
|
||||||
|
help="How often to print a one-line status report (0 (default) means never)")
|
||||||
|
(options, sys.argv) = parser.parse_args()
|
||||||
|
|
||||||
|
config = Configuration.Config()
|
||||||
|
# db = fpdb_db.fpdb_db()
|
||||||
|
|
||||||
|
settings = {}
|
||||||
|
settings['minPrint'] = options.minPrint
|
||||||
|
if os.name == 'nt': settings['os'] = 'windows'
|
||||||
|
else: settings['os'] = 'linuxmac'
|
||||||
|
|
||||||
|
settings.update(config.get_db_parameters('fpdb'))
|
||||||
|
settings.update(config.get_tv_parameters())
|
||||||
|
settings.update(config.get_import_parameters())
|
||||||
|
settings.update(config.get_default_paths())
|
||||||
|
|
||||||
|
if(options.gui == True):
|
||||||
|
i = GuiAutoImport(settings, config)
|
||||||
|
main_window = gtk.Window()
|
||||||
|
main_window.connect('destroy', destroy)
|
||||||
|
main_window.add(i.mainVBox)
|
||||||
|
main_window.show()
|
||||||
|
gtk.main()
|
||||||
|
else:
|
||||||
|
pass
|
||||||
|
|
||||||
i = GuiAutoImport(settings)
|
|
||||||
main_window = gtk.Window()
|
|
||||||
main_window.connect("destroy", destroy)
|
|
||||||
main_window.add(i.mainVBox)
|
|
||||||
main_window.show()
|
|
||||||
gtk.main()
|
|
||||||
|
|
|
@ -1,156 +1,267 @@
|
||||||
#!/usr/bin/python
|
#!/usr/bin/python
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
#Copyright 2008 Steffen Jobbagy-Felso
|
# Copyright 2008 Steffen Jobbagy-Felso
|
||||||
#This program is free software: you can redistribute it and/or modify
|
# 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
|
# it under the terms of the GNU Affero General Public License as published by
|
||||||
#the Free Software Foundation, version 3 of the License.
|
# the Free Software Foundation, version 3 of the License.
|
||||||
#
|
#
|
||||||
#This program is distributed in the hope that it will be useful,
|
# This program is distributed in the hope that it will be useful,
|
||||||
#but WITHOUT ANY WARRANTY; without even the implied warranty of
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
#GNU General Public License for more details.
|
# GNU General Public License for more details.
|
||||||
#
|
#
|
||||||
#You should have received a copy of the GNU Affero General Public License
|
# 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/>.
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
#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.
|
||||||
|
|
||||||
import threading
|
# Standard Library modules
|
||||||
import fpdb_simple
|
import os
|
||||||
import fpdb_import
|
import sys
|
||||||
|
from time import time
|
||||||
|
from optparse import OptionParser
|
||||||
|
|
||||||
|
# pyGTK modules
|
||||||
import pygtk
|
import pygtk
|
||||||
pygtk.require('2.0')
|
pygtk.require('2.0')
|
||||||
import gtk
|
import gtk
|
||||||
import os #todo: remove this once import_dir is in fpdb_import
|
|
||||||
from time import time
|
|
||||||
|
|
||||||
class GuiBulkImport (threading.Thread):
|
# fpdb/FreePokerTools modules
|
||||||
def import_dir(self):
|
import fpdb_simple
|
||||||
"""imports a directory, non-recursive. todo: move this to fpdb_import so CLI can use it"""
|
import fpdb_import
|
||||||
self.path=self.inputFile
|
import fpdb_db
|
||||||
self.importer.addImportDirectory(self.path)
|
import Configuration
|
||||||
self.importer.setCallHud(False)
|
|
||||||
starttime = time()
|
|
||||||
self.importer.runImport()
|
|
||||||
print "GuiBulkImport.import_dir done in %s" %(time() - starttime)
|
|
||||||
|
|
||||||
def load_clicked(self, widget, data=None):
|
class GuiBulkImport():
|
||||||
self.inputFile=self.chooser.get_filename()
|
|
||||||
|
|
||||||
self.handCount=self.hand_count_tbuffer.get_text(self.hand_count_tbuffer.get_start_iter(), self.hand_count_tbuffer.get_end_iter())
|
def import_dir(self):
|
||||||
if (self.handCount=="unlimited" or self.handCount=="Unlimited"):
|
"""imports a directory, non-recursive. todo: move this to fpdb_import so CLI can use it"""
|
||||||
self.importer.setHandCount(0)
|
|
||||||
else:
|
|
||||||
self.importer.setHandCount(int(self.handCount))
|
|
||||||
|
|
||||||
self.errorFile="failed.txt"
|
self.path = self.inputFile
|
||||||
|
self.importer.addImportDirectory(self.path)
|
||||||
|
self.importer.setCallHud(False)
|
||||||
|
starttime = time()
|
||||||
|
if not self.importer.settings['threads'] > 1:
|
||||||
|
(stored, dups, partial, errs, ttime) = self.importer.runImport()
|
||||||
|
print 'GuiBulkImport.import_dir done: Stored: %d Duplicates: %d Partial: %d Errors: %d in %s seconds - %d/sec'\
|
||||||
|
% (stored, dups, partial, errs, ttime, stored / ttime)
|
||||||
|
else:
|
||||||
|
self.importer.RunImportThreaded()
|
||||||
|
|
||||||
self.minPrint=self.min_print_tbuffer.get_text(self.min_print_tbuffer.get_start_iter(), self.min_print_tbuffer.get_end_iter())
|
def load_clicked(self, widget, data=None):
|
||||||
if (self.minPrint=="never" or self.minPrint=="Never"):
|
# get the dir to import from the chooser
|
||||||
self.importer.setMinPrint(0)
|
self.inputFile = self.chooser.get_filename()
|
||||||
else:
|
|
||||||
self.importer.setMinPrint=int(self.minPrint)
|
|
||||||
|
|
||||||
self.quiet=self.info_tbuffer.get_text(self.info_tbuffer.get_start_iter(), self.info_tbuffer.get_end_iter())
|
# get the import settings from the gui and save in the importer
|
||||||
if (self.quiet=="yes"):
|
self.importer.setHandCount(int(self.spin_hands.get_text()))
|
||||||
self.importer.setQuiet(False)
|
self.importer.setMinPrint(int(self.spin_hands.get_text()))
|
||||||
else:
|
self.importer.setQuiet(self.chk_st_st.get_active())
|
||||||
self.importer.setQuiet(True)
|
self.importer.setFailOnError(self.chk_fail.get_active())
|
||||||
|
self.importer.setThreads(int(self.spin_threads.get_text()))
|
||||||
|
self.importer.setHandsInDB(self.n_hands_in_db)
|
||||||
|
cb_model = self.cb_dropindexes.get_model()
|
||||||
|
cb_index = self.cb_dropindexes.get_active()
|
||||||
|
if cb_index:
|
||||||
|
self.importer.setDropIndexes(cb_model[cb_index][0])
|
||||||
|
else:
|
||||||
|
self.importer.setDropIndexes("auto")
|
||||||
|
hhc=self.cbfilter.get_model()[self.cbfilter.get_active()][0]
|
||||||
|
self.lab_info.set_text("Importing")
|
||||||
|
|
||||||
self.failOnError=self.fail_error_tbuffer.get_text(self.fail_error_tbuffer.get_start_iter(), self.fail_error_tbuffer.get_end_iter())
|
self.importer.addBulkImportImportFileOrDir(self.inputFile,filter=hhc)
|
||||||
if (self.failOnError=="no"):
|
self.importer.setCallHud(False)
|
||||||
self.importer.setFailOnError(False)
|
starttime = time()
|
||||||
else:
|
(stored, dups, partial, errs, ttime) = self.importer.runImport()
|
||||||
self.importer.setFailOnError(True)
|
print 'GuiBulkImport.import_dir done: Stored: %d \tDuplicates: %d \tPartial: %d \tErrors: %d in %s seconds - %d/sec'\
|
||||||
|
% (stored, dups, partial, errs, ttime, stored / ttime)
|
||||||
|
self.importer.clearFileList()
|
||||||
|
|
||||||
if os.path.isdir(self.inputFile):
|
self.lab_info.set_text("Import finished")
|
||||||
self.import_dir()
|
|
||||||
else:
|
|
||||||
self.importer.addImportFile(self.inputFile)
|
|
||||||
self.importer.setCallHud(False)
|
|
||||||
self.importer.runImport()
|
|
||||||
self.importer.clearFileList()
|
|
||||||
|
|
||||||
def get_vbox(self):
|
def get_vbox(self):
|
||||||
"""returns the vbox of this thread"""
|
"""returns the vbox of this thread"""
|
||||||
return self.vbox
|
return self.vbox
|
||||||
#end def get_vbox
|
|
||||||
|
|
||||||
def run (self):
|
def __init__(self, db, settings, config):
|
||||||
print "todo: implement bulk import thread"
|
self.db = db # this is an instance of fpdb_db
|
||||||
#end def run
|
self.settings = settings
|
||||||
|
self.config = config
|
||||||
|
self.importer = fpdb_import.Importer(self, self.settings,
|
||||||
|
config)
|
||||||
|
|
||||||
def __init__(self, db, settings, config):
|
self.vbox = gtk.VBox(False, 0)
|
||||||
self.db=db
|
self.vbox.show()
|
||||||
self.settings=settings
|
|
||||||
self.config=config
|
|
||||||
self.importer = fpdb_import.Importer(self,self.settings, config)
|
|
||||||
|
|
||||||
self.vbox=gtk.VBox(False,1)
|
self.chooser = gtk.FileChooserWidget()
|
||||||
self.vbox.show()
|
self.chooser.set_filename(self.settings['bulkImport-defaultPath'])
|
||||||
|
self.vbox.add(self.chooser)
|
||||||
|
self.chooser.show()
|
||||||
|
|
||||||
self.chooser = gtk.FileChooserWidget()
|
# Table widget to hold the settings
|
||||||
self.chooser.set_filename(self.settings['bulkImport-defaultPath'])
|
self.table = gtk.Table(rows = 3, columns = 5, homogeneous = False)
|
||||||
#chooser.set_default_response(gtk.RESPONSE_OK)
|
self.vbox.add(self.table)
|
||||||
#self.filesel.ok_button.connect_object("clicked", gtk.Widget.destroy, self.filesel)
|
self.table.show()
|
||||||
self.vbox.add(self.chooser)
|
|
||||||
self.chooser.show()
|
# checkbox - print start/stop?
|
||||||
|
self.chk_st_st = gtk.CheckButton('Print Start/Stop Info')
|
||||||
|
self.table.attach(self.chk_st_st, 0, 1, 0, 1, xpadding = 10, ypadding = 0, yoptions=gtk.SHRINK)
|
||||||
|
self.chk_st_st.show()
|
||||||
|
self.chk_st_st.set_active(True)
|
||||||
|
|
||||||
|
# label - status
|
||||||
|
self.lab_status = gtk.Label("Hands/status print:")
|
||||||
|
self.table.attach(self.lab_status, 1, 2, 0, 1, xpadding = 0, ypadding = 0, yoptions=gtk.SHRINK)
|
||||||
|
self.lab_status.show()
|
||||||
|
self.lab_status.set_justify(gtk.JUSTIFY_RIGHT)
|
||||||
|
|
||||||
|
# spin button - status
|
||||||
|
status_adj = gtk.Adjustment(value=100, lower=0, upper=300, step_incr=10, page_incr=1, page_size=0) #not sure what upper value should be!
|
||||||
|
self.spin_status = gtk.SpinButton(adjustment=status_adj, climb_rate=0.0, digits=0)
|
||||||
|
self.table.attach(self.spin_status, 2, 3, 0, 1, xpadding = 10, ypadding = 0, yoptions=gtk.SHRINK)
|
||||||
|
self.spin_status.show()
|
||||||
|
|
||||||
|
# label - threads
|
||||||
|
self.lab_threads = gtk.Label("Number of threads:")
|
||||||
|
self.table.attach(self.lab_threads, 3, 4, 0, 1, xpadding = 0, ypadding = 0, yoptions=gtk.SHRINK)
|
||||||
|
self.lab_threads.show()
|
||||||
|
self.lab_threads.set_sensitive(False)
|
||||||
|
self.lab_threads.set_justify(gtk.JUSTIFY_RIGHT)
|
||||||
|
|
||||||
|
# spin button - threads
|
||||||
|
threads_adj = gtk.Adjustment(value=0, lower=0, upper=10, step_incr=1, page_incr=1, page_size=0) #not sure what upper value should be!
|
||||||
|
self.spin_threads = gtk.SpinButton(adjustment=threads_adj, climb_rate=0.0, digits=0)
|
||||||
|
self.table.attach(self.spin_threads, 4, 5, 0, 1, xpadding = 0, ypadding = 0, yoptions=gtk.SHRINK)
|
||||||
|
self.spin_threads.show()
|
||||||
|
self.spin_threads.set_sensitive(False)
|
||||||
|
|
||||||
|
# checkbox - fail on error?
|
||||||
|
self.chk_fail = gtk.CheckButton('Fail on error')
|
||||||
|
self.table.attach(self.chk_fail, 0, 1, 1, 2, xpadding = 10, ypadding = 0, yoptions=gtk.SHRINK)
|
||||||
|
self.chk_fail.show()
|
||||||
|
|
||||||
|
# label - hands
|
||||||
|
self.lab_hands = gtk.Label("Hands/file:")
|
||||||
|
self.table.attach(self.lab_hands, 1, 2, 1, 2, xpadding = 0, ypadding = 0, yoptions=gtk.SHRINK)
|
||||||
|
self.lab_hands.show()
|
||||||
|
self.lab_hands.set_justify(gtk.JUSTIFY_RIGHT)
|
||||||
|
|
||||||
|
# spin button - hands to import
|
||||||
|
hands_adj = gtk.Adjustment(value=0, lower=0, upper=10, step_incr=1, page_incr=1, page_size=0) #not sure what upper value should be!
|
||||||
|
self.spin_hands = gtk.SpinButton(adjustment=hands_adj, climb_rate=0.0, digits=0)
|
||||||
|
self.table.attach(self.spin_hands, 2, 3, 1, 2, xpadding = 10, ypadding = 0, yoptions=gtk.SHRINK)
|
||||||
|
self.spin_hands.show()
|
||||||
|
|
||||||
|
# label - drop indexes
|
||||||
|
self.lab_drop = gtk.Label("Drop indexes:")
|
||||||
|
self.table.attach(self.lab_drop, 3, 4, 1, 2, xpadding = 0, ypadding = 0, yoptions=gtk.SHRINK)
|
||||||
|
self.lab_drop.show()
|
||||||
|
self.lab_drop.set_justify(gtk.JUSTIFY_RIGHT)
|
||||||
|
|
||||||
|
# ComboBox - drop indexes
|
||||||
|
self.cb_dropindexes = gtk.combo_box_new_text()
|
||||||
|
self.cb_dropindexes.append_text('auto')
|
||||||
|
self.cb_dropindexes.append_text("don't drop")
|
||||||
|
self.cb_dropindexes.append_text('drop')
|
||||||
|
self.cb_dropindexes.set_active(0)
|
||||||
|
self.table.attach(self.cb_dropindexes, 4, 5, 1, 2, xpadding = 10, ypadding = 0, yoptions=gtk.SHRINK)
|
||||||
|
self.cb_dropindexes.show()
|
||||||
|
|
||||||
|
# label - filter
|
||||||
|
self.lab_filter = gtk.Label("Site filter:")
|
||||||
|
self.table.attach(self.lab_filter, 2, 3, 2, 3, xpadding = 0, ypadding = 0, yoptions=gtk.SHRINK)
|
||||||
|
self.lab_filter.show()
|
||||||
|
self.lab_filter.set_justify(gtk.JUSTIFY_RIGHT)
|
||||||
|
|
||||||
|
# ComboBox - filter
|
||||||
|
self.cbfilter = gtk.combo_box_new_text()
|
||||||
|
self.cbfilter.append_text("passthrough")
|
||||||
|
self.cbfilter.append_text("BetfairToFpdb")
|
||||||
|
self.cbfilter.append_text("EverleafToFpdb")
|
||||||
|
self.cbfilter.append_text("FulltiltToFpdb")
|
||||||
|
self.cbfilter.append_text("PokerStarsToFpdb")
|
||||||
|
self.cbfilter.set_active(0)
|
||||||
|
self.table.attach(self.cbfilter, 3, 4, 2, 3, xpadding = 10, ypadding = 0, yoptions=gtk.SHRINK)
|
||||||
|
self.cbfilter.show()
|
||||||
|
|
||||||
|
# label - info
|
||||||
|
self.lab_info = gtk.Label()
|
||||||
|
self.table.attach(self.lab_info, 0, 4, 2, 3, xpadding = 0, ypadding = 0, yoptions=gtk.SHRINK)
|
||||||
|
self.lab_info.show()
|
||||||
|
|
||||||
|
# button - Import
|
||||||
|
self.load_button = gtk.Button('Import') # todo: rename variables to import too
|
||||||
|
self.load_button.connect('clicked', self.load_clicked,
|
||||||
|
'Import clicked')
|
||||||
|
self.table.attach(self.load_button, 4, 5, 2, 3, xpadding = 0, ypadding = 0, yoptions=gtk.SHRINK)
|
||||||
|
self.load_button.show()
|
||||||
|
|
||||||
|
# see how many hands are in the db and adjust accordingly
|
||||||
|
tcursor = self.importer.fdb.db.cursor()
|
||||||
|
tcursor.execute("Select count(1) from Hands")
|
||||||
|
row = tcursor.fetchone()
|
||||||
|
tcursor.close()
|
||||||
|
self.n_hands_in_db = row[0]
|
||||||
|
if self.n_hands_in_db == 0:
|
||||||
|
self.cb_dropindexes.set_active(2)
|
||||||
|
self.cb_dropindexes.set_sensitive(False)
|
||||||
|
self.lab_drop.set_sensitive(False)
|
||||||
|
|
||||||
|
def main(argv=None):
|
||||||
|
"""main can also be called in the python interpreter, by supplying the command line as the argument."""
|
||||||
|
if argv is None:
|
||||||
|
argv = sys.argv[1:]
|
||||||
|
|
||||||
|
def destroy(*args): # call back for terminating the main eventloop
|
||||||
|
gtk.main_quit()
|
||||||
|
|
||||||
|
parser = OptionParser()
|
||||||
|
parser.add_option("-f", "--file", dest="filename", metavar="FILE", default=None,
|
||||||
|
help="Input file in quiet mode")
|
||||||
|
parser.add_option("-q", "--quiet", action="store_false", dest="gui", default=True,
|
||||||
|
help="don't start gui; deprecated (just give a filename with -f).")
|
||||||
|
parser.add_option("-c", "--convert", dest="filtername", default="passthrough", metavar="FILTER",
|
||||||
|
help="Conversion filter (*passthrough, FullTiltToFpdb, PokerStarsToFpdb, EverleafToFpdb)")
|
||||||
|
parser.add_option("-x", "--failOnError", action="store_true", default=False,
|
||||||
|
help="If this option is passed it quits when it encounters any error")
|
||||||
|
parser.add_option("-m", "--minPrint", "--status", dest="minPrint", default="0", type="int",
|
||||||
|
help="How often to print a one-line status report (0 (default) means never)")
|
||||||
|
(options, sys.argv) = parser.parse_args(args = argv)
|
||||||
|
|
||||||
|
config = Configuration.Config()
|
||||||
|
db = None
|
||||||
|
|
||||||
|
settings = {}
|
||||||
|
settings['minPrint'] = options.minPrint
|
||||||
|
if os.name == 'nt': settings['os'] = 'windows'
|
||||||
|
else: settings['os'] = 'linuxmac'
|
||||||
|
|
||||||
|
settings.update(config.get_db_parameters())
|
||||||
|
settings.update(config.get_tv_parameters())
|
||||||
|
settings.update(config.get_import_parameters())
|
||||||
|
settings.update(config.get_default_paths())
|
||||||
|
|
||||||
|
if not options.gui:
|
||||||
|
print '-q is deprecated. Just use "-f filename" instead'
|
||||||
|
# This is because -q on its own causes an error, so -f is necessary and sufficient for cmd line use
|
||||||
|
if not options.filename:
|
||||||
|
i = GuiBulkImport(db, settings, config)
|
||||||
|
main_window = gtk.Window()
|
||||||
|
main_window.connect('destroy', destroy)
|
||||||
|
main_window.add(i.vbox)
|
||||||
|
main_window.show()
|
||||||
|
gtk.main()
|
||||||
|
else:
|
||||||
|
#Do something useful
|
||||||
|
importer = fpdb_import.Importer(False,settings, config)
|
||||||
|
importer.setDropIndexes("auto")
|
||||||
|
importer.setFailOnError(options.failOnError)
|
||||||
|
importer.addBulkImportImportFileOrDir(os.path.expanduser(options.filename), filter=options.filtername)
|
||||||
|
importer.setCallHud(False)
|
||||||
|
importer.runImport()
|
||||||
|
importer.clearFileList()
|
||||||
|
|
||||||
|
|
||||||
self.settings_hbox = gtk.HBox(False, 0)
|
if __name__ == '__main__':
|
||||||
self.vbox.pack_end(self.settings_hbox, False, True, 0)
|
sys.exit(main())
|
||||||
self.settings_hbox.show()
|
|
||||||
|
|
||||||
self.hand_count_label = gtk.Label("Hands to import per file")
|
|
||||||
self.settings_hbox.add(self.hand_count_label)
|
|
||||||
self.hand_count_label.show()
|
|
||||||
|
|
||||||
self.hand_count_tbuffer=gtk.TextBuffer()
|
|
||||||
self.hand_count_tbuffer.set_text("unlimited")
|
|
||||||
self.hand_count_tview=gtk.TextView(self.hand_count_tbuffer)
|
|
||||||
self.settings_hbox.add(self.hand_count_tview)
|
|
||||||
self.hand_count_tview.show()
|
|
||||||
|
|
||||||
self.min_hands_label = gtk.Label("Status every")
|
|
||||||
self.settings_hbox.add(self.min_hands_label)
|
|
||||||
self.min_hands_label.show()
|
|
||||||
|
|
||||||
self.min_print_tbuffer=gtk.TextBuffer()
|
|
||||||
self.min_print_tbuffer.set_text("never")
|
|
||||||
self.min_print_tview=gtk.TextView(self.min_print_tbuffer)
|
|
||||||
self.settings_hbox.add(self.min_print_tview)
|
|
||||||
self.min_print_tview.show()
|
|
||||||
|
|
||||||
|
|
||||||
self.toggles_hbox = gtk.HBox(False, 0)
|
|
||||||
self.vbox.pack_end(self.toggles_hbox, False, True, 0)
|
|
||||||
self.toggles_hbox.show()
|
|
||||||
|
|
||||||
self.info_label = gtk.Label("Print start/end info:")
|
|
||||||
self.toggles_hbox.add(self.info_label)
|
|
||||||
self.info_label.show()
|
|
||||||
|
|
||||||
self.info_tbuffer=gtk.TextBuffer()
|
|
||||||
self.info_tbuffer.set_text("yes")
|
|
||||||
self.info_tview=gtk.TextView(self.info_tbuffer)
|
|
||||||
self.toggles_hbox.add(self.info_tview)
|
|
||||||
self.info_tview.show()
|
|
||||||
|
|
||||||
self.fail_error_label = gtk.Label("Fail on error:")
|
|
||||||
self.toggles_hbox.add(self.fail_error_label)
|
|
||||||
self.fail_error_label.show()
|
|
||||||
|
|
||||||
self.fail_error_tbuffer=gtk.TextBuffer()
|
|
||||||
self.fail_error_tbuffer.set_text("no")
|
|
||||||
self.fail_error_tview=gtk.TextView(self.fail_error_tbuffer)
|
|
||||||
self.toggles_hbox.add(self.fail_error_tview)
|
|
||||||
self.fail_error_tview.show()
|
|
||||||
|
|
||||||
self.load_button = gtk.Button("Import") #todo: rename variables to import too
|
|
||||||
self.load_button.connect("clicked", self.load_clicked, "Import clicked")
|
|
||||||
self.toggles_hbox.add(self.load_button)
|
|
||||||
self.load_button.show()
|
|
||||||
|
|
||||||
threading.Thread.__init__ ( self )
|
|
||||||
print "initialised new bulk import thread (not actually a thread yet)"
|
|
||||||
#end class import_threaded
|
|
||||||
|
|
|
@ -20,7 +20,7 @@ import pygtk
|
||||||
pygtk.require('2.0')
|
pygtk.require('2.0')
|
||||||
import gtk
|
import gtk
|
||||||
import os
|
import os
|
||||||
from time import time
|
from time import *
|
||||||
#import pokereval
|
#import pokereval
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
@ -46,9 +46,15 @@ class GuiGraphViewer (threading.Thread):
|
||||||
return self.mainHBox
|
return self.mainHBox
|
||||||
#end def get_vbox
|
#end def get_vbox
|
||||||
|
|
||||||
|
def clearGraphData(self):
|
||||||
|
self.fig.clf()
|
||||||
|
if self.canvas is not None:
|
||||||
|
self.canvas.destroy()
|
||||||
|
|
||||||
|
self.canvas = FigureCanvas(self.fig) # a gtk.DrawingArea
|
||||||
|
|
||||||
def generateGraph(self, widget, data):
|
def generateGraph(self, widget, data):
|
||||||
try: self.canvas.destroy()
|
self.clearGraphData()
|
||||||
except AttributeError: pass
|
|
||||||
|
|
||||||
sitenos = []
|
sitenos = []
|
||||||
playerids = []
|
playerids = []
|
||||||
|
@ -62,17 +68,16 @@ class GuiGraphViewer (threading.Thread):
|
||||||
if len(result) == 1:
|
if len(result) == 1:
|
||||||
playerids.append(result[0][0])
|
playerids.append(result[0][0])
|
||||||
|
|
||||||
if sitenos == []:
|
if not sitenos:
|
||||||
#Should probably pop up here.
|
#Should probably pop up here.
|
||||||
print "No sites selected - defaulting to PokerStars"
|
print "No sites selected - defaulting to PokerStars"
|
||||||
sitenos = [2]
|
sitenos = [2]
|
||||||
|
|
||||||
|
|
||||||
if playerids == []:
|
if not playerids:
|
||||||
print "No player ids found"
|
print "No player ids found"
|
||||||
return
|
return
|
||||||
|
|
||||||
self.fig = Figure(figsize=(5,4), dpi=100)
|
|
||||||
|
|
||||||
#Set graph properties
|
#Set graph properties
|
||||||
self.ax = self.fig.add_subplot(111)
|
self.ax = self.fig.add_subplot(111)
|
||||||
|
@ -104,9 +109,9 @@ class GuiGraphViewer (threading.Thread):
|
||||||
#Draw plot
|
#Draw plot
|
||||||
self.ax.plot(line,)
|
self.ax.plot(line,)
|
||||||
|
|
||||||
self.canvas = FigureCanvas(self.fig) # a gtk.DrawingArea
|
|
||||||
self.graphBox.add(self.canvas)
|
self.graphBox.add(self.canvas)
|
||||||
self.canvas.show()
|
self.canvas.show()
|
||||||
|
self.exportButton.set_sensitive(True)
|
||||||
#end of def showClicked
|
#end of def showClicked
|
||||||
|
|
||||||
def getRingProfitGraph(self, names, sites):
|
def getRingProfitGraph(self, names, sites):
|
||||||
|
@ -279,16 +284,24 @@ class GuiGraphViewer (threading.Thread):
|
||||||
win.destroy()
|
win.destroy()
|
||||||
|
|
||||||
def exportGraph (self, widget, data):
|
def exportGraph (self, widget, data):
|
||||||
|
if self.fig is None:
|
||||||
|
return # Might want to disable export button until something has been generated.
|
||||||
dia_chooser = gtk.FileChooserDialog(title="Please choose the directory you wish to export to:",
|
dia_chooser = gtk.FileChooserDialog(title="Please choose the directory you wish to export to:",
|
||||||
action=gtk.FILE_CHOOSER_ACTION_OPEN,
|
action=gtk.FILE_CHOOSER_ACTION_OPEN,
|
||||||
buttons=(gtk.STOCK_CANCEL,gtk.RESPONSE_CANCEL,gtk.STOCK_OPEN,gtk.RESPONSE_OK))
|
buttons=(gtk.STOCK_CANCEL,gtk.RESPONSE_CANCEL,gtk.STOCK_OPEN,gtk.RESPONSE_OK))
|
||||||
|
#TODO: Suggest path and filename to start with
|
||||||
|
|
||||||
response = dia_chooser.run()
|
response = dia_chooser.run()
|
||||||
if response == gtk.RESPONSE_OK:
|
if response == gtk.RESPONSE_OK:
|
||||||
self.exportDir = dia_chooser.get_filename()
|
self.exportDir = dia_chooser.get_filename()
|
||||||
|
print "DEBUG: self.exportDir = %s" %(self.exportDir)
|
||||||
elif response == gtk.RESPONSE_CANCEL:
|
elif response == gtk.RESPONSE_CANCEL:
|
||||||
print 'Closed, no graph exported'
|
print 'Closed, no graph exported'
|
||||||
dia_chooser.destroy()
|
dia_chooser.destroy()
|
||||||
|
#TODO: Check to see if file exists
|
||||||
|
#NOTE: Dangerous - will happily overwrite any file we have write access too
|
||||||
|
#TODO: This asks for a directory but will take a filename and overwrite it.
|
||||||
|
self.fig.savefig(self.exportDir, format="png")
|
||||||
|
|
||||||
def __init__(self, db, settings, querylist, config, debug=True):
|
def __init__(self, db, settings, querylist, config, debug=True):
|
||||||
"""Constructor for GraphViewer"""
|
"""Constructor for GraphViewer"""
|
||||||
|
@ -354,8 +367,10 @@ class GuiGraphViewer (threading.Thread):
|
||||||
graphButton.connect("clicked", self.generateGraph, "cliced data")
|
graphButton.connect("clicked", self.generateGraph, "cliced data")
|
||||||
graphButton.show()
|
graphButton.show()
|
||||||
|
|
||||||
|
self.fig = None
|
||||||
self.exportButton=gtk.Button("Export to File")
|
self.exportButton=gtk.Button("Export to File")
|
||||||
self.exportButton.connect("clicked", self.exportGraph, "show clicked")
|
self.exportButton.connect("clicked", self.exportGraph, "show clicked")
|
||||||
|
self.exportButton.set_sensitive(False)
|
||||||
self.exportButton.show()
|
self.exportButton.show()
|
||||||
|
|
||||||
self.leftPanelBox.add(playerFrame)
|
self.leftPanelBox.add(playerFrame)
|
||||||
|
@ -366,3 +381,34 @@ class GuiGraphViewer (threading.Thread):
|
||||||
|
|
||||||
self.leftPanelBox.show()
|
self.leftPanelBox.show()
|
||||||
self.graphBox.show()
|
self.graphBox.show()
|
||||||
|
|
||||||
|
self.fig = Figure(figsize=(5,4), dpi=100)
|
||||||
|
self.canvas = None
|
||||||
|
|
||||||
|
#################################
|
||||||
|
#
|
||||||
|
# self.db.cursor.execute("""select UNIX_TIMESTAMP(handStart) as time, id from Hands ORDER BY time""")
|
||||||
|
# THRESHOLD = 1800
|
||||||
|
# hands = self.db.cursor.fetchall()
|
||||||
|
#
|
||||||
|
# times = map(lambda x:long(x[0]), hands)
|
||||||
|
# handids = map(lambda x:int(x[1]), hands)
|
||||||
|
# print "DEBUG: len(times) %s" %(len(times))
|
||||||
|
# diffs = diff(times)
|
||||||
|
# print "DEBUG: len(diffs) %s" %(len(diffs))
|
||||||
|
# index = nonzero(diff(times) > THRESHOLD)
|
||||||
|
# print "DEBUG: len(index[0]) %s" %(len(index[0]))
|
||||||
|
# print "DEBUG: index %s" %(index)
|
||||||
|
# print "DEBUG: index[0][0] %s" %(index[0][0])
|
||||||
|
#
|
||||||
|
# total = 0
|
||||||
|
#
|
||||||
|
# last_idx = 0
|
||||||
|
# for i in range(len(index[0])):
|
||||||
|
# print "Hands in session %4s: %4s Start: %s End: %s Total: %s" %(i, index[0][i] - last_idx, strftime("%d/%m/%Y %H:%M", localtime(times[last_idx])), strftime("%d/%m/%Y %H:%M", localtime(times[index[0][i]])), times[index[0][i]] - times[last_idx])
|
||||||
|
# total = total + (index[0][i] - last_idx)
|
||||||
|
# last_idx = index[0][i] + 1
|
||||||
|
#
|
||||||
|
# print "Total: ", total
|
||||||
|
#################################
|
||||||
|
|
||||||
|
|
|
@ -67,7 +67,7 @@ class GuiPlayerStats (threading.Thread):
|
||||||
for t in titles:
|
for t in titles:
|
||||||
l = gtk.Label(titles[col])
|
l = gtk.Label(titles[col])
|
||||||
l.show()
|
l.show()
|
||||||
self.stats_table.attach(l, col, col+1, row, row+1)
|
self.stats_table.attach(l, col, col+1, row, row+1, yoptions=gtk.SHRINK)
|
||||||
col +=1
|
col +=1
|
||||||
|
|
||||||
for row in range(rows-1):
|
for row in range(rows-1):
|
||||||
|
@ -87,7 +87,7 @@ class GuiPlayerStats (threading.Thread):
|
||||||
else:
|
else:
|
||||||
l.set_alignment(xalign=1.0, yalign=0.5)
|
l.set_alignment(xalign=1.0, yalign=0.5)
|
||||||
eb.add(l)
|
eb.add(l)
|
||||||
self.stats_table.attach(eb, col, col+1, row+1, row+2)
|
self.stats_table.attach(eb, col, col+1, row+1, row+2, yoptions=gtk.SHRINK)
|
||||||
l.show()
|
l.show()
|
||||||
eb.show()
|
eb.show()
|
||||||
self.fdb.db.commit()
|
self.fdb.db.commit()
|
||||||
|
|
211
pyfpdb/GuiPositionalStats.py
Normal file
|
@ -0,0 +1,211 @@
|
||||||
|
#!/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 threading
|
||||||
|
import pygtk
|
||||||
|
pygtk.require('2.0')
|
||||||
|
import gtk
|
||||||
|
import os
|
||||||
|
|
||||||
|
import fpdb_import
|
||||||
|
import fpdb_db
|
||||||
|
import FpdbSQLQueries
|
||||||
|
|
||||||
|
class GuiPositionalStats (threading.Thread):
|
||||||
|
def get_vbox(self):
|
||||||
|
"""returns the vbox of this thread"""
|
||||||
|
return self.main_hbox
|
||||||
|
|
||||||
|
def toggleCallback(self, widget, data=None):
|
||||||
|
# print "%s was toggled %s" % (data, ("OFF", "ON")[widget.get_active()])
|
||||||
|
self.activesite = data
|
||||||
|
print "DEBUG: activesite set to %s" %(self.activesite)
|
||||||
|
|
||||||
|
def cardCallback(self, widget, data=None):
|
||||||
|
print "DEBUG: %s was toggled %s" % (data, ("OFF", "ON")[widget.get_active()])
|
||||||
|
|
||||||
|
def refreshStats(self, widget, data):
|
||||||
|
try: self.stats_table.destroy()
|
||||||
|
except AttributeError: pass
|
||||||
|
self.fillStatsFrame(self.stats_frame)
|
||||||
|
|
||||||
|
def fillStatsFrame(self, vbox):
|
||||||
|
# Get currently active site and grab playerid
|
||||||
|
print "DEBUG: attempting to fill stats frame"
|
||||||
|
tmp = self.sql.query['playerStatsByPosition']
|
||||||
|
|
||||||
|
result = self.cursor.execute(self.sql.query['getPlayerId'], (self.heroes[self.activesite],))
|
||||||
|
result = self.cursor.fetchall()
|
||||||
|
if not result == ():
|
||||||
|
pid = result[0][0]
|
||||||
|
pid = result[0][0]
|
||||||
|
tmp = tmp.replace("<player_test>", "(" + str(pid) + ")")
|
||||||
|
self.cursor.execute(tmp)
|
||||||
|
result = self.cursor.fetchall()
|
||||||
|
cols = 16
|
||||||
|
rows = len(result)+1 # +1 for title row
|
||||||
|
self.stats_table = gtk.Table(rows, cols, False)
|
||||||
|
self.stats_table.set_col_spacings(4)
|
||||||
|
self.stats_table.show()
|
||||||
|
vbox.add(self.stats_table)
|
||||||
|
|
||||||
|
# Create header row
|
||||||
|
titles = ("Game", "Position", "#", "VPIP", "PFR", "Saw_F", "SawSD", "WtSDwsF", "W$SD", "FlAFq", "TuAFq", "RvAFq", "PoFAFq", "Net($)", "BB/100", "$/hand", "Variance")
|
||||||
|
|
||||||
|
col = 0
|
||||||
|
row = 0
|
||||||
|
for t in titles:
|
||||||
|
l = gtk.Label(titles[col])
|
||||||
|
l.show()
|
||||||
|
self.stats_table.attach(l, col, col+1, row, row+1, yoptions=gtk.SHRINK)
|
||||||
|
col +=1
|
||||||
|
|
||||||
|
for row in range(rows-1):
|
||||||
|
if(row%2 == 0):
|
||||||
|
bgcolor = "white"
|
||||||
|
else:
|
||||||
|
bgcolor = "lightgrey"
|
||||||
|
for col in range(cols):
|
||||||
|
eb = gtk.EventBox()
|
||||||
|
eb.modify_bg(gtk.STATE_NORMAL, gtk.gdk.color_parse(bgcolor))
|
||||||
|
if result[row][col]:
|
||||||
|
l = gtk.Label(result[row][col])
|
||||||
|
else:
|
||||||
|
l = gtk.Label(' ')
|
||||||
|
if col == 0:
|
||||||
|
l.set_alignment(xalign=0.0, yalign=0.5)
|
||||||
|
else:
|
||||||
|
l.set_alignment(xalign=1.0, yalign=0.5)
|
||||||
|
eb.add(l)
|
||||||
|
self.stats_table.attach(eb, col, col+1, row+1, row+2, yoptions=gtk.SHRINK)
|
||||||
|
l.show()
|
||||||
|
eb.show()
|
||||||
|
self.fdb.db.commit()
|
||||||
|
#end def fillStatsFrame(self, vbox):
|
||||||
|
|
||||||
|
def fillPlayerFrame(self, vbox):
|
||||||
|
for site in self.conf.supported_sites.keys():
|
||||||
|
hbox = gtk.HBox(False, 0)
|
||||||
|
vbox.pack_start(hbox, False, True, 0)
|
||||||
|
hbox.show()
|
||||||
|
|
||||||
|
player = self.conf.supported_sites[site].screen_name
|
||||||
|
self.createPlayerLine(hbox, site, player)
|
||||||
|
hbox = gtk.HBox(False, 0)
|
||||||
|
button = gtk.Button("Refresh")
|
||||||
|
button.connect("clicked", self.refreshStats, False)
|
||||||
|
button.show()
|
||||||
|
hbox.add(button)
|
||||||
|
vbox.pack_start(hbox, False, True, 0)
|
||||||
|
hbox.show()
|
||||||
|
|
||||||
|
def fillCardsFrame(self, vbox):
|
||||||
|
hbox1 = gtk.HBox(True,0)
|
||||||
|
hbox1.show()
|
||||||
|
vbox.pack_start(hbox1, True, True, 0)
|
||||||
|
|
||||||
|
cards = [ "A", "K","Q","J","T","9","8","7","6","5","4","3","2" ]
|
||||||
|
|
||||||
|
for j in range(0, len(cards)):
|
||||||
|
hbox1 = gtk.HBox(True,0)
|
||||||
|
hbox1.show()
|
||||||
|
vbox.pack_start(hbox1, True, True, 0)
|
||||||
|
for i in range(0, len(cards)):
|
||||||
|
if i < (j + 1):
|
||||||
|
suit = "o"
|
||||||
|
else:
|
||||||
|
suit = "s"
|
||||||
|
button = gtk.ToggleButton("%s%s%s" %(cards[i], cards[j], suit))
|
||||||
|
button.connect("toggled", self.cardCallback, "%s%s%s" %(cards[i], cards[j], suit))
|
||||||
|
hbox1.pack_start(button, True, True, 0)
|
||||||
|
button.show()
|
||||||
|
|
||||||
|
def createPlayerLine(self, hbox, site, player):
|
||||||
|
if(self.buttongroup == None):
|
||||||
|
button = gtk.RadioButton(None, site + " id:")
|
||||||
|
button.set_active(True)
|
||||||
|
self.buttongroup = button
|
||||||
|
self.activesite = site
|
||||||
|
else:
|
||||||
|
button = gtk.RadioButton(self.buttongroup, site + " id:")
|
||||||
|
hbox.pack_start(button, True, True, 0)
|
||||||
|
button.connect("toggled", self.toggleCallback, site)
|
||||||
|
button.show()
|
||||||
|
|
||||||
|
pname = gtk.Entry()
|
||||||
|
pname.set_text(player)
|
||||||
|
pname.set_width_chars(20)
|
||||||
|
hbox.pack_start(pname, False, True, 0)
|
||||||
|
pname.connect("changed", self.__set_hero_name, site)
|
||||||
|
#TODO: Look at GtkCompletion - to fill out usernames
|
||||||
|
pname.show()
|
||||||
|
self.__set_hero_name(pname, site)
|
||||||
|
|
||||||
|
def __set_hero_name(self, w, site):
|
||||||
|
self.heroes[site] = w.get_text()
|
||||||
|
|
||||||
|
def __init__(self, db, config, querylist, debug=True):
|
||||||
|
self.debug=debug
|
||||||
|
self.conf=config
|
||||||
|
|
||||||
|
# create new db connection to avoid conflicts with other threads
|
||||||
|
self.fdb = fpdb_db.fpdb_db()
|
||||||
|
self.fdb.do_connect(self.conf)
|
||||||
|
self.cursor=self.fdb.cursor
|
||||||
|
|
||||||
|
self.sql = querylist
|
||||||
|
|
||||||
|
self.activesite = None
|
||||||
|
self.buttongroup = None
|
||||||
|
|
||||||
|
self.heroes = {}
|
||||||
|
self.stat_table = None
|
||||||
|
self.stats_frame = None
|
||||||
|
|
||||||
|
self.main_hbox = gtk.HBox(False, 0)
|
||||||
|
self.main_hbox.show()
|
||||||
|
|
||||||
|
playerFrame = gtk.Frame("Hero:")
|
||||||
|
playerFrame.set_label_align(0.0, 0.0)
|
||||||
|
playerFrame.show()
|
||||||
|
vbox = gtk.VBox(False, 0)
|
||||||
|
vbox.show()
|
||||||
|
|
||||||
|
self.fillPlayerFrame(vbox)
|
||||||
|
playerFrame.add(vbox)
|
||||||
|
|
||||||
|
cardsFrame = gtk.Frame("Cards:")
|
||||||
|
cardsFrame.set_label_align(0.0, 0.0)
|
||||||
|
cardsFrame.show()
|
||||||
|
vbox = gtk.VBox(False, 0)
|
||||||
|
vbox.show()
|
||||||
|
|
||||||
|
self.fillCardsFrame(vbox)
|
||||||
|
cardsFrame.add(vbox)
|
||||||
|
|
||||||
|
statsFrame = gtk.Frame("Stats:")
|
||||||
|
statsFrame.set_label_align(0.0, 0.0)
|
||||||
|
statsFrame.show()
|
||||||
|
self.stats_frame = gtk.VBox(False, 0)
|
||||||
|
self.stats_frame.show()
|
||||||
|
|
||||||
|
self.fillStatsFrame(self.stats_frame)
|
||||||
|
statsFrame.add(self.stats_frame)
|
||||||
|
|
||||||
|
self.main_hbox.pack_start(playerFrame)
|
||||||
|
self.main_hbox.pack_start(statsFrame)
|
||||||
|
|
|
@ -1,19 +1,25 @@
|
||||||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||||
|
|
||||||
<FreePokerToolsConfig xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="FreePokerToolsConfig.xsd">
|
<FreePokerToolsConfig xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="FreePokerToolsConfig.xsd">
|
||||||
|
|
||||||
|
<import callFpdbHud = "True" interval = "10" fastStoreHudCache="False" hhArchiveBase="~/.fpdb/HandHistories/" saveActions="True"></import>
|
||||||
|
|
||||||
<supported_sites>
|
<supported_sites>
|
||||||
|
|
||||||
<site enabled="True"
|
<site enabled="True"
|
||||||
site_name="PokerStars"
|
site_name="PokerStars"
|
||||||
table_finder="PokerStars.exe"
|
table_finder="PokerStars.exe"
|
||||||
screen_name="ENTER HERO NAME"
|
screen_name="YOUR SCREEN NAME HERE"
|
||||||
site_path=""
|
site_path="C:/Program Files/PokerStars/"
|
||||||
HH_path=""
|
HH_path="C:/Program Files/PokerStars/HandHistory/YOUR SCREEN NAME HERE/"
|
||||||
decoder="pokerstars_decode_table"
|
decoder="pokerstars_decode_table"
|
||||||
converter="passthrough"
|
bgcolor="#000000"
|
||||||
bgcolor="#000000"
|
fgcolor="#FFFFFF"
|
||||||
fgcolor="#FFFFFF"
|
hudopacity="1.0"
|
||||||
hudopacity="1.0"
|
font="Sans"
|
||||||
supported_games="holdem,razz,omahahi,omahahilo,studhi,studhilo">
|
font_size="8"
|
||||||
|
converter="passthrough"
|
||||||
|
supported_games="holdem,razz,omahahi,omahahilo,studhi,studhilo">
|
||||||
<layout max="8" width="792" height="546" fav_seat="0">
|
<layout max="8" width="792" height="546" fav_seat="0">
|
||||||
<location seat="1" x="684" y="61"> </location>
|
<location seat="1" x="684" y="61"> </location>
|
||||||
<location seat="2" x="689" y="239"> </location>
|
<location seat="2" x="689" y="239"> </location>
|
||||||
|
@ -60,18 +66,21 @@
|
||||||
<location seat="2" x="10" y="288"> </location>
|
<location seat="2" x="10" y="288"> </location>
|
||||||
</layout>
|
</layout>
|
||||||
</site>
|
</site>
|
||||||
|
|
||||||
<site enabled="True"
|
<site enabled="True"
|
||||||
site_name="Full Tilt Poker"
|
site_name="Full Tilt Poker"
|
||||||
table_finder="FullTiltPoker.exe"
|
table_finder="FullTiltPoker"
|
||||||
screen_name="ENTER HERO NAME"
|
screen_name="YOUR SCREEN NAME HERE"
|
||||||
site_path=""
|
site_path="C:/Program Files/Full Tilt Poker/"
|
||||||
HH_path=""
|
HH_path="C:/Program Files/Full Tilt Poker/HandHistory/YOUR SCREEN NAME HERE/"
|
||||||
decoder="fulltilt_decode_table"
|
decoder="fulltilt_decode_table"
|
||||||
converter="passthrough"
|
bgcolor="#000000"
|
||||||
bgcolor="#000000"
|
fgcolor="#FFFFFF"
|
||||||
fgcolor="#FFFFFF"
|
hudopacity="1.0"
|
||||||
hudopacity="1.0"
|
font="Sans"
|
||||||
supported_games="holdem,razz,omahahi,omahahilo,studhi,studhilo">
|
font_size="8"
|
||||||
|
converter="passthrough"
|
||||||
|
supported_games="holdem,razz,omahahi,omahahilo,studhi,studhilo">
|
||||||
<layout fav_seat="0" height="547" max="8" width="794">
|
<layout fav_seat="0" height="547" max="8" width="794">
|
||||||
<location seat="1" x="640" y="64"> </location>
|
<location seat="1" x="640" y="64"> </location>
|
||||||
<location seat="2" x="650" y="230"> </location>
|
<location seat="2" x="650" y="230"> </location>
|
||||||
|
@ -106,46 +115,55 @@
|
||||||
<location seat="9" x="70" y="53"> </location>
|
<location seat="9" x="70" y="53"> </location>
|
||||||
</layout>
|
</layout>
|
||||||
</site>
|
</site>
|
||||||
|
|
||||||
<site enabled="False"
|
<site enabled="False"
|
||||||
site_name="Everleaf"
|
site_name="Everleaf"
|
||||||
table_finder="Poker.exe"
|
table_finder="Everleaf.exe"
|
||||||
screen_name="ENTER HERO NAME"
|
screen_name="YOUR SCREEN NAME HERE"
|
||||||
site_path=""
|
site_path=""
|
||||||
HH_path=""
|
HH_path=""
|
||||||
decoder="Unknown"
|
decoder="everleaf_decode_table"
|
||||||
converter="EverleafToFpdb"
|
converter="EverleafToFpdb"
|
||||||
supported_games="holdem,razz,omahahi,omahahilo,studhi"
|
supported_games="holdem">
|
||||||
fgcolor="#48D1CC"
|
<layout fav_seat="0" height="547" max="8" width="794">
|
||||||
bgcolor="#000000"
|
<location seat="1" x="640" y="64"> </location>
|
||||||
opacity="0.75">
|
<location seat="2" x="650" y="230"> </location>
|
||||||
<layout fav_seat="0" height="546" max="6" width="792">
|
<location seat="3" x="650" y="385"> </location>
|
||||||
<location seat="1" x="581" y="109"> </location>
|
<location seat="4" x="588" y="425"> </location>
|
||||||
<location seat="2" x="605" y="287"> </location>
|
<location seat="5" x="92" y="425"> </location>
|
||||||
<location seat="3" x="544" y="423"> </location>
|
<location seat="6" x="0" y="373"> </location>
|
||||||
<location seat="4" x="80" y="393"> </location>
|
<location seat="7" x="0" y="223"> </location>
|
||||||
<location seat="5" x="5" y="284"> </location>
|
<location seat="8" x="25" y="50"> </location>
|
||||||
<location seat="6" x="38" y="108"> </location>
|
|
||||||
</layout>
|
</layout>
|
||||||
<layout fav_seat="0" height="546" max="10" width="792">
|
<layout fav_seat="0" height="547" max="6" width="794">
|
||||||
<location seat="1" x="473" y="78"> </location>
|
<location seat="1" x="640" y="58"> </location>
|
||||||
<location seat="2" x="650" y="93"> </location>
|
<location seat="2" x="654" y="288"> </location>
|
||||||
<location seat="3" x="670" y="219"> </location>
|
<location seat="3" x="615" y="424"> </location>
|
||||||
<location seat="4" x="633" y="358"> </location>
|
<location seat="4" x="70" y="421"> </location>
|
||||||
<location seat="5" x="437" y="393"> </location>
|
<location seat="5" x="0" y="280"> </location>
|
||||||
<location seat="6" x="249" y="396"> </location>
|
<location seat="6" x="70" y="58"> </location>
|
||||||
<location seat="7" x="42" y="357"> </location>
|
|
||||||
<location seat="8" x="8" y="218"> </location>
|
|
||||||
<location seat="9" x="35" y="89"> </location>
|
|
||||||
<location seat="10" x="217" y="78"> </location>
|
|
||||||
</layout>
|
</layout>
|
||||||
<layout fav_seat="0" height="546" max="2" width="792">
|
<layout fav_seat="0" height="547" max="2" width="794">
|
||||||
<location seat="1" x="651" y="288"> </location>
|
<location seat="1" x="651" y="288"> </location>
|
||||||
<location seat="2" x="10" y="288"> </location>
|
<location seat="2" x="10" y="288"> </location>
|
||||||
|
</layout>
|
||||||
|
<layout fav_seat="0" height="547" max="9" width="794">
|
||||||
|
<location seat="1" x="634" y="38"> </location>
|
||||||
|
<location seat="2" x="667" y="184"> </location>
|
||||||
|
<location seat="3" x="667" y="321"> </location>
|
||||||
|
<location seat="4" x="667" y="445"> </location>
|
||||||
|
<location seat="5" x="337" y="459"> </location>
|
||||||
|
<location seat="6" x="0" y="400"> </location>
|
||||||
|
<location seat="7" x="0" y="322"> </location>
|
||||||
|
<location seat="8" x="0" y="181"> </location>
|
||||||
|
<location seat="9" x="70" y="53"> </location>
|
||||||
</layout>
|
</layout>
|
||||||
</site>
|
</site>
|
||||||
</supported_sites>
|
</supported_sites>
|
||||||
|
|
||||||
<supported_games>
|
<supported_games>
|
||||||
<game cols="3" db="fpdb" game_name="holdem" rows="2">
|
|
||||||
|
<game cols="3" db="fpdb" game_name="holdem" rows="2" aux="mucked">
|
||||||
<stat click="tog_decorate" col="0" popup="default" row="0" stat_name="vpip" tip="tip1"> </stat>
|
<stat click="tog_decorate" col="0" popup="default" row="0" stat_name="vpip" tip="tip1"> </stat>
|
||||||
<stat click="tog_decorate" col="1" popup="default" row="0" stat_name="pfr" tip="tip1"> </stat>
|
<stat click="tog_decorate" col="1" popup="default" row="0" stat_name="pfr" tip="tip1"> </stat>
|
||||||
<stat click="tog_decorate" col="2" popup="default" row="0" stat_name="ffreq_1" tip="tip1"> </stat>
|
<stat click="tog_decorate" col="2" popup="default" row="0" stat_name="ffreq_1" tip="tip1"> </stat>
|
||||||
|
@ -153,6 +171,7 @@
|
||||||
<stat click="tog_decorate" col="1" popup="default" row="1" stat_name="wtsd" tip="tip1"> </stat>
|
<stat click="tog_decorate" col="1" popup="default" row="1" stat_name="wtsd" tip="tip1"> </stat>
|
||||||
<stat click="tog_decorate" col="2" popup="default" row="1" stat_name="wmsd" tip="tip1"> </stat>
|
<stat click="tog_decorate" col="2" popup="default" row="1" stat_name="wmsd" tip="tip1"> </stat>
|
||||||
</game>
|
</game>
|
||||||
|
|
||||||
<game cols="3" db="fpdb" game_name="razz" rows="2" aux="stud_mucked">
|
<game cols="3" db="fpdb" game_name="razz" rows="2" aux="stud_mucked">
|
||||||
<stat click="tog_decorate" col="0" popup="default" row="0" stat_name="vpip" tip="tip1"> </stat>
|
<stat click="tog_decorate" col="0" popup="default" row="0" stat_name="vpip" tip="tip1"> </stat>
|
||||||
<stat click="tog_decorate" col="1" popup="default" row="0" stat_name="pfr" tip="tip1"> </stat>
|
<stat click="tog_decorate" col="1" popup="default" row="0" stat_name="pfr" tip="tip1"> </stat>
|
||||||
|
@ -161,7 +180,8 @@
|
||||||
<stat click="tog_decorate" col="1" popup="default" row="1" stat_name="wtsd" tip="tip1"> </stat>
|
<stat click="tog_decorate" col="1" popup="default" row="1" stat_name="wtsd" tip="tip1"> </stat>
|
||||||
<stat click="tog_decorate" col="2" popup="default" row="1" stat_name="wmsd" tip="tip1"> </stat>
|
<stat click="tog_decorate" col="2" popup="default" row="1" stat_name="wmsd" tip="tip1"> </stat>
|
||||||
</game>
|
</game>
|
||||||
<game cols="3" db="fpdb" game_name="omahahi" rows="2">
|
|
||||||
|
<game cols="3" db="fpdb" game_name="omahahi" rows="2" aux="mucked">
|
||||||
<stat click="tog_decorate" col="0" popup="default" row="0" stat_name="vpip" tip="tip1"> </stat>
|
<stat click="tog_decorate" col="0" popup="default" row="0" stat_name="vpip" tip="tip1"> </stat>
|
||||||
<stat click="tog_decorate" col="1" popup="default" row="0" stat_name="pfr" tip="tip1"> </stat>
|
<stat click="tog_decorate" col="1" popup="default" row="0" stat_name="pfr" tip="tip1"> </stat>
|
||||||
<stat click="tog_decorate" col="2" popup="default" row="0" stat_name="ffreq_1" tip="tip1"> </stat>
|
<stat click="tog_decorate" col="2" popup="default" row="0" stat_name="ffreq_1" tip="tip1"> </stat>
|
||||||
|
@ -169,7 +189,8 @@
|
||||||
<stat click="tog_decorate" col="1" popup="default" row="1" stat_name="wtsd" tip="tip1"> </stat>
|
<stat click="tog_decorate" col="1" popup="default" row="1" stat_name="wtsd" tip="tip1"> </stat>
|
||||||
<stat click="tog_decorate" col="2" popup="default" row="1" stat_name="wmsd" tip="tip1"> </stat>
|
<stat click="tog_decorate" col="2" popup="default" row="1" stat_name="wmsd" tip="tip1"> </stat>
|
||||||
</game>
|
</game>
|
||||||
<game cols="3" db="fpdb" game_name="omahahilo" rows="2">
|
|
||||||
|
<game cols="3" db="fpdb" game_name="omahahilo" rows="2" aux="mucked">
|
||||||
<stat click="tog_decorate" col="0" popup="default" row="0" stat_name="vpip" tip="tip1"> </stat>
|
<stat click="tog_decorate" col="0" popup="default" row="0" stat_name="vpip" tip="tip1"> </stat>
|
||||||
<stat click="tog_decorate" col="1" popup="default" row="0" stat_name="pfr" tip="tip1"> </stat>
|
<stat click="tog_decorate" col="1" popup="default" row="0" stat_name="pfr" tip="tip1"> </stat>
|
||||||
<stat click="tog_decorate" col="2" popup="default" row="0" stat_name="ffreq_1" tip="tip1"> </stat>
|
<stat click="tog_decorate" col="2" popup="default" row="0" stat_name="ffreq_1" tip="tip1"> </stat>
|
||||||
|
@ -177,6 +198,7 @@
|
||||||
<stat click="tog_decorate" col="1" popup="default" row="1" stat_name="wtsd" tip="tip1"> </stat>
|
<stat click="tog_decorate" col="1" popup="default" row="1" stat_name="wtsd" tip="tip1"> </stat>
|
||||||
<stat click="tog_decorate" col="2" popup="default" row="1" stat_name="wmsd" tip="tip1"> </stat>
|
<stat click="tog_decorate" col="2" popup="default" row="1" stat_name="wmsd" tip="tip1"> </stat>
|
||||||
</game>
|
</game>
|
||||||
|
|
||||||
<game cols="3" db="fpdb" game_name="studhi" rows="2" aux="stud_mucked">
|
<game cols="3" db="fpdb" game_name="studhi" rows="2" aux="stud_mucked">
|
||||||
<stat click="tog_decorate" col="0" popup="default" row="0" stat_name="vpip" tip="tip1"> </stat>
|
<stat click="tog_decorate" col="0" popup="default" row="0" stat_name="vpip" tip="tip1"> </stat>
|
||||||
<stat click="tog_decorate" col="1" popup="default" row="0" stat_name="pfr" tip="tip1"> </stat>
|
<stat click="tog_decorate" col="1" popup="default" row="0" stat_name="pfr" tip="tip1"> </stat>
|
||||||
|
@ -185,6 +207,7 @@
|
||||||
<stat click="tog_decorate" col="1" popup="default" row="1" stat_name="wtsd" tip="tip1"> </stat>
|
<stat click="tog_decorate" col="1" popup="default" row="1" stat_name="wtsd" tip="tip1"> </stat>
|
||||||
<stat click="tog_decorate" col="2" popup="default" row="1" stat_name="wmsd" tip="tip1"> </stat>
|
<stat click="tog_decorate" col="2" popup="default" row="1" stat_name="wmsd" tip="tip1"> </stat>
|
||||||
</game>
|
</game>
|
||||||
|
|
||||||
<game cols="3" db="fpdb" game_name="studhilo" rows="2" aux="stud_mucked">
|
<game cols="3" db="fpdb" game_name="studhilo" rows="2" aux="stud_mucked">
|
||||||
<stat click="tog_decorate" col="0" popup="default" row="0" stat_name="vpip" tip="tip1"> </stat>
|
<stat click="tog_decorate" col="0" popup="default" row="0" stat_name="vpip" tip="tip1"> </stat>
|
||||||
<stat click="tog_decorate" col="1" popup="default" row="0" stat_name="pfr" tip="tip1"> </stat>
|
<stat click="tog_decorate" col="1" popup="default" row="0" stat_name="pfr" tip="tip1"> </stat>
|
||||||
|
@ -194,6 +217,7 @@
|
||||||
<stat click="tog_decorate" col="2" popup="default" row="1" stat_name="wmsd" tip="tip1"> </stat>
|
<stat click="tog_decorate" col="2" popup="default" row="1" stat_name="wmsd" tip="tip1"> </stat>
|
||||||
</game>
|
</game>
|
||||||
</supported_games>
|
</supported_games>
|
||||||
|
|
||||||
<popup_windows>
|
<popup_windows>
|
||||||
<pu pu_name="default">
|
<pu pu_name="default">
|
||||||
<pu_stat pu_stat_name="n"> </pu_stat>
|
<pu_stat pu_stat_name="n"> </pu_stat>
|
||||||
|
@ -220,15 +244,54 @@
|
||||||
<pu_stat pu_stat_name="ffreq_4"> </pu_stat>
|
<pu_stat pu_stat_name="ffreq_4"> </pu_stat>
|
||||||
</pu>
|
</pu>
|
||||||
</popup_windows>
|
</popup_windows>
|
||||||
<import callFpdbHud = "True" interval = "10" hhArchiveBase="~/.fpdb/HandHistories/"></import>
|
|
||||||
<tv combinedStealFold = "True" combined2B3B = "True" combinedPostflop = "True"></tv>
|
|
||||||
|
|
||||||
<supported_databases>
|
|
||||||
<database db_name="fpdb" db_server="mysql" db_ip="localhost" db_user="fpdb" db_pass="YOUR MYSQL PASSWORD" db_type="fpdb"> </database>
|
|
||||||
</supported_databases>
|
|
||||||
<aux_windows>
|
<aux_windows>
|
||||||
<aw card_ht="42" card_wd="30" class="Stud_mucked" cols="11" deck="Cards01.png" module="Mucked" name="stud_mucked" rows="8"> </aw>
|
<aw card_ht="42" card_wd="30" class="Stud_mucked" cols="11" deck="Cards01.png" module="Mucked" name="stud_mucked" rows="8"> </aw>
|
||||||
|
<aw class="Hello" module="Hello" name="Hello"> </aw>
|
||||||
|
<aw class="Hello_Menu" module="Hello" name="Hello_menu"> </aw>
|
||||||
|
<aw class="Hello_plus" module="Hello" name="Hello_plus"> </aw>
|
||||||
|
<aw card_ht="42" card_wd="30" class="Flop_Mucked" deck="Cards01.png" module="Mucked" name="mucked" opacity="0.7" timeout="5">
|
||||||
|
<layout height="546" max="6" width="792">
|
||||||
|
<location seat="1" x="555" y="169"> </location>
|
||||||
|
<location seat="2" x="572" y="276"> </location>
|
||||||
|
<location seat="3" x="363" y="348"> </location>
|
||||||
|
<location seat="4" x="150" y="273"> </location>
|
||||||
|
<location seat="5" x="150" y="169"> </location>
|
||||||
|
<location seat="6" x="363" y="113"> </location>
|
||||||
|
<location common="1" x="323" y="232"> </location>
|
||||||
|
</layout>
|
||||||
|
<layout height="546" max="9" width="792">
|
||||||
|
<location seat="1" x="486" y="113"> </location>
|
||||||
|
<location seat="2" x="555" y="169"> </location>
|
||||||
|
<location seat="3" x="572" y="276"> </location>
|
||||||
|
<location seat="4" x="522" y="345"> </location>
|
||||||
|
<location seat="5" x="363" y="348"> </location>
|
||||||
|
<location seat="6" x="217" y="341"> </location>
|
||||||
|
<location seat="7" x="150" y="273"> </location>
|
||||||
|
<location seat="8" x="150" y="169"> </location>
|
||||||
|
<location seat="9" x="230" y="115"> </location>
|
||||||
|
<location common="1" x="323" y="232"> </location>
|
||||||
|
</layout>
|
||||||
|
<layout height="546" max="10" width="792">
|
||||||
|
<location seat="1" x="486" y="113"> </location>
|
||||||
|
<location seat="2" x="499" y="138"> </location>
|
||||||
|
<location seat="3" x="522" y="212"> </location>
|
||||||
|
<location seat="4" x="501" y="281"> </location>
|
||||||
|
<location seat="5" x="402" y="323"> </location>
|
||||||
|
<location seat="6" x="243" y="311"> </location>
|
||||||
|
<location seat="7" x="203" y="262"> </location>
|
||||||
|
<location seat="8" x="170" y="185"> </location>
|
||||||
|
<location seat="9" x="183" y="128"> </location>
|
||||||
|
<location seat="10" x="213" y="86"> </location>
|
||||||
|
<location common="1" x="317" y="237"> </location>
|
||||||
|
</layout>
|
||||||
|
</aw>
|
||||||
</aux_windows>
|
</aux_windows>
|
||||||
|
|
||||||
|
<supported_databases>
|
||||||
|
<database db_name="fpdb" db_server="mysql" db_ip="localhost" db_user="fpdb" db_pass="YOUR MYSQL PASSWORD" db_type="fpdb"></database>
|
||||||
|
</supported_databases>
|
||||||
|
|
||||||
</FreePokerToolsConfig>
|
</FreePokerToolsConfig>
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
|
|
||||||
Main for FreePokerTools HUD.
|
Main for FreePokerTools HUD.
|
||||||
"""
|
"""
|
||||||
# Copyright 2008, Ray E. Barker
|
# Copyright 2008, 2009, Ray E. Barker
|
||||||
#
|
#
|
||||||
# This program is free software; you can redistribute it and/or modify
|
# This program is free software; you can redistribute it and/or modify
|
||||||
# it under the terms of the GNU General Public License as published by
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
@ -26,10 +26,14 @@ Main for FreePokerTools HUD.
|
||||||
# to do hud to echo, but ignore non numbers
|
# to do hud to echo, but ignore non numbers
|
||||||
# to do no stat window for hero
|
# to do no stat window for hero
|
||||||
# to do things to add to config.xml
|
# to do things to add to config.xml
|
||||||
# to do font and size
|
|
||||||
|
|
||||||
# Standard Library modules
|
# Standard Library modules
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
|
# redirect the stderr
|
||||||
|
errorfile = open('HUD-error.txt', 'w', 0)
|
||||||
|
sys.stderr = errorfile
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import thread
|
import thread
|
||||||
import time
|
import time
|
||||||
|
@ -47,143 +51,163 @@ import Database
|
||||||
import Tables
|
import Tables
|
||||||
import Hud
|
import Hud
|
||||||
|
|
||||||
# global dict for keeping the huds
|
aggregate_stats = {"ring": False, "tour": False} # config file!
|
||||||
hud_dict = {}
|
|
||||||
eb = 0 # our former event-box
|
|
||||||
|
|
||||||
db_connection = 0;
|
class HUD_main(object):
|
||||||
config = 0;
|
"""A main() object to own both the read_stdin thread and the gui."""
|
||||||
|
# This class mainly provides state for controlling the multiple HUDs.
|
||||||
|
|
||||||
def destroy(*args): # call back for terminating the main eventloop
|
def __init__(self, db_name = 'fpdb'):
|
||||||
gtk.main_quit()
|
self.db_name = db_name
|
||||||
|
self.config = Configuration.Config()
|
||||||
|
self.hud_dict = {}
|
||||||
|
|
||||||
def create_HUD(new_hand_id, table, db_name, table_name, max, poker_game, db_connection, config, stat_dict):
|
# a thread to read stdin
|
||||||
global hud_dict, eb
|
gobject.threads_init() # this is required
|
||||||
|
thread.start_new_thread(self.read_stdin, ()) # starts the thread
|
||||||
|
|
||||||
def idle_func():
|
# a main window
|
||||||
global hud_dict, eb
|
self.main_window = gtk.Window()
|
||||||
|
self.main_window.connect("destroy", self.destroy)
|
||||||
|
self.vb = gtk.VBox()
|
||||||
|
self.label = gtk.Label('Closing this window will exit from the HUD.')
|
||||||
|
self.vb.add(self.label)
|
||||||
|
self.main_window.add(self.vb)
|
||||||
|
self.main_window.set_title("HUD Main Window")
|
||||||
|
self.main_window.show_all()
|
||||||
|
|
||||||
gtk.gdk.threads_enter()
|
def destroy(*args): # call back for terminating the main eventloop
|
||||||
try:
|
gtk.main_quit()
|
||||||
newlabel = gtk.Label(table_name)
|
|
||||||
eb.add(newlabel)
|
|
||||||
newlabel.show()
|
|
||||||
|
|
||||||
hud_dict[table_name] = Hud.Hud(table, max, poker_game, config, db_connection)
|
def kill_hud(self, event, table):
|
||||||
hud_dict[table_name].tablehudlabel = newlabel
|
# called by an event in the HUD, to kill this specific HUD
|
||||||
hud_dict[table_name].create(new_hand_id, config)
|
self.hud_dict[table].kill()
|
||||||
for m in hud_dict[table_name].aux_windows:
|
self.hud_dict[table].main_window.destroy()
|
||||||
m.update_data(new_hand_id, db_connection)
|
self.vb.remove(self.hud_dict[table].tablehudlabel)
|
||||||
m.update_gui(new_hand_id)
|
del(self.hud_dict[table])
|
||||||
hud_dict[table_name].update(new_hand_id, config, stat_dict)
|
self.main_window.resize(1,1)
|
||||||
hud_dict[table_name].reposition_windows()
|
|
||||||
return False
|
|
||||||
finally:
|
|
||||||
gtk.gdk.threads_leave()
|
|
||||||
gobject.idle_add(idle_func)
|
|
||||||
|
|
||||||
def update_HUD(new_hand_id, table_name, config, stat_dict):
|
def create_HUD(self, new_hand_id, table, table_name, max, poker_game, stat_dict, cards):
|
||||||
global hud_dict
|
|
||||||
def idle_func():
|
|
||||||
gtk.gdk.threads_enter()
|
|
||||||
try:
|
|
||||||
hud_dict[table_name].update(new_hand_id, config, stat_dict)
|
|
||||||
for m in hud_dict[table_name].aux_windows:
|
|
||||||
m.update_gui(new_hand_id)
|
|
||||||
return False
|
|
||||||
finally:
|
|
||||||
gtk.gdk.threads_leave()
|
|
||||||
gobject.idle_add(idle_func)
|
|
||||||
|
|
||||||
def HUD_removed(tablename):
|
def idle_func():
|
||||||
global hud_dict, eb
|
|
||||||
|
|
||||||
if tablename in hud_dict and hud_dict[tablename].deleted:
|
gtk.gdk.threads_enter()
|
||||||
eb.remove(hud_dict[tablename].tablehudlabel)
|
try:
|
||||||
del(hud_dict[tablename])
|
newlabel = gtk.Label("%s - %s" % (table.site, table_name))
|
||||||
return False
|
self.vb.add(newlabel)
|
||||||
|
newlabel.show()
|
||||||
|
self.main_window.resize_children()
|
||||||
|
|
||||||
return True
|
self.hud_dict[table_name].tablehudlabel = newlabel
|
||||||
|
self.hud_dict[table_name].create(new_hand_id, self.config, stat_dict, cards)
|
||||||
|
for m in self.hud_dict[table_name].aux_windows:
|
||||||
|
m.create()
|
||||||
|
m.update_gui(new_hand_id)
|
||||||
|
self.hud_dict[table_name].update(new_hand_id, self.config)
|
||||||
|
self.hud_dict[table_name].reposition_windows()
|
||||||
|
return False
|
||||||
|
finally:
|
||||||
|
gtk.gdk.threads_leave()
|
||||||
|
|
||||||
def read_stdin(): # This is the thread function
|
self.hud_dict[table_name] = Hud.Hud(self, table, max, poker_game, self.config, self.db_connection)
|
||||||
global hud_dict, eb
|
self.hud_dict[table_name].table_name = table_name
|
||||||
|
self.hud_dict[table_name].stat_dict = stat_dict
|
||||||
|
self.hud_dict[table_name].cards = cards
|
||||||
|
[aw.update_data(new_hand_id, self.db_connection) for aw in self.hud_dict[table_name].aux_windows]
|
||||||
|
gobject.idle_add(idle_func)
|
||||||
|
|
||||||
db_connection = Database.Database(config, db_name, 'temp')
|
def update_HUD(self, new_hand_id, table_name, config):
|
||||||
tourny_finder = re.compile('(\d+) (\d+)')
|
"""Update a HUD gui from inside the non-gui read_stdin thread."""
|
||||||
|
# This is written so that only 1 thread can touch the gui--mainly
|
||||||
|
# for compatibility with Windows. This method dispatches the
|
||||||
|
# function idle_func() to be run by the gui thread, at its leisure.
|
||||||
|
def idle_func():
|
||||||
|
gtk.gdk.threads_enter()
|
||||||
|
try:
|
||||||
|
self.hud_dict[table_name].update(new_hand_id, config)
|
||||||
|
[aw.update_gui(new_hand_id) for aw in self.hud_dict[table_name].aux_windows]
|
||||||
|
return False
|
||||||
|
finally:
|
||||||
|
gtk.gdk.threads_leave()
|
||||||
|
gobject.idle_add(idle_func)
|
||||||
|
|
||||||
while True: # wait for a new hand number on stdin
|
def read_stdin(self): # This is the thread function
|
||||||
new_hand_id = sys.stdin.readline()
|
"""Do all the non-gui heavy lifting for the HUD program."""
|
||||||
new_hand_id = string.rstrip(new_hand_id)
|
|
||||||
if new_hand_id == "": # blank line means quit
|
|
||||||
destroy()
|
|
||||||
break # this thread is not always killed immediately with gtk.main_quit()
|
|
||||||
|
|
||||||
# delete hud_dict entries for any HUD destroyed since last iteration
|
# This db connection is for the read_stdin thread only. It should not
|
||||||
# for h in hud_dict:
|
# be passed to HUDs for use in the gui thread. HUD objects should not
|
||||||
# HUD_removed(h)
|
# need their own access to the database, but should open their own
|
||||||
# removing this function, we shouldn't need it anymore, since the hud should notify us anyway, right?
|
# if it is required.
|
||||||
|
self.db_connection = Database.Database(self.config, self.db_name, 'temp')
|
||||||
|
tourny_finder = re.compile('(\d+) (\d+)')
|
||||||
|
|
||||||
|
while 1: # wait for a new hand number on stdin
|
||||||
|
new_hand_id = sys.stdin.readline()
|
||||||
|
new_hand_id = string.rstrip(new_hand_id)
|
||||||
|
if new_hand_id == "": # blank line means quit
|
||||||
|
self.destroy()
|
||||||
|
break # this thread is not always killed immediately with gtk.main_quit()
|
||||||
|
|
||||||
# get basic info about the new hand from the db
|
# get basic info about the new hand from the db
|
||||||
(table_name, max, poker_game) = db_connection.get_table_name(new_hand_id)
|
# if there is a db error, complain, skip hand, and proceed
|
||||||
|
try:
|
||||||
|
(table_name, max, poker_game, type) = self.db_connection.get_table_name(new_hand_id)
|
||||||
|
stat_dict = self.db_connection.get_stats_from_hand(new_hand_id, aggregate = aggregate_stats[type])
|
||||||
|
cards = self.db_connection.get_cards(new_hand_id)
|
||||||
|
comm_cards = self.db_connection.get_common_cards(new_hand_id)
|
||||||
|
if comm_cards != {}: # stud!
|
||||||
|
cards['common'] = comm_cards['common']
|
||||||
|
except Exception, err:
|
||||||
|
print "db error: skipping ", new_hand_id, err
|
||||||
|
sys.stderr.write("Database error %s in hand %d. Skipping.\n" % (err, int(new_hand_id)))
|
||||||
|
continue
|
||||||
|
|
||||||
# find out if this hand is from a tournament
|
if type == "tour": # hand is from a tournament
|
||||||
is_tournament = False
|
mat_obj = tourny_finder.search(table_name)
|
||||||
(tour_number, tab_number) = (0, 0)
|
if mat_obj:
|
||||||
mat_obj = tourny_finder.search(table_name)
|
(tour_number, tab_number) = mat_obj.group(1, 2)
|
||||||
if mat_obj:
|
temp_key = tour_number
|
||||||
is_tournament = True
|
else: # tourney, but can't get number and table
|
||||||
(tour_number, tab_number) = mat_obj.group(1, 2)
|
print "could not find tournamtne: skipping "
|
||||||
|
sys.stderr.write("Could not find tournament %d in hand %d. Skipping.\n" % (int(tour_number), int(new_hand_id)))
|
||||||
|
continue
|
||||||
|
|
||||||
stat_dict = db_connection.get_stats_from_hand(new_hand_id)
|
|
||||||
|
|
||||||
# if a hud for this CASH table exists, just update it
|
|
||||||
if table_name in hud_dict:
|
|
||||||
# update the data for the aux_windows
|
|
||||||
for aw in hud_dict[table_name].aux_windows:
|
|
||||||
aw.update_data(new_hand_id, db_connection)
|
|
||||||
update_HUD(new_hand_id, table_name, config, stat_dict)
|
|
||||||
|
|
||||||
# if a hud for this TOURNAMENT table exists, just update it
|
|
||||||
elif tour_number in hud_dict:
|
|
||||||
update_HUD(new_hand_id, tour_number, config, stat_dict)
|
|
||||||
|
|
||||||
# otherwise create a new hud
|
|
||||||
else:
|
|
||||||
if is_tournament:
|
|
||||||
tablewindow = Tables.discover_tournament_table(config, tour_number, tab_number)
|
|
||||||
if tablewindow == None:
|
|
||||||
sys.stderr.write("tournament %s, table %s not found\n" % (tour_number, tab_number))
|
|
||||||
else:
|
|
||||||
create_HUD(new_hand_id, tablewindow, db_name, tour_number, max, poker_game, db_connection, config, stat_dict)
|
|
||||||
else:
|
else:
|
||||||
tablewindow = Tables.discover_table_by_name(config, table_name)
|
temp_key = table_name
|
||||||
if tablewindow == None:
|
|
||||||
sys.stderr.write("table name "+table_name+" not found\n")
|
# Update an existing HUD
|
||||||
|
if temp_key in self.hud_dict:
|
||||||
|
self.hud_dict[temp_key].stat_dict = stat_dict
|
||||||
|
self.hud_dict[temp_key].cards = cards
|
||||||
|
[aw.update_data(new_hand_id, self.db_connection) for aw in self.hud_dict[temp_key].aux_windows]
|
||||||
|
self.update_HUD(new_hand_id, temp_key, self.config)
|
||||||
|
|
||||||
|
# Or create a new HUD
|
||||||
|
else:
|
||||||
|
if type == "tour":
|
||||||
|
tablewindow = Tables.discover_tournament_table(self.config, tour_number, tab_number)
|
||||||
else:
|
else:
|
||||||
create_HUD(new_hand_id, tablewindow, db_name, table_name, max, poker_game, db_connection, config, stat_dict)
|
tablewindow = Tables.discover_table_by_name(self.config, table_name)
|
||||||
|
if tablewindow == None:
|
||||||
|
# If no client window is found on the screen, complain and continue
|
||||||
|
if type == "tour":
|
||||||
|
table_name = "%s %s" % (tour_number, tab_number)
|
||||||
|
sys.stderr.write("table name "+table_name+" not found, skipping.\n")
|
||||||
|
else:
|
||||||
|
self.create_HUD(new_hand_id, tablewindow, temp_key, max, poker_game, stat_dict, cards)
|
||||||
|
|
||||||
if __name__== "__main__":
|
if __name__== "__main__":
|
||||||
sys.stderr.write("HUD_main starting\n")
|
sys.stderr.write("HUD_main starting\n")
|
||||||
|
|
||||||
|
# database name can be passed on command line
|
||||||
try:
|
try:
|
||||||
db_name = sys.argv[1]
|
db_name = sys.argv[1]
|
||||||
except:
|
except:
|
||||||
db_name = 'fpdb'
|
db_name = 'fpdb'
|
||||||
sys.stderr.write("Using db name = %s\n" % (db_name))
|
sys.stderr.write("Using db name = %s\n" % (db_name))
|
||||||
|
|
||||||
config = Configuration.Config()
|
# start the HUD_main object
|
||||||
|
hm = HUD_main(db_name = db_name)
|
||||||
gobject.threads_init() # this is required
|
|
||||||
thread.start_new_thread(read_stdin, ()) # starts the thread
|
|
||||||
|
|
||||||
main_window = gtk.Window()
|
|
||||||
main_window.connect("destroy", destroy)
|
|
||||||
eb = gtk.VBox()
|
|
||||||
label = gtk.Label('Closing this window will exit from the HUD.')
|
|
||||||
eb.add(label)
|
|
||||||
main_window.add(eb)
|
|
||||||
|
|
||||||
main_window.set_title("HUD Main Window")
|
|
||||||
main_window.show_all()
|
|
||||||
|
|
||||||
|
# start the event loop
|
||||||
gtk.main()
|
gtk.main()
|
||||||
|
|
0
pyfpdb/HUD_run_me.py
Normal file → Executable file
903
pyfpdb/Hand.py
|
@ -15,12 +15,12 @@
|
||||||
#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.
|
||||||
|
|
||||||
import Configuration
|
|
||||||
import FpdbRegex
|
|
||||||
import Hand
|
import Hand
|
||||||
import re
|
import re
|
||||||
import sys
|
import sys
|
||||||
import traceback
|
import traceback
|
||||||
|
import logging
|
||||||
|
from optparse import OptionParser
|
||||||
import os
|
import os
|
||||||
import os.path
|
import os.path
|
||||||
import xml.dom.minidom
|
import xml.dom.minidom
|
||||||
|
@ -28,7 +28,7 @@ import codecs
|
||||||
from decimal import Decimal
|
from decimal import Decimal
|
||||||
import operator
|
import operator
|
||||||
from xml.dom.minidom import Node
|
from xml.dom.minidom import Node
|
||||||
from pokereval import PokerEval
|
# from pokereval import PokerEval
|
||||||
import time
|
import time
|
||||||
import datetime
|
import datetime
|
||||||
import gettext
|
import gettext
|
||||||
|
@ -71,85 +71,178 @@ letter2names = {
|
||||||
import gettext
|
import gettext
|
||||||
gettext.install('myapplication')
|
gettext.install('myapplication')
|
||||||
|
|
||||||
|
class HandHistoryConverter():
|
||||||
|
|
||||||
|
READ_CHUNK_SIZE = 10000 # bytes to read at a time from file (in tail mode)
|
||||||
|
def __init__(self, in_path = '-', out_path = '-', sitename = None, follow=False):
|
||||||
|
logging.info("HandHistory init called")
|
||||||
|
|
||||||
class HandHistoryConverter:
|
# default filetype and codepage. Subclasses should set these properly.
|
||||||
eval = PokerEval()
|
|
||||||
def __init__(self, config, file, sitename):
|
|
||||||
print "HandHistory init called"
|
|
||||||
self.c = config
|
|
||||||
self.sitename = sitename
|
|
||||||
self.obs = "" # One big string
|
|
||||||
self.filetype = "text"
|
self.filetype = "text"
|
||||||
self.codepage = "utf8"
|
self.codepage = "utf8"
|
||||||
self.doc = None # For XML based HH files
|
|
||||||
self.file = file
|
self.in_path = in_path
|
||||||
self.hhbase = self.c.get_import_parameters().get("hhArchiveBase")
|
self.out_path = out_path
|
||||||
self.hhbase = os.path.expanduser(self.hhbase)
|
if self.out_path == '-':
|
||||||
self.hhdir = os.path.join(self.hhbase,sitename)
|
# write to stdout
|
||||||
self.gametype = []
|
self.out_fh = sys.stdout
|
||||||
# self.ofile = os.path.join(self.hhdir,file)
|
else:
|
||||||
self.rexx = FpdbRegex.FpdbRegex()
|
# TODO: out_path should be sanity checked before opening. Perhaps in fpdb_import?
|
||||||
|
# I'm not sure what we're looking for, although we don't want out_path==in_path!='-'
|
||||||
|
self.out_fh = open(self.out_path, 'w') # doomswitch is now on :|
|
||||||
|
self.sitename = sitename
|
||||||
|
self.follow = follow
|
||||||
|
self.compiledPlayers = set()
|
||||||
|
self.maxseats = 10
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
|
#TODO : I got rid of most of the hhdir stuff.
|
||||||
tmp = "HandHistoryConverter: '%s'\n" % (self.sitename)
|
tmp = "HandHistoryConverter: '%s'\n" % (self.sitename)
|
||||||
tmp = tmp + "\thhbase: '%s'\n" % (self.hhbase)
|
#tmp = tmp + "\thhbase: '%s'\n" % (self.hhbase)
|
||||||
tmp = tmp + "\thhdir: '%s'\n" % (self.hhdir)
|
#tmp = tmp + "\thhdir: '%s'\n" % (self.hhdir)
|
||||||
tmp = tmp + "\tfiletype: '%s'\n" % (self.filetype)
|
tmp = tmp + "\tfiletype: '%s'\n" % (self.filetype)
|
||||||
tmp = tmp + "\tinfile: '%s'\n" % (self.file)
|
tmp = tmp + "\tinfile: '%s'\n" % (self.in_path)
|
||||||
# tmp = tmp + "\toutfile: '%s'\n" % (self.ofile)
|
tmp = tmp + "\toutfile: '%s'\n" % (self.out_path)
|
||||||
# tmp = tmp + "\tgametype: '%s'\n" % (self.gametype[0])
|
#tmp = tmp + "\tgametype: '%s'\n" % (self.gametype[0])
|
||||||
# tmp = tmp + "\tgamebase: '%s'\n" % (self.gametype[1])
|
#tmp = tmp + "\tgamebase: '%s'\n" % (self.gametype[1])
|
||||||
# tmp = tmp + "\tlimit: '%s'\n" % (self.gametype[2])
|
#tmp = tmp + "\tlimit: '%s'\n" % (self.gametype[2])
|
||||||
# tmp = tmp + "\tsb/bb: '%s/%s'\n" % (self.gametype[3], self.gametype[4])
|
#tmp = tmp + "\tsb/bb: '%s/%s'\n" % (self.gametype[3], self.gametype[4])
|
||||||
return tmp
|
return tmp
|
||||||
|
|
||||||
def processFile(self):
|
def start(self):
|
||||||
|
"""process a hand at a time from the input specified by in_path.
|
||||||
|
If in follow mode, wait for more data to turn up.
|
||||||
|
Otherwise, finish at eof..."""
|
||||||
starttime = time.time()
|
starttime = time.time()
|
||||||
if not self.sanityCheck():
|
if not self.sanityCheck():
|
||||||
print "Cowardly refusing to continue after failed sanity check"
|
print "Cowardly refusing to continue after failed sanity check"
|
||||||
return
|
return
|
||||||
self.readFile(self.file)
|
|
||||||
self.gametype = self.determineGameType()
|
|
||||||
self.hands = self.splitFileIntoHands()
|
|
||||||
for hand in self.hands:
|
|
||||||
print "\nInput:\n"+hand.string
|
|
||||||
self.readHandInfo(hand)
|
|
||||||
self.readPlayerStacks(hand)
|
|
||||||
print "DEBUG stacks:", hand.stacks
|
|
||||||
self.markStreets(hand)
|
|
||||||
self.readBlinds(hand)
|
|
||||||
self.readHeroCards(hand) # want to generalise to draw games
|
|
||||||
|
|
||||||
self.readShowdownActions(hand)
|
|
||||||
|
|
||||||
# Read actions in street order
|
|
||||||
for street in hand.streetList: # go through them in order
|
|
||||||
if hand.streets.group(street) is not None:
|
|
||||||
self.readCommunityCards(hand, street) # read community cards
|
|
||||||
self.readAction(hand, street)
|
|
||||||
|
|
||||||
|
|
||||||
self.readCollectPot(hand)
|
|
||||||
self.readShownCards(hand)
|
|
||||||
|
|
||||||
# finalise it (total the pot)
|
|
||||||
hand.totalPot()
|
|
||||||
self.getRake(hand)
|
|
||||||
|
|
||||||
hand.writeHand(sys.stderr)
|
|
||||||
#if(hand.involved == True):
|
|
||||||
#self.writeHand("output file", hand)
|
|
||||||
#hand.printHand()
|
|
||||||
#else:
|
|
||||||
#pass #Don't write out observed hands
|
|
||||||
|
|
||||||
|
if self.follow:
|
||||||
|
numHands = 0
|
||||||
|
for handText in self.tailHands():
|
||||||
|
numHands+=1
|
||||||
|
self.processHand(handText)
|
||||||
|
else:
|
||||||
|
handsList = self.allHandsAsList()
|
||||||
|
logging.info("Parsing %d hands" % len(handsList))
|
||||||
|
for handText in handsList:
|
||||||
|
self.processHand(handText)
|
||||||
|
numHands= len(handsList)
|
||||||
endtime = time.time()
|
endtime = time.time()
|
||||||
print "Processed %d hands in %d seconds" % (len(self.hands), endtime-starttime)
|
print "Processed %d hands in %.3f seconds" % (numHands, endtime - starttime)
|
||||||
|
if self.out_fh != sys.stdout:
|
||||||
|
self.out_fh.close()
|
||||||
|
|
||||||
|
|
||||||
|
def tailHands(self):
|
||||||
|
"""Generator of handTexts from a tailed file:
|
||||||
|
Tail the in_path file and yield handTexts separated by re_SplitHands"""
|
||||||
|
if self.in_path == '-': raise StopIteration
|
||||||
|
interval = 1.0 # seconds to sleep between reads for new data
|
||||||
|
fd = codecs.open(self.in_path,'r', self.codepage)
|
||||||
|
data = ''
|
||||||
|
while 1:
|
||||||
|
where = fd.tell()
|
||||||
|
newdata = fd.read(self.READ_CHUNK_SIZE)
|
||||||
|
if not newdata:
|
||||||
|
fd_results = os.fstat(fd.fileno())
|
||||||
|
try:
|
||||||
|
st_results = os.stat(self.in_path)
|
||||||
|
except OSError:
|
||||||
|
st_results = fd_results
|
||||||
|
if st_results[1] == fd_results[1]:
|
||||||
|
time.sleep(interval)
|
||||||
|
fd.seek(where)
|
||||||
|
else:
|
||||||
|
logging.debug("%s changed inode numbers from %d to %d" % (self.in_path, fd_results[1], st_results[1]))
|
||||||
|
fd = codecs.open(self.in_path, 'r', self.codepage)
|
||||||
|
fd.seek(where)
|
||||||
|
else:
|
||||||
|
# yield hands
|
||||||
|
data = data + newdata
|
||||||
|
result = self.re_SplitHands.split(data)
|
||||||
|
result = iter(result)
|
||||||
|
data = ''
|
||||||
|
# --x data (- is bit of splitter, x is paragraph) yield,...,keep
|
||||||
|
# [,--,x] result of re.split (with group around splitter)
|
||||||
|
# ,x our output: yield nothing, keep x
|
||||||
|
#
|
||||||
|
# --x--x [,--,x,--,x] x,x
|
||||||
|
# -x--x [-x,--,x] x,x
|
||||||
|
# x- [x-] ,x-
|
||||||
|
# x-- [x,--,] x,--
|
||||||
|
# x--x [x,--,x] x,x
|
||||||
|
# x--x-- [x,--,x,--,] x,x,--
|
||||||
|
|
||||||
|
# The length is always odd.
|
||||||
|
# 'odd' indices are always splitters.
|
||||||
|
# 'even' indices are always paragraphs or ''
|
||||||
|
# We want to discard all the ''
|
||||||
|
# We want to discard splitters unless the final item is '' (because the splitter could grow with new data)
|
||||||
|
# We want to yield all paragraphs followed by a splitter, i.e. all even indices except the last.
|
||||||
|
for para in result:
|
||||||
|
try:
|
||||||
|
result.next()
|
||||||
|
splitter = True
|
||||||
|
except StopIteration:
|
||||||
|
splitter = False
|
||||||
|
if splitter: # para is followed by a splitter
|
||||||
|
if para: yield para # para not ''
|
||||||
|
else:
|
||||||
|
data = para # keep final partial paragraph
|
||||||
|
|
||||||
|
|
||||||
|
def allHandsAsList(self):
|
||||||
|
"""Return a list of handtexts in the file at self.in_path"""
|
||||||
|
#TODO : any need for this to be generator? e.g. stars support can email one huge file of all hands in a year. Better to read bit by bit than all at once.
|
||||||
|
self.readFile()
|
||||||
|
self.obs = self.obs.strip()
|
||||||
|
self.obs = self.obs.replace('\r\n', '\n')
|
||||||
|
if self.obs == "" or self.obs == None:
|
||||||
|
logging.info("Read no hands.")
|
||||||
|
return
|
||||||
|
return re.split(self.re_SplitHands, self.obs)
|
||||||
|
|
||||||
|
def processHand(self, handText):
|
||||||
|
gametype = self.determineGameType(handText)
|
||||||
|
logging.debug("gametype %s" % gametype)
|
||||||
|
if gametype is None:
|
||||||
|
l = None
|
||||||
|
gametype = "unmatched"
|
||||||
|
# TODO: not ideal, just trying to not error.
|
||||||
|
# TODO: Need to count failed hands.
|
||||||
|
else:
|
||||||
|
# See if gametype is supported.
|
||||||
|
type = gametype['type']
|
||||||
|
base = gametype['base']
|
||||||
|
limit = gametype['limitType']
|
||||||
|
l = [type] + [base] + [limit]
|
||||||
|
hand = None
|
||||||
|
if l in self.readSupportedGames():
|
||||||
|
hand = None
|
||||||
|
if gametype['base'] == 'hold':
|
||||||
|
logging.debug("hand = Hand.HoldemOmahaHand(self, self.sitename, gametype, handtext)")
|
||||||
|
hand = Hand.HoldemOmahaHand(self, self.sitename, gametype, handText)
|
||||||
|
elif gametype['base'] == 'stud':
|
||||||
|
hand = Hand.StudHand(self, self.sitename, gametype, handText)
|
||||||
|
elif gametype['base'] == 'draw':
|
||||||
|
hand = Hand.DrawHand(self, self.sitename, gametype, handText)
|
||||||
|
else:
|
||||||
|
logging.info("Unsupported game type: %s" % gametype)
|
||||||
|
|
||||||
|
if hand:
|
||||||
|
hand.writeHand(self.out_fh)
|
||||||
|
else:
|
||||||
|
logging.info("Unsupported game type: %s" % gametype)
|
||||||
|
# TODO: pity we don't know the HID at this stage. Log the entire hand?
|
||||||
|
# From the log we can deduce that it is the hand after the one before :)
|
||||||
|
|
||||||
|
|
||||||
#####
|
|
||||||
# These functions are parse actions that may be overridden by the inheriting class
|
# These functions are parse actions that may be overridden by the inheriting class
|
||||||
#
|
# This function should return a list of lists looking like:
|
||||||
|
# return [["ring", "hold", "nl"], ["tour", "hold", "nl"]]
|
||||||
|
# Showing all supported games limits and types
|
||||||
|
|
||||||
def readSupportedGames(self): abstract
|
def readSupportedGames(self): abstract
|
||||||
|
|
||||||
|
@ -157,22 +250,38 @@ class HandHistoryConverter:
|
||||||
# type base limit
|
# type base limit
|
||||||
# [ ring, hold, nl , sb, bb ]
|
# [ ring, hold, nl , sb, bb ]
|
||||||
# Valid types specified in docs/tabledesign.html in Gametypes
|
# Valid types specified in docs/tabledesign.html in Gametypes
|
||||||
def determineGameType(self): abstract
|
def determineGameType(self, handText): abstract
|
||||||
|
"""return dict with keys/values:
|
||||||
|
'type' in ('ring', 'tour')
|
||||||
|
'limitType' in ('nl', 'cn', 'pl', 'cp', 'fl')
|
||||||
|
'base' in ('hold', 'stud', 'draw')
|
||||||
|
'category' in ('holdem', 'omahahi', omahahilo', 'razz', 'studhi', 'studhilo', 'fivedraw', '27_1draw', '27_3draw', 'badugi')
|
||||||
|
'hilo' in ('h','l','s')
|
||||||
|
'smallBlind' int?
|
||||||
|
'bigBlind' int?
|
||||||
|
'smallBet'
|
||||||
|
'bigBet'
|
||||||
|
'currency' in ('USD', 'EUR', 'T$', <countrycode>)
|
||||||
|
or None if we fail to get the info """
|
||||||
|
#TODO: which parts are optional/required?
|
||||||
|
|
||||||
# Read any of:
|
# Read any of:
|
||||||
# HID HandID
|
# HID HandID
|
||||||
# TABLE Table name
|
# TABLE Table name
|
||||||
# SB small blind
|
# SB small blind
|
||||||
# BB big blind
|
# BB big blind
|
||||||
# GAMETYPE gametype
|
# GAMETYPE gametype
|
||||||
# YEAR MON DAY HR MIN SEC datetime
|
# YEAR MON DAY HR MIN SEC datetime
|
||||||
# BUTTON button seat number
|
# BUTTON button seat number
|
||||||
def readHandInfo(self, hand): abstract
|
def readHandInfo(self, hand): abstract
|
||||||
|
|
||||||
# Needs to return a list of lists in the format
|
# Needs to return a list of lists in the format
|
||||||
# [['seat#', 'player1name', 'stacksize'] ['seat#', 'player2name', 'stacksize'] [...]]
|
# [['seat#', 'player1name', 'stacksize'] ['seat#', 'player2name', 'stacksize'] [...]]
|
||||||
def readPlayerStacks(self, hand): abstract
|
def readPlayerStacks(self, hand): abstract
|
||||||
|
|
||||||
|
def compilePlayerRegexs(self): abstract
|
||||||
|
"""Compile dynamic regexes -- these explicitly match known player names and must be updated if a new player joins"""
|
||||||
|
|
||||||
# Needs to return a MatchObject with group names identifying the streets into the Hand object
|
# Needs to return a MatchObject with group names identifying the streets into the Hand object
|
||||||
# so groups are called by street names 'PREFLOP', 'FLOP', 'STREET2' etc
|
# so groups are called by street names 'PREFLOP', 'FLOP', 'STREET2' etc
|
||||||
# blinds are done seperately
|
# blinds are done seperately
|
||||||
|
@ -182,7 +291,11 @@ class HandHistoryConverter:
|
||||||
# ['player1name', 'player2name', ...] where player1name is the sb and player2name is bb,
|
# ['player1name', 'player2name', ...] where player1name is the sb and player2name is bb,
|
||||||
# addtional players are assumed to post a bb oop
|
# addtional players are assumed to post a bb oop
|
||||||
def readBlinds(self, hand): abstract
|
def readBlinds(self, hand): abstract
|
||||||
|
def readAntes(self, hand): abstract
|
||||||
|
def readBringIn(self, hand): abstract
|
||||||
|
def readButton(self, hand): abstract
|
||||||
def readHeroCards(self, hand): abstract
|
def readHeroCards(self, hand): abstract
|
||||||
|
def readPlayerCards(self, hand, street): abstract
|
||||||
def readAction(self, hand, street): abstract
|
def readAction(self, hand, street): abstract
|
||||||
def readCollectPot(self, hand): abstract
|
def readCollectPot(self, hand): abstract
|
||||||
def readShownCards(self, hand): abstract
|
def readShownCards(self, hand): abstract
|
||||||
|
@ -194,23 +307,34 @@ class HandHistoryConverter:
|
||||||
|
|
||||||
|
|
||||||
def sanityCheck(self):
|
def sanityCheck(self):
|
||||||
|
"""Check we aren't going to do some stupid things"""
|
||||||
|
#TODO: the hhbase stuff needs to be in fpdb_import
|
||||||
sane = False
|
sane = False
|
||||||
base_w = False
|
base_w = False
|
||||||
#Check if hhbase exists and is writable
|
#~ #Check if hhbase exists and is writable
|
||||||
#Note: Will not try to create the base HH directory
|
#~ #Note: Will not try to create the base HH directory
|
||||||
if not (os.access(self.hhbase, os.W_OK) and os.path.isdir(self.hhbase)):
|
#~ if not (os.access(self.hhbase, os.W_OK) and os.path.isdir(self.hhbase)):
|
||||||
print "HH Sanity Check: Directory hhbase '" + self.hhbase + "' doesn't exist or is not writable"
|
#~ print "HH Sanity Check: Directory hhbase '" + self.hhbase + "' doesn't exist or is not writable"
|
||||||
else:
|
#~ else:
|
||||||
#Check if hhdir exists and is writable
|
#~ #Check if hhdir exists and is writable
|
||||||
if not os.path.isdir(self.hhdir):
|
#~ if not os.path.isdir(self.hhdir):
|
||||||
# In first pass, dir may not exist. Attempt to create dir
|
#~ # In first pass, dir may not exist. Attempt to create dir
|
||||||
print "Creating directory: '%s'" % (self.hhdir)
|
#~ print "Creating directory: '%s'" % (self.hhdir)
|
||||||
os.mkdir(self.hhdir)
|
#~ os.mkdir(self.hhdir)
|
||||||
sane = True
|
#~ sane = True
|
||||||
elif os.access(self.hhdir, os.W_OK):
|
#~ elif os.access(self.hhdir, os.W_OK):
|
||||||
sane = True
|
#~ sane = True
|
||||||
else:
|
#~ else:
|
||||||
print "HH Sanity Check: Directory hhdir '" + self.hhdir + "' or its parent directory are not writable"
|
#~ print "HH Sanity Check: Directory hhdir '" + self.hhdir + "' or its parent directory are not writable"
|
||||||
|
|
||||||
|
# Make sure input and output files are different or we'll overwrite the source file
|
||||||
|
if True: # basically.. I don't know
|
||||||
|
sane = True
|
||||||
|
|
||||||
|
if(self.in_path != '-' and self.out_path == self.in_path):
|
||||||
|
print "HH Sanity Check: output and input files are the same, check config"
|
||||||
|
sane = False
|
||||||
|
|
||||||
|
|
||||||
return sane
|
return sane
|
||||||
|
|
||||||
|
@ -221,21 +345,27 @@ class HandHistoryConverter:
|
||||||
|
|
||||||
def splitFileIntoHands(self):
|
def splitFileIntoHands(self):
|
||||||
hands = []
|
hands = []
|
||||||
self.obs.strip()
|
self.obs = self.obs.strip()
|
||||||
list = self.rexx.split_hand_re.split(self.obs)
|
list = self.re_SplitHands.split(self.obs)
|
||||||
list.pop() #Last entry is empty
|
list.pop() #Last entry is empty
|
||||||
for l in list:
|
for l in list:
|
||||||
# print "'" + l + "'"
|
# print "'" + l + "'"
|
||||||
hands = hands + [Hand.Hand(self.sitename, self.gametype, l)]
|
hands = hands + [Hand.Hand(self.sitename, self.gametype, l)]
|
||||||
return hands
|
return hands
|
||||||
|
|
||||||
def readFile(self, filename):
|
def readFile(self):
|
||||||
"""Read file"""
|
"""open in_path according to self.codepage"""
|
||||||
print "Reading file: '%s'" %(filename)
|
|
||||||
if(self.filetype == "text"):
|
if(self.filetype == "text"):
|
||||||
infile=codecs.open(filename, "rU", self.codepage)
|
if self.in_path == '-':
|
||||||
self.obs = infile.read()
|
# read from stdin
|
||||||
infile.close()
|
logging.debug("Reading stdin with %s" % self.codepage) # is this necessary? or possible? or what?
|
||||||
|
in_fh = codecs.getreader('cp1252')(sys.stdin)
|
||||||
|
else:
|
||||||
|
logging.debug("Opening %s with %s" % (self.in_path, self.codepage))
|
||||||
|
in_fh = codecs.open(self.in_path, 'r', self.codepage)
|
||||||
|
self.obs = in_fh.read()
|
||||||
|
in_fh.close()
|
||||||
elif(self.filetype == "xml"):
|
elif(self.filetype == "xml"):
|
||||||
try:
|
try:
|
||||||
doc = xml.dom.minidom.parse(filename)
|
doc = xml.dom.minidom.parse(filename)
|
||||||
|
@ -244,18 +374,9 @@ class HandHistoryConverter:
|
||||||
traceback.print_exc(file=sys.stderr)
|
traceback.print_exc(file=sys.stderr)
|
||||||
|
|
||||||
|
|
||||||
#takes a poker float (including , for thousand seperator and converts it to an int
|
def getStatus(self):
|
||||||
def float2int (self, string):
|
#TODO: Return a status of true if file processed ok
|
||||||
pos=string.find(",")
|
return True
|
||||||
if (pos!=-1): #remove , the thousand seperator
|
|
||||||
string=string[0:pos]+string[pos+1:]
|
|
||||||
|
|
||||||
pos=string.find(".")
|
def getProcessedFile(self):
|
||||||
if (pos!=-1): #remove decimal point
|
return self.out_path
|
||||||
string=string[0:pos]+string[pos+1:]
|
|
||||||
|
|
||||||
result = int(string)
|
|
||||||
if pos==-1: #no decimal point - was in full dollars - need to multiply with 100
|
|
||||||
result*=100
|
|
||||||
return result
|
|
||||||
#end def float2int
|
|
||||||
|
|
113
pyfpdb/Hello.py
Normal file
|
@ -0,0 +1,113 @@
|
||||||
|
#!/usr/bin/env python
|
||||||
|
"""Hello.py
|
||||||
|
|
||||||
|
Hello World demostration for Aux_Window.
|
||||||
|
"""
|
||||||
|
# Copyright 2009, Ray E. Barker
|
||||||
|
#
|
||||||
|
# This program is free software; you can redistribute it and/or modify
|
||||||
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
# the Free Software Foundation; either version 2 of the License, or
|
||||||
|
# (at your option) any later version.
|
||||||
|
#
|
||||||
|
# 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 General Public License
|
||||||
|
# along with this program; if not, write to the Free Software
|
||||||
|
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
|
||||||
|
########################################################################
|
||||||
|
|
||||||
|
# to do
|
||||||
|
# add another class that demonstrates querying the db
|
||||||
|
|
||||||
|
# Standard Library modules
|
||||||
|
import sys
|
||||||
|
|
||||||
|
# pyGTK modules
|
||||||
|
import pygtk
|
||||||
|
import gtk
|
||||||
|
import gobject
|
||||||
|
|
||||||
|
# FreePokerTools modules
|
||||||
|
from Mucked import Aux_Window
|
||||||
|
|
||||||
|
class Hello(Aux_Window):
|
||||||
|
"""A 'Hello World' Aux_Window demo."""
|
||||||
|
def create(self):
|
||||||
|
# This demo simply creates a label in a window.
|
||||||
|
self.container = gtk.Window()
|
||||||
|
self.container.add(gtk.Label("Hello World"))
|
||||||
|
# and shows it. There is no functionality.
|
||||||
|
self.container.show_all()
|
||||||
|
|
||||||
|
class Hello_plus(Aux_Window):
|
||||||
|
"""A slightly more complex 'Hello World demo."""
|
||||||
|
def __init__(self, hud, config, params):
|
||||||
|
"""Initialize a new aux_window object."""
|
||||||
|
# Initialize the aux_window object. Do not interact with the gui
|
||||||
|
# in this function.
|
||||||
|
self.hud = hud # hud object that this aux window supports
|
||||||
|
self.config = config # configuration object for this aux window to use
|
||||||
|
self.params = params # hash aux params from config
|
||||||
|
|
||||||
|
self.hands_played = 0 # initialize the hands played counter
|
||||||
|
|
||||||
|
# get the site we are playing from the HUD
|
||||||
|
self.site = hud.site
|
||||||
|
print "site =", hud.site # print it to the terminal, to make sure
|
||||||
|
|
||||||
|
# now get our screen name for that site from the configuration
|
||||||
|
# wrap it in a try/except in case screen name isn't set up in the config file
|
||||||
|
try:
|
||||||
|
site_params = self.config.get_site_parameters(self.hud.site)
|
||||||
|
self.hero = site_params['screen_name']
|
||||||
|
except:
|
||||||
|
self.hero = 'YOUR NAME HERE'
|
||||||
|
print "hero =", self.hero
|
||||||
|
|
||||||
|
|
||||||
|
def create(self):
|
||||||
|
"""Creates the gui."""
|
||||||
|
self.container = gtk.Window() # create a gtk window for our container
|
||||||
|
self.label = gtk.Label("") # create a blank label to write in update_gui
|
||||||
|
self.container.add(self.label) # add it to our container
|
||||||
|
self.container.show_all() # show the container and its contents
|
||||||
|
|
||||||
|
def update_data(self, new_hand_id, db_connection):
|
||||||
|
"""Increment the hands.played attribute."""
|
||||||
|
# This function will be called from the main program, in a thread separate from
|
||||||
|
# the gui. Therefore complex calculations can be done without slowing down the
|
||||||
|
# HUD. Long-running calculations will delay the appearance or updating of the HUD.
|
||||||
|
# This function should NOT interact with the gui--that will cause unpredictable
|
||||||
|
# results on some systems.
|
||||||
|
|
||||||
|
# This long running calculation is incrementing the number of hands played.
|
||||||
|
self.hands_played = self.hands_played + 1
|
||||||
|
|
||||||
|
def update_gui(self, new_hand_id):
|
||||||
|
"""Update the aux_window gui."""
|
||||||
|
# This function runs inside the gui thread and should only be used for
|
||||||
|
# interacting with the gui. Long-running calculations should not be done
|
||||||
|
# in this function--they will prevent HUD interaction until they are
|
||||||
|
# complete.
|
||||||
|
|
||||||
|
# Here, we just update the label in our aux_window from the number of
|
||||||
|
# hands played that was updated in the "update_data()" function.
|
||||||
|
self.label.set_text("Hello %s\nYou have played %d hands\n on %s." % (self.hero, self.hands_played, self.site))
|
||||||
|
|
||||||
|
class Hello_Menu(Aux_Window):
|
||||||
|
"""A 'Hello World' Aux_Window demo."""
|
||||||
|
def create(self):
|
||||||
|
# This demo puts a menu item on the HUD mainwindow.
|
||||||
|
self.item = gtk.MenuItem('Print cards')
|
||||||
|
self.hud.menu.append(self.item)
|
||||||
|
self.item.connect("activate", self.print_cards)
|
||||||
|
self.item.show()
|
||||||
|
|
||||||
|
def print_cards(self, *args):
|
||||||
|
# callback for the menu item
|
||||||
|
print "cards =", self.hud.cards
|
268
pyfpdb/Hud.py
|
@ -3,7 +3,7 @@
|
||||||
|
|
||||||
Create and manage the hud overlays.
|
Create and manage the hud overlays.
|
||||||
"""
|
"""
|
||||||
# Copyright 2008, Ray E. Barker
|
# Copyright 2008, 2009 Ray E. Barker
|
||||||
|
|
||||||
#
|
#
|
||||||
# This program is free software; you can redistribute it and/or modify
|
# This program is free software; you can redistribute it and/or modify
|
||||||
|
@ -45,9 +45,22 @@ import Mucked
|
||||||
import Database
|
import Database
|
||||||
import HUD_main
|
import HUD_main
|
||||||
|
|
||||||
|
def importName(module_name, name):
|
||||||
|
"""Import a named object 'name' from module 'module_name'."""
|
||||||
|
# Recipe 16.3 in the Python Cookbook, 2nd ed. Thanks!!!!
|
||||||
|
|
||||||
|
try:
|
||||||
|
module = __import__(module_name, globals(), locals(), [name])
|
||||||
|
except:
|
||||||
|
return None
|
||||||
|
return(getattr(module, name))
|
||||||
|
|
||||||
class Hud:
|
class Hud:
|
||||||
|
|
||||||
def __init__(self, table, max, poker_game, config, db_connection):
|
def __init__(self, parent, table, max, poker_game, config, db_connection):
|
||||||
|
# __init__ is (now) intended to be called from the stdin thread, so it
|
||||||
|
# cannot touch the gui
|
||||||
|
self.parent = parent
|
||||||
self.table = table
|
self.table = table
|
||||||
self.config = config
|
self.config = config
|
||||||
self.poker_game = poker_game
|
self.poker_game = poker_game
|
||||||
|
@ -56,29 +69,40 @@ class Hud:
|
||||||
self.deleted = False
|
self.deleted = False
|
||||||
self.stacked = True
|
self.stacked = True
|
||||||
self.site = table.site
|
self.site = table.site
|
||||||
self.colors = config.get_default_colors(self.table.site)
|
self.mw_created = False
|
||||||
|
|
||||||
self.stat_windows = {}
|
self.stat_windows = {}
|
||||||
self.popup_windows = {}
|
self.popup_windows = {}
|
||||||
self.aux_windows = []
|
self.aux_windows = []
|
||||||
|
|
||||||
(font, font_size) = config.get_default_font(self.table.site)
|
(font, font_size) = config.get_default_font(self.table.site)
|
||||||
|
self.colors = config.get_default_colors(self.table.site)
|
||||||
|
|
||||||
if font == None:
|
if font == None:
|
||||||
font = "Sans"
|
font = "Sans"
|
||||||
if font_size == None:
|
if font_size == None:
|
||||||
font_size = "8"
|
font_size = "8"
|
||||||
|
self.font = pango.FontDescription("%s %s" % (font, font_size))
|
||||||
self.font = pango.FontDescription(font + " " + font_size)
|
|
||||||
|
|
||||||
# do we need to add some sort of condition here for dealing with a request for a font that doesn't exist?
|
# do we need to add some sort of condition here for dealing with a request for a font that doesn't exist?
|
||||||
|
|
||||||
|
game_params = config.get_game_parameters(self.poker_game)
|
||||||
|
if not game_params['aux'] == [""]:
|
||||||
|
for aux in game_params['aux']:
|
||||||
|
aux_params = config.get_aux_parameters(aux)
|
||||||
|
my_import = importName(aux_params['module'], aux_params['class'])
|
||||||
|
if my_import == None:
|
||||||
|
continue
|
||||||
|
self.aux_windows.append(my_import(self, config, aux_params))
|
||||||
|
|
||||||
|
def create_mw(self):
|
||||||
|
|
||||||
# Set up a main window for this this instance of the HUD
|
# Set up a main window for this this instance of the HUD
|
||||||
self.main_window = gtk.Window()
|
self.main_window = gtk.Window()
|
||||||
self.main_window.set_gravity(gtk.gdk.GRAVITY_STATIC)
|
self.main_window.set_gravity(gtk.gdk.GRAVITY_STATIC)
|
||||||
self.main_window.set_title(table.name + " FPDBHUD")
|
self.main_window.set_title("%s FPDBHUD" % (self.table.name))
|
||||||
self.main_window.connect("destroy", self.kill_hud)
|
|
||||||
self.main_window.set_decorated(False)
|
self.main_window.set_decorated(False)
|
||||||
self.main_window.set_opacity(self.colors["hudopacity"])
|
self.main_window.set_opacity(self.colors["hudopacity"])
|
||||||
|
self.main_window.set_focus_on_map(False)
|
||||||
|
|
||||||
self.ebox = gtk.EventBox()
|
self.ebox = gtk.EventBox()
|
||||||
self.label = gtk.Label("FPDB Menu (Right Click)\nLeft-drag to move")
|
self.label = gtk.Label("FPDB Menu (Right Click)\nLeft-drag to move")
|
||||||
|
@ -101,7 +125,7 @@ class Hud:
|
||||||
self.menu = gtk.Menu()
|
self.menu = gtk.Menu()
|
||||||
self.item1 = gtk.MenuItem('Kill this HUD')
|
self.item1 = gtk.MenuItem('Kill this HUD')
|
||||||
self.menu.append(self.item1)
|
self.menu.append(self.item1)
|
||||||
self.item1.connect("activate", self.kill_hud)
|
self.item1.connect("activate", self.parent.kill_hud, self.table_name)
|
||||||
self.item1.show()
|
self.item1.show()
|
||||||
|
|
||||||
self.item2 = gtk.MenuItem('Save Layout')
|
self.item2 = gtk.MenuItem('Save Layout')
|
||||||
|
@ -122,6 +146,7 @@ class Hud:
|
||||||
self.ebox.connect_object("button-press-event", self.on_button_press, self.menu)
|
self.ebox.connect_object("button-press-event", self.on_button_press, self.menu)
|
||||||
|
|
||||||
self.main_window.show_all()
|
self.main_window.show_all()
|
||||||
|
self.mw_created = True
|
||||||
|
|
||||||
# TODO: fold all uses of this type of 'topify' code into a single function, if the differences between the versions don't
|
# TODO: fold all uses of this type of 'topify' code into a single function, if the differences between the versions don't
|
||||||
# create adverse effects?
|
# create adverse effects?
|
||||||
|
@ -129,14 +154,16 @@ class Hud:
|
||||||
if os.name == 'nt':
|
if os.name == 'nt':
|
||||||
self.topify_window(self.main_window)
|
self.topify_window(self.main_window)
|
||||||
else:
|
else:
|
||||||
self.main_window.parentgdkhandle = gtk.gdk.window_foreign_new(self.table.number) # gets a gdk handle for poker client
|
self.main_window.parentgdkhandle = gtk.gdk.window_foreign_new(int(self.table.number)) # gets a gdk handle for poker client
|
||||||
self.main_window.gdkhandle = gtk.gdk.window_foreign_new(self.main_window.window.xid) # gets a gdk handle for the hud table window
|
self.main_window.gdkhandle = gtk.gdk.window_foreign_new(self.main_window.window.xid) # gets a gdk handle for the hud table window
|
||||||
self.main_window.gdkhandle.set_transient_for(self.main_window.parentgdkhandle) #
|
self.main_window.gdkhandle.set_transient_for(self.main_window.parentgdkhandle) #
|
||||||
|
|
||||||
|
self.update_table_position()
|
||||||
|
|
||||||
def update_table_position(self):
|
def update_table_position(self):
|
||||||
if os.name == 'nt':
|
if os.name == 'nt':
|
||||||
if not win32gui.IsWindow(self.table.number):
|
if not win32gui.IsWindow(self.table.number):
|
||||||
self.kill_hud()
|
self.parent.kill_hud(self, self.table.name)
|
||||||
return False
|
return False
|
||||||
# anyone know how to do this in unix, or better yet, trap the X11 error that is triggered when executing the get_origin() for a closed window?
|
# anyone know how to do this in unix, or better yet, trap the X11 error that is triggered when executing the get_origin() for a closed window?
|
||||||
|
|
||||||
|
@ -147,10 +174,10 @@ class Hud:
|
||||||
self.main_window.move(x, y)
|
self.main_window.move(x, y)
|
||||||
adj = self.adj_seats(self.hand, self.config)
|
adj = self.adj_seats(self.hand, self.config)
|
||||||
loc = self.config.get_locations(self.table.site, self.max)
|
loc = self.config.get_locations(self.table.site, self.max)
|
||||||
for i in range(1, self.max + 1):
|
# TODO: is stat_windows getting converted somewhere from a list to a dict, for no good reason?
|
||||||
(x, y) = loc[adj[i]]
|
for i, w in enumerate(self.stat_windows.itervalues()):
|
||||||
if i in self.stat_windows:
|
(x, y) = loc[adj[i+1]]
|
||||||
self.stat_windows[i].relocate(x, y)
|
w.relocate(x, y)
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def on_button_press(self, widget, event):
|
def on_button_press(self, widget, event):
|
||||||
|
@ -162,20 +189,29 @@ class Hud:
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def kill_hud(self, *args):
|
def kill(self, *args):
|
||||||
for k in self.stat_windows:
|
# kill all stat_windows, popups and aux_windows in this HUD
|
||||||
self.stat_windows[k].window.destroy()
|
# heap dead, burnt bodies, blood 'n guts, veins between my teeth
|
||||||
self.main_window.destroy()
|
for s in self.stat_windows.itervalues():
|
||||||
self.deleted = True
|
s.kill_popups()
|
||||||
HUD_main.HUD_removed(self.table.name)
|
s.window.destroy()
|
||||||
|
self.stat_windows = {}
|
||||||
|
# also kill any aux windows
|
||||||
|
for aux in self.aux_windows:
|
||||||
|
aux.destroy()
|
||||||
|
self.aux_windows = []
|
||||||
|
|
||||||
def reposition_windows(self, *args):
|
def reposition_windows(self, *args):
|
||||||
for w in self.stat_windows:
|
for w in self.stat_windows.itervalues():
|
||||||
self.stat_windows[w].window.move(self.stat_windows[w].x, self.stat_windows[w].y)
|
if type(w) == int:
|
||||||
|
# print "in reposition, w =", w
|
||||||
|
continue
|
||||||
|
# print "in reposition, w =", w, w.x, w.y
|
||||||
|
w.window.move(w.x, w.y)
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def debug_stat_windows(self, *args):
|
def debug_stat_windows(self, *args):
|
||||||
print self.table, "\n", self.main_window.window.get_transient_for()
|
# print self.table, "\n", self.main_window.window.get_transient_for()
|
||||||
for w in self.stat_windows:
|
for w in self.stat_windows:
|
||||||
print self.stat_windows[w].window.window.get_transient_for()
|
print self.stat_windows[w].window.window.get_transient_for()
|
||||||
|
|
||||||
|
@ -186,42 +222,67 @@ class Hud:
|
||||||
new_loc = (loc[0] - self.table.x, loc[1] - self.table.y)
|
new_loc = (loc[0] - self.table.x, loc[1] - self.table.y)
|
||||||
new_layout[self.stat_windows[sw].adj - 1] = new_loc
|
new_layout[self.stat_windows[sw].adj - 1] = new_loc
|
||||||
self.config.edit_layout(self.table.site, self.max, locations = new_layout)
|
self.config.edit_layout(self.table.site, self.max, locations = new_layout)
|
||||||
|
# ask each aux to save its layout back to the config object
|
||||||
|
(aux.save_layout() for aux in self.aux_windows)
|
||||||
|
# save the config object back to the file
|
||||||
|
print "saving new xml file"
|
||||||
self.config.save()
|
self.config.save()
|
||||||
|
|
||||||
def adj_seats(self, hand, config):
|
def adj_seats(self, hand, config):
|
||||||
|
|
||||||
|
# Need range here, not xrange -> need the actual list
|
||||||
adj = range(0, self.max + 1) # default seat adjustments = no adjustment
|
adj = range(0, self.max + 1) # default seat adjustments = no adjustment
|
||||||
# does the user have a fav_seat?
|
# does the user have a fav_seat?
|
||||||
try:
|
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:
|
||||||
|
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
|
||||||
# db_connection = Database.Database(config, self.db_name, 'temp')
|
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.db_connection.get_actual_seat(hand, config.supported_sites[self.table.site].screen_name)
|
||||||
# db_connection.close_connection()
|
actual_seat = self.get_actual_seat(config.supported_sites[self.table.site].screen_name)
|
||||||
for i in range(0, self.max + 1):
|
sys.stderr.write("found actual seat = %d\n" % actual_seat)
|
||||||
|
for i in xrange(0, self.max + 1):
|
||||||
j = actual_seat + i
|
j = actual_seat + i
|
||||||
if j > self.max: j = j - self.max
|
if j > self.max:
|
||||||
|
j = j - self.max
|
||||||
adj[j] = fav_seat + i
|
adj[j] = fav_seat + i
|
||||||
if adj[j] > self.max: adj[j] = adj[j] - self.max
|
if adj[j] > self.max:
|
||||||
except:
|
adj[j] = adj[j] - self.max
|
||||||
pass
|
except Exception, inst:
|
||||||
|
sys.stderr.write("exception in adj!!!\n\n")
|
||||||
|
sys.stderr.write("error is %s" % inst) # __str__ allows args to printed directly
|
||||||
return adj
|
return adj
|
||||||
|
|
||||||
def create(self, hand, config):
|
def get_actual_seat(self, name):
|
||||||
|
for key in self.stat_dict:
|
||||||
|
if self.stat_dict[key]['screen_name'] == name:
|
||||||
|
return self.stat_dict[key]['seat']
|
||||||
|
sys.stderr.write("Error finding actual seat.\n")
|
||||||
|
|
||||||
|
def create(self, hand, config, stat_dict, cards):
|
||||||
# update this hud, to the stats and players as of "hand"
|
# update this hud, to the stats and players as of "hand"
|
||||||
# hand is the hand id of the most recent hand played at this table
|
# hand is the hand id of the most recent hand played at this table
|
||||||
#
|
#
|
||||||
# this method also manages the creating and destruction of stat
|
# this method also manages the creating and destruction of stat
|
||||||
# windows via calls to the Stat_Window class
|
# windows via calls to the Stat_Window class
|
||||||
|
self.hand = hand
|
||||||
|
if not self.mw_created:
|
||||||
|
self.create_mw()
|
||||||
|
|
||||||
|
self.stat_dict = stat_dict
|
||||||
|
self.cards = cards
|
||||||
|
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
|
||||||
for i in range(1, self.max + 1):
|
for i in xrange(1, self.max + 1):
|
||||||
(x, y) = loc[adj[i]]
|
(x, y) = loc[adj[i]]
|
||||||
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,
|
||||||
|
@ -233,56 +294,49 @@ class Hud:
|
||||||
font = self.font)
|
font = self.font)
|
||||||
|
|
||||||
self.stats = []
|
self.stats = []
|
||||||
for i in range(0, config.supported_games[self.poker_game].rows + 1):
|
game = config.supported_games[self.poker_game]
|
||||||
row_list = [''] * config.supported_games[self.poker_game].cols
|
|
||||||
|
for i in xrange(0, game.rows + 1):
|
||||||
|
row_list = [''] * game.cols
|
||||||
self.stats.append(row_list)
|
self.stats.append(row_list)
|
||||||
for stat in config.supported_games[self.poker_game].stats:
|
for stat in game.stats:
|
||||||
self.stats[config.supported_games[self.poker_game].stats[stat].row] \
|
self.stats[config.supported_games[self.poker_game].stats[stat].row] \
|
||||||
[config.supported_games[self.poker_game].stats[stat].col] = \
|
[config.supported_games[self.poker_game].stats[stat].col] = \
|
||||||
config.supported_games[self.poker_game].stats[stat].stat_name
|
config.supported_games[self.poker_game].stats[stat].stat_name
|
||||||
|
|
||||||
game_params = config.get_game_parameters(self.poker_game)
|
|
||||||
if not game_params['aux'] == "":
|
|
||||||
aux_params = config.get_aux_parameters(game_params['aux'])
|
|
||||||
self.aux_windows.append(eval("%s.%s(gtk.Window(), self, config, aux_params)" % (aux_params['module'], aux_params['class'])))
|
|
||||||
|
|
||||||
if os.name == "nt":
|
if os.name == "nt":
|
||||||
gobject.timeout_add(500, self.update_table_position)
|
gobject.timeout_add(500, self.update_table_position)
|
||||||
|
|
||||||
def update(self, hand, config, stat_dict):
|
def update(self, hand, config):
|
||||||
self.hand = hand # this is the last hand, so it is available later
|
self.hand = hand # this is the last hand, so it is available later
|
||||||
self.stat_dict = stat_dict # so this is available for popups, etc
|
if os.name == 'nt':
|
||||||
self.update_table_position()
|
self.update_table_position()
|
||||||
self.stat_dict = stat_dict
|
|
||||||
|
|
||||||
for s in stat_dict:
|
for s in self.stat_dict:
|
||||||
|
statd = self.stat_dict[s]
|
||||||
try:
|
try:
|
||||||
self.stat_windows[stat_dict[s]['seat']].player_id = stat_dict[s]['player_id']
|
self.stat_windows[self.stat_dict[s]['seat']].player_id = self.stat_dict[s]['player_id']
|
||||||
except: # omg, we have more seats than stat windows .. damn poker sites with incorrect max seating info .. let's force 10 here
|
except: # omg, we have more seats than stat windows .. damn poker sites with incorrect max seating info .. let's force 10 here
|
||||||
self.max = 10
|
self.max = 10
|
||||||
self.create(hand, config)
|
self.create(hand, config, self.stat_dict, self.cards)
|
||||||
self.stat_windows[stat_dict[s]['seat']].player_id = stat_dict[s]['player_id']
|
self.stat_windows[statd['seat']].player_id = statd['player_id']
|
||||||
|
|
||||||
for r in range(0, config.supported_games[self.poker_game].rows):
|
for r in xrange(0, config.supported_games[self.poker_game].rows):
|
||||||
for c in range(0, config.supported_games[self.poker_game].cols):
|
for c in xrange(0, config.supported_games[self.poker_game].cols):
|
||||||
this_stat = config.supported_games[self.poker_game].stats[self.stats[r][c]]
|
this_stat = config.supported_games[self.poker_game].stats[self.stats[r][c]]
|
||||||
number = Stats.do_stat(stat_dict, player = stat_dict[s]['player_id'], stat = self.stats[r][c])
|
number = Stats.do_stat(self.stat_dict, player = statd['player_id'], stat = self.stats[r][c])
|
||||||
statstring = this_stat.hudprefix + str(number[1]) + this_stat.hudsuffix
|
statstring = "%s%s%s" % (this_stat.hudprefix, str(number[1]), this_stat.hudsuffix)
|
||||||
|
window = self.stat_windows[statd['seat']]
|
||||||
|
|
||||||
if this_stat.hudcolor != "":
|
if this_stat.hudcolor != "":
|
||||||
self.label.modify_fg(gtk.STATE_NORMAL, gtk.gdk.color_parse(self.colors['hudfgcolor']))
|
self.label.modify_fg(gtk.STATE_NORMAL, gtk.gdk.color_parse(self.colors['hudfgcolor']))
|
||||||
self.stat_windows[stat_dict[s]['seat']].label[r][c].modify_fg(gtk.STATE_NORMAL, gtk.gdk.color_parse(this_stat.hudcolor))
|
window.label[r][c].modify_fg(gtk.STATE_NORMAL, gtk.gdk.color_parse(this_stat.hudcolor))
|
||||||
|
|
||||||
self.stat_windows[stat_dict[s]['seat']].label[r][c].set_text(statstring)
|
window.label[r][c].set_text(statstring)
|
||||||
if statstring != "xxx": # is there a way to tell if this particular stat window is visible already, or no?
|
if statstring != "xxx": # is there a way to tell if this particular stat window is visible already, or no?
|
||||||
self.stat_windows[stat_dict[s]['seat']].window.show_all()
|
window.window.show_all()
|
||||||
# self.reposition_windows()
|
tip = "%s\n%s\n%s, %s" % (statd['screen_name'], number[5], number[3], number[4])
|
||||||
tip = stat_dict[s]['screen_name'] + "\n" + number[5] + "\n" + \
|
Stats.do_tip(window.e_box[r][c], tip)
|
||||||
number[3] + ", " + number[4]
|
|
||||||
Stats.do_tip(self.stat_windows[stat_dict[s]['seat']].e_box[r][c], tip)
|
|
||||||
# for m in self.aux_windows:
|
|
||||||
# m.update_data(hand)
|
|
||||||
# m.update_gui(hand)
|
|
||||||
|
|
||||||
def topify_window(self, window):
|
def topify_window(self, window):
|
||||||
"""Set the specified gtk window to stayontop in MS Windows."""
|
"""Set the specified gtk window to stayontop in MS Windows."""
|
||||||
|
@ -306,6 +360,8 @@ class Hud:
|
||||||
style = win32gui.GetWindowLong(self.table.number, win32con.GWL_EXSTYLE)
|
style = win32gui.GetWindowLong(self.table.number, win32con.GWL_EXSTYLE)
|
||||||
style |= win32con.WS_CLIPCHILDREN
|
style |= win32con.WS_CLIPCHILDREN
|
||||||
win32gui.SetWindowLong(self.table.number, win32con.GWL_EXSTYLE, style)
|
win32gui.SetWindowLong(self.table.number, win32con.GWL_EXSTYLE, style)
|
||||||
|
break
|
||||||
|
|
||||||
window.set_title(real_name)
|
window.set_title(real_name)
|
||||||
|
|
||||||
class Stat_Window:
|
class Stat_Window:
|
||||||
|
@ -316,7 +372,7 @@ class Stat_Window:
|
||||||
# and double-clicks.
|
# and double-clicks.
|
||||||
|
|
||||||
if event.button == 3: # right button event
|
if event.button == 3: # right button event
|
||||||
Popup_window(widget, self)
|
self.popups.append(Popup_window(widget, self))
|
||||||
|
|
||||||
if event.button == 2: # middle button event
|
if event.button == 2: # middle button event
|
||||||
self.window.hide()
|
self.window.hide()
|
||||||
|
@ -328,6 +384,14 @@ class Stat_Window:
|
||||||
else:
|
else:
|
||||||
self.window.begin_move_drag(event.button, int(event.x_root), int(event.y_root), event.time)
|
self.window.begin_move_drag(event.button, int(event.x_root), int(event.y_root), event.time)
|
||||||
|
|
||||||
|
def kill_popup(self, popup):
|
||||||
|
popup.window.destroy()
|
||||||
|
self.popups.remove(popup)
|
||||||
|
|
||||||
|
def kill_popups(self):
|
||||||
|
map(lambda x: x.window.destroy(), self.popups)
|
||||||
|
self.popups = { }
|
||||||
|
|
||||||
def relocate(self, x, y):
|
def relocate(self, x, y):
|
||||||
self.x = x + self.table.x
|
self.x = x + self.table.x
|
||||||
self.y = y + self.table.y
|
self.y = y + self.table.y
|
||||||
|
@ -343,6 +407,8 @@ class Stat_Window:
|
||||||
self.y = y + table.y # x and y are the location relative to table.x & y
|
self.y = y + table.y # x and y are the location relative to table.x & y
|
||||||
self.player_id = player_id # looks like this isn't used ;)
|
self.player_id = player_id # looks like this isn't used ;)
|
||||||
self.sb_click = 0 # used to figure out button clicks
|
self.sb_click = 0 # used to figure out button clicks
|
||||||
|
self.popups = [] # list of open popups for this stat window
|
||||||
|
self.useframes = parent.config.get_frames(parent.site)
|
||||||
|
|
||||||
self.window = gtk.Window()
|
self.window = gtk.Window()
|
||||||
self.window.set_decorated(0)
|
self.window.set_decorated(0)
|
||||||
|
@ -351,32 +417,48 @@ class Stat_Window:
|
||||||
self.window.set_title("%s" % seat)
|
self.window.set_title("%s" % seat)
|
||||||
self.window.set_property("skip-taskbar-hint", True)
|
self.window.set_property("skip-taskbar-hint", True)
|
||||||
self.window.set_transient_for(parent.main_window)
|
self.window.set_transient_for(parent.main_window)
|
||||||
|
self.window.set_focus_on_map(False)
|
||||||
|
|
||||||
self.grid = gtk.Table(rows = self.game.rows, columns = self.game.cols, homogeneous = False)
|
grid = gtk.Table(rows = game.rows, columns = game.cols, homogeneous = False)
|
||||||
self.window.add(self.grid)
|
self.grid = grid
|
||||||
|
self.window.add(grid)
|
||||||
|
self.window.modify_bg(gtk.STATE_NORMAL, parent.backgroundcolor)
|
||||||
|
|
||||||
self.e_box = []
|
self.e_box = []
|
||||||
self.frame = []
|
self.frame = []
|
||||||
self.label = []
|
self.label = []
|
||||||
for r in range(self.game.rows):
|
usegtkframes = self.useframes
|
||||||
self.e_box.append([])
|
e_box = self.e_box
|
||||||
self.label.append([])
|
label = self.label
|
||||||
for c in range(self.game.cols):
|
for r in xrange(game.rows):
|
||||||
self.e_box[r].append( gtk.EventBox() )
|
if usegtkframes:
|
||||||
|
self.frame.append([])
|
||||||
|
e_box.append([])
|
||||||
|
label.append([])
|
||||||
|
for c in xrange(game.cols):
|
||||||
|
if usegtkframes:
|
||||||
|
self.frame[r].append( gtk.Frame() )
|
||||||
|
e_box[r].append( gtk.EventBox() )
|
||||||
|
|
||||||
self.e_box[r][c].modify_bg(gtk.STATE_NORMAL, parent.backgroundcolor)
|
e_box[r][c].modify_bg(gtk.STATE_NORMAL, parent.backgroundcolor)
|
||||||
self.e_box[r][c].modify_fg(gtk.STATE_NORMAL, parent.foregroundcolor)
|
e_box[r][c].modify_fg(gtk.STATE_NORMAL, parent.foregroundcolor)
|
||||||
|
|
||||||
Stats.do_tip(self.e_box[r][c], 'stuff')
|
Stats.do_tip(e_box[r][c], 'stuff')
|
||||||
self.grid.attach(self.e_box[r][c], c, c+1, r, r+1, xpadding = 0, ypadding = 0)
|
if usegtkframes:
|
||||||
self.label[r].append( gtk.Label('xxx') )
|
grid.attach(self.frame[r][c], c, c+1, r, r+1, xpadding = 0, ypadding = 0)
|
||||||
|
self.frame[r][c].add(e_box[r][c])
|
||||||
|
else:
|
||||||
|
grid.attach(e_box[r][c], c, c+1, r, r+1, xpadding = 0, ypadding = 0)
|
||||||
|
label[r].append( gtk.Label('xxx') )
|
||||||
|
|
||||||
self.label[r][c].modify_bg(gtk.STATE_NORMAL, parent.backgroundcolor)
|
if usegtkframes:
|
||||||
self.label[r][c].modify_fg(gtk.STATE_NORMAL, parent.foregroundcolor)
|
self.frame[r][c].modify_bg(gtk.STATE_NORMAL, parent.backgroundcolor)
|
||||||
|
label[r][c].modify_bg(gtk.STATE_NORMAL, parent.backgroundcolor)
|
||||||
|
label[r][c].modify_fg(gtk.STATE_NORMAL, parent.foregroundcolor)
|
||||||
|
|
||||||
self.e_box[r][c].add(self.label[r][c])
|
e_box[r][c].add(self.label[r][c])
|
||||||
self.e_box[r][c].connect("button_press_event", self.button_press_cb)
|
e_box[r][c].connect("button_press_event", self.button_press_cb)
|
||||||
self.label[r][c].modify_font(font)
|
label[r][c].modify_font(font)
|
||||||
|
|
||||||
self.window.set_opacity(parent.colors['hudopacity'])
|
self.window.set_opacity(parent.colors['hudopacity'])
|
||||||
|
|
||||||
|
@ -390,6 +472,7 @@ def destroy(*args): # call back for terminating the main eventloop
|
||||||
class Popup_window:
|
class Popup_window:
|
||||||
def __init__(self, parent, stat_window):
|
def __init__(self, parent, stat_window):
|
||||||
self.sb_click = 0
|
self.sb_click = 0
|
||||||
|
self.stat_window = stat_window
|
||||||
|
|
||||||
# create the popup window
|
# create the popup window
|
||||||
self.window = gtk.Window()
|
self.window = gtk.Window()
|
||||||
|
@ -419,8 +502,8 @@ class Popup_window:
|
||||||
# figure out the row, col address of the click that activated the popup
|
# figure out the row, col address of the click that activated the popup
|
||||||
row = 0
|
row = 0
|
||||||
col = 0
|
col = 0
|
||||||
for r in range(0, stat_window.game.rows):
|
for r in xrange(0, stat_window.game.rows):
|
||||||
for c in range(0, stat_window.game.cols):
|
for c in xrange(0, stat_window.game.cols):
|
||||||
if stat_window.e_box[r][c] == parent:
|
if stat_window.e_box[r][c] == parent:
|
||||||
row = r
|
row = r
|
||||||
col = c
|
col = c
|
||||||
|
@ -472,7 +555,8 @@ class Popup_window:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
if event.button == 3: # right button event
|
if event.button == 3: # right button event
|
||||||
self.window.destroy()
|
self.stat_window.kill_popup(self)
|
||||||
|
# self.window.destroy()
|
||||||
|
|
||||||
def toggle_decorated(self, widget):
|
def toggle_decorated(self, widget):
|
||||||
top = widget.get_toplevel()
|
top = widget.get_toplevel()
|
||||||
|
@ -500,7 +584,11 @@ class Popup_window:
|
||||||
|
|
||||||
for w in tl_windows:
|
for w in tl_windows:
|
||||||
if w[1] == unique_name:
|
if w[1] == unique_name:
|
||||||
win32gui.SetWindowPos(w[0], win32con.HWND_TOPMOST, 0, 0, 0, 0, win32con.SWP_NOMOVE|win32con.SWP_NOSIZE)
|
window.set_transient_for(self.parent.main_window)
|
||||||
|
style = win32gui.GetWindowLong(self.table.number, win32con.GWL_EXSTYLE)
|
||||||
|
style |= win32con.WS_CLIPCHILDREN
|
||||||
|
win32gui.SetWindowLong(self.table.number, win32con.GWL_EXSTYLE, style)
|
||||||
|
break
|
||||||
|
|
||||||
window.set_title(real_name)
|
window.set_title(real_name)
|
||||||
|
|
||||||
|
|
288
pyfpdb/Mucked.py
|
@ -3,7 +3,7 @@
|
||||||
|
|
||||||
Mucked cards display for FreePokerTools HUD.
|
Mucked cards display for FreePokerTools HUD.
|
||||||
"""
|
"""
|
||||||
# Copyright 2008, Ray E. Barker
|
# Copyright 2008, 2009, Ray E. Barker
|
||||||
#
|
#
|
||||||
# This program is free software; you can redistribute it and/or modify
|
# This program is free software; you can redistribute it and/or modify
|
||||||
# it under the terms of the GNU General Public License as published by
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
@ -25,6 +25,7 @@ Mucked cards display for FreePokerTools HUD.
|
||||||
|
|
||||||
# Standard Library modules
|
# Standard Library modules
|
||||||
import sys
|
import sys
|
||||||
|
import pprint
|
||||||
|
|
||||||
# pyGTK modules
|
# pyGTK modules
|
||||||
import pygtk
|
import pygtk
|
||||||
|
@ -36,26 +37,63 @@ import Configuration
|
||||||
import Database
|
import Database
|
||||||
|
|
||||||
class Aux_Window:
|
class Aux_Window:
|
||||||
def __init__(self, container, hud, params, config):
|
def __init__(self, hud, params, config):
|
||||||
self.config = hud
|
self.hud = hud
|
||||||
|
self.params = params
|
||||||
self.config = config
|
self.config = config
|
||||||
self.container = container
|
|
||||||
|
|
||||||
self.vbox = gtk.VBox()
|
def update_data(self, *args):
|
||||||
self.container.add(self.vbox)
|
|
||||||
|
|
||||||
def update_data(self):
|
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def update_gui(self):
|
def update_gui(self, *args):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
def create(self, *args):
|
||||||
|
pass
|
||||||
|
|
||||||
|
def relocate(self, *args):
|
||||||
|
pass
|
||||||
|
|
||||||
|
def save_layout(self, *args):
|
||||||
|
pass
|
||||||
|
|
||||||
|
def destroy(self):
|
||||||
|
try:
|
||||||
|
self.container.destroy()
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
|
||||||
|
############################################################################
|
||||||
|
# Some utility routines useful for Aux_Windows
|
||||||
|
#
|
||||||
|
def get_card_images(self):
|
||||||
|
card_images = {}
|
||||||
|
suits = ('S', 'H', 'D', 'C')
|
||||||
|
ranks = ('A', 'K', 'Q', 'J', 'T', '9', '8', '7', '6', '5', '4', '3', '2', 'B')
|
||||||
|
pb = gtk.gdk.pixbuf_new_from_file(self.config.execution_path(self.params['deck']))
|
||||||
|
|
||||||
|
for j in range(0, 14):
|
||||||
|
for i in range(0, 4):
|
||||||
|
temp_pb = gtk.gdk.Pixbuf(gtk.gdk.COLORSPACE_RGB, pb.get_has_alpha(), pb.get_bits_per_sample(), 30, 42)
|
||||||
|
pb.copy_area(30*j, 42*i, 30, 42, temp_pb, 0, 0)
|
||||||
|
card_images[(ranks[j], suits[i])] = temp_pb
|
||||||
|
return(card_images)
|
||||||
|
# cards are 30 wide x 42 high
|
||||||
|
|
||||||
|
def split_cards(self, card):
|
||||||
|
if card == 'xx': return ('B', 'S')
|
||||||
|
return (card[0], card[1].upper())
|
||||||
|
|
||||||
|
def has_cards(self, cards):
|
||||||
|
for c in cards:
|
||||||
|
if c in set('shdc'): return True
|
||||||
|
return False
|
||||||
|
|
||||||
class Stud_mucked(Aux_Window):
|
class Stud_mucked(Aux_Window):
|
||||||
def __init__(self, container, hud, config, params):
|
def __init__(self, hud, config, params):
|
||||||
|
|
||||||
self.hud = hud # hud object that this aux window supports
|
self.hud = hud # hud object that this aux window supports
|
||||||
self.config = config # configuration object for this aux window to use
|
self.config = config # configuration object for this aux window to use
|
||||||
self.container = container # parent container for this aux window widget
|
|
||||||
self.params = params # hash aux params from config
|
self.params = params # hash aux params from config
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
@ -64,12 +102,18 @@ class Stud_mucked(Aux_Window):
|
||||||
except:
|
except:
|
||||||
self.hero = ''
|
self.hero = ''
|
||||||
|
|
||||||
|
self.mucked_list = Stud_list(self, params, config, self.hero)
|
||||||
|
self.mucked_cards = Stud_cards(self, params, config)
|
||||||
|
self.mucked_list.mucked_cards = self.mucked_cards
|
||||||
|
|
||||||
|
def create(self):
|
||||||
|
|
||||||
|
self.container =gtk.Window()
|
||||||
self.vbox = gtk.VBox()
|
self.vbox = gtk.VBox()
|
||||||
self.container.add(self.vbox)
|
self.container.add(self.vbox)
|
||||||
|
|
||||||
self.mucked_list = Stud_list(self.vbox, self, params, config, self.hero)
|
self.mucked_list.create(self.vbox)
|
||||||
self.mucked_cards = Stud_cards(self.vbox, self, params, config)
|
self.mucked_cards.create(self.vbox)
|
||||||
self.mucked_list.mucked_cards = self.mucked_cards
|
|
||||||
self.container.show_all()
|
self.container.show_all()
|
||||||
|
|
||||||
def update_data(self, new_hand_id, db_connection):
|
def update_data(self, new_hand_id, db_connection):
|
||||||
|
@ -81,16 +125,16 @@ class Stud_mucked(Aux_Window):
|
||||||
self.mucked_list.update_gui(new_hand_id)
|
self.mucked_list.update_gui(new_hand_id)
|
||||||
|
|
||||||
class Stud_list:
|
class Stud_list:
|
||||||
def __init__(self, container, parent, params, config, hero):
|
def __init__(self, parent, params, config, hero):
|
||||||
|
|
||||||
self.container = container
|
|
||||||
self.parent = parent
|
self.parent = parent
|
||||||
self.params = params
|
self.params = params
|
||||||
self.config = config
|
self.config = config
|
||||||
self.hero = hero
|
self.hero = hero
|
||||||
# self.db_name = db_name
|
|
||||||
|
|
||||||
|
def create(self, container):
|
||||||
# set up a scrolled window to hold the listbox
|
# set up a scrolled window to hold the listbox
|
||||||
|
self.container = container
|
||||||
self.scrolled_window = gtk.ScrolledWindow()
|
self.scrolled_window = gtk.ScrolledWindow()
|
||||||
self.scrolled_window.set_policy(gtk.POLICY_NEVER, gtk.POLICY_ALWAYS)
|
self.scrolled_window.set_policy(gtk.POLICY_NEVER, gtk.POLICY_ALWAYS)
|
||||||
self.container.add(self.scrolled_window)
|
self.container.add(self.scrolled_window)
|
||||||
|
@ -151,7 +195,7 @@ class Stud_list:
|
||||||
winners = winners + player
|
winners = winners + player
|
||||||
pot_dec = "%.2f" % (float(pot)/100)
|
pot_dec = "%.2f" % (float(pot)/100)
|
||||||
|
|
||||||
hero_cards = self.get_hero_cards(self.parent.hero, self.parent.mucked_cards.cards)
|
hero_cards = self.get_hero_cards(self.parent.hero, self.parent.hud.cards)
|
||||||
self.info_row = ((new_hand_id, hero_cards, pot_dec, winners), )
|
self.info_row = ((new_hand_id, hero_cards, pot_dec, winners), )
|
||||||
|
|
||||||
def get_hero_cards(self, hero, cards):
|
def get_hero_cards(self, hero, cards):
|
||||||
|
@ -160,11 +204,10 @@ class Stud_list:
|
||||||
if hero == '':
|
if hero == '':
|
||||||
return "xxxxxx"
|
return "xxxxxx"
|
||||||
else:
|
else:
|
||||||
for k in cards.keys():
|
# find the hero's seat from the stat_dict
|
||||||
if cards[k]['screen_name'] == hero:
|
for stat in self.parent.hud.stat_dict.itervalues():
|
||||||
return trans[cards[k]['card1Value']] + cards[k]['card1Suit'] \
|
if stat['screen_name'] == hero:
|
||||||
+ trans[cards[k]['card2Value']] + cards[k]['card2Suit'] \
|
return self.parent.hud.cards[stat['seat']][0:6]
|
||||||
+ trans[cards[k]['card3Value']] + cards[k]['card3Suit']
|
|
||||||
return "xxxxxx"
|
return "xxxxxx"
|
||||||
|
|
||||||
def update_gui(self, new_hand_id):
|
def update_gui(self, new_hand_id):
|
||||||
|
@ -176,21 +219,23 @@ class Stud_list:
|
||||||
vadj.set_value(vadj.upper)
|
vadj.set_value(vadj.upper)
|
||||||
|
|
||||||
class Stud_cards:
|
class Stud_cards:
|
||||||
def __init__(self, container, parent, params, config):
|
def __init__(self, parent, params, config):
|
||||||
|
|
||||||
self.container = container #this is the parent container of the mucked cards widget
|
|
||||||
self.parent = parent
|
self.parent = parent
|
||||||
self.params = params
|
self.params = params
|
||||||
self.config = config
|
self.config = config
|
||||||
# self.db_name = db_name
|
# self.db_name = db_name
|
||||||
|
|
||||||
self.card_images = self.get_card_images()
|
self.card_images = self.parent.get_card_images()
|
||||||
self.seen_cards = {}
|
self.seen_cards = {}
|
||||||
self.grid_contents = {}
|
self.grid_contents = {}
|
||||||
self.eb = {}
|
self.eb = {}
|
||||||
|
|
||||||
self.rows = 8
|
self.rows = 8
|
||||||
self.cols = 7
|
self.cols = 7
|
||||||
|
|
||||||
|
def create(self, container):
|
||||||
|
self.container = container
|
||||||
self.grid = gtk.Table(self.rows, self.cols + 4, homogeneous = False)
|
self.grid = gtk.Table(self.rows, self.cols + 4, homogeneous = False)
|
||||||
|
|
||||||
for r in range(0, self.rows):
|
for r in range(0, self.rows):
|
||||||
|
@ -222,25 +267,7 @@ class Stud_cards:
|
||||||
|
|
||||||
self.container.add(self.grid)
|
self.container.add(self.grid)
|
||||||
|
|
||||||
def translate_cards(self, old_cards):
|
|
||||||
ranks = ('', '', '2', '3', '4', '5', '6', '7', '8', '9', 'T', 'J', 'Q', 'K', 'A')
|
|
||||||
|
|
||||||
for c in old_cards.keys():
|
|
||||||
for i in range(1, 8):
|
|
||||||
rank = 'card' + str(i) + 'Value'
|
|
||||||
suit = 'card' + str(i) + 'Suit'
|
|
||||||
key = 'hole_card_' + str(i)
|
|
||||||
if old_cards[c][rank] == 0:
|
|
||||||
old_cards[c][key] = 'xx'
|
|
||||||
else:
|
|
||||||
old_cards[c][key] = ranks[old_cards[c][rank]] + old_cards[c][suit]
|
|
||||||
return old_cards
|
|
||||||
|
|
||||||
def update_data(self, new_hand_id, db_connection):
|
def update_data(self, new_hand_id, db_connection):
|
||||||
# db_connection = Database.Database(self.config, 'fpdb', '')
|
|
||||||
cards = db_connection.get_cards(new_hand_id)
|
|
||||||
self.cards = self.translate_cards(cards)
|
|
||||||
|
|
||||||
self.tips = []
|
self.tips = []
|
||||||
action = db_connection.get_action_from_hand(new_hand_id)
|
action = db_connection.get_action_from_hand(new_hand_id)
|
||||||
for street in action:
|
for street in action:
|
||||||
|
@ -258,13 +285,13 @@ class Stud_cards:
|
||||||
|
|
||||||
def update_gui(self, new_hand_id):
|
def update_gui(self, new_hand_id):
|
||||||
self.clear()
|
self.clear()
|
||||||
for c in self.cards.keys():
|
for c, cards in self.parent.hud.cards.iteritems():
|
||||||
self.grid_contents[(1, self.cards[c]['seat_number'] - 1)].set_text(self.cards[c]['screen_name'])
|
self.grid_contents[(1, c - 1)].set_text(self.get_screen_name(c))
|
||||||
for i in ((0, 'hole_card_1'), (1, 'hole_card_2'), (2, 'hole_card_3'), (3, 'hole_card_4'),
|
for i in ((0, cards[0:2]), (1, cards[2:4]), (2, cards[4:6]), (3, cards[6:8]),
|
||||||
(4, 'hole_card_5'), (5, 'hole_card_6'), (6, 'hole_card_7')):
|
(4, cards[8:10]), (5, cards[10:12]), (6, cards[12:14])):
|
||||||
if not self.cards[c][i[1]] == "xx":
|
if not i[1] == "xx":
|
||||||
self.seen_cards[(i[0], self.cards[c]['seat_number'] - 1)]. \
|
self.seen_cards[(i[0], c - 1)]. \
|
||||||
set_from_pixbuf(self.card_images[self.split_cards(self.cards[c][i[1]])])
|
set_from_pixbuf(self.card_images[self.parent.split_cards(i[1])])
|
||||||
## action in tool tips for 3rd street cards
|
## action in tool tips for 3rd street cards
|
||||||
for c in (0, 1, 2):
|
for c in (0, 1, 2):
|
||||||
for r in range(0, self.rows):
|
for r in range(0, self.rows):
|
||||||
|
@ -276,8 +303,12 @@ class Stud_cards:
|
||||||
for r in range(0, self.rows):
|
for r in range(0, self.rows):
|
||||||
self.eb[(round_to_col[round], r)].set_tooltip_text(self.tips[round])
|
self.eb[(round_to_col[round], r)].set_tooltip_text(self.tips[round])
|
||||||
|
|
||||||
def split_cards(self, card):
|
def get_screen_name(self, seat_no):
|
||||||
return (card[0], card[1].upper())
|
"""Gets and returns the screen name from stat_dict, given seat number."""
|
||||||
|
for k in self.parent.hud.stat_dict.keys():
|
||||||
|
if self.parent.hud.stat_dict[k]['seat'] == seat_no:
|
||||||
|
return self.parent.hud.stat_dict[k]['screen_name']
|
||||||
|
return "No Name"
|
||||||
|
|
||||||
def clear(self):
|
def clear(self):
|
||||||
for r in range(0, self.rows):
|
for r in range(0, self.rows):
|
||||||
|
@ -286,20 +317,147 @@ class Stud_cards:
|
||||||
self.seen_cards[(c, r)].set_from_pixbuf(self.card_images[('B', 'S')])
|
self.seen_cards[(c, r)].set_from_pixbuf(self.card_images[('B', 'S')])
|
||||||
self.eb[(c, r)].set_tooltip_text('')
|
self.eb[(c, r)].set_tooltip_text('')
|
||||||
|
|
||||||
def get_card_images(self):
|
class Flop_Mucked(Aux_Window):
|
||||||
card_images = {}
|
"""Aux_Window class for displaying mucked cards for flop games."""
|
||||||
suits = ('S', 'H', 'D', 'C')
|
|
||||||
ranks = ('A', 'K', 'Q', 'J', 'T', '9', '8', '7', '6', '5', '4', '3', '2', 'B')
|
|
||||||
pb = gtk.gdk.pixbuf_new_from_file(self.config.execution_path(self.params['deck']))
|
|
||||||
|
|
||||||
for j in range(0, 14):
|
def __init__(self, hud, config, params):
|
||||||
for i in range(0, 4):
|
self.hud = hud # hud object that this aux window supports
|
||||||
temp_pb = gtk.gdk.Pixbuf(gtk.gdk.COLORSPACE_RGB, pb.get_has_alpha(), pb.get_bits_per_sample(), 30, 42)
|
self.config = config # configuration object for this aux window to use
|
||||||
pb.copy_area(30*j, 42*i, 30, 42, temp_pb, 0, 0)
|
self.params = params # dict aux params from config
|
||||||
card_images[(ranks[j], suits[i])] = temp_pb
|
self.positions = {} # dict of window positions
|
||||||
return(card_images)
|
# self.rel_positions = {} # dict of window positions, relative to the table origin
|
||||||
|
self.displayed_cards = False
|
||||||
|
self.timer_on = False # bool = Ture if the timeout for removing the cards is on
|
||||||
|
self.card_images = self.get_card_images()
|
||||||
|
|
||||||
# cards are 30 wide x 42 high
|
def create(self):
|
||||||
|
self.adj = self.hud.adj_seats(0, self.config)
|
||||||
|
loc = self.config.get_aux_locations(self.params['name'], int(self.hud.max))
|
||||||
|
|
||||||
|
self.m_windows = {} # windows to put the card images in
|
||||||
|
self.eb = {} # event boxes so we can interact with the mucked cards
|
||||||
|
self.seen_cards = {} # image objects to stash the cards in
|
||||||
|
|
||||||
|
for i in (range(1, self.hud.max + 1) + ['common']):
|
||||||
|
if i == 'common':
|
||||||
|
(x, y) = self.params['layout'][self.hud.max].common
|
||||||
|
else:
|
||||||
|
(x, y) = loc[self.adj[i]]
|
||||||
|
self.m_windows[i] = gtk.Window()
|
||||||
|
self.m_windows[i].set_decorated(False)
|
||||||
|
self.m_windows[i].set_property("skip-taskbar-hint", True)
|
||||||
|
self.m_windows[i].set_transient_for(self.hud.main_window)
|
||||||
|
self.m_windows[i].set_focus_on_map(False)
|
||||||
|
self.eb[i] = gtk.EventBox()
|
||||||
|
self.eb[i].connect("button_press_event", self.button_press_cb)
|
||||||
|
self.m_windows[i].connect("configure_event", self.configure_event_cb, i)
|
||||||
|
self.m_windows[i].add(self.eb[i])
|
||||||
|
self.seen_cards[i] = gtk.image_new_from_pixbuf(self.card_images[('B', 'H')])
|
||||||
|
self.eb[i].add(self.seen_cards[i])
|
||||||
|
self.positions[i] = (int(x) + self.hud.table.x, int(y) + self.hud.table.y)
|
||||||
|
# self.rel_positions[i] = (int(x), int(y))
|
||||||
|
self.m_windows[i].move(self.positions[i][0], self.positions[i][1])
|
||||||
|
self.m_windows[i].set_opacity(float(self.params['opacity']))
|
||||||
|
self.m_windows[i].show_all()
|
||||||
|
self.m_windows[i].hide()
|
||||||
|
|
||||||
|
def update_gui(self, new_hand_id):
|
||||||
|
"""Prepare and show the mucked cards."""
|
||||||
|
if self.displayed_cards:
|
||||||
|
self.hide_mucked_cards()
|
||||||
|
self.displayed_cards = False
|
||||||
|
for (i, cards) in self.hud.cards.iteritems():
|
||||||
|
if self.has_cards(cards):
|
||||||
|
# scratch is a working pixbuf, used to assemble the image
|
||||||
|
scratch = gtk.gdk.Pixbuf(gtk.gdk.COLORSPACE_RGB, True, 8,
|
||||||
|
int(self.params['card_wd'])*len(cards)/2,
|
||||||
|
int(self.params['card_ht']))
|
||||||
|
x = 0 # x coord where the next card starts in scratch
|
||||||
|
for card in [cards[k:k+2] for k in xrange(0, len(cards), 2)]:
|
||||||
|
# concatenate each card image to scratch
|
||||||
|
self.card_images[self.split_cards(card)].copy_area(0, 0,
|
||||||
|
int(self.params['card_wd']), int(self.params['card_ht']),
|
||||||
|
scratch, x, 0)
|
||||||
|
x = x + int(self.params['card_wd'])
|
||||||
|
self.seen_cards[i].set_from_pixbuf(scratch)
|
||||||
|
# self.m_windows[i].show_all()
|
||||||
|
self.m_windows[i].resize(1,1)
|
||||||
|
self.m_windows[i].show()
|
||||||
|
self.m_windows[i].move(self.positions[i][0], self.positions[i][1]) # here is where I move back
|
||||||
|
self.displayed_cards = True
|
||||||
|
|
||||||
|
for stats in self.hud.stat_dict.itervalues():
|
||||||
|
self.eb[stats['seat']].set_tooltip_text(stats['screen_name'])
|
||||||
|
|
||||||
|
if self.displayed_cards and float(self.params['timeout']) > 0:
|
||||||
|
self.timer_on = True
|
||||||
|
gobject.timeout_add(int(1000*float(self.params['timeout'])), self.timed_out)
|
||||||
|
|
||||||
|
def destroy(self):
|
||||||
|
"""Destroy all of the mucked windows."""
|
||||||
|
for w in self.m_windows.values():
|
||||||
|
w.destroy()
|
||||||
|
|
||||||
|
def timed_out(self):
|
||||||
|
# this is the callback from the timeout
|
||||||
|
|
||||||
|
# if timer_on is False the user has cancelled the timer with a click
|
||||||
|
# so just return False to cancel the timer
|
||||||
|
if not self.timer_on:
|
||||||
|
return False
|
||||||
|
else:
|
||||||
|
self.hide_mucked_cards()
|
||||||
|
return False
|
||||||
|
|
||||||
|
def hide_mucked_cards(self):
|
||||||
|
"""Hide the mucked card windows."""
|
||||||
|
for (i, w) in self.m_windows.iteritems():
|
||||||
|
w.hide()
|
||||||
|
self.displayed_cards = False
|
||||||
|
|
||||||
|
def button_press_cb(self, widget, event, *args):
|
||||||
|
"""Handle button clicks in the event boxes."""
|
||||||
|
|
||||||
|
# shift-any button exposes all the windows and turns off the timer
|
||||||
|
if event.state & gtk.gdk.SHIFT_MASK:
|
||||||
|
self.timer_on = False
|
||||||
|
self.expose_all()
|
||||||
|
return
|
||||||
|
|
||||||
|
if event.button == 3: # right button event
|
||||||
|
pass
|
||||||
|
|
||||||
|
elif event.button == 2: # middle button event
|
||||||
|
if self.timer_on == True:
|
||||||
|
self.timer_on = False
|
||||||
|
else:
|
||||||
|
self.timer_on = False
|
||||||
|
self.hide_mucked_cards()
|
||||||
|
|
||||||
|
elif event.button == 1: # left button event
|
||||||
|
window = widget.get_parent()
|
||||||
|
window.begin_move_drag(event.button, int(event.x_root), int(event.y_root), event.time)
|
||||||
|
|
||||||
|
def configure_event_cb(self, widget, event, i, *args):
|
||||||
|
self.positions[i] = widget.get_position()
|
||||||
|
# self.rel_positions[i] = (self.positions[i][0] - self.hud.table.x, self.positions[i][1] - self.hud.table.y)
|
||||||
|
|
||||||
|
def expose_all(self):
|
||||||
|
for (i, cards) in self.hud.cards.iteritems():
|
||||||
|
self.m_windows[i].show()
|
||||||
|
self.m_windows[i].move(self.positions[i][0], self.positions[i][1]) # here is where I move back
|
||||||
|
self.displayed_cards = True
|
||||||
|
|
||||||
|
def save_layout(self, *args):
|
||||||
|
"""Save new layout back to the aux element in the config file."""
|
||||||
|
new_locs = {}
|
||||||
|
# print "adj =", self.adj
|
||||||
|
for (i, pos) in self.positions.iteritems():
|
||||||
|
if i != 'common':
|
||||||
|
new_locs[self.adj[int(i)]] = (pos[0] - self.hud.table.x, pos[1] - self.hud.table.y)
|
||||||
|
else:
|
||||||
|
new_locs[i] = (pos[0] - self.hud.table.x, pos[1] - self.hud.table.y)
|
||||||
|
self.config.edit_aux_layout(self.params['name'], self.hud.max, locations = new_locs)
|
||||||
|
|
||||||
if __name__== "__main__":
|
if __name__== "__main__":
|
||||||
|
|
||||||
|
|
335
pyfpdb/PokerStarsToFpdb.py
Executable file
|
@ -0,0 +1,335 @@
|
||||||
|
#!/usr/bin/env python
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
#
|
||||||
|
# Copyright 2008, Carl Gherardi
|
||||||
|
#
|
||||||
|
# This program is free software; you can redistribute it and/or modify
|
||||||
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
# the Free Software Foundation; either version 2 of the License, or
|
||||||
|
# (at your option) any later version.
|
||||||
|
#
|
||||||
|
# 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 General Public License
|
||||||
|
# along with this program; if not, write to the Free Software
|
||||||
|
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
########################################################################
|
||||||
|
|
||||||
|
import sys
|
||||||
|
from HandHistoryConverter import *
|
||||||
|
|
||||||
|
# PokerStars HH Format
|
||||||
|
|
||||||
|
class PokerStars(HandHistoryConverter):
|
||||||
|
|
||||||
|
# Static regexes
|
||||||
|
re_GameInfo = re.compile("PokerStars Game #(?P<HID>[0-9]+):\s+(HORSE)? \(?(?P<GAME>Hold\'em|Razz|7 Card Stud|Omaha|Omaha Hi/Lo|Badugi) (?P<LIMIT>No Limit|Limit|Pot Limit),? \(?(?P<CURRENCY>\$|)?(?P<SB>[.0-9]+)/\$?(?P<BB>[.0-9]+)\) - (?P<DATETIME>.*$)", re.MULTILINE)
|
||||||
|
re_SplitHands = re.compile('(\n\n+)')
|
||||||
|
re_HandInfo = re.compile("^Table \'(?P<TABLE>[- a-zA-Z]+)\'(?P<TABLEATTRIBUTES>.+?$)?", re.MULTILINE)
|
||||||
|
re_Button = re.compile('Seat #(?P<BUTTON>\d+) is the button', re.MULTILINE)
|
||||||
|
re_PlayerInfo = re.compile('^Seat (?P<SEAT>[0-9]+): (?P<PNAME>.*) \(\$?(?P<CASH>[.0-9]+) in chips\)', re.MULTILINE)
|
||||||
|
re_Board = re.compile(r"\[(?P<CARDS>.+)\]")
|
||||||
|
# self.re_setHandInfoRegex('.*#(?P<HID>[0-9]+): Table (?P<TABLE>[ a-zA-Z]+) - \$?(?P<SB>[.0-9]+)/\$?(?P<BB>[.0-9]+) - (?P<GAMETYPE>.*) - (?P<HR>[0-9]+):(?P<MIN>[0-9]+) ET - (?P<YEAR>[0-9]+)/(?P<MON>[0-9]+)/(?P<DAY>[0-9]+)Table (?P<TABLE>[ a-zA-Z]+)\nSeat (?P<BUTTON>[0-9]+)')
|
||||||
|
|
||||||
|
def __init__(self, in_path = '-', out_path = '-', follow = False, autostart=True):
|
||||||
|
"""\
|
||||||
|
in_path (default '-' = sys.stdin)
|
||||||
|
out_path (default '-' = sys.stdout)
|
||||||
|
follow : whether to tail -f the input"""
|
||||||
|
HandHistoryConverter.__init__(self, in_path, out_path, sitename="PokerStars", follow=follow)
|
||||||
|
logging.info("Initialising PokerStars converter class")
|
||||||
|
self.filetype = "text"
|
||||||
|
self.codepage = "cp1252"
|
||||||
|
if autostart:
|
||||||
|
self.start()
|
||||||
|
|
||||||
|
|
||||||
|
def compilePlayerRegexs(self, hand):
|
||||||
|
players = set([player[1] for player in hand.players])
|
||||||
|
if not players <= self.compiledPlayers: # x <= y means 'x is subset of y'
|
||||||
|
# we need to recompile the player regexs.
|
||||||
|
self.compiledPlayers = players
|
||||||
|
player_re = "(?P<PNAME>" + "|".join(map(re.escape, players)) + ")"
|
||||||
|
logging.debug("player_re: " + player_re)
|
||||||
|
self.re_PostSB = re.compile(r"^%s: posts small blind \$?(?P<SB>[.0-9]+)" % player_re, re.MULTILINE)
|
||||||
|
self.re_PostBB = re.compile(r"^%s: posts big blind \$?(?P<BB>[.0-9]+)" % player_re, re.MULTILINE)
|
||||||
|
self.re_Antes = re.compile(r"^%s: posts the ante \$?(?P<ANTE>[.0-9]+)" % player_re, re.MULTILINE)
|
||||||
|
self.re_BringIn = re.compile(r"^%s: brings[- ]in( low|) for \$?(?P<BRINGIN>[.0-9]+)" % player_re, re.MULTILINE)
|
||||||
|
self.re_PostBoth = re.compile(r"^%s: posts small \& big blinds \[\$? (?P<SBBB>[.0-9]+)" % player_re, re.MULTILINE)
|
||||||
|
self.re_HeroCards = re.compile(r"^Dealt to %s(?: \[(?P<OLDCARDS>.+?)\])?( \[(?P<NEWCARDS>.+?)\])" % player_re, re.MULTILINE)
|
||||||
|
self.re_Action = re.compile(r"^%s:(?P<ATYPE> bets| checks| raises| calls| folds| discards| stands pat)( \$(?P<BET>[.\d]+))?( to \$(?P<BETTO>[.\d]+))?( (?P<NODISCARDED>\d) cards?( \[(?P<DISCARDED>.+?)\])?)?" % player_re, re.MULTILINE)
|
||||||
|
self.re_ShowdownAction = re.compile(r"^%s: shows \[(?P<CARDS>.*)\]" % player_re, re.MULTILINE)
|
||||||
|
self.re_CollectPot = re.compile(r"Seat (?P<SEAT>[0-9]+): %s (\(button\) |\(small blind\) |\(big blind\) )?(collected|showed \[.*\] and won) \(\$(?P<POT>[.\d]+)\)(, mucked| with.*|)" % player_re, re.MULTILINE)
|
||||||
|
self.re_sitsOut = re.compile("^%s sits out" % player_re, re.MULTILINE)
|
||||||
|
self.re_ShownCards = re.compile("^Seat (?P<SEAT>[0-9]+): %s \(.*\) showed \[(?P<CARDS>.*)\].*" % player_re, re.MULTILINE)
|
||||||
|
|
||||||
|
|
||||||
|
def readSupportedGames(self):
|
||||||
|
return [["ring", "hold", "nl"],
|
||||||
|
["ring", "hold", "pl"],
|
||||||
|
["ring", "hold", "fl"],
|
||||||
|
["ring", "stud", "fl"],
|
||||||
|
["ring", "draw", "fl"],
|
||||||
|
["ring", "omaha", "pl"]
|
||||||
|
]
|
||||||
|
|
||||||
|
def determineGameType(self, handText):
|
||||||
|
info = {'type':'ring'}
|
||||||
|
|
||||||
|
m = self.re_GameInfo.search(handText)
|
||||||
|
if not m:
|
||||||
|
return None
|
||||||
|
|
||||||
|
mg = m.groupdict()
|
||||||
|
|
||||||
|
# translations from captured groups to our info strings
|
||||||
|
limits = { 'No Limit':'nl', 'Pot Limit':'pl', 'Limit':'fl' }
|
||||||
|
games = { # base, category
|
||||||
|
"Hold'em" : ('hold','holdem'),
|
||||||
|
'Omaha' : ('hold','omahahi'),
|
||||||
|
'Omaha Hi/Lo' : ('hold','omahahilo'),
|
||||||
|
'Razz' : ('stud','razz'),
|
||||||
|
'7 Card Stud' : ('stud','studhi'),
|
||||||
|
'Badugi' : ('draw','badugi')
|
||||||
|
}
|
||||||
|
currencies = { u'€':'EUR', '$':'USD', '':'T$' }
|
||||||
|
if 'LIMIT' in mg:
|
||||||
|
info['limitType'] = limits[mg['LIMIT']]
|
||||||
|
if 'GAME' in mg:
|
||||||
|
(info['base'], info['category']) = games[mg['GAME']]
|
||||||
|
if 'SB' in mg:
|
||||||
|
info['sb'] = mg['SB']
|
||||||
|
if 'BB' in mg:
|
||||||
|
info['bb'] = mg['BB']
|
||||||
|
if 'CURRENCY' in mg:
|
||||||
|
info['currency'] = currencies[mg['CURRENCY']]
|
||||||
|
# NB: SB, BB must be interpreted as blinds or bets depending on limit type.
|
||||||
|
|
||||||
|
return info
|
||||||
|
|
||||||
|
|
||||||
|
def readHandInfo(self, hand):
|
||||||
|
info = {}
|
||||||
|
m = self.re_HandInfo.search(hand.handText,re.DOTALL)
|
||||||
|
if m:
|
||||||
|
info.update(m.groupdict())
|
||||||
|
# TODO: Be less lazy and parse maxseats from the HandInfo regex
|
||||||
|
if m.group('TABLEATTRIBUTES'):
|
||||||
|
m2 = re.search("\s*(\d+)-max", m.group('TABLEATTRIBUTES'))
|
||||||
|
hand.maxseats = int(m2.group(1))
|
||||||
|
m = self.re_GameInfo.search(hand.handText)
|
||||||
|
if m: info.update(m.groupdict())
|
||||||
|
m = self.re_Button.search(hand.handText)
|
||||||
|
if m: info.update(m.groupdict())
|
||||||
|
# TODO : I rather like the idea of just having this dict as hand.info
|
||||||
|
logging.debug("readHandInfo: %s" % info)
|
||||||
|
for key in info:
|
||||||
|
if key == 'DATETIME':
|
||||||
|
#2008/11/12 10:00:48 CET [2008/11/12 4:00:48 ET]
|
||||||
|
#2008/08/17 - 01:14:43 (ET)
|
||||||
|
#2008/09/07 06:23:14 ET
|
||||||
|
m2 = re.search("(?P<Y>[0-9]{4})\/(?P<M>[0-9]{2})\/(?P<D>[0-9]{2})[\- ]+(?P<H>[0-9]+):(?P<MIN>[0-9]+):(?P<S>[0-9]+)", info[key])
|
||||||
|
datetime = "%s/%s/%s %s:%s:%s" % (m2.group('Y'), m2.group('M'),m2.group('D'),m2.group('H'),m2.group('MIN'),m2.group('S'))
|
||||||
|
hand.starttime = time.strptime(datetime, "%Y/%m/%d %H:%M:%S")
|
||||||
|
if key == 'HID':
|
||||||
|
hand.handid = info[key]
|
||||||
|
if key == 'TABLE':
|
||||||
|
hand.tablename = info[key]
|
||||||
|
if key == 'BUTTON':
|
||||||
|
hand.buttonpos = info[key]
|
||||||
|
|
||||||
|
def readButton(self, hand):
|
||||||
|
m = self.re_Button.search(hand.handText)
|
||||||
|
if m:
|
||||||
|
hand.buttonpos = int(m.group('BUTTON'))
|
||||||
|
else:
|
||||||
|
logging.info('readButton: not found')
|
||||||
|
|
||||||
|
def readPlayerStacks(self, hand):
|
||||||
|
logging.debug("readPlayerStacks")
|
||||||
|
m = self.re_PlayerInfo.finditer(hand.handText)
|
||||||
|
players = []
|
||||||
|
for a in m:
|
||||||
|
hand.addPlayer(int(a.group('SEAT')), a.group('PNAME'), a.group('CASH'))
|
||||||
|
|
||||||
|
def markStreets(self, hand):
|
||||||
|
# PREFLOP = ** Dealing down cards **
|
||||||
|
# This re fails if, say, river is missing; then we don't get the ** that starts the river.
|
||||||
|
if hand.gametype['base'] in ("hold"):
|
||||||
|
m = re.search(r"\*\*\* HOLE CARDS \*\*\*(?P<PREFLOP>.+(?=\*\*\* FLOP \*\*\*)|.+)"
|
||||||
|
r"(\*\*\* FLOP \*\*\*(?P<FLOP> \[\S\S \S\S \S\S\].+(?=\*\*\* TURN \*\*\*)|.+))?"
|
||||||
|
r"(\*\*\* TURN \*\*\* \[\S\S \S\S \S\S] (?P<TURN>\[\S\S\].+(?=\*\*\* RIVER \*\*\*)|.+))?"
|
||||||
|
r"(\*\*\* RIVER \*\*\* \[\S\S \S\S \S\S \S\S] (?P<RIVER>\[\S\S\].+))?", hand.handText,re.DOTALL)
|
||||||
|
elif hand.gametype['base'] in ("stud"):
|
||||||
|
m = re.search(r"(?P<ANTES>.+(?=\*\*\* 3rd STREET \*\*\*)|.+)"
|
||||||
|
r"(\*\*\* 3rd STREET \*\*\*(?P<THIRD>.+(?=\*\*\* 4th STREET \*\*\*)|.+))?"
|
||||||
|
r"(\*\*\* 4th STREET \*\*\*(?P<FOURTH>.+(?=\*\*\* 5th STREET \*\*\*)|.+))?"
|
||||||
|
r"(\*\*\* 5th STREET \*\*\*(?P<FIFTH>.+(?=\*\*\* 6th STREET \*\*\*)|.+))?"
|
||||||
|
r"(\*\*\* 6th STREET \*\*\*(?P<SIXTH>.+(?=\*\*\* RIVER \*\*\*)|.+))?"
|
||||||
|
r"(\*\*\* RIVER \*\*\*(?P<SEVENTH>.+))?", hand.handText,re.DOTALL)
|
||||||
|
elif hand.gametype['base'] in ("draw"):
|
||||||
|
m = re.search(r"(?P<PREDEAL>.+(?=\*\*\* DEALING HANDS \*\*\*)|.+)"
|
||||||
|
r"(\*\*\* DEALING HANDS \*\*\*(?P<DEAL>.+(?=\*\*\* FIRST DRAW \*\*\*)|.+))?"
|
||||||
|
r"(\*\*\* FIRST DRAW \*\*\*(?P<DRAWONE>.+(?=\*\*\* SECOND DRAW \*\*\*)|.+))?"
|
||||||
|
r"(\*\*\* SECOND DRAW \*\*\*(?P<DRAWTWO>.+(?=\*\*\* THIRD DRAW \*\*\*)|.+))?"
|
||||||
|
r"(\*\*\* THIRD DRAW \*\*\*(?P<DRAWTHREE>.+))?", hand.handText,re.DOTALL)
|
||||||
|
hand.addStreets(m)
|
||||||
|
|
||||||
|
def readCommunityCards(self, hand, street): # street has been matched by markStreets, so exists in this hand
|
||||||
|
if street in ('FLOP','TURN','RIVER'): # a list of streets which get dealt community cards (i.e. all but PREFLOP)
|
||||||
|
#print "DEBUG readCommunityCards:", street, hand.streets.group(street)
|
||||||
|
m = self.re_Board.search(hand.streets[street])
|
||||||
|
hand.setCommunityCards(street, m.group('CARDS').split(' '))
|
||||||
|
|
||||||
|
def readAntes(self, hand):
|
||||||
|
logging.debug("reading antes")
|
||||||
|
m = self.re_Antes.finditer(hand.handText)
|
||||||
|
for player in m:
|
||||||
|
#~ logging.debug("hand.addAnte(%s,%s)" %(player.group('PNAME'), player.group('ANTE')))
|
||||||
|
hand.addAnte(player.group('PNAME'), player.group('ANTE'))
|
||||||
|
|
||||||
|
def readBringIn(self, hand):
|
||||||
|
m = self.re_BringIn.search(hand.handText,re.DOTALL)
|
||||||
|
if m:
|
||||||
|
#~ logging.debug("readBringIn: %s for %s" %(m.group('PNAME'), m.group('BRINGIN')))
|
||||||
|
hand.addBringIn(m.group('PNAME'), m.group('BRINGIN'))
|
||||||
|
|
||||||
|
def readBlinds(self, hand):
|
||||||
|
try:
|
||||||
|
m = self.re_PostSB.search(hand.handText)
|
||||||
|
hand.addBlind(m.group('PNAME'), 'small blind', m.group('SB'))
|
||||||
|
except: # no small blind
|
||||||
|
hand.addBlind(None, None, None)
|
||||||
|
for a in self.re_PostBB.finditer(hand.handText):
|
||||||
|
hand.addBlind(a.group('PNAME'), 'big blind', a.group('BB'))
|
||||||
|
for a in self.re_PostBoth.finditer(hand.handText):
|
||||||
|
hand.addBlind(a.group('PNAME'), 'small & big blinds', a.group('SBBB'))
|
||||||
|
|
||||||
|
def readHeroCards(self, hand):
|
||||||
|
m = self.re_HeroCards.search(hand.handText)
|
||||||
|
if(m == None):
|
||||||
|
#Not involved in hand
|
||||||
|
hand.involved = False
|
||||||
|
else:
|
||||||
|
hand.hero = m.group('PNAME')
|
||||||
|
# "2c, qh" -> set(["2c","qc"])
|
||||||
|
# Also works with Omaha hands.
|
||||||
|
cards = m.group('NEWCARDS')
|
||||||
|
cards = set(cards.split(' '))
|
||||||
|
hand.addHoleCards(cards, m.group('PNAME'))
|
||||||
|
|
||||||
|
def readDrawCards(self, hand, street):
|
||||||
|
logging.debug("readDrawCards")
|
||||||
|
m = self.re_HeroCards.finditer(hand.streets[street])
|
||||||
|
if m == None:
|
||||||
|
hand.involved = False
|
||||||
|
else:
|
||||||
|
for player in m:
|
||||||
|
hand.hero = player.group('PNAME') # Only really need to do this once
|
||||||
|
newcards = player.group('NEWCARDS')
|
||||||
|
oldcards = player.group('OLDCARDS')
|
||||||
|
if newcards == None:
|
||||||
|
newcards = set()
|
||||||
|
else:
|
||||||
|
newcards = set(newcards.split(' '))
|
||||||
|
if oldcards == None:
|
||||||
|
oldcards = set()
|
||||||
|
else:
|
||||||
|
oldcards = set(oldcards.split(' '))
|
||||||
|
hand.addDrawHoleCards(newcards, oldcards, player.group('PNAME'), street)
|
||||||
|
|
||||||
|
|
||||||
|
def readStudPlayerCards(self, hand, street):
|
||||||
|
# See comments of reference implementation in FullTiltToFpdb.py
|
||||||
|
logging.debug("readStudPlayerCards")
|
||||||
|
m = self.re_HeroCards.finditer(hand.streets[street])
|
||||||
|
for player in m:
|
||||||
|
#~ logging.debug(player.groupdict())
|
||||||
|
(pname, oldcards, newcards) = (player.group('PNAME'), player.group('OLDCARDS'), player.group('NEWCARDS'))
|
||||||
|
if oldcards:
|
||||||
|
oldcards = [c.strip() for c in oldcards.split(' ')]
|
||||||
|
if newcards:
|
||||||
|
newcards = [c.strip() for c in newcards.split(' ')]
|
||||||
|
if street=='ANTES':
|
||||||
|
return
|
||||||
|
elif street=='THIRD':
|
||||||
|
# we'll have observed hero holecards in CARDS and thirdstreet open cards in 'NEWCARDS'
|
||||||
|
# hero: [xx][o]
|
||||||
|
# others: [o]
|
||||||
|
hand.addPlayerCards(player = player.group('PNAME'), street = street, closed = oldcards, open = newcards)
|
||||||
|
elif street in ('FOURTH', 'FIFTH', 'SIXTH'):
|
||||||
|
# 4th:
|
||||||
|
# hero: [xxo] [o]
|
||||||
|
# others: [o] [o]
|
||||||
|
# 5th:
|
||||||
|
# hero: [xxoo] [o]
|
||||||
|
# others: [oo] [o]
|
||||||
|
# 6th:
|
||||||
|
# hero: [xxooo] [o]
|
||||||
|
# others: [ooo] [o]
|
||||||
|
hand.addPlayerCards(player = player.group('PNAME'), street = street, open = newcards)
|
||||||
|
# we may additionally want to check the earlier streets tally with what we have but lets trust it for now.
|
||||||
|
elif street=='SEVENTH' and newcards:
|
||||||
|
# hero: [xxoooo] [x]
|
||||||
|
# others: not reported.
|
||||||
|
hand.addPlayerCards(player = player.group('PNAME'), street = street, closed = newcards)
|
||||||
|
|
||||||
|
def readAction(self, hand, street):
|
||||||
|
m = self.re_Action.finditer(hand.streets[street])
|
||||||
|
for action in m:
|
||||||
|
if action.group('ATYPE') == ' raises':
|
||||||
|
hand.addRaiseBy( street, action.group('PNAME'), action.group('BET') )
|
||||||
|
elif action.group('ATYPE') == ' calls':
|
||||||
|
hand.addCall( street, action.group('PNAME'), action.group('BET') )
|
||||||
|
elif action.group('ATYPE') == ' bets':
|
||||||
|
hand.addBet( street, action.group('PNAME'), action.group('BET') )
|
||||||
|
elif action.group('ATYPE') == ' folds':
|
||||||
|
hand.addFold( street, action.group('PNAME'))
|
||||||
|
elif action.group('ATYPE') == ' checks':
|
||||||
|
hand.addCheck( street, action.group('PNAME'))
|
||||||
|
elif action.group('ATYPE') == ' discards':
|
||||||
|
hand.addDiscard(street, action.group('PNAME'), action.group('NODISCARDED'), action.group('DISCARDED'))
|
||||||
|
elif action.group('ATYPE') == ' stands pat':
|
||||||
|
hand.addStandsPat( street, action.group('PNAME'))
|
||||||
|
else:
|
||||||
|
print "DEBUG: unimplemented readAction: '%s' '%s'" %(action.group('PNAME'),action.group('ATYPE'),)
|
||||||
|
|
||||||
|
|
||||||
|
def readShowdownActions(self, hand):
|
||||||
|
for shows in self.re_ShowdownAction.finditer(hand.handText):
|
||||||
|
cards = shows.group('CARDS')
|
||||||
|
cards = set(cards.split(' '))
|
||||||
|
hand.addShownCards(cards, shows.group('PNAME'))
|
||||||
|
|
||||||
|
def readCollectPot(self,hand):
|
||||||
|
for m in self.re_CollectPot.finditer(hand.handText):
|
||||||
|
hand.addCollectPot(player=m.group('PNAME'),pot=m.group('POT'))
|
||||||
|
|
||||||
|
def readShownCards(self,hand):
|
||||||
|
for m in self.re_ShownCards.finditer(hand.handText):
|
||||||
|
if m.group('CARDS') is not None:
|
||||||
|
cards = m.group('CARDS')
|
||||||
|
cards = set(cards.split(' '))
|
||||||
|
hand.addShownCards(cards=cards, player=m.group('PNAME'))
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
parser = OptionParser()
|
||||||
|
parser.add_option("-i", "--input", dest="ipath", help="parse input hand history", default="regression-test-files/pokerstars/HH20090226 Natalie V - $0.10-$0.20 - HORSE.txt")
|
||||||
|
parser.add_option("-o", "--output", dest="opath", help="output translation to", default="-")
|
||||||
|
parser.add_option("-f", "--follow", dest="follow", help="follow (tail -f) the input", action="store_true", default=False)
|
||||||
|
parser.add_option("-q", "--quiet",
|
||||||
|
action="store_const", const=logging.CRITICAL, dest="verbosity", default=logging.INFO)
|
||||||
|
parser.add_option("-v", "--verbose",
|
||||||
|
action="store_const", const=logging.INFO, dest="verbosity")
|
||||||
|
parser.add_option("--vv",
|
||||||
|
action="store_const", const=logging.DEBUG, dest="verbosity")
|
||||||
|
|
||||||
|
(options, args) = parser.parse_args()
|
||||||
|
|
||||||
|
LOG_FILENAME = './logging.out'
|
||||||
|
logging.basicConfig(filename=LOG_FILENAME,level=options.verbosity)
|
||||||
|
|
||||||
|
e = PokerStars(in_path = options.ipath, out_path = options.opath, follow = options.follow)
|
|
@ -1,113 +0,0 @@
|
||||||
#!/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.
|
|
||||||
|
|
||||||
|
|
||||||
############################################################################
|
|
||||||
#
|
|
||||||
# File for Regression Testing fpdb
|
|
||||||
#
|
|
||||||
|
|
||||||
import os
|
|
||||||
import sys
|
|
||||||
|
|
||||||
import datetime
|
|
||||||
import Configuration
|
|
||||||
import fpdb_db
|
|
||||||
import fpdb_import
|
|
||||||
import fpdb_simple
|
|
||||||
import FpdbSQLQueries
|
|
||||||
import Tables
|
|
||||||
|
|
||||||
import unittest
|
|
||||||
|
|
||||||
class TestSequenceFunctions(unittest.TestCase):
|
|
||||||
|
|
||||||
def setUp(self):
|
|
||||||
"""Configure MySQL settings/database and establish connection"""
|
|
||||||
self.c = Configuration.Config()
|
|
||||||
self.mysql_settings={ 'db-host':"localhost",
|
|
||||||
'db-backend':2,
|
|
||||||
'db-databaseName':"fpdbtest",
|
|
||||||
'db-user':"fpdb",
|
|
||||||
'db-password':"fpdb"}
|
|
||||||
self.mysql_db = fpdb_db.fpdb_db()
|
|
||||||
self.mysql_db.connect(self.mysql_settings['db-backend'], self.mysql_settings['db-host'],
|
|
||||||
self.mysql_settings['db-databaseName'], self.mysql_settings['db-user'],
|
|
||||||
self.mysql_settings['db-password'])
|
|
||||||
self.mysqldict = FpdbSQLQueries.FpdbSQLQueries('MySQL InnoDB')
|
|
||||||
self.mysqlimporter = fpdb_import.Importer(self, self.mysql_settings, self.c)
|
|
||||||
self.mysqlimporter.setCallHud(False)
|
|
||||||
|
|
||||||
# """Configure Postgres settings/database and establish connection"""
|
|
||||||
# self.pg_settings={ 'db-host':"localhost", 'db-backend':3, 'db-databaseName':"fpdbtest", 'db-user':"fpdb", 'db-password':"fpdb"}
|
|
||||||
# self.pg_db = fpdb_db.fpdb_db()
|
|
||||||
# self.pg_db.connect(self.pg_settings['db-backend'], self.pg_settings['db-host'],
|
|
||||||
# self.pg_settings['db-databaseName'], self.pg_settings['db-user'],
|
|
||||||
# self.pg_settings['db-password'])
|
|
||||||
# self.pgdict = FpdbSQLQueries.FpdbSQLQueries('PostgreSQL')
|
|
||||||
|
|
||||||
|
|
||||||
def testDatabaseConnection(self):
|
|
||||||
"""Test all supported DBs"""
|
|
||||||
self.result = self.mysql_db.cursor.execute(self.mysqldict.query['list_tables'])
|
|
||||||
self.failUnless(self.result==13, "Number of tables in database incorrect. Expected 13 got " + str(self.result))
|
|
||||||
|
|
||||||
# self.result = self.pg_db.cursor.execute(self.pgdict.query['list_tables'])
|
|
||||||
# self.failUnless(self.result==13, "Number of tables in database incorrect. Expected 13 got " + str(self.result))
|
|
||||||
|
|
||||||
def testMySQLRecreateTables(self):
|
|
||||||
"""Test droping then recreating fpdb table schema"""
|
|
||||||
self.mysql_db.recreate_tables()
|
|
||||||
self.result = self.mysql_db.cursor.execute("SHOW TABLES")
|
|
||||||
self.failUnless(self.result==13, "Number of tables in database incorrect. Expected 13 got " + str(self.result))
|
|
||||||
|
|
||||||
def testPokerStarsHHDate(self):
|
|
||||||
latest = "PokerStars Game #21969660557: Hold'em No Limit ($0.50/$1.00) - 2008/11/12 10:00:48 CET [2008/11/12 4:00:48 ET]"
|
|
||||||
previous = "PokerStars Game #21969660557: Hold'em No Limit ($0.50/$1.00) - 2008/08/17 - 01:14:43 (ET)"
|
|
||||||
older1 = "PokerStars Game #21969660557: Hold'em No Limit ($0.50/$1.00) - 2008/09/07 06:23:14 ET"
|
|
||||||
|
|
||||||
result = fpdb_simple.parseHandStartTime(older1, "ps")
|
|
||||||
self.failUnless(result==datetime.datetime(2008,9,7,11,23,14),
|
|
||||||
"Date incorrect, expected: 2008-09-07 11:23:14 got: " + str(result))
|
|
||||||
result = fpdb_simple.parseHandStartTime(latest, "ps")
|
|
||||||
self.failUnless(result==datetime.datetime(2008,11,12,15,00,48),
|
|
||||||
"Date incorrect, expected: 2008-11-12 15:00:48 got: " + str(result))
|
|
||||||
result = fpdb_simple.parseHandStartTime(previous, "ps")
|
|
||||||
self.failUnless(result==datetime.datetime(2008,8,17,6,14,43),
|
|
||||||
"Date incorrect, expected: 2008-08-17 01:14:43 got: " + str(result))
|
|
||||||
|
|
||||||
def testTableDetection(self):
|
|
||||||
result = Tables.clean_title("French (deep)")
|
|
||||||
self.failUnless(result == "French", "French (deep) parsed incorrectly. Expected 'French' got: " + str(result))
|
|
||||||
# result = ("French (deep) - $0.25/$0.50 - No Limit Hold'em - Logged In As xxxx")
|
|
||||||
|
|
||||||
def testImportHandHistoryFiles(self):
|
|
||||||
"""Test import of single HH file"""
|
|
||||||
self.mysqlimporter.addImportFile("regression-test-files/hand-histories/ps-lhe-ring-3hands.txt")
|
|
||||||
self.mysqlimporter.runImport()
|
|
||||||
self.mysqlimporter.addImportDirectory("regression-test-files/hand-histories")
|
|
||||||
self.mysqlimporter.runImport()
|
|
||||||
|
|
||||||
# def testPostgresSQLRecreateTables(self):
|
|
||||||
# """Test droping then recreating fpdb table schema"""
|
|
||||||
# self.pg_db.recreate_tables()
|
|
||||||
# self.result = self.pg_db.cursor.execute(self.pgdict.query['list_tables'])
|
|
||||||
# self.failUnless(self.result==13, "Number of tables in database incorrect. Expected 13 got " + str(self.result))
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
|
||||||
unittest.main()
|
|
||||||
|
|
|
@ -173,6 +173,8 @@ class Sql:
|
||||||
|
|
||||||
self.query['get_stats_from_hand'] = """
|
self.query['get_stats_from_hand'] = """
|
||||||
SELECT HudCache.playerId AS player_id,
|
SELECT HudCache.playerId AS player_id,
|
||||||
|
seatNo AS seat,
|
||||||
|
name AS screen_name,
|
||||||
sum(HDs) AS n,
|
sum(HDs) AS n,
|
||||||
sum(street0VPI) AS vpip,
|
sum(street0VPI) AS vpip,
|
||||||
sum(street0Aggr) AS pfr,
|
sum(street0Aggr) AS pfr,
|
||||||
|
@ -233,6 +235,7 @@ class Sql:
|
||||||
INNER JOIN HandsPlayers ON (HandsPlayers.handId = %s)
|
INNER JOIN HandsPlayers ON (HandsPlayers.handId = %s)
|
||||||
INNER JOIN HudCache ON ( HudCache.PlayerId = HandsPlayers.PlayerId+0
|
INNER JOIN HudCache ON ( HudCache.PlayerId = HandsPlayers.PlayerId+0
|
||||||
AND HudCache.gametypeId+0 = Hands.gametypeId+0)
|
AND HudCache.gametypeId+0 = Hands.gametypeId+0)
|
||||||
|
INNER JOIN Players ON (Players.id = HandsPlayers.PlayerId+0)
|
||||||
WHERE Hands.id = %s
|
WHERE Hands.id = %s
|
||||||
GROUP BY HudCache.PlayerId
|
GROUP BY HudCache.PlayerId
|
||||||
"""
|
"""
|
||||||
|
@ -328,7 +331,7 @@ class Sql:
|
||||||
"""
|
"""
|
||||||
|
|
||||||
self.query['get_table_name'] = """
|
self.query['get_table_name'] = """
|
||||||
select tableName, maxSeats, category
|
select tableName, maxSeats, category, type
|
||||||
from Hands,Gametypes
|
from Hands,Gametypes
|
||||||
where Hands.id = %s
|
where Hands.id = %s
|
||||||
and Gametypes.id = Hands.gametypeId
|
and Gametypes.id = Hands.gametypeId
|
||||||
|
@ -358,6 +361,17 @@ class Sql:
|
||||||
order by seatNo
|
order by seatNo
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
self.query['get_common_cards'] = """
|
||||||
|
select
|
||||||
|
card1Value, card1Suit,
|
||||||
|
card2Value, card2Suit,
|
||||||
|
card3Value, card3Suit,
|
||||||
|
card4Value, card4Suit,
|
||||||
|
card5Value, card5Suit
|
||||||
|
from BoardCards
|
||||||
|
where handId = %s
|
||||||
|
"""
|
||||||
|
|
||||||
self.query['get_action_from_hand'] = """
|
self.query['get_action_from_hand'] = """
|
||||||
SELECT street, Players.name, HandsActions.action, HandsActions.amount, actionno
|
SELECT street, Players.name, HandsActions.action, HandsActions.amount, actionno
|
||||||
FROM Players, HandsActions, HandsPlayers
|
FROM Players, HandsActions, HandsPlayers
|
||||||
|
|
|
@ -72,6 +72,13 @@ def do_stat(stat_dict, player = 24, stat = 'vpip'):
|
||||||
###########################################
|
###########################################
|
||||||
# functions that return individual stats
|
# functions that return individual stats
|
||||||
|
|
||||||
|
def totalprofit(stat_dict, player):
|
||||||
|
""" Total Profit."""
|
||||||
|
if stat_dict[player]['net'] != 0:
|
||||||
|
stat = float(stat_dict[player]['net']) / 100
|
||||||
|
return (stat, '$%.2f' % stat, 'tp=$%.2f' % stat, 'totalprofit=$%.2f' % stat, str(stat), 'Total Profit')
|
||||||
|
return ('0', '$0.00', 'tp=0', 'totalprofit=0', '0', 'Total Profit')
|
||||||
|
|
||||||
def playername(stat_dict, player):
|
def playername(stat_dict, player):
|
||||||
""" Player Name."""
|
""" Player Name."""
|
||||||
return (stat_dict[player]['screen_name'],
|
return (stat_dict[player]['screen_name'],
|
||||||
|
|
|
@ -35,6 +35,7 @@ if os.name == 'nt':
|
||||||
import win32process
|
import win32process
|
||||||
import win32api
|
import win32api
|
||||||
import win32con
|
import win32con
|
||||||
|
import win32security
|
||||||
|
|
||||||
# FreePokerTools modules
|
# FreePokerTools modules
|
||||||
import Configuration
|
import Configuration
|
||||||
|
@ -129,12 +130,14 @@ def discover_posix(c):
|
||||||
# xwininfo -root -tree -id 0xnnnnn gets the info on a single window
|
# xwininfo -root -tree -id 0xnnnnn gets the info on a single window
|
||||||
for s in c.get_supported_sites():
|
for s in c.get_supported_sites():
|
||||||
params = c.get_site_parameters(s)
|
params = c.get_site_parameters(s)
|
||||||
|
|
||||||
|
# TODO: We need to make a list of phrases, shared between the WIndows and Unix code!!!!!!
|
||||||
if re.search(params['table_finder'], listing):
|
if re.search(params['table_finder'], listing):
|
||||||
if re.search('Lobby', listing): continue
|
if 'Lobby' in listing: continue
|
||||||
if re.search('Instant Hand History', listing): continue
|
if 'Instant Hand History' in listing: continue
|
||||||
if re.search('\"Full Tilt Poker\"', listing): continue # FTP Lobby
|
# if '\"Full Tilt Poker\"' in listing: continue
|
||||||
if re.search('History for table:', listing): continue
|
if 'History for table:' in listing: continue
|
||||||
if re.search('has no name', listing): continue
|
if 'has no name' in listing: continue
|
||||||
info = decode_xwininfo(c, listing)
|
info = decode_xwininfo(c, listing)
|
||||||
if info['site'] == None: continue
|
if info['site'] == None: continue
|
||||||
if info['title'] == info['exe']: continue
|
if info['title'] == info['exe']: continue
|
||||||
|
@ -147,8 +150,8 @@ def discover_posix(c):
|
||||||
def discover_posix_by_name(c, tablename):
|
def discover_posix_by_name(c, tablename):
|
||||||
"""Find an XWindows poker client of the given name."""
|
"""Find an XWindows poker client of the given name."""
|
||||||
for listing in os.popen('xwininfo -root -tree').readlines():
|
for listing in os.popen('xwininfo -root -tree').readlines():
|
||||||
if re.search(tablename, listing):
|
if tablename in listing:
|
||||||
if re.search('History for table:', listing): continue
|
if 'History for table:' in listing: continue
|
||||||
info = decode_xwininfo(c, listing)
|
info = decode_xwininfo(c, listing)
|
||||||
if not info['name'] == tablename: continue
|
if not info['name'] == tablename: continue
|
||||||
return info
|
return info
|
||||||
|
@ -195,9 +198,9 @@ def discover_nt(c):
|
||||||
titles = {}
|
titles = {}
|
||||||
tables = {}
|
tables = {}
|
||||||
win32gui.EnumWindows(win_enum_handler, titles)
|
win32gui.EnumWindows(win_enum_handler, titles)
|
||||||
for hwnd in titles.keys():
|
for hwnd in titles:
|
||||||
if re.search('Logged In as', titles[hwnd], re.IGNORECASE) and not re.search('Lobby', titles[hwnd]):
|
if 'Logged In as' in titles[hwnd] and not 'Lobby' in titles[hwnd]:
|
||||||
if re.search('Full Tilt Poker', titles[hwnd]):
|
if 'Full Tilt Poker' in titles[hwnd]:
|
||||||
continue
|
continue
|
||||||
tw = Table_Window()
|
tw = Table_Window()
|
||||||
tw.number = hwnd
|
tw.number = hwnd
|
||||||
|
@ -207,14 +210,16 @@ def discover_nt(c):
|
||||||
tw.height = int( height ) - b_width - tb_height
|
tw.height = int( height ) - b_width - tb_height
|
||||||
tw.x = int( x ) + b_width
|
tw.x = int( x ) + b_width
|
||||||
tw.y = int( y ) + tb_height
|
tw.y = int( y ) + tb_height
|
||||||
if re.search('Logged In as', titles[hwnd]):
|
|
||||||
|
# TODO: Isn't the site being determined by the EXE name it belongs to? is this section of code even useful? cleaning it anyway
|
||||||
|
if 'Logged In as' in titles[hwnd]:
|
||||||
tw.site = "PokerStars"
|
tw.site = "PokerStars"
|
||||||
elif re.search('Logged In As', titles[hwnd]): #wait, what??!
|
elif 'Logged In As' in titles[hwnd]:
|
||||||
tw.site = "Full Tilt"
|
tw.site = "Full Tilt"
|
||||||
else:
|
else:
|
||||||
tw.site = "Unknown"
|
tw.site = "Unknown"
|
||||||
sys.stderr.write("Found unknown table = %s" % tw.title)
|
sys.stderr.write("Found unknown table = %s" % tw.title)
|
||||||
if not tw.site == "Unknown":
|
if tw.site != "Unknown":
|
||||||
eval("%s(tw)" % c.supported_sites[tw.site].decoder)
|
eval("%s(tw)" % c.supported_sites[tw.site].decoder)
|
||||||
else:
|
else:
|
||||||
tw.name = "Unknown"
|
tw.name = "Unknown"
|
||||||
|
@ -226,10 +231,10 @@ def discover_nt_by_name(c, tablename):
|
||||||
titles = {}
|
titles = {}
|
||||||
win32gui.EnumWindows(win_enum_handler, titles)
|
win32gui.EnumWindows(win_enum_handler, titles)
|
||||||
for hwnd in titles:
|
for hwnd in titles:
|
||||||
if titles[hwnd].find(tablename) == -1: continue
|
if not tablename in titles[hwnd]: continue
|
||||||
if titles[hwnd].find("History for table:") > -1: continue
|
if 'History for table:' in titles[hwnd]: continue # Everleaf Network HH viewer window
|
||||||
if titles[hwnd].find("HUD:") > -1: continue
|
if 'HUD:' in titles[hwnd]: continue # FPDB HUD window
|
||||||
if titles[hwnd].find("Chat:") > -1: continue
|
if 'Chat:' in titles[hwnd]: continue # Some sites (FTP? PS? Others?) have seperable or seperately constructed chat windows
|
||||||
return decode_windows(c, titles[hwnd], hwnd)
|
return decode_windows(c, titles[hwnd], hwnd)
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
@ -246,10 +251,23 @@ def discover_nt_tournament(c, tour_number, tab_number):
|
||||||
|
|
||||||
def get_nt_exe(hwnd):
|
def get_nt_exe(hwnd):
|
||||||
"""Finds the name of the executable that the given window handle belongs to."""
|
"""Finds the name of the executable that the given window handle belongs to."""
|
||||||
|
|
||||||
|
# Request privileges to enable "debug process", so we can later use PROCESS_VM_READ, retardedly required to GetModuleFileNameEx()
|
||||||
|
priv_flags = win32security.TOKEN_ADJUST_PRIVILEGES | win32security.TOKEN_QUERY
|
||||||
|
hToken = win32security.OpenProcessToken (win32api.GetCurrentProcess(), priv_flags)
|
||||||
|
# enable "debug process"
|
||||||
|
privilege_id = win32security.LookupPrivilegeValue (None, win32security.SE_DEBUG_NAME)
|
||||||
|
old_privs = win32security.AdjustTokenPrivileges (hToken, 0, [(privilege_id, win32security.SE_PRIVILEGE_ENABLED)])
|
||||||
|
|
||||||
|
# Open the process, and query it's filename
|
||||||
processid = win32process.GetWindowThreadProcessId(hwnd)
|
processid = win32process.GetWindowThreadProcessId(hwnd)
|
||||||
pshandle = win32api.OpenProcess(win32con.PROCESS_QUERY_INFORMATION | win32con.PROCESS_VM_READ, False, processid[1])
|
pshandle = win32api.OpenProcess(win32con.PROCESS_QUERY_INFORMATION | win32con.PROCESS_VM_READ, False, processid[1])
|
||||||
exename = win32process.GetModuleFileNameEx(pshandle, 0)
|
exename = win32process.GetModuleFileNameEx(pshandle, 0)
|
||||||
|
|
||||||
|
# clean up
|
||||||
win32api.CloseHandle(pshandle)
|
win32api.CloseHandle(pshandle)
|
||||||
|
win32api.CloseHandle(hToken)
|
||||||
|
|
||||||
return exename
|
return exename
|
||||||
|
|
||||||
def decode_windows(c, title, hwnd):
|
def decode_windows(c, title, hwnd):
|
||||||
|
@ -343,7 +361,7 @@ def clean_title(name):
|
||||||
' \(deep hu\)', ' \(deep 6\)', ' \(2\)',
|
' \(deep hu\)', ' \(deep 6\)', ' \(2\)',
|
||||||
' \(edu\)', ' \(edu, 6 max\)', ' \(6\)',
|
' \(edu\)', ' \(edu, 6 max\)', ' \(6\)',
|
||||||
' \(speed\)',
|
' \(speed\)',
|
||||||
' no all-in', ' fast', ',', ' 50BB min', '\s+$']:
|
' no all-in', ' fast', ',', ' 50BB min', '50bb min', '\s+$']:
|
||||||
name = re.sub(pattern, '', name)
|
name = re.sub(pattern, '', name)
|
||||||
name = name.rstrip()
|
name = name.rstrip()
|
||||||
return name
|
return name
|
||||||
|
@ -369,12 +387,12 @@ def discover_mac_by_name(c, tablename):
|
||||||
if __name__=="__main__":
|
if __name__=="__main__":
|
||||||
c = Configuration.Config()
|
c = Configuration.Config()
|
||||||
|
|
||||||
print discover_table_by_name(c, "Ringe")
|
print discover_table_by_name(c, "Torino")
|
||||||
# print discover_tournament_table(c, "118942908", "3")
|
# print discover_tournament_table(c, "118942908", "3")
|
||||||
|
|
||||||
# tables = discover(c)
|
tables = discover(c)
|
||||||
# for t in tables.keys():
|
for t in tables.keys():
|
||||||
# print tables[t]
|
print tables[t]
|
||||||
|
|
||||||
print "press enter to continue"
|
print "press enter to continue"
|
||||||
sys.stdin.readline()
|
sys.stdin.readline()
|
||||||
|
|
690
pyfpdb/fpdb.py
|
@ -22,13 +22,15 @@ from optparse import OptionParser
|
||||||
|
|
||||||
parser = OptionParser()
|
parser = OptionParser()
|
||||||
parser.add_option("-x", "--errorsToConsole", action="store_true",
|
parser.add_option("-x", "--errorsToConsole", action="store_true",
|
||||||
help="If passed error output will go to the console rather than .")
|
help="If passed error output will go to the console rather than .")
|
||||||
|
parser.add_option("-d", "--databaseName", dest="dbname", default="fpdb",
|
||||||
|
help="Overrides the default database name")
|
||||||
(options, sys.argv) = parser.parse_args()
|
(options, sys.argv) = parser.parse_args()
|
||||||
|
|
||||||
if not options.errorsToConsole:
|
if not options.errorsToConsole:
|
||||||
print "Note: error output is being diverted to fpdb-error-log.txt and HUD-error.txt. Any major error will be reported there _only_."
|
print "Note: error output is being diverted to fpdb-error-log.txt and HUD-error.txt. Any major error will be reported there _only_."
|
||||||
errorFile = open('fpdb-error-log.txt', 'w', 0)
|
errorFile = open('fpdb-error-log.txt', 'w', 0)
|
||||||
sys.stderr = errorFile
|
sys.stderr = errorFile
|
||||||
|
|
||||||
import pygtk
|
import pygtk
|
||||||
pygtk.require('2.0')
|
pygtk.require('2.0')
|
||||||
|
@ -38,426 +40,428 @@ import fpdb_db
|
||||||
import fpdb_simple
|
import fpdb_simple
|
||||||
import GuiBulkImport
|
import GuiBulkImport
|
||||||
import GuiPlayerStats
|
import GuiPlayerStats
|
||||||
|
import GuiPositionalStats
|
||||||
import GuiTableViewer
|
import GuiTableViewer
|
||||||
import GuiAutoImport
|
import GuiAutoImport
|
||||||
import GuiGraphViewer
|
import GuiGraphViewer
|
||||||
import FpdbSQLQueries
|
import FpdbSQLQueries
|
||||||
import Configuration
|
import Configuration
|
||||||
|
|
||||||
|
VERSION = "0.11"
|
||||||
|
|
||||||
class fpdb:
|
class fpdb:
|
||||||
def tab_clicked(self, widget, tab_name):
|
def tab_clicked(self, widget, tab_name):
|
||||||
"""called when a tab button is clicked to activate that tab"""
|
"""called when a tab button is clicked to activate that tab"""
|
||||||
#print "start of tab_clicked"
|
#print "start of tab_clicked"
|
||||||
self.display_tab(tab_name)
|
self.display_tab(tab_name)
|
||||||
#end def tab_clicked
|
#end def tab_clicked
|
||||||
|
|
||||||
def add_and_display_tab(self, new_tab, new_tab_name):
|
def add_and_display_tab(self, new_tab, new_tab_name):
|
||||||
"""just calls the component methods"""
|
"""just calls the component methods"""
|
||||||
self.add_tab(new_tab, new_tab_name)
|
self.add_tab(new_tab, new_tab_name)
|
||||||
self.display_tab(new_tab_name)
|
self.display_tab(new_tab_name)
|
||||||
#end def add_and_display_tab
|
#end def add_and_display_tab
|
||||||
|
|
||||||
def add_tab(self, new_tab, new_tab_name):
|
def add_tab(self, new_tab, new_tab_name):
|
||||||
"""adds a tab, namely creates the button and displays it and appends all the relevant arrays"""
|
"""adds a tab, namely creates the button and displays it and appends all the relevant arrays"""
|
||||||
#print "start of add_tab"
|
#print "start of add_tab"
|
||||||
for i in self.tab_names: #todo: check this is valid
|
for i in self.tab_names: #todo: check this is valid
|
||||||
if i==new_tab_name:
|
if i==new_tab_name:
|
||||||
return # we depend on this to not create duplicate tabs, there's no reason to raise an error here?
|
return # we depend on this to not create duplicate tabs, there's no reason to raise an error here?
|
||||||
# raise fpdb_simple.FpdbError("duplicate tab_name not permitted")
|
# raise fpdb_simple.FpdbError("duplicate tab_name not permitted")
|
||||||
|
|
||||||
self.tabs.append(new_tab)
|
self.tabs.append(new_tab)
|
||||||
self.tab_names.append(new_tab_name)
|
self.tab_names.append(new_tab_name)
|
||||||
|
|
||||||
new_tab_sel_button=gtk.ToggleButton(new_tab_name)
|
new_tab_sel_button=gtk.ToggleButton(new_tab_name)
|
||||||
new_tab_sel_button.connect("clicked", self.tab_clicked, new_tab_name)
|
new_tab_sel_button.connect("clicked", self.tab_clicked, new_tab_name)
|
||||||
self.tab_box.add(new_tab_sel_button)
|
self.tab_box.add(new_tab_sel_button)
|
||||||
new_tab_sel_button.show()
|
new_tab_sel_button.show()
|
||||||
self.tab_buttons.append(new_tab_sel_button)
|
self.tab_buttons.append(new_tab_sel_button)
|
||||||
#end def add_tab
|
#end def add_tab
|
||||||
|
|
||||||
def display_tab(self, new_tab_name):
|
def display_tab(self, new_tab_name):
|
||||||
"""displays the indicated tab"""
|
"""displays the indicated tab"""
|
||||||
#print "start of display_tab, len(self.tab_names):",len(self.tab_names)
|
#print "start of display_tab, len(self.tab_names):",len(self.tab_names)
|
||||||
tab_no=-1
|
tab_no = -1
|
||||||
#if len(self.tab_names)>1:
|
for i, name in enumerate(self.tab_names):
|
||||||
for i in range(len(self.tab_names)):
|
if name == new_tab_name:
|
||||||
#print "display_tab, new_tab_name:",new_tab_name," self.tab_names[i]:", self.tab_names[i]
|
tab_no = i
|
||||||
if (new_tab_name==self.tab_names[i]):
|
break
|
||||||
tab_no=i
|
|
||||||
#self.tab_buttons[i].set_active(False)
|
|
||||||
#else:
|
|
||||||
# tab_no=0
|
|
||||||
|
|
||||||
#current_tab_no=-1
|
if tab_no == -1:
|
||||||
for i in range(len(self.tab_names)):
|
raise fpdb_simple.FpdbError("invalid tab_no")
|
||||||
if self.current_tab==self.tabs[i]:
|
else:
|
||||||
#self.tab_buttons[i].set_active(False)
|
self.main_vbox.remove(self.current_tab)
|
||||||
pass
|
#self.current_tab.destroy()
|
||||||
|
self.current_tab=self.tabs[tab_no]
|
||||||
|
self.main_vbox.add(self.current_tab)
|
||||||
|
self.tab_buttons[tab_no].set_active(True)
|
||||||
|
self.current_tab.show()
|
||||||
|
#end def display_tab
|
||||||
|
|
||||||
if tab_no==-1:
|
def delete_event(self, widget, event, data=None):
|
||||||
raise fpdb_simple.FpdbError("invalid tab_no")
|
return False
|
||||||
else:
|
#end def delete_event
|
||||||
self.main_vbox.remove(self.current_tab)
|
|
||||||
#self.current_tab.destroy()
|
|
||||||
self.current_tab=self.tabs[tab_no]
|
|
||||||
self.main_vbox.add(self.current_tab)
|
|
||||||
self.tab_buttons[tab_no].set_active(True)
|
|
||||||
self.current_tab.show()
|
|
||||||
#end def display_tab
|
|
||||||
|
|
||||||
def delete_event(self, widget, event, data=None):
|
def destroy(self, widget, data=None):
|
||||||
return False
|
self.quit(widget, data)
|
||||||
#end def delete_event
|
#end def destroy
|
||||||
|
|
||||||
def destroy(self, widget, data=None):
|
def dia_about(self, widget, data):
|
||||||
self.quit(widget, data)
|
print "todo: implement dia_about",
|
||||||
#end def destroy
|
print " version = %s, requires database version %s" % (VERSION, "118")
|
||||||
|
#end def dia_about
|
||||||
|
|
||||||
def dia_about(self, widget, data):
|
def dia_create_del_database(self, widget, data):
|
||||||
print "todo: implement dia_about"
|
print "todo: implement dia_create_del_database"
|
||||||
#end def dia_about
|
self.obtain_global_lock()
|
||||||
|
#end def dia_create_del_database
|
||||||
|
|
||||||
def dia_create_del_database(self, widget, data):
|
def dia_create_del_user(self, widget, data):
|
||||||
print "todo: implement dia_create_del_database"
|
print "todo: implement dia_create_del_user"
|
||||||
self.obtain_global_lock()
|
self.obtain_global_lock()
|
||||||
#end def dia_create_del_database
|
#end def dia_create_del_user
|
||||||
|
|
||||||
def dia_create_del_user(self, widget, data):
|
def dia_database_stats(self, widget, data):
|
||||||
print "todo: implement dia_create_del_user"
|
print "todo: implement dia_database_stats"
|
||||||
self.obtain_global_lock()
|
#string=fpdb_db.getDbStats(db, cursor)
|
||||||
#end def dia_create_del_user
|
#end def dia_database_stats
|
||||||
|
|
||||||
def dia_database_stats(self, widget, data):
|
def dia_delete_db_parts(self, widget, data):
|
||||||
print "todo: implement dia_database_stats"
|
print "todo: implement dia_delete_db_parts"
|
||||||
#string=fpdb_db.getDbStats(db, cursor)
|
self.obtain_global_lock()
|
||||||
#end def dia_database_stats
|
#end def dia_delete_db_parts
|
||||||
|
|
||||||
def dia_delete_db_parts(self, widget, data):
|
def dia_edit_profile(self, widget=None, data=None, create_default=False, path=None):
|
||||||
print "todo: implement dia_delete_db_parts"
|
print "todo: implement dia_edit_profile"
|
||||||
self.obtain_global_lock()
|
self.obtain_global_lock()
|
||||||
#end def dia_delete_db_parts
|
#end def dia_edit_profile
|
||||||
|
|
||||||
def dia_edit_profile(self, widget=None, data=None, create_default=False, path=None):
|
def dia_export_db(self, widget, data):
|
||||||
print "todo: implement dia_edit_profile"
|
print "todo: implement dia_export_db"
|
||||||
self.obtain_global_lock()
|
self.obtain_global_lock()
|
||||||
#end def dia_edit_profile
|
#end def dia_export_db
|
||||||
|
|
||||||
def dia_export_db(self, widget, data):
|
def dia_get_db_root_credentials(self):
|
||||||
print "todo: implement dia_export_db"
|
"""obtains db root credentials from user"""
|
||||||
self.obtain_global_lock()
|
print "todo: implement dia_get_db_root_credentials"
|
||||||
#end def dia_export_db
|
# user, pw=None, None
|
||||||
|
|
||||||
def dia_get_db_root_credentials(self):
|
|
||||||
"""obtains db root credentials from user"""
|
|
||||||
print "todo: implement dia_get_db_root_credentials"
|
|
||||||
# user, pw=None, None
|
|
||||||
#
|
#
|
||||||
# dialog=gtk.Dialog(title="DB Credentials needed", parent=None, flags=0,
|
# dialog=gtk.Dialog(title="DB Credentials needed", parent=None, flags=0,
|
||||||
# buttons=(gtk.STOCK_CANCEL,gtk.RESPONSE_CANCEL,"Connect and recreate",gtk.RESPONSE_OK))
|
# buttons=(gtk.STOCK_CANCEL,gtk.RESPONSE_CANCEL,"Connect and recreate",gtk.RESPONSE_OK))
|
||||||
#
|
#
|
||||||
# label_warning1=gtk.Label("Please enter credentials for a database user for "+self.host+" that has permissions to create a database.")
|
# label_warning1=gtk.Label("Please enter credentials for a database user for "+self.host+" that has permissions to create a database.")
|
||||||
#
|
#
|
||||||
#
|
#
|
||||||
# label_user=gtk.Label("Username")
|
# label_user=gtk.Label("Username")
|
||||||
# dialog.vbox.add(label_user)
|
# dialog.vbox.add(label_user)
|
||||||
# label_user.show()
|
# label_user.show()
|
||||||
#
|
#
|
||||||
# response=dialog.run()
|
# response=dialog.run()
|
||||||
# dialog.destroy()
|
# dialog.destroy()
|
||||||
# return (user, pw, response)
|
# return (user, pw, response)
|
||||||
#end def dia_get_db_root_credentials
|
#end def dia_get_db_root_credentials
|
||||||
|
|
||||||
def dia_import_db(self, widget, data):
|
def dia_import_db(self, widget, data):
|
||||||
print "todo: implement dia_import_db"
|
print "todo: implement dia_import_db"
|
||||||
self.obtain_global_lock()
|
self.obtain_global_lock()
|
||||||
#end def dia_import_db
|
#end def dia_import_db
|
||||||
|
|
||||||
def dia_licensing(self, widget, data):
|
def dia_licensing(self, widget, data):
|
||||||
print "todo: implement dia_licensing"
|
print "todo: implement dia_licensing"
|
||||||
#end def dia_licensing
|
#end def dia_licensing
|
||||||
|
|
||||||
def dia_load_profile(self, widget, data):
|
def dia_load_profile(self, widget, data):
|
||||||
"""Dialogue to select a file to load a profile from"""
|
"""Dialogue to select a file to load a profile from"""
|
||||||
self.obtain_global_lock()
|
self.obtain_global_lock()
|
||||||
chooser = gtk.FileChooserDialog(title="Please select a profile file to load",
|
chooser = gtk.FileChooserDialog(title="Please select a profile file to load",
|
||||||
action=gtk.FILE_CHOOSER_ACTION_OPEN,
|
action=gtk.FILE_CHOOSER_ACTION_OPEN,
|
||||||
buttons=(gtk.STOCK_CANCEL,gtk.RESPONSE_CANCEL,gtk.STOCK_OPEN,gtk.RESPONSE_OK))
|
buttons=(gtk.STOCK_CANCEL,gtk.RESPONSE_CANCEL,gtk.STOCK_OPEN,gtk.RESPONSE_OK))
|
||||||
chooser.set_filename(self.profile)
|
chooser.set_filename(self.profile)
|
||||||
|
|
||||||
response = chooser.run()
|
response = chooser.run()
|
||||||
chooser.destroy()
|
chooser.destroy()
|
||||||
if response == gtk.RESPONSE_OK:
|
if response == gtk.RESPONSE_OK:
|
||||||
self.load_profile(chooser.get_filename())
|
self.load_profile(chooser.get_filename())
|
||||||
elif response == gtk.RESPONSE_CANCEL:
|
elif response == gtk.RESPONSE_CANCEL:
|
||||||
print 'User cancelled loading profile'
|
print 'User cancelled loading profile'
|
||||||
#end def dia_load_profile
|
#end def dia_load_profile
|
||||||
|
|
||||||
def dia_recreate_tables(self, widget, data):
|
def dia_recreate_tables(self, widget, data):
|
||||||
"""Dialogue that asks user to confirm that he wants to delete and recreate the tables"""
|
"""Dialogue that asks user to confirm that he wants to delete and recreate the tables"""
|
||||||
self.obtain_global_lock()
|
self.obtain_global_lock()
|
||||||
dia_confirm=gtk.MessageDialog(parent=None, flags=0, type=gtk.MESSAGE_WARNING,
|
|
||||||
buttons=(gtk.BUTTONS_YES_NO), message_format="Confirm deleting and recreating tables")
|
|
||||||
diastring=("Please confirm that you want to (re-)create the tables. If there already are tables in the database "+self.db.database+" on "+self.db.host+" they will be deleted.")
|
|
||||||
dia_confirm.format_secondary_text(diastring)#todo: make above string with bold for db, host and deleted
|
|
||||||
|
|
||||||
response=dia_confirm.run()
|
dia_confirm = gtk.MessageDialog(parent=None, flags=0, type=gtk.MESSAGE_WARNING,
|
||||||
dia_confirm.destroy()
|
buttons=(gtk.BUTTONS_YES_NO), message_format="Confirm deleting and recreating tables")
|
||||||
if response == gtk.RESPONSE_YES:
|
diastring = "Please confirm that you want to (re-)create the tables. If there already are tables in the database "+self.db.database+" on "+self.db.host+" they will be deleted."
|
||||||
self.db.recreate_tables()
|
dia_confirm.format_secondary_text(diastring)#todo: make above string with bold for db, host and deleted
|
||||||
elif response == gtk.RESPONSE_NO:
|
|
||||||
print 'User cancelled recreating tables'
|
|
||||||
#end def dia_recreate_tables
|
|
||||||
|
|
||||||
def dia_regression_test(self, widget, data):
|
response = dia_confirm.run()
|
||||||
print "todo: implement dia_regression_test"
|
dia_confirm.destroy()
|
||||||
self.obtain_global_lock()
|
if response == gtk.RESPONSE_YES:
|
||||||
#end def dia_regression_test
|
self.db.recreate_tables()
|
||||||
|
elif response == gtk.RESPONSE_NO:
|
||||||
|
print 'User cancelled recreating tables'
|
||||||
|
#end def dia_recreate_tables
|
||||||
|
|
||||||
def dia_save_profile(self, widget, data):
|
def dia_regression_test(self, widget, data):
|
||||||
print "todo: implement dia_save_profile"
|
print "todo: implement dia_regression_test"
|
||||||
#end def dia_save_profile
|
self.obtain_global_lock()
|
||||||
|
#end def dia_regression_test
|
||||||
|
|
||||||
def diaSetupWizard(self, path):
|
def dia_save_profile(self, widget, data):
|
||||||
print "todo: implement setup wizard"
|
print "todo: implement dia_save_profile"
|
||||||
print "setup wizard not implemented - please create the default configuration file:", path
|
#end def dia_save_profile
|
||||||
diaSetupWizard = gtk.Dialog(title="Fatal Error - Config File Missing", parent=None, flags=0, buttons=(gtk.STOCK_QUIT,gtk.RESPONSE_OK))
|
|
||||||
|
|
||||||
label = gtk.Label("Please copy the config file from the docs folder to:")
|
def diaSetupWizard(self, path):
|
||||||
diaSetupWizard.vbox.add(label)
|
print "todo: implement setup wizard"
|
||||||
label.show()
|
print "setup wizard not implemented - please create the default configuration file:", path
|
||||||
|
diaSetupWizard = gtk.Dialog(title="Fatal Error - Config File Missing", parent=None, flags=0, buttons=(gtk.STOCK_QUIT,gtk.RESPONSE_OK))
|
||||||
|
|
||||||
label = gtk.Label(path)
|
label = gtk.Label("Please copy the config file from the docs folder to:")
|
||||||
diaSetupWizard.vbox.add(label)
|
diaSetupWizard.vbox.add(label)
|
||||||
label.show()
|
label.show()
|
||||||
|
|
||||||
label = gtk.Label("and edit it according to the install documentation at http://fpdb.sourceforge.net")
|
label = gtk.Label(path)
|
||||||
diaSetupWizard.vbox.add(label)
|
diaSetupWizard.vbox.add(label)
|
||||||
label.show()
|
label.show()
|
||||||
|
|
||||||
response = diaSetupWizard.run()
|
label = gtk.Label("and edit it according to the install documentation at http://fpdb.sourceforge.net")
|
||||||
sys.exit(1)
|
diaSetupWizard.vbox.add(label)
|
||||||
#end def diaSetupWizard
|
label.show()
|
||||||
|
|
||||||
def get_menu(self, window):
|
response = diaSetupWizard.run()
|
||||||
"""returns the menu for this program"""
|
sys.exit(1)
|
||||||
accel_group = gtk.AccelGroup()
|
#end def diaSetupWizard
|
||||||
self.item_factory = gtk.ItemFactory(gtk.MenuBar, "<main>", accel_group)
|
|
||||||
self.item_factory.create_items(self.menu_items)
|
|
||||||
window.add_accel_group(accel_group)
|
|
||||||
return self.item_factory.get_widget("<main>")
|
|
||||||
#end def get_menu
|
|
||||||
|
|
||||||
def load_profile(self):
|
def get_menu(self, window):
|
||||||
"""Loads profile from the provided path name."""
|
"""returns the menu for this program"""
|
||||||
self.settings = {}
|
accel_group = gtk.AccelGroup()
|
||||||
if (os.sep=="/"):
|
self.item_factory = gtk.ItemFactory(gtk.MenuBar, "<main>", accel_group)
|
||||||
self.settings['os']="linuxmac"
|
self.item_factory.create_items(self.menu_items)
|
||||||
else:
|
window.add_accel_group(accel_group)
|
||||||
self.settings['os']="windows"
|
return self.item_factory.get_widget("<main>")
|
||||||
|
#end def get_menu
|
||||||
|
|
||||||
self.settings.update(self.config.get_db_parameters())
|
def load_profile(self):
|
||||||
self.settings.update(self.config.get_tv_parameters())
|
"""Loads profile from the provided path name."""
|
||||||
self.settings.update(self.config.get_import_parameters())
|
self.settings = {}
|
||||||
self.settings.update(self.config.get_default_paths())
|
if (os.sep=="/"):
|
||||||
|
self.settings['os']="linuxmac"
|
||||||
|
else:
|
||||||
|
self.settings['os']="windows"
|
||||||
|
|
||||||
if self.db!=None:
|
self.settings.update(self.config.get_db_parameters())
|
||||||
self.db.disconnect()
|
self.settings.update(self.config.get_tv_parameters())
|
||||||
|
self.settings.update(self.config.get_import_parameters())
|
||||||
|
self.settings.update(self.config.get_default_paths())
|
||||||
|
|
||||||
self.db = fpdb_db.fpdb_db()
|
if self.db!=None:
|
||||||
#print "end of fpdb.load_profile, databaseName:",self.settings['db-databaseName']
|
self.db.disconnect()
|
||||||
self.db.connect(self.settings['db-backend'],
|
|
||||||
|
self.db = fpdb_db.fpdb_db()
|
||||||
|
#print "end of fpdb.load_profile, databaseName:",self.settings['db-databaseName']
|
||||||
|
self.db.connect(self.settings['db-backend'],
|
||||||
self.settings['db-host'],
|
self.settings['db-host'],
|
||||||
self.settings['db-databaseName'],
|
self.settings['db-databaseName'],
|
||||||
self.settings['db-user'],
|
self.settings['db-user'],
|
||||||
self.settings['db-password'])
|
self.settings['db-password'])
|
||||||
if self.db.wrongDbVersion:
|
if self.db.wrongDbVersion:
|
||||||
diaDbVersionWarning = gtk.Dialog(title="Strong Warning - Invalid database version", parent=None, flags=0, buttons=(gtk.STOCK_OK,gtk.RESPONSE_OK))
|
diaDbVersionWarning = gtk.Dialog(title="Strong Warning - Invalid database version", parent=None, flags=0, buttons=(gtk.STOCK_OK,gtk.RESPONSE_OK))
|
||||||
|
|
||||||
label = gtk.Label("An invalid DB version or missing tables have been detected.")
|
label = gtk.Label("An invalid DB version or missing tables have been detected.")
|
||||||
diaDbVersionWarning.vbox.add(label)
|
diaDbVersionWarning.vbox.add(label)
|
||||||
label.show()
|
label.show()
|
||||||
|
|
||||||
label = gtk.Label("This error is not necessarily fatal but it is strongly recommended that you recreate the tables by using the Database menu.")
|
label = gtk.Label("This error is not necessarily fatal but it is strongly recommended that you recreate the tables by using the Database menu.")
|
||||||
diaDbVersionWarning.vbox.add(label)
|
diaDbVersionWarning.vbox.add(label)
|
||||||
label.show()
|
label.show()
|
||||||
|
|
||||||
label = gtk.Label("Not doing this will likely lead to misbehaviour including fpdb crashes, corrupt data etc.")
|
label = gtk.Label("Not doing this will likely lead to misbehaviour including fpdb crashes, corrupt data etc.")
|
||||||
diaDbVersionWarning.vbox.add(label)
|
diaDbVersionWarning.vbox.add(label)
|
||||||
label.show()
|
label.show()
|
||||||
|
|
||||||
response = diaDbVersionWarning.run()
|
response = diaDbVersionWarning.run()
|
||||||
diaDbVersionWarning.destroy()
|
diaDbVersionWarning.destroy()
|
||||||
|
|
||||||
# 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.querydict = FpdbSQLQueries.FpdbSQLQueries(self.db.get_backend_name())
|
||||||
self.db.db.rollback()
|
self.db.db.rollback()
|
||||||
#end def load_profile
|
#end def load_profile
|
||||||
|
|
||||||
def not_implemented(self):
|
def not_implemented(self):
|
||||||
print "todo: called unimplemented menu entry (users: pls ignore this)"#remove this once more entries are implemented
|
print "todo: called unimplemented menu entry (users: pls ignore this)"#remove this once more entries are implemented
|
||||||
#end def not_implemented
|
#end def not_implemented
|
||||||
|
|
||||||
def obtain_global_lock(self):
|
def obtain_global_lock(self):
|
||||||
print "todo: implement obtain_global_lock (users: pls ignore this)"
|
print "todo: implement obtain_global_lock (users: pls ignore this)"
|
||||||
#end def obtain_global_lock
|
#end def obtain_global_lock
|
||||||
|
|
||||||
def quit(self, widget, data):
|
def quit(self, widget, data):
|
||||||
print "Quitting normally"
|
print "Quitting normally"
|
||||||
#check if current settings differ from profile, if so offer to save or abort
|
#check if current settings differ from profile, if so offer to save or abort
|
||||||
self.db.disconnect()
|
self.db.disconnect()
|
||||||
gtk.main_quit()
|
gtk.main_quit()
|
||||||
#end def quit_cliecked
|
#end def quit_cliecked
|
||||||
|
|
||||||
def release_global_lock(self):
|
def release_global_lock(self):
|
||||||
print "todo: implement release_global_lock"
|
print "todo: implement release_global_lock"
|
||||||
#end def release_global_lock
|
#end def release_global_lock
|
||||||
|
|
||||||
def tab_abbreviations(self, widget, data):
|
def tab_abbreviations(self, widget, data):
|
||||||
print "todo: implement tab_abbreviations"
|
print "todo: implement tab_abbreviations"
|
||||||
#end def tab_abbreviations
|
#end def tab_abbreviations
|
||||||
|
|
||||||
def tab_auto_import(self, widget, data):
|
def tab_auto_import(self, widget, data):
|
||||||
"""opens the auto import tab"""
|
"""opens the auto import tab"""
|
||||||
new_aimp_thread=GuiAutoImport.GuiAutoImport(self.settings, self.config)
|
new_aimp_thread=GuiAutoImport.GuiAutoImport(self.settings, self.config)
|
||||||
self.threads.append(new_aimp_thread)
|
self.threads.append(new_aimp_thread)
|
||||||
aimp_tab=new_aimp_thread.get_vbox()
|
aimp_tab=new_aimp_thread.get_vbox()
|
||||||
self.add_and_display_tab(aimp_tab, "Auto Import")
|
self.add_and_display_tab(aimp_tab, "Auto Import")
|
||||||
#end def tab_auto_import
|
#end def tab_auto_import
|
||||||
|
|
||||||
def tab_bulk_import(self, widget, data):
|
def tab_bulk_import(self, widget, data):
|
||||||
"""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.db, self.settings, self.config)
|
new_import_thread=GuiBulkImport.GuiBulkImport(self.db, self.settings, self.config)
|
||||||
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")
|
||||||
#end def tab_bulk_import
|
#end def tab_bulk_import
|
||||||
|
|
||||||
def tab_player_stats(self, widget, data):
|
def tab_player_stats(self, widget, data):
|
||||||
new_ps_thread=GuiPlayerStats.GuiPlayerStats(self.db, self.config, self.querydict)
|
new_ps_thread=GuiPlayerStats.GuiPlayerStats(self.db, self.config, self.querydict)
|
||||||
self.threads.append(new_ps_thread)
|
self.threads.append(new_ps_thread)
|
||||||
ps_tab=new_ps_thread.get_vbox()
|
ps_tab=new_ps_thread.get_vbox()
|
||||||
self.add_and_display_tab(ps_tab, "Player Stats")
|
self.add_and_display_tab(ps_tab, "Player Stats")
|
||||||
|
|
||||||
|
def tab_positional_stats(self, widget, data):
|
||||||
|
new_ps_thread=GuiPositionalStats.GuiPositionalStats(self.db, self.config, self.querydict)
|
||||||
|
self.threads.append(new_ps_thread)
|
||||||
|
ps_tab=new_ps_thread.get_vbox()
|
||||||
|
self.add_and_display_tab(ps_tab, "Positional Stats")
|
||||||
|
|
||||||
|
|
||||||
def tab_main_help(self, widget, data):
|
def tab_main_help(self, widget, data):
|
||||||
"""Displays a tab with the main fpdb help screen"""
|
"""Displays a tab with the main fpdb help screen"""
|
||||||
#print "start of tab_main_help"
|
#print "start of tab_main_help"
|
||||||
mh_tab=gtk.Label("""Welcome to Fpdb!
|
mh_tab=gtk.Label("""Welcome to Fpdb!
|
||||||
For documentation please visit our website at http://fpdb.sourceforge.net/ or check the docs directory in the fpdb folder.
|
For documentation please visit our website at http://fpdb.sourceforge.net/ or check the docs directory in the fpdb folder.
|
||||||
Please note that default.conf is no longer needed nor used, all configuration now happens in HUD_config.xml
|
Please note that default.conf is no longer needed nor used, all configuration now happens in HUD_config.xml
|
||||||
This program is licensed under the AGPL3, see docs"""+os.sep+"agpl-3.0.txt")
|
This program is licensed under the AGPL3, see docs"""+os.sep+"agpl-3.0.txt")
|
||||||
self.add_and_display_tab(mh_tab, "Help")
|
self.add_and_display_tab(mh_tab, "Help")
|
||||||
#end def tab_main_help
|
#end def tab_main_help
|
||||||
|
|
||||||
def tab_table_viewer(self, widget, data):
|
def tab_table_viewer(self, widget, data):
|
||||||
"""opens a table viewer tab"""
|
"""opens a table viewer tab"""
|
||||||
#print "start of tab_table_viewer"
|
#print "start of tab_table_viewer"
|
||||||
new_tv_thread=GuiTableViewer.GuiTableViewer(self.db, self.settings)
|
new_tv_thread=GuiTableViewer.GuiTableViewer(self.db, self.settings)
|
||||||
self.threads.append(new_tv_thread)
|
self.threads.append(new_tv_thread)
|
||||||
tv_tab=new_tv_thread.get_vbox()
|
tv_tab=new_tv_thread.get_vbox()
|
||||||
self.add_and_display_tab(tv_tab, "Table Viewer")
|
self.add_and_display_tab(tv_tab, "Table Viewer")
|
||||||
#end def tab_table_viewer
|
#end def tab_table_viewer
|
||||||
|
|
||||||
def tabGraphViewer(self, widget, data):
|
def tabGraphViewer(self, widget, data):
|
||||||
"""opens a graph viewer tab"""
|
"""opens a graph viewer tab"""
|
||||||
#print "start of tabGraphViewer"
|
#print "start of tabGraphViewer"
|
||||||
new_gv_thread=GuiGraphViewer.GuiGraphViewer(self.db, self.settings, self.querydict, self.config)
|
new_gv_thread=GuiGraphViewer.GuiGraphViewer(self.db, self.settings, self.querydict, self.config)
|
||||||
self.threads.append(new_gv_thread)
|
self.threads.append(new_gv_thread)
|
||||||
gv_tab=new_gv_thread.get_vbox()
|
gv_tab=new_gv_thread.get_vbox()
|
||||||
self.add_and_display_tab(gv_tab, "Graphs")
|
self.add_and_display_tab(gv_tab, "Graphs")
|
||||||
#end def tabGraphViewer
|
#end def tabGraphViewer
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.threads=[]
|
self.threads=[]
|
||||||
self.db=None
|
self.db=None
|
||||||
self.config = Configuration.Config()
|
self.config = Configuration.Config(dbname=options.dbname)
|
||||||
self.load_profile()
|
self.load_profile()
|
||||||
|
|
||||||
self.window = gtk.Window(gtk.WINDOW_TOPLEVEL)
|
self.window = gtk.Window(gtk.WINDOW_TOPLEVEL)
|
||||||
self.window.connect("delete_event", self.delete_event)
|
self.window.connect("delete_event", self.delete_event)
|
||||||
self.window.connect("destroy", self.destroy)
|
self.window.connect("destroy", self.destroy)
|
||||||
self.window.set_title("Free Poker DB - version: alpha9+, p143 or higher")
|
self.window.set_title("Free Poker DB - v%s or higher" % (VERSION, ))
|
||||||
self.window.set_border_width(1)
|
self.window.set_border_width(1)
|
||||||
self.window.set_size_request(1020,400)
|
self.window.set_size_request(1020,400)
|
||||||
self.window.set_resizable(True)
|
self.window.set_resizable(True)
|
||||||
|
|
||||||
self.menu_items = (
|
self.menu_items = (
|
||||||
( "/_Main", None, None, 0, "<Branch>" ),
|
( "/_Main", None, None, 0, "<Branch>" ),
|
||||||
( "/Main/_Load Profile (broken)", "<control>L", self.dia_load_profile, 0, None ),
|
( "/Main/_Load Profile (broken)", "<control>L", self.dia_load_profile, 0, None ),
|
||||||
( "/Main/_Edit Profile (todo)", "<control>E", self.dia_edit_profile, 0, None ),
|
( "/Main/_Edit Profile (todo)", "<control>E", self.dia_edit_profile, 0, None ),
|
||||||
( "/Main/_Save Profile (todo)", None, self.dia_save_profile, 0, None ),
|
( "/Main/_Save Profile (todo)", None, self.dia_save_profile, 0, None ),
|
||||||
("/Main/sep1", None, None, 0, "<Separator>" ),
|
("/Main/sep1", None, None, 0, "<Separator>" ),
|
||||||
("/Main/_Quit", "<control>Q", self.quit, 0, None ),
|
("/Main/_Quit", "<control>Q", self.quit, 0, None ),
|
||||||
("/_Import", None, None, 0, "<Branch>" ),
|
("/_Import", None, None, 0, "<Branch>" ),
|
||||||
("/Import/_Bulk Import", "<control>B", self.tab_bulk_import, 0, None ),
|
("/Import/_Bulk Import", "<control>B", self.tab_bulk_import, 0, None ),
|
||||||
("/Import/_Auto Import and HUD", "<control>A", self.tab_auto_import, 0, None ),
|
("/Import/_Auto Import and HUD", "<control>A", self.tab_auto_import, 0, None ),
|
||||||
("/Import/Auto _Rating (todo)", "<control>R", self.not_implemented, 0, None ),
|
("/Import/Auto _Rating (todo)", "<control>R", self.not_implemented, 0, None ),
|
||||||
("/_Viewers", None, None, 0, "<Branch>" ),
|
("/_Viewers", None, None, 0, "<Branch>" ),
|
||||||
("/_Viewers/_Auto Import and HUD", "<control>A", self.tab_auto_import, 0, None ),
|
("/_Viewers/_Auto Import and HUD", "<control>A", self.tab_auto_import, 0, None ),
|
||||||
("/Viewers/_Graphs", "<control>G", self.tabGraphViewer, 0, None ),
|
("/Viewers/_Graphs", "<control>G", self.tabGraphViewer, 0, None ),
|
||||||
("/Viewers/Hand _Replayer (todo)", None, self.not_implemented, 0, None ),
|
("/Viewers/Hand _Replayer (todo)", None, self.not_implemented, 0, None ),
|
||||||
("/Viewers/Player _Details (todo)", None, self.not_implemented, 0, None ),
|
("/Viewers/Player _Details (todo)", None, self.not_implemented, 0, None ),
|
||||||
("/Viewers/_Player Stats (tabulated view)", None, self.tab_player_stats, 0, None ),
|
("/Viewers/_Player Stats (tabulated view)", None, self.tab_player_stats, 0, None ),
|
||||||
("/Viewers/Starting _Hands (todo)", None, self.not_implemented, 0, None ),
|
("/Viewers/Positional Stats (tabulated view)", None, self.tab_positional_stats, 0, None ),
|
||||||
("/Viewers/_Session Replayer (todo)", None, self.not_implemented, 0, None ),
|
("/Viewers/Starting _Hands (todo)", None, self.not_implemented, 0, None ),
|
||||||
("/Viewers/Poker_table Viewer (mostly obselete)", "<control>T", self.tab_table_viewer, 0, None ),
|
("/Viewers/_Session Replayer (todo)", None, self.not_implemented, 0, None ),
|
||||||
#( "/Viewers/Tourney Replayer
|
("/Viewers/Poker_table Viewer (mostly obselete)", "<control>T", self.tab_table_viewer, 0, None ),
|
||||||
( "/_Database", None, None, 0, "<Branch>" ),
|
#( "/Viewers/Tourney Replayer
|
||||||
( "/Database/Create or Delete _Database (todo)", None, self.dia_create_del_database, 0, None ),
|
( "/_Database", None, None, 0, "<Branch>" ),
|
||||||
( "/Database/Create or Delete _User (todo)", None, self.dia_create_del_user, 0, None ),
|
( "/Database/Create or Delete _Database (todo)", None, self.dia_create_del_database, 0, None ),
|
||||||
( "/Database/Create or Recreate _Tables", None, self.dia_recreate_tables, 0, None ),
|
( "/Database/Create or Delete _User (todo)", None, self.dia_create_del_user, 0, None ),
|
||||||
( "/Database/_Statistics (todo)", None, self.dia_database_stats, 0, None ),
|
( "/Database/Create or Recreate _Tables", None, self.dia_recreate_tables, 0, None ),
|
||||||
( "/D_ebugging", None, None, 0, "<Branch>" ),
|
( "/Database/_Statistics (todo)", None, self.dia_database_stats, 0, None ),
|
||||||
( "/Debugging/_Delete Parts of Database (todo)", None, self.dia_delete_db_parts, 0, None ),
|
( "/D_ebugging", None, None, 0, "<Branch>" ),
|
||||||
( "/Debugging/_Export DB (todo)", None, self.dia_export_db, 0, None ),
|
( "/Debugging/_Delete Parts of Database (todo)", None, self.dia_delete_db_parts, 0, None ),
|
||||||
( "/Debugging/_Import DB (todo)", None, self.dia_import_db, 0, None ),
|
( "/Debugging/_Export DB (todo)", None, self.dia_export_db, 0, None ),
|
||||||
( "/Debugging/_Regression test (todo)", None, self.dia_regression_test, 0, None ),
|
( "/Debugging/_Import DB (todo)", None, self.dia_import_db, 0, None ),
|
||||||
( "/_Help", None, None, 0, "<LastBranch>" ),
|
( "/Debugging/_Regression test (todo)", None, self.dia_regression_test, 0, None ),
|
||||||
( "/Help/_Main Help", "<control>H", self.tab_main_help, 0, None ),
|
( "/_Help", None, None, 0, "<LastBranch>" ),
|
||||||
( "/Help/_Abbrevations (todo)", None, self.tab_abbreviations, 0, None ),
|
( "/Help/_Main Help", "<control>H", self.tab_main_help, 0, None ),
|
||||||
( "/Help/sep1", None, None, 0, "<Separator>" ),
|
( "/Help/_Abbrevations (todo)", None, self.tab_abbreviations, 0, None ),
|
||||||
( "/Help/A_bout (todo)", None, self.dia_about, 0, None ),
|
( "/Help/sep1", None, None, 0, "<Separator>" ),
|
||||||
( "/Help/_License and Copying (todo)", None, self.dia_licensing, 0, None )
|
( "/Help/A_bout (todo)", None, self.dia_about, 0, None ),
|
||||||
)
|
( "/Help/_License and Copying (todo)", None, self.dia_licensing, 0, None )
|
||||||
|
)
|
||||||
|
|
||||||
self.main_vbox = gtk.VBox(False, 1)
|
self.main_vbox = gtk.VBox(False, 1)
|
||||||
self.main_vbox.set_border_width(1)
|
self.main_vbox.set_border_width(1)
|
||||||
self.window.add(self.main_vbox)
|
self.window.add(self.main_vbox)
|
||||||
self.main_vbox.show()
|
self.main_vbox.show()
|
||||||
|
|
||||||
menubar = self.get_menu(self.window)
|
menubar = self.get_menu(self.window)
|
||||||
self.main_vbox.pack_start(menubar, False, True, 0)
|
self.main_vbox.pack_start(menubar, False, True, 0)
|
||||||
menubar.show()
|
menubar.show()
|
||||||
#done menubar
|
#done menubar
|
||||||
|
|
||||||
self.tabs=[]
|
self.tabs=[]
|
||||||
self.tab_names=[]
|
self.tab_names=[]
|
||||||
self.tab_buttons=[]
|
self.tab_buttons=[]
|
||||||
self.tab_box = gtk.HBox(False,1)
|
self.tab_box = gtk.HBox(False,1)
|
||||||
self.main_vbox.pack_start(self.tab_box, False, True, 0)
|
self.main_vbox.pack_start(self.tab_box, False, True, 0)
|
||||||
self.tab_box.show()
|
self.tab_box.show()
|
||||||
#done tab bar
|
#done tab bar
|
||||||
|
|
||||||
self.current_tab = gtk.VBox(False,1)
|
self.current_tab = gtk.VBox(False,1)
|
||||||
self.current_tab.set_border_width(1)
|
self.current_tab.set_border_width(1)
|
||||||
self.main_vbox.add(self.current_tab)
|
self.main_vbox.add(self.current_tab)
|
||||||
self.current_tab.show()
|
self.current_tab.show()
|
||||||
|
|
||||||
self.tab_main_help(None, None)
|
self.tab_main_help(None, None)
|
||||||
|
|
||||||
self.status_bar = gtk.Label("Status: Connected to "+self.db.get_backend_name()+" database named "+self.db.database+" on host "+self.db.host)
|
self.status_bar = gtk.Label("Status: Connected to "+self.db.get_backend_name()+" database named "+self.db.database+" on host "+self.db.host)
|
||||||
self.main_vbox.pack_end(self.status_bar, False, True, 0)
|
self.main_vbox.pack_end(self.status_bar, False, True, 0)
|
||||||
self.status_bar.show()
|
self.status_bar.show()
|
||||||
|
|
||||||
self.window.show()
|
self.window.show()
|
||||||
#end def __init__
|
#end def __init__
|
||||||
|
|
||||||
def main(self):
|
def main(self):
|
||||||
gtk.main()
|
gtk.main()
|
||||||
return 0
|
return 0
|
||||||
#end def main
|
#end def main
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
me = fpdb()
|
me = fpdb()
|
||||||
me.main()
|
me.main()
|
||||||
|
|
|
@ -23,12 +23,12 @@ import FpdbSQLQueries
|
||||||
class fpdb_db:
|
class fpdb_db:
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
"""Simple constructor, doesnt really do anything"""
|
"""Simple constructor, doesnt really do anything"""
|
||||||
self.db=None
|
self.db = None
|
||||||
self.cursor=None
|
self.cursor = None
|
||||||
self.sql = {}
|
self.sql = {}
|
||||||
self.MYSQL_INNODB=2
|
self.MYSQL_INNODB = 2
|
||||||
self.PGSQL=3
|
self.PGSQL = 3
|
||||||
self.SQLITE=4
|
self.SQLITE = 4
|
||||||
#end def __init__
|
#end def __init__
|
||||||
|
|
||||||
def do_connect(self, config=None):
|
def do_connect(self, config=None):
|
||||||
|
@ -37,10 +37,7 @@ class fpdb_db:
|
||||||
raise FpdbError('Configuration not defined')
|
raise FpdbError('Configuration not defined')
|
||||||
|
|
||||||
self.settings = {}
|
self.settings = {}
|
||||||
if (os.sep=="/"):
|
self.settings['os'] = "linuxmac" if os.name != "nt" else "windows"
|
||||||
self.settings['os']="linuxmac"
|
|
||||||
else:
|
|
||||||
self.settings['os']="windows"
|
|
||||||
|
|
||||||
self.settings.update(config.get_db_parameters())
|
self.settings.update(config.get_db_parameters())
|
||||||
self.connect(self.settings['db-backend'],
|
self.connect(self.settings['db-backend'],
|
||||||
|
@ -62,7 +59,7 @@ class fpdb_db:
|
||||||
self.database=database
|
self.database=database
|
||||||
if backend==self.MYSQL_INNODB:
|
if backend==self.MYSQL_INNODB:
|
||||||
import MySQLdb
|
import MySQLdb
|
||||||
self.db=MySQLdb.connect(host = host, user = user, passwd = password, db = database)
|
self.db=MySQLdb.connect(host = host, user = user, passwd = password, db = database, use_unicode=True)
|
||||||
elif backend==self.PGSQL:
|
elif backend==self.PGSQL:
|
||||||
import psycopg2
|
import psycopg2
|
||||||
# If DB connection is made over TCP, then the variables
|
# If DB connection is made over TCP, then the variables
|
||||||
|
|
|
@ -17,8 +17,24 @@
|
||||||
|
|
||||||
#see status.txt for site/games support info
|
#see status.txt for site/games support info
|
||||||
|
|
||||||
import sys
|
# Standard Library modules
|
||||||
|
|
||||||
|
import os # todo: remove this once import_dir is in fpdb_import
|
||||||
|
import sys
|
||||||
|
from time import time, strftime
|
||||||
|
import traceback
|
||||||
|
import math
|
||||||
|
import datetime
|
||||||
|
import re
|
||||||
|
|
||||||
|
# fpdb/FreePokerTools modules
|
||||||
|
|
||||||
|
import fpdb_simple
|
||||||
|
import fpdb_db
|
||||||
|
import fpdb_parse_logic
|
||||||
|
import Configuration
|
||||||
|
|
||||||
|
# database interface modules
|
||||||
try:
|
try:
|
||||||
import MySQLdb
|
import MySQLdb
|
||||||
mysqlLibFound=True
|
mysqlLibFound=True
|
||||||
|
@ -31,40 +47,30 @@ try:
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
import traceback
|
|
||||||
import math
|
|
||||||
import os
|
|
||||||
import datetime
|
|
||||||
import re
|
|
||||||
import fpdb_db
|
|
||||||
import fpdb_simple
|
|
||||||
import fpdb_parse_logic
|
|
||||||
from time import time
|
|
||||||
|
|
||||||
class Importer:
|
class Importer:
|
||||||
|
|
||||||
def __init__(self, caller, settings, config):
|
def __init__(self, caller, settings, config):
|
||||||
"""Constructor"""
|
"""Constructor"""
|
||||||
self.settings=settings
|
self.settings = settings
|
||||||
self.caller=caller
|
self.caller = caller
|
||||||
self.config = config
|
self.config = config
|
||||||
self.fdb = None
|
self.fdb = None
|
||||||
self.cursor = None
|
self.cursor = None
|
||||||
self.filelist = {}
|
self.filelist = {}
|
||||||
self.dirlist = {}
|
self.dirlist = {}
|
||||||
self.monitor = False
|
self.addToDirList = {}
|
||||||
self.updated = {} #Time last import was run {file:mtime}
|
self.removeFromFileList = {} # to remove deleted files
|
||||||
self.lines = None
|
self.monitor = False
|
||||||
self.faobs = None #File as one big string
|
self.updated = {} #Time last import was run {file:mtime}
|
||||||
|
self.lines = None
|
||||||
|
self.faobs = None #File as one big string
|
||||||
self.pos_in_file = {} # dict to remember how far we have read in the file
|
self.pos_in_file = {} # dict to remember how far we have read in the file
|
||||||
#Set defaults
|
#Set defaults
|
||||||
self.callHud = self.config.get_import_parameters().get("callFpdbHud")
|
self.callHud = self.config.get_import_parameters().get("callFpdbHud")
|
||||||
if not self.settings.has_key('minPrint'):
|
|
||||||
#TODO: Is this value in the xml file?
|
self.settings.setdefault("minPrint", 30)
|
||||||
self.settings['minPrint'] = 30
|
self.settings.setdefault("handCount", 0)
|
||||||
if not self.settings.has_key('handCount'):
|
|
||||||
#TODO: Is this value in the xml file?
|
|
||||||
self.settings['handCount'] = 0
|
|
||||||
self.fdb = fpdb_db.fpdb_db() # sets self.fdb.db self.fdb.cursor and self.fdb.sql
|
self.fdb = fpdb_db.fpdb_db() # sets self.fdb.db self.fdb.cursor and self.fdb.sql
|
||||||
self.fdb.do_connect(self.config)
|
self.fdb.do_connect(self.config)
|
||||||
self.fdb.db.rollback()
|
self.fdb.db.rollback()
|
||||||
|
@ -85,6 +91,15 @@ class Importer:
|
||||||
def setFailOnError(self, value):
|
def setFailOnError(self, value):
|
||||||
self.settings['failOnError'] = value
|
self.settings['failOnError'] = value
|
||||||
|
|
||||||
|
def setHandsInDB(self, value):
|
||||||
|
self.settings['handsInDB'] = value
|
||||||
|
|
||||||
|
def setThreads(self, value):
|
||||||
|
self.settings['threads'] = value
|
||||||
|
|
||||||
|
def setDropIndexes(self, value):
|
||||||
|
self.settings['dropIndexes'] = value
|
||||||
|
|
||||||
# def setWatchTime(self):
|
# def setWatchTime(self):
|
||||||
# self.updated = time()
|
# self.updated = time()
|
||||||
|
|
||||||
|
@ -93,14 +108,30 @@ class Importer:
|
||||||
|
|
||||||
#Add an individual file to filelist
|
#Add an individual file to filelist
|
||||||
def addImportFile(self, filename, site = "default", filter = "passthrough"):
|
def addImportFile(self, filename, site = "default", filter = "passthrough"):
|
||||||
#TODO: test it is a valid file
|
#TODO: test it is a valid file -> put that in config!!
|
||||||
self.filelist[filename] = [site] + [filter]
|
self.filelist[filename] = [site] + [filter]
|
||||||
|
|
||||||
|
# Called from GuiBulkImport to add a file or directory.
|
||||||
|
def addBulkImportImportFileOrDir(self, inputPath,filter = "passthrough"):
|
||||||
|
"""Add a file or directory for bulk import"""
|
||||||
|
|
||||||
|
# Bulk import never monitors
|
||||||
|
# if directory, add all files in it. Otherwise add single file.
|
||||||
|
# TODO: only add sane files?
|
||||||
|
if os.path.isdir(inputPath):
|
||||||
|
for subdir in os.walk(inputPath):
|
||||||
|
for file in subdir[2]:
|
||||||
|
self.addImportFile(os.path.join(inputPath, subdir[0], file), site="default", filter=filter)
|
||||||
|
else:
|
||||||
|
self.addImportFile(inputPath, site="default", filter=filter)
|
||||||
#Add a directory of files to filelist
|
#Add a directory of files to filelist
|
||||||
#Only one import directory per site supported.
|
#Only one import directory per site supported.
|
||||||
#dirlist is a hash of lists:
|
#dirlist is a hash of lists:
|
||||||
#dirlist{ 'PokerStars' => ["/path/to/import/", "filtername"] }
|
#dirlist{ 'PokerStars' => ["/path/to/import/", "filtername"] }
|
||||||
def addImportDirectory(self,dir,monitor = False, site = "default", filter = "passthrough"):
|
def addImportDirectory(self,dir,monitor = False, site = "default", filter = "passthrough"):
|
||||||
|
#gets called by GuiAutoImport.
|
||||||
|
#This should really be using os.walk
|
||||||
|
#http://docs.python.org/library/os.html
|
||||||
if os.path.isdir(dir):
|
if os.path.isdir(dir):
|
||||||
if monitor == True:
|
if monitor == True:
|
||||||
self.monitor = True
|
self.monitor = True
|
||||||
|
@ -109,69 +140,156 @@ class Importer:
|
||||||
for file in os.listdir(dir):
|
for file in os.listdir(dir):
|
||||||
self.addImportFile(os.path.join(dir, file), site, filter)
|
self.addImportFile(os.path.join(dir, file), site, filter)
|
||||||
else:
|
else:
|
||||||
print "Warning: Attempted to add: '" + str(dir) + "' as an import directory"
|
print "Warning: Attempted to add non-directory: '" + str(dir) + "' as an import directory"
|
||||||
|
|
||||||
#Run full import on filelist
|
|
||||||
def runImport(self):
|
def runImport(self):
|
||||||
fpdb_simple.prepareBulkImport(self.fdb)
|
""""Run full import on self.filelist."""
|
||||||
|
start = datetime.datetime.now()
|
||||||
|
print "started at", start, "--", len(self.filelist), "files to import.", self.settings['dropIndexes']
|
||||||
|
if self.settings['dropIndexes'] == 'auto':
|
||||||
|
self.settings['dropIndexes'] = self.calculate_auto()
|
||||||
|
if self.settings['dropIndexes'] == 'drop':
|
||||||
|
fpdb_simple.prepareBulkImport(self.fdb)
|
||||||
|
totstored = 0
|
||||||
|
totdups = 0
|
||||||
|
totpartial = 0
|
||||||
|
toterrors = 0
|
||||||
|
tottime = 0
|
||||||
|
# if threads <= 1: do this bit
|
||||||
for file in self.filelist:
|
for file in self.filelist:
|
||||||
self.import_file_dict(file, self.filelist[file][0], self.filelist[file][1])
|
(stored, duplicates, partial, errors, ttime) = self.import_file_dict(file, self.filelist[file][0], self.filelist[file][1])
|
||||||
fpdb_simple.afterBulkImport(self.fdb)
|
totstored += stored
|
||||||
|
totdups += duplicates
|
||||||
|
totpartial += partial
|
||||||
|
toterrors += errors
|
||||||
|
tottime += ttime
|
||||||
|
if self.settings['dropIndexes'] == 'drop':
|
||||||
|
fpdb_simple.afterBulkImport(self.fdb)
|
||||||
fpdb_simple.analyzeDB(self.fdb)
|
fpdb_simple.analyzeDB(self.fdb)
|
||||||
|
return (totstored, totdups, totpartial, toterrors, tottime)
|
||||||
|
# else: import threaded
|
||||||
|
|
||||||
|
def calculate_auto(self):
|
||||||
|
"""An heuristic to determine a reasonable value of drop/don't drop"""
|
||||||
|
if len(self.filelist) == 1: return "don't drop"
|
||||||
|
if 'handsInDB' not in self.settings:
|
||||||
|
try:
|
||||||
|
tmpcursor = self.fdb.db.cursor()
|
||||||
|
tmpcursor.execute("Select count(1) from Hands;")
|
||||||
|
self.settings['handsInDB'] = tmpcursor.fetchone()[0]
|
||||||
|
except:
|
||||||
|
pass # if this fails we're probably doomed anyway
|
||||||
|
if self.settings['handsInDB'] < 5000: return "drop"
|
||||||
|
if len(self.filelist) < 50: return "don't drop"
|
||||||
|
if self.settings['handsInDB'] > 50000: return "don't drop"
|
||||||
|
return "drop"
|
||||||
|
|
||||||
#Run import on updated files, then store latest update time.
|
#Run import on updated files, then store latest update time.
|
||||||
def runUpdated(self):
|
def runUpdated(self):
|
||||||
#Check for new files in directory
|
#Check for new files in monitored directories
|
||||||
#todo: make efficient - always checks for new file, should be able to use mtime of directory
|
#todo: make efficient - always checks for new file, should be able to use mtime of directory
|
||||||
# ^^ May not work on windows
|
# ^^ May not work on windows
|
||||||
|
|
||||||
for site in self.dirlist:
|
for site in self.dirlist:
|
||||||
self.addImportDirectory(self.dirlist[site][0], False, site, self.dirlist[site][1])
|
self.addImportDirectory(self.dirlist[site][0], False, site, self.dirlist[site][1])
|
||||||
|
|
||||||
for file in self.filelist:
|
for file in self.filelist:
|
||||||
stat_info = os.stat(file)
|
if os.path.exists(file):
|
||||||
try:
|
stat_info = os.stat(file)
|
||||||
lastupdate = self.updated[file]
|
try:
|
||||||
if stat_info.st_mtime > lastupdate:
|
lastupdate = self.updated[file]
|
||||||
self.import_file_dict(file, self.filelist[file][0], self.filelist[file][1])
|
if stat_info.st_mtime > lastupdate:
|
||||||
|
self.import_file_dict(file, self.filelist[file][0], self.filelist[file][1])
|
||||||
|
self.updated[file] = time()
|
||||||
|
except:
|
||||||
self.updated[file] = time()
|
self.updated[file] = time()
|
||||||
except:
|
# If modified in the last minute run an immediate import.
|
||||||
self.updated[file] = time()
|
# This codepath only runs first time the file is found.
|
||||||
# This codepath only runs first time the file is found, if modified in the last
|
if os.path.isdir(file) or (time() - stat_info.st_mtime) < 60:
|
||||||
# minute run an immediate import.
|
# TODO attach a HHC thread to the file
|
||||||
if (time() - stat_info.st_mtime) < 60:
|
# TODO import the output of the HHC thread -- this needs to wait for the HHC to block?
|
||||||
self.import_file_dict(file, self.filelist[file][0], self.filelist[file][1])
|
self.import_file_dict(file, self.filelist[file][0], self.filelist[file][1])
|
||||||
|
# TODO we also test if directory, why?
|
||||||
|
#if os.path.isdir(file):
|
||||||
|
#self.import_file_dict(file, self.filelist[file][0], self.filelist[file][1])
|
||||||
|
else:
|
||||||
|
removeFromFileList[file] = True
|
||||||
|
self.addToDirList = filter(lambda x: self.addImportDirectory(x, True, self.addToDirList[x][0], self.addToDirList[x][1]), self.addToDirList)
|
||||||
|
|
||||||
|
for file in self.removeFromFileList:
|
||||||
|
if file in self.filelist:
|
||||||
|
del self.filelist[file]
|
||||||
|
|
||||||
|
self.addToDirList = {}
|
||||||
|
self.removeFromFileList = {}
|
||||||
|
|
||||||
# This is now an internal function that should not be called directly.
|
# This is now an internal function that should not be called directly.
|
||||||
def import_file_dict(self, file, site, filter):
|
def import_file_dict(self, file, site, filter):
|
||||||
if(filter == "passthrough"):
|
if os.path.isdir(file):
|
||||||
self.import_fpdb_file(file, site)
|
self.addToDirList[file] = [site] + [filter]
|
||||||
|
return
|
||||||
|
if filter == "passthrough" or filter == "":
|
||||||
|
(stored, duplicates, partial, errors, ttime) = self.import_fpdb_file(file, site)
|
||||||
else:
|
else:
|
||||||
#Load filter, and run filtered file though main importer
|
conv = None
|
||||||
self.import_fpdb_file(file, site)
|
# Load filter, process file, pass returned filename to import_fpdb_file
|
||||||
|
|
||||||
|
print "converting %s" % file
|
||||||
|
hhbase = self.config.get_import_parameters().get("hhArchiveBase")
|
||||||
|
hhbase = os.path.expanduser(hhbase)
|
||||||
|
hhdir = os.path.join(hhbase,site)
|
||||||
|
try:
|
||||||
|
out_path = os.path.join(hhdir, file.split(os.path.sep)[-2]+"-"+os.path.basename(file))
|
||||||
|
except:
|
||||||
|
out_path = os.path.join(hhdir, "x"+strftime("%d-%m-%y")+os.path.basename(file))
|
||||||
|
|
||||||
|
filter_name = filter.replace("ToFpdb", "")
|
||||||
|
|
||||||
|
mod = __import__(filter)
|
||||||
|
obj = getattr(mod, filter_name, None)
|
||||||
|
if callable(obj):
|
||||||
|
conv = obj(in_path = file, out_path = out_path)
|
||||||
|
if(conv.getStatus()):
|
||||||
|
(stored, duplicates, partial, errors, ttime) = self.import_fpdb_file(out_path, site)
|
||||||
|
else:
|
||||||
|
# conversion didn't work
|
||||||
|
# TODO: appropriate response?
|
||||||
|
return (0, 0, 0, 1, 0)
|
||||||
|
else:
|
||||||
|
print "Unknown filter filter_name:'%s' in filter:'%s'" %(filter_name, filter)
|
||||||
|
return
|
||||||
|
|
||||||
|
#This will barf if conv.getStatus != True
|
||||||
|
return (stored, duplicates, partial, errors, ttime)
|
||||||
|
|
||||||
|
|
||||||
def import_fpdb_file(self, file, site):
|
def import_fpdb_file(self, file, site):
|
||||||
starttime = time()
|
starttime = time()
|
||||||
last_read_hand=0
|
last_read_hand = 0
|
||||||
loc = 0
|
loc = 0
|
||||||
if (file=="stdin"):
|
if file == "stdin":
|
||||||
inputFile=sys.stdin
|
inputFile = sys.stdin
|
||||||
else:
|
else:
|
||||||
inputFile=open(file, "rU")
|
if os.path.exists(file):
|
||||||
try: loc = self.pos_in_file[file]
|
inputFile = open(file, "rU")
|
||||||
except: pass
|
else:
|
||||||
|
self.removeFromFileList[file] = True
|
||||||
|
return (0, 0, 0, 1, 0)
|
||||||
|
try:
|
||||||
|
loc = self.pos_in_file[file]
|
||||||
|
except:
|
||||||
|
pass
|
||||||
# Read input file into class and close file
|
# Read input file into class and close file
|
||||||
inputFile.seek(loc)
|
inputFile.seek(loc)
|
||||||
self.lines=fpdb_simple.removeTrailingEOL(inputFile.readlines())
|
self.lines = fpdb_simple.removeTrailingEOL(inputFile.readlines())
|
||||||
self.pos_in_file[file] = inputFile.tell()
|
self.pos_in_file[file] = inputFile.tell()
|
||||||
inputFile.close()
|
inputFile.close()
|
||||||
|
|
||||||
try: # sometimes we seem to be getting an empty self.lines, in which case, we just want to return.
|
try: # sometimes we seem to be getting an empty self.lines, in which case, we just want to return.
|
||||||
firstline = self.lines[0]
|
firstline = self.lines[0]
|
||||||
except:
|
except:
|
||||||
# print "import_fpdb_file", file, site, self.lines, "\n"
|
print "DEBUG: import_fpdb_file: failed on self.lines[0]: '%s' '%s' '%s' '%s' " %( file, site, self.lines, loc)
|
||||||
return
|
return (0,0,0,1,0)
|
||||||
|
|
||||||
if firstline.find("Tournament Summary")!=-1:
|
if firstline.find("Tournament Summary")!=-1:
|
||||||
print "TODO: implement importing tournament summaries"
|
print "TODO: implement importing tournament summaries"
|
||||||
|
@ -179,66 +297,79 @@ class Importer:
|
||||||
#self.parseTourneyHistory()
|
#self.parseTourneyHistory()
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
site=fpdb_simple.recogniseSite(firstline)
|
site = fpdb_simple.recogniseSite(firstline)
|
||||||
category=fpdb_simple.recogniseCategory(firstline)
|
category = fpdb_simple.recogniseCategory(firstline)
|
||||||
|
|
||||||
startpos=0
|
startpos = 0
|
||||||
stored=0 #counter
|
stored = 0 #counter
|
||||||
duplicates=0 #counter
|
duplicates = 0 #counter
|
||||||
partial=0 #counter
|
partial = 0 #counter
|
||||||
errors=0 #counter
|
errors = 0 #counter
|
||||||
|
|
||||||
for i in range (len(self.lines)): #main loop, iterates through the lines of a file and calls the appropriate parser method
|
for i in xrange (len(self.lines)): #main loop, iterates through the lines of a file and calls the appropriate parser method
|
||||||
if (len(self.lines[i])<2):
|
if len(self.lines[i]) < 2:
|
||||||
endpos=i
|
endpos = i
|
||||||
hand=self.lines[startpos:endpos]
|
hand = self.lines[startpos:endpos]
|
||||||
|
|
||||||
if (len(hand[0])<2):
|
if len(hand[0]) < 2:
|
||||||
hand=hand[1:]
|
hand = hand[1:]
|
||||||
|
|
||||||
cancelled=False
|
cancelled=False
|
||||||
damaged=False
|
damaged=False
|
||||||
if (site=="ftp"):
|
if (site=="ftp"):
|
||||||
for i in range (len(hand)):
|
for i in range (len(hand)):
|
||||||
if (hand[i].endswith(" has been canceled")): #this is their typo. this is a typo, right?
|
if hand[i].endswith(" has been canceled"): #this is their typo. this is a typo, right?
|
||||||
cancelled=True
|
cancelled = True
|
||||||
|
|
||||||
seat1=hand[i].find("Seat ") #todo: make this recover by skipping this line
|
#FTP generates lines looking like:
|
||||||
if (seat1!=-1):
|
#Seat 1: IOS Seat 2: kashman59 (big blind) showed [8c 9d] and won ($3.25) with a pair of Eights
|
||||||
if (hand[i].find("Seat ", seat1+3)!=-1):
|
#ie. Seat X multiple times on the same line in the summary section, when a new player sits down in the
|
||||||
damaged=True
|
#middle of the hand.
|
||||||
|
#TODO: Deal with this properly, either fix the file or make the parsing code work with this line.
|
||||||
|
if "Seat" in hand[i]:
|
||||||
|
mo = re.search(" Seat [0-9]+: ", hand[i])
|
||||||
|
if mo:
|
||||||
|
print "mo=", mo, "\nmo.start=", mo.start(),"\nhand[i]=",hand[i]
|
||||||
|
hand.insert(i+1, hand[i][mo.start()+1:])
|
||||||
|
hand[i] = hand[i][0:mo.start()]
|
||||||
|
|
||||||
if (len(hand)<3):
|
if len(hand) < 3:
|
||||||
pass
|
pass
|
||||||
#todo: the above 2 lines are kind of a dirty hack, the mentioned circumstances should be handled elsewhere but that doesnt work with DOS/Win EOL. actually this doesnt work.
|
#todo: the above 2 lines are kind of a dirty hack, the mentioned circumstances should be handled elsewhere but that doesnt work with DOS/Win EOL. actually this doesnt work.
|
||||||
elif (hand[0].endswith(" (partial)")): #partial hand - do nothing
|
elif hand[0].endswith(" (partial)"): #partial hand - do nothing
|
||||||
partial+=1
|
partial += 1
|
||||||
elif (hand[1].find("Seat")==-1 and hand[2].find("Seat")==-1 and hand[3].find("Seat")==-1):#todo: should this be or instead of and?
|
elif "Seat" not in hand[1] and "Seat" not in hand[2] and "Seat" not in hand[3]:
|
||||||
partial+=1
|
partial += 1
|
||||||
elif (cancelled or damaged):
|
elif cancelled or damaged:
|
||||||
partial+=1
|
partial += 1
|
||||||
|
if damaged:
|
||||||
|
print """
|
||||||
|
DEBUG: Partial hand triggered by a line containing 'Seat X:' twice. This is a
|
||||||
|
bug in the FTP software when a player sits down in the middle of a hand.
|
||||||
|
Adding a newline after the player name will fix the issue
|
||||||
|
"""
|
||||||
|
print "File: %s" %(file)
|
||||||
|
print "Line: %s" %(startpos)
|
||||||
else: #normal processing
|
else: #normal processing
|
||||||
isTourney=fpdb_simple.isTourney(hand[0])
|
isTourney = fpdb_simple.isTourney(hand[0])
|
||||||
if not isTourney:
|
if not isTourney:
|
||||||
fpdb_simple.filterAnteBlindFold(site,hand)
|
hand = fpdb_simple.filterAnteBlindFold(site,hand)
|
||||||
hand=fpdb_simple.filterCrap(site, hand, isTourney)
|
|
||||||
self.hand=hand
|
self.hand=hand
|
||||||
|
|
||||||
try:
|
try:
|
||||||
handsId=fpdb_parse_logic.mainParser(self.settings['db-backend'], self.fdb.db
|
handsId = fpdb_parse_logic.mainParser(self.settings['db-backend'], self.fdb.db
|
||||||
,self.fdb.cursor, site, category, hand)
|
,self.fdb.cursor, site, category, hand, self.config)
|
||||||
self.fdb.db.commit()
|
self.fdb.db.commit()
|
||||||
|
|
||||||
stored+=1
|
stored += 1
|
||||||
if self.callHud:
|
if self.callHud:
|
||||||
#print "call to HUD here. handsId:",handsId
|
#print "call to HUD here. handsId:",handsId
|
||||||
#pipe the Hands.id out to the HUD
|
#pipe the Hands.id out to the HUD
|
||||||
self.caller.pipe_to_hud.stdin.write("%s" % (handsId) + os.linesep)
|
self.caller.pipe_to_hud.stdin.write("%s" % (handsId) + os.linesep)
|
||||||
except fpdb_simple.DuplicateError:
|
except fpdb_simple.DuplicateError:
|
||||||
duplicates+=1
|
duplicates += 1
|
||||||
self.fdb.db.rollback()
|
|
||||||
except (ValueError), fe:
|
except (ValueError), fe:
|
||||||
errors+=1
|
errors += 1
|
||||||
self.printEmailErrorMessage(errors, file, hand)
|
self.printEmailErrorMessage(errors, file, hand)
|
||||||
|
|
||||||
if (self.settings['failOnError']):
|
if (self.settings['failOnError']):
|
||||||
|
@ -247,31 +378,33 @@ class Importer:
|
||||||
else:
|
else:
|
||||||
self.fdb.db.rollback()
|
self.fdb.db.rollback()
|
||||||
except (fpdb_simple.FpdbError), fe:
|
except (fpdb_simple.FpdbError), fe:
|
||||||
errors+=1
|
errors += 1
|
||||||
self.printEmailErrorMessage(errors, file, hand)
|
self.printEmailErrorMessage(errors, file, hand)
|
||||||
|
|
||||||
#fe.printStackTrace() #todo: get stacktrace
|
#fe.printStackTrace() #todo: get stacktrace
|
||||||
self.fdb.db.rollback()
|
self.fdb.db.rollback()
|
||||||
|
|
||||||
if (self.settings['failOnError']):
|
if self.settings['failOnError']:
|
||||||
self.fdb.db.commit() #dont remove this, in case hand processing was cancelled.
|
self.fdb.db.commit() #dont remove this, in case hand processing was cancelled.
|
||||||
raise
|
raise
|
||||||
if (self.settings['minPrint']!=0):
|
|
||||||
if ((stored+duplicates+partial+errors)%self.settings['minPrint']==0):
|
if self.settings['minPrint']:
|
||||||
|
if not ((stored+duplicates+partial+errors) % self.settings['minPrint']):
|
||||||
print "stored:", stored, "duplicates:", duplicates, "partial:", partial, "errors:", errors
|
print "stored:", stored, "duplicates:", duplicates, "partial:", partial, "errors:", errors
|
||||||
|
|
||||||
if (self.settings['handCount']!=0):
|
if self.settings['handCount']:
|
||||||
if ((stored+duplicates+partial+errors)>=self.settings['handCount']):
|
if ((stored+duplicates+partial+errors) >= self.settings['handCount']):
|
||||||
if (not self.settings['quiet']):
|
if not self.settings['quiet']:
|
||||||
print "quitting due to reaching the amount of hands to be imported"
|
print "quitting due to reaching the amount of hands to be imported"
|
||||||
print "Total stored:", stored, "duplicates:", duplicates, "partial/damaged:", partial, "errors:", errors, " time:", (time() - starttime)
|
print "Total stored:", stored, "duplicates:", duplicates, "partial/damaged:", partial, "errors:", errors, " time:", (time() - starttime)
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
startpos=endpos
|
startpos = endpos
|
||||||
print "Total stored:", stored, "duplicates:", duplicates, "partial:", partial, "errors:", errors, " time:", (time() - starttime)
|
ttime = time() - starttime
|
||||||
|
print "\rTotal stored:", stored, "duplicates:", duplicates, "partial:", partial, "errors:", errors, " time:", ttime
|
||||||
|
|
||||||
if stored==0:
|
if not stored:
|
||||||
if duplicates>0:
|
if duplicates:
|
||||||
for line_no in range(len(self.lines)):
|
for line_no in xrange(len(self.lines)):
|
||||||
if self.lines[line_no].find("Game #")!=-1:
|
if self.lines[line_no].find("Game #")!=-1:
|
||||||
final_game_line=self.lines[line_no]
|
final_game_line=self.lines[line_no]
|
||||||
handsId=fpdb_simple.parseSiteHandNo(final_game_line)
|
handsId=fpdb_simple.parseSiteHandNo(final_game_line)
|
||||||
|
@ -281,7 +414,7 @@ class Importer:
|
||||||
#todo: this will cause return of an unstored hand number if the last hand was error or partial
|
#todo: this will cause return of an unstored hand number if the last hand was error or partial
|
||||||
self.fdb.db.commit()
|
self.fdb.db.commit()
|
||||||
self.handsId=handsId
|
self.handsId=handsId
|
||||||
return handsId
|
return (stored, duplicates, partial, errors, ttime)
|
||||||
|
|
||||||
def parseTourneyHistory(self):
|
def parseTourneyHistory(self):
|
||||||
print "Tourney history parser stub"
|
print "Tourney history parser stub"
|
||||||
|
|
|
@ -21,144 +21,143 @@ import fpdb_simple
|
||||||
import fpdb_save_to_db
|
import fpdb_save_to_db
|
||||||
|
|
||||||
#parses a holdem hand
|
#parses a holdem hand
|
||||||
def mainParser(backend, db, cursor, site, category, hand):
|
def mainParser(backend, db, cursor, site, category, hand, config):
|
||||||
if (category=="holdem" or category=="omahahi" or category=="omahahilo"):
|
category = fpdb_simple.recogniseCategory(hand[0])
|
||||||
base="hold"
|
|
||||||
else:
|
base = "hold" if category == "holdem" or category == "omahahi" or category == "omahahilo" else "stud"
|
||||||
base="stud"
|
|
||||||
#part 0: create the empty arrays
|
#part 0: create the empty arrays
|
||||||
lineTypes=[] #char, valid values: header, name, cards, action, win, rake, ignore
|
lineTypes = [] #char, valid values: header, name, cards, action, win, rake, ignore
|
||||||
lineStreets=[] #char, valid values: (predeal, preflop, flop, turn, river)
|
lineStreets = [] #char, valid values: (predeal, preflop, flop, turn, river)
|
||||||
|
|
||||||
cardValues, cardSuits, boardValues, boardSuits, antes, actionTypes, allIns, actionAmounts, actionNos, actionTypeByNo, seatLines, winnings, rakes=[],[],[],[],[],[],[],[],[],[],[],[],[]
|
cardValues, cardSuits, boardValues, boardSuits, antes, actionTypes, allIns, actionAmounts, actionNos, actionTypeByNo, seatLines, winnings, rakes=[],[],[],[],[],[],[],[],[],[],[],[],[]
|
||||||
|
|
||||||
#part 1: read hand no and check for duplicate
|
#part 1: read hand no and check for duplicate
|
||||||
siteHandNo=fpdb_simple.parseSiteHandNo(hand[0])
|
siteHandNo = fpdb_simple.parseSiteHandNo(hand[0])
|
||||||
handStartTime=fpdb_simple.parseHandStartTime(hand[0], site)
|
handStartTime = fpdb_simple.parseHandStartTime(hand[0], site)
|
||||||
siteID=fpdb_simple.recogniseSiteID(cursor, site)
|
siteID = fpdb_simple.recogniseSiteID(cursor, site)
|
||||||
#print "parse logic, siteID:",siteID,"site:",site
|
#print "parse logic, siteID:",siteID,"site:",site
|
||||||
|
|
||||||
isTourney=fpdb_simple.isTourney(hand[0])
|
isTourney = fpdb_simple.isTourney(hand[0])
|
||||||
smallBlindLine=0
|
smallBlindLine = 0
|
||||||
for i in range(len(hand)):
|
for i, line in enumerate(hand):
|
||||||
if hand[i].find("posts small blind")!=-1 or hand[i].find("posts the small blind")!=-1:
|
if 'posts small blind' in line or 'posts the small blind' in line:
|
||||||
if hand[i][-2:] == "$0":
|
if line[-2:] == "$0": continue
|
||||||
continue
|
smallBlindLine = i
|
||||||
smallBlindLine=i
|
|
||||||
#print "found small blind line:",smallBlindLine
|
|
||||||
break
|
break
|
||||||
#print "small blind line:",smallBlindLine
|
#print "small blind line:",smallBlindLine
|
||||||
gametypeID=fpdb_simple.recogniseGametypeID(backend, db, cursor, hand[0], hand[smallBlindLine], siteID, category, isTourney)
|
|
||||||
if isTourney:
|
|
||||||
if site!="ps":
|
|
||||||
raise fpdb_simple.FpdbError("tourneys are only supported on PS right now")
|
|
||||||
siteTourneyNo=fpdb_simple.parseTourneyNo(hand[0])
|
|
||||||
buyin=fpdb_simple.parseBuyin(hand[0])
|
|
||||||
fee=fpdb_simple.parseFee(hand[0])
|
|
||||||
entries=-1 #todo: parse this
|
|
||||||
prizepool=-1 #todo: parse this
|
|
||||||
knockout=0
|
|
||||||
tourneyStartTime=handStartTime #todo: read tourney start time
|
|
||||||
rebuyOrAddon=fpdb_simple.isRebuyOrAddon(hand[0])
|
|
||||||
|
|
||||||
tourneyTypeId=fpdb_simple.recogniseTourneyTypeId(cursor, siteID, buyin, fee, knockout, rebuyOrAddon)
|
gametypeID = fpdb_simple.recogniseGametypeID(backend, db, cursor, hand[0], hand[smallBlindLine], siteID, category, isTourney)
|
||||||
|
if isTourney:
|
||||||
|
if site != "ps":
|
||||||
|
raise fpdb_simple.FpdbError("tourneys are only supported on PS right now")
|
||||||
|
siteTourneyNo = fpdb_simple.parseTourneyNo(hand[0])
|
||||||
|
buyin = fpdb_simple.parseBuyin(hand[0])
|
||||||
|
fee = fpdb_simple.parseFee(hand[0])
|
||||||
|
entries = -1 #todo: parse this
|
||||||
|
prizepool = -1 #todo: parse this
|
||||||
|
knockout = 0
|
||||||
|
tourneyStartTime= handStartTime #todo: read tourney start time
|
||||||
|
rebuyOrAddon = fpdb_simple.isRebuyOrAddon(hand[0])
|
||||||
|
|
||||||
|
tourneyTypeId = fpdb_simple.recogniseTourneyTypeId(cursor, siteID, buyin, fee, knockout, rebuyOrAddon)
|
||||||
|
|
||||||
fpdb_simple.isAlreadyInDB(cursor, gametypeID, siteHandNo)
|
fpdb_simple.isAlreadyInDB(cursor, gametypeID, siteHandNo)
|
||||||
|
|
||||||
|
hand = fpdb_simple.filterCrap(site, hand, isTourney)
|
||||||
|
|
||||||
#part 2: classify lines by type (e.g. cards, action, win, sectionchange) and street
|
#part 2: classify lines by type (e.g. cards, action, win, sectionchange) and street
|
||||||
fpdb_simple.classifyLines(hand, category, lineTypes, lineStreets)
|
fpdb_simple.classifyLines(hand, category, lineTypes, lineStreets)
|
||||||
|
|
||||||
#part 3: read basic player info
|
#part 3: read basic player info
|
||||||
#3a read player names, startcashes
|
#3a read player names, startcashes
|
||||||
for i in range (len(hand)): #todo: use maxseats+1 here.
|
for i, line in enumerate(hand):
|
||||||
if (lineTypes[i]=="name"):
|
if lineTypes[i] == "name":
|
||||||
seatLines.append(hand[i])
|
seatLines.append(line)
|
||||||
names=fpdb_simple.parseNames(seatLines)
|
|
||||||
playerIDs = fpdb_simple.recognisePlayerIDs(cursor, names, siteID)
|
names = fpdb_simple.parseNames(seatLines)
|
||||||
tmp=fpdb_simple.parseCashesAndSeatNos(seatLines, site)
|
playerIDs = fpdb_simple.recognisePlayerIDs(cursor, names, siteID)
|
||||||
startCashes=tmp['startCashes']
|
tmp = fpdb_simple.parseCashesAndSeatNos(seatLines, site)
|
||||||
seatNos=tmp['seatNos']
|
startCashes = tmp['startCashes']
|
||||||
|
seatNos = tmp['seatNos']
|
||||||
|
|
||||||
fpdb_simple.createArrays(category, len(names), cardValues, cardSuits, antes, winnings, rakes, actionTypes, allIns, actionAmounts, actionNos, actionTypeByNo)
|
fpdb_simple.createArrays(category, len(names), cardValues, cardSuits, antes, winnings, rakes, actionTypes, allIns, actionAmounts, actionNos, actionTypeByNo)
|
||||||
|
|
||||||
#3b read positions
|
#3b read positions
|
||||||
if base=="hold":
|
if base == "hold":
|
||||||
positions = fpdb_simple.parsePositions (hand, names)
|
positions = fpdb_simple.parsePositions(hand, names)
|
||||||
|
|
||||||
#part 4: take appropriate action for each line based on linetype
|
#part 4: take appropriate action for each line based on linetype
|
||||||
for i in range(len(hand)):
|
for i, line in enumerate(hand):
|
||||||
if (lineTypes[i]=="cards"):
|
if lineTypes[i] == "cards":
|
||||||
fpdb_simple.parseCardLine (site, category, lineStreets[i], hand[i], names, cardValues, cardSuits, boardValues, boardSuits)
|
fpdb_simple.parseCardLine(site, category, lineStreets[i], line, names, cardValues, cardSuits, boardValues, boardSuits)
|
||||||
#if category=="studhilo":
|
#if category=="studhilo":
|
||||||
# print "hand[i]:", hand[i]
|
# print "hand[i]:", hand[i]
|
||||||
# print "cardValues:", cardValues
|
# print "cardValues:", cardValues
|
||||||
# print "cardSuits:", cardSuits
|
# print "cardSuits:", cardSuits
|
||||||
elif (lineTypes[i]=="action"):
|
elif lineTypes[i] == "action":
|
||||||
fpdb_simple.parseActionLine (site, base, isTourney, hand[i], lineStreets[i], playerIDs, names, actionTypes, allIns, actionAmounts, actionNos, actionTypeByNo)
|
fpdb_simple.parseActionLine(site, base, isTourney, line, lineStreets[i], playerIDs, names, actionTypes, allIns, actionAmounts, actionNos, actionTypeByNo)
|
||||||
elif (lineTypes[i]=="win"):
|
elif lineTypes[i] == "win":
|
||||||
fpdb_simple.parseWinLine (hand[i], site, names, winnings, isTourney)
|
fpdb_simple.parseWinLine(line, site, names, winnings, isTourney)
|
||||||
elif (lineTypes[i]=="rake"):
|
elif lineTypes[i] == "rake":
|
||||||
if isTourney:
|
totalRake = 0 if isTourney else fpdb_simple.parseRake(line)
|
||||||
totalRake=0
|
|
||||||
else:
|
|
||||||
totalRake=fpdb_simple.parseRake(hand[i])
|
|
||||||
fpdb_simple.splitRake(winnings, rakes, totalRake)
|
fpdb_simple.splitRake(winnings, rakes, totalRake)
|
||||||
elif (lineTypes[i]=="header" or lineTypes[i]=="rake" or lineTypes[i]=="name" or lineTypes[i]=="ignore"):
|
elif lineTypes[i]=="header" or lineTypes[i]=="rake" or lineTypes[i]=="name" or lineTypes[i]=="ignore":
|
||||||
pass
|
pass
|
||||||
elif (lineTypes[i]=="ante"):
|
elif lineTypes[i]=="ante":
|
||||||
fpdb_simple.parseAnteLine(hand[i], site, isTourney, names, antes)
|
fpdb_simple.parseAnteLine(line, site, isTourney, names, antes)
|
||||||
elif (lineTypes[i]=="table"):
|
elif lineTypes[i]=="table":
|
||||||
tableResult=fpdb_simple.parseTableLine(site, base, hand[i])
|
tableResult=fpdb_simple.parseTableLine(site, base, line)
|
||||||
else:
|
else:
|
||||||
raise fpdb_simple.FpdbError("unrecognised lineType:"+lineTypes[i])
|
raise fpdb_simple.FpdbError("unrecognised lineType:"+lineTypes[i])
|
||||||
if site=="ftp":
|
|
||||||
tableResult=fpdb_simple.parseTableLine(site, base, hand[0])
|
if site == "ftp":
|
||||||
maxSeats=tableResult['maxSeats']
|
tableResult = fpdb_simple.parseTableLine(site, base, hand[0])
|
||||||
tableName=tableResult['tableName']
|
|
||||||
|
maxSeats = tableResult['maxSeats']
|
||||||
|
tableName = tableResult['tableName']
|
||||||
#print "before part5, antes:", antes
|
#print "before part5, antes:", antes
|
||||||
|
|
||||||
#part 5: final preparations, then call fpdb_save_to_db.* with
|
#part 5: final preparations, then call fpdb_save_to_db.* with
|
||||||
# the arrays as they are - that file will fill them.
|
# the arrays as they are - that file will fill them.
|
||||||
fpdb_simple.convertCardValues(cardValues)
|
fpdb_simple.convertCardValues(cardValues)
|
||||||
if base=="hold":
|
if base == "hold":
|
||||||
fpdb_simple.convertCardValuesBoard(boardValues)
|
fpdb_simple.convertCardValuesBoard(boardValues)
|
||||||
fpdb_simple.convertBlindBet(actionTypes, actionAmounts)
|
fpdb_simple.convertBlindBet(actionTypes, actionAmounts)
|
||||||
fpdb_simple.checkPositions(positions)
|
fpdb_simple.checkPositions(positions)
|
||||||
|
|
||||||
cursor.execute("SELECT limitType FROM Gametypes WHERE id=%s",(gametypeID, ))
|
cursor.execute("SELECT limitType FROM Gametypes WHERE id=%s",(gametypeID, ))
|
||||||
limit_type=cursor.fetchone()[0]
|
limit_type = cursor.fetchone()[0]
|
||||||
fpdb_simple.convert3B4B(site, category, limit_type, actionTypes, actionAmounts)
|
fpdb_simple.convert3B4B(site, category, limit_type, actionTypes, actionAmounts)
|
||||||
|
|
||||||
totalWinnings=0
|
totalWinnings = sum(winnings)
|
||||||
for i in range(len(winnings)):
|
|
||||||
totalWinnings+=winnings[i]
|
|
||||||
|
|
||||||
if base=="hold":
|
# if hold'em, use positions and not antes, if stud do not use positions, use antes
|
||||||
hudImportData=fpdb_simple.generateHudCacheData(playerIDs, base, category, actionTypes
|
if base == "hold":
|
||||||
|
hudImportData = fpdb_simple.generateHudCacheData(playerIDs, base, category, actionTypes
|
||||||
, allIns, actionTypeByNo, winnings, totalWinnings, positions
|
, allIns, actionTypeByNo, winnings, totalWinnings, positions
|
||||||
, actionTypes, actionAmounts, None)
|
, actionTypes, actionAmounts, None)
|
||||||
else:
|
else:
|
||||||
hudImportData=fpdb_simple.generateHudCacheData(playerIDs, base, category, actionTypes
|
hudImportData = fpdb_simple.generateHudCacheData(playerIDs, base, category, actionTypes
|
||||||
, allIns, actionTypeByNo, winnings, totalWinnings, None
|
, allIns, actionTypeByNo, winnings, totalWinnings, None
|
||||||
, actionTypes, actionAmounts, antes)
|
, actionTypes, actionAmounts, antes)
|
||||||
|
|
||||||
if isTourney:
|
if isTourney:
|
||||||
ranks=[]
|
ranks = map(lambda x: 0, names) # create an array of 0's equal to the length of names
|
||||||
for i in range (len(names)):
|
payin_amounts = fpdb_simple.calcPayin(len(names), buyin, fee)
|
||||||
ranks.append(0)
|
|
||||||
payin_amounts=fpdb_simple.calcPayin(len(names), buyin, fee)
|
|
||||||
|
|
||||||
if base=="hold":
|
if base == "hold":
|
||||||
result = fpdb_save_to_db.tourney_holdem_omaha(
|
result = fpdb_save_to_db.tourney_holdem_omaha(
|
||||||
backend, db, cursor, base, category, siteTourneyNo, buyin
|
config, backend, db, cursor, base, category, siteTourneyNo, buyin
|
||||||
, fee, knockout, entries, prizepool, tourneyStartTime
|
, fee, knockout, entries, prizepool, tourneyStartTime
|
||||||
, payin_amounts, ranks, tourneyTypeId, siteID, siteHandNo
|
, payin_amounts, ranks, tourneyTypeId, siteID, siteHandNo
|
||||||
, gametypeID, handStartTime, names, playerIDs, startCashes
|
, gametypeID, handStartTime, names, playerIDs, startCashes
|
||||||
, positions, cardValues, cardSuits, boardValues, boardSuits
|
, positions, 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":
|
elif base == "stud":
|
||||||
result = fpdb_save_to_db.tourney_stud(
|
result = fpdb_save_to_db.tourney_stud(
|
||||||
backend, db, cursor, base, category, siteTourneyNo
|
config, backend, db, cursor, base, category, siteTourneyNo
|
||||||
, buyin, fee, knockout, entries, prizepool, tourneyStartTime
|
, buyin, fee, knockout, entries, prizepool, tourneyStartTime
|
||||||
, payin_amounts, ranks, tourneyTypeId, siteID, siteHandNo
|
, payin_amounts, ranks, tourneyTypeId, siteID, siteHandNo
|
||||||
, gametypeID, handStartTime, names, playerIDs, startCashes
|
, gametypeID, handStartTime, names, playerIDs, startCashes
|
||||||
|
@ -166,25 +165,25 @@ def mainParser(backend, db, cursor, site, category, hand):
|
||||||
, allIns, actionAmounts, actionNos, hudImportData, maxSeats
|
, allIns, actionAmounts, actionNos, hudImportData, maxSeats
|
||||||
, tableName, seatNos)
|
, tableName, seatNos)
|
||||||
else:
|
else:
|
||||||
raise fpdb_simple.FpdbError ("unrecognised category")
|
raise fpdb_simple.FpdbError("unrecognised category") # it's impossible to get here, but w/e
|
||||||
else:
|
else:
|
||||||
if base=="hold":
|
if base == "hold":
|
||||||
result = fpdb_save_to_db.ring_holdem_omaha(
|
result = fpdb_save_to_db.ring_holdem_omaha(
|
||||||
backend, db, cursor, base, category, siteHandNo
|
config, backend, db, cursor, base, category, siteHandNo
|
||||||
, gametypeID, handStartTime, names, playerIDs
|
, gametypeID, handStartTime, names, playerIDs
|
||||||
, startCashes, positions, cardValues, cardSuits
|
, startCashes, positions, cardValues, cardSuits
|
||||||
, boardValues, boardSuits, winnings, rakes
|
, boardValues, boardSuits, winnings, rakes
|
||||||
, actionTypes, allIns, actionAmounts, actionNos
|
, actionTypes, allIns, actionAmounts, actionNos
|
||||||
, hudImportData, maxSeats, tableName, seatNos)
|
, hudImportData, maxSeats, tableName, seatNos)
|
||||||
elif base=="stud":
|
elif base == "stud":
|
||||||
result = fpdb_save_to_db.ring_stud(
|
result = fpdb_save_to_db.ring_stud(
|
||||||
backend, db, cursor, base, category, siteHandNo, gametypeID
|
config, backend, db, cursor, base, category, siteHandNo, gametypeID
|
||||||
, handStartTime, names, playerIDs, startCashes, antes
|
, handStartTime, names, playerIDs, startCashes, antes
|
||||||
, cardValues, cardSuits, winnings, rakes, actionTypes, allIns
|
, cardValues, cardSuits, winnings, rakes, actionTypes, allIns
|
||||||
, actionAmounts, actionNos, hudImportData, maxSeats, tableName
|
, actionAmounts, actionNos, hudImportData, maxSeats, tableName
|
||||||
, seatNos)
|
, seatNos)
|
||||||
else:
|
else:
|
||||||
raise fpdb_simple.FpdbError ("unrecognised category")
|
raise fpdb_simple.FpdbError ("unrecognised category") # also impossible to get here
|
||||||
db.commit()
|
db.commit()
|
||||||
return result
|
return result
|
||||||
#end def mainParser
|
#end def mainParser
|
||||||
|
|
|
@ -22,29 +22,36 @@ from time import time
|
||||||
|
|
||||||
import fpdb_simple
|
import fpdb_simple
|
||||||
|
|
||||||
MYSQL_INNODB=2
|
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
|
saveActions = True # set this to False to avoid storing action data
|
||||||
# Pros: speeds up imports
|
# Pros: speeds up imports
|
||||||
# Cons: no action data is saved, so you need to keep the hand histories
|
# Cons: no action data is saved, so you need to keep the hand histories
|
||||||
# variance not available on stats page
|
# 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(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
|
||||||
,action_types, allIns, action_amounts, actionNos, hudImportData, maxSeats, tableName
|
,action_types, allIns, action_amounts, actionNos, hudImportData, maxSeats, tableName
|
||||||
,seatNos):
|
,seatNos):
|
||||||
|
|
||||||
|
import_options = config.get_import_parameters()
|
||||||
|
|
||||||
|
saveActions = False if import_options['saveActions'] == False else True
|
||||||
|
fastStoreHudCache = True if import_options['fastStoreHudCache'] == True else False
|
||||||
|
|
||||||
fpdb_simple.fillCardArrays(len(names), base, category, card_values, card_suits)
|
fpdb_simple.fillCardArrays(len(names), base, category, card_values, card_suits)
|
||||||
|
|
||||||
hands_id=fpdb_simple.storeHands(backend, db, cursor, site_hand_no, gametype_id
|
hands_id = fpdb_simple.storeHands(backend, db, cursor, site_hand_no, gametype_id
|
||||||
,hand_start_time, names, tableName, maxSeats)
|
,hand_start_time, names, tableName, maxSeats)
|
||||||
|
|
||||||
#print "before calling store_hands_players_stud, antes:", antes
|
#print "before calling store_hands_players_stud, antes:", antes
|
||||||
hands_players_ids=fpdb_simple.store_hands_players_stud(backend, db, cursor, hands_id, player_ids
|
hands_players_ids = fpdb_simple.store_hands_players_stud(backend, db, cursor, hands_id, player_ids
|
||||||
,start_cashes, antes, card_values
|
,start_cashes, antes, card_values
|
||||||
,card_suits, winnings, rakes, seatNos)
|
,card_suits, winnings, rakes, seatNos)
|
||||||
|
|
||||||
|
@ -56,21 +63,29 @@ def ring_stud(backend, db, cursor, base, category, site_hand_no, gametype_id, ha
|
||||||
return hands_id
|
return hands_id
|
||||||
#end def ring_stud
|
#end def ring_stud
|
||||||
|
|
||||||
def ring_holdem_omaha(backend, db, cursor, base, category, site_hand_no, gametype_id
|
def ring_holdem_omaha(config, backend, db, cursor, base, category, site_hand_no, gametype_id
|
||||||
,hand_start_time, names, player_ids, start_cashes, positions, card_values
|
,hand_start_time, names, player_ids, start_cashes, positions, card_values
|
||||||
,card_suits, board_values, board_suits, winnings, rakes, action_types, allIns
|
,card_suits, board_values, board_suits, winnings, rakes, action_types, allIns
|
||||||
,action_amounts, actionNos, hudImportData, maxSeats, tableName, seatNos):
|
,action_amounts, actionNos, hudImportData, maxSeats, tableName, seatNos):
|
||||||
"""stores a holdem/omaha hand into the database"""
|
"""stores a holdem/omaha hand into the database"""
|
||||||
|
|
||||||
|
import_options = config.get_import_parameters()
|
||||||
|
saveActions = False if import_options['saveActions'] == False else True
|
||||||
|
fastStoreHudCache = True if import_options['fastStoreHudCache'] == True else False
|
||||||
|
|
||||||
|
# print "DEBUG: saveActions = '%s' fastStoreHudCache = '%s'"%(saveActions, fastStoreHudCache)
|
||||||
|
# print "DEBUG: import_options = ", import_options
|
||||||
|
|
||||||
t0 = time()
|
t0 = time()
|
||||||
fpdb_simple.fillCardArrays(len(names), base, category, card_values, card_suits)
|
fpdb_simple.fillCardArrays(len(names), base, category, card_values, card_suits)
|
||||||
t1 = time()
|
t1 = time()
|
||||||
fpdb_simple.fill_board_cards(board_values, board_suits)
|
fpdb_simple.fill_board_cards(board_values, board_suits)
|
||||||
t2 = time()
|
t2 = time()
|
||||||
|
|
||||||
hands_id=fpdb_simple.storeHands(backend, db, cursor, site_hand_no, gametype_id
|
hands_id = fpdb_simple.storeHands(backend, db, cursor, site_hand_no, gametype_id
|
||||||
,hand_start_time, names, tableName, maxSeats)
|
,hand_start_time, names, tableName, maxSeats)
|
||||||
t3 = time()
|
t3 = time()
|
||||||
hands_players_ids=fpdb_simple.store_hands_players_holdem_omaha(
|
hands_players_ids = fpdb_simple.store_hands_players_holdem_omaha(
|
||||||
backend, db, cursor, category, hands_id, player_ids, start_cashes
|
backend, db, cursor, category, hands_id, player_ids, start_cashes
|
||||||
, positions, card_values, card_suits, winnings, rakes, seatNos)
|
, positions, card_values, card_suits, winnings, rakes, seatNos)
|
||||||
t4 = time()
|
t4 = time()
|
||||||
|
@ -89,7 +104,7 @@ def ring_holdem_omaha(backend, db, cursor, base, category, site_hand_no, gametyp
|
||||||
return hands_id
|
return hands_id
|
||||||
#end def ring_holdem_omaha
|
#end def ring_holdem_omaha
|
||||||
|
|
||||||
def tourney_holdem_omaha(backend, db, cursor, base, category, siteTourneyNo, buyin, fee, knockout
|
def tourney_holdem_omaha(config, backend, db, cursor, base, category, siteTourneyNo, buyin, fee, knockout
|
||||||
,entries, prizepool, tourney_start, payin_amounts, ranks, tourneyTypeId
|
,entries, prizepool, tourney_start, payin_amounts, ranks, tourneyTypeId
|
||||||
,siteId #end of tourney specific params
|
,siteId #end of tourney specific params
|
||||||
,site_hand_no, gametype_id, hand_start_time, names, player_ids
|
,site_hand_no, gametype_id, hand_start_time, names, player_ids
|
||||||
|
@ -97,16 +112,21 @@ def tourney_holdem_omaha(backend, db, cursor, base, category, siteTourneyNo, buy
|
||||||
,board_suits, winnings, rakes, action_types, allIns, action_amounts
|
,board_suits, winnings, rakes, action_types, allIns, action_amounts
|
||||||
,actionNos, hudImportData, maxSeats, tableName, seatNos):
|
,actionNos, hudImportData, maxSeats, tableName, seatNos):
|
||||||
"""stores a tourney holdem/omaha hand into the database"""
|
"""stores a tourney holdem/omaha hand into the database"""
|
||||||
|
|
||||||
|
import_options = config.get_import_parameters()
|
||||||
|
saveActions = True if import_options['saveActions'] == True else False
|
||||||
|
fastStoreHudCache = True if import_options['fastStoreHudCache'] == True else False
|
||||||
|
|
||||||
fpdb_simple.fillCardArrays(len(names), base, category, card_values, card_suits)
|
fpdb_simple.fillCardArrays(len(names), base, category, card_values, card_suits)
|
||||||
fpdb_simple.fill_board_cards(board_values, board_suits)
|
fpdb_simple.fill_board_cards(board_values, board_suits)
|
||||||
|
|
||||||
tourney_id=fpdb_simple.store_tourneys(cursor, tourneyTypeId, siteTourneyNo, entries, prizepool, tourney_start)
|
tourney_id = fpdb_simple.store_tourneys(cursor, tourneyTypeId, siteTourneyNo, entries, prizepool, tourney_start)
|
||||||
tourneys_players_ids=fpdb_simple.store_tourneys_players(cursor, tourney_id, player_ids, payin_amounts, ranks, winnings)
|
tourneys_players_ids = fpdb_simple.store_tourneys_players(cursor, tourney_id, player_ids, payin_amounts, ranks, winnings)
|
||||||
|
|
||||||
hands_id=fpdb_simple.storeHands(backend, db, cursor, site_hand_no, gametype_id
|
hands_id = fpdb_simple.storeHands(backend, db, cursor, site_hand_no, gametype_id
|
||||||
,hand_start_time, names, tableName, maxSeats)
|
,hand_start_time, names, tableName, maxSeats)
|
||||||
|
|
||||||
hands_players_ids=fpdb_simple.store_hands_players_holdem_omaha_tourney(
|
hands_players_ids = fpdb_simple.store_hands_players_holdem_omaha_tourney(
|
||||||
backend, db, cursor, category, hands_id, player_ids, start_cashes, positions
|
backend, db, cursor, category, hands_id, player_ids, start_cashes, positions
|
||||||
, card_values, card_suits, winnings, rakes, seatNos, tourneys_players_ids)
|
, card_values, card_suits, winnings, rakes, seatNos, tourneys_players_ids)
|
||||||
|
|
||||||
|
@ -123,21 +143,26 @@ def tourney_holdem_omaha(backend, db, cursor, base, category, siteTourneyNo, buy
|
||||||
return hands_id
|
return hands_id
|
||||||
#end def tourney_holdem_omaha
|
#end def tourney_holdem_omaha
|
||||||
|
|
||||||
def tourney_stud(backend, db, cursor, base, category, siteTourneyNo, buyin, fee, knockout, entries
|
def tourney_stud(config, backend, db, cursor, base, category, siteTourneyNo, buyin, fee, knockout, entries
|
||||||
,prizepool, tourneyStartTime, payin_amounts, ranks, tourneyTypeId, siteId
|
,prizepool, tourneyStartTime, payin_amounts, ranks, tourneyTypeId, siteId
|
||||||
,siteHandNo, gametypeId, handStartTime, names, playerIds, startCashes, antes
|
,siteHandNo, gametypeId, handStartTime, names, playerIds, startCashes, antes
|
||||||
,cardValues, cardSuits, winnings, rakes, actionTypes, allIns, actionAmounts
|
,cardValues, cardSuits, winnings, rakes, actionTypes, allIns, actionAmounts
|
||||||
,actionNos, hudImportData, maxSeats, tableName, seatNos):
|
,actionNos, hudImportData, maxSeats, tableName, seatNos):
|
||||||
#stores a tourney stud/razz hand into the database
|
#stores a tourney stud/razz hand into the database
|
||||||
|
|
||||||
|
import_options = config.get_import_parameters()
|
||||||
|
saveActions = True if import_options['saveActions'] == True else False
|
||||||
|
fastStoreHudCache = True if import_options['fastStoreHudCache'] == True else False
|
||||||
|
|
||||||
fpdb_simple.fillCardArrays(len(names), base, category, cardValues, cardSuits)
|
fpdb_simple.fillCardArrays(len(names), base, category, cardValues, cardSuits)
|
||||||
|
|
||||||
tourney_id=fpdb_simple.store_tourneys(cursor, tourneyTypeId, siteTourneyNo, entries, prizepool, tourneyStartTime)
|
tourney_id = fpdb_simple.store_tourneys(cursor, tourneyTypeId, siteTourneyNo, entries, prizepool, tourneyStartTime)
|
||||||
|
|
||||||
tourneys_players_ids=fpdb_simple.store_tourneys_players(cursor, tourney_id, playerIds, payin_amounts, ranks, winnings)
|
tourneys_players_ids = fpdb_simple.store_tourneys_players(cursor, tourney_id, playerIds, payin_amounts, ranks, winnings)
|
||||||
|
|
||||||
hands_id=fpdb_simple.storeHands(backend, db, cursor, siteHandNo, gametypeId, handStartTime, names, tableName, maxSeats)
|
hands_id = fpdb_simple.storeHands(backend, db, cursor, siteHandNo, gametypeId, handStartTime, names, tableName, maxSeats)
|
||||||
|
|
||||||
hands_players_ids=fpdb_simple.store_hands_players_stud_tourney(backend, db, cursor, hands_id
|
hands_players_ids = fpdb_simple.store_hands_players_stud_tourney(backend, db, cursor, hands_id
|
||||||
, playerIds, startCashes, antes, cardValues, cardSuits
|
, playerIds, startCashes, antes, cardValues, cardSuits
|
||||||
, winnings, rakes, seatNos, tourneys_players_ids)
|
, winnings, rakes, seatNos, tourneys_players_ids)
|
||||||
|
|
||||||
|
|
21
pyfpdb/test_Betfair.py
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
import BetfairToFpdb
|
||||||
|
import py
|
||||||
|
|
||||||
|
|
||||||
|
def checkGameInfo(hhc, header, info):
|
||||||
|
assert hhc.determineGameType(header) == info
|
||||||
|
|
||||||
|
def testGameInfo():
|
||||||
|
hhc = BetfairToFpdb.Betfair(autostart=False)
|
||||||
|
pairs = (
|
||||||
|
(u"""***** Betfair Poker Hand History for Game 472386869 *****
|
||||||
|
NL $0.02/$0.04 Texas Hold'em - Sunday, January 25, 10:10:42 GMT 2009
|
||||||
|
Table Rookie 191 6-max (Real Money)
|
||||||
|
Seat 1 is the button
|
||||||
|
Total number of active players : 6""",
|
||||||
|
{'type':'ring', 'base':"hold", 'category':'holdem', 'limitType':'nl', 'sb':'0.02', 'bb':'0.04', 'currency':'USD'}),
|
||||||
|
)
|
||||||
|
|
||||||
|
for (header, info) in pairs:
|
||||||
|
yield checkGameInfo, hhc, header, info
|
52
pyfpdb/test_Everleaf.py
Normal file
|
@ -0,0 +1,52 @@
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
import EverleafToFpdb
|
||||||
|
import py
|
||||||
|
|
||||||
|
|
||||||
|
def checkGameInfo(hhc, header, info):
|
||||||
|
assert hhc.determineGameType(header) == info
|
||||||
|
|
||||||
|
def testGameInfo():
|
||||||
|
hhc = EverleafToFpdb.Everleaf(autostart=False)
|
||||||
|
pairs = (
|
||||||
|
(u"""Everleaf Gaming Game #3732225
|
||||||
|
***** Hand history for game #3732225 *****
|
||||||
|
Blinds €0.50/ €1 NL Hold'em - 2009/01/11 - 16:09:40
|
||||||
|
Table Casino Lyon Vert 58
|
||||||
|
Seat 3 is the button
|
||||||
|
Total number of players: 6""",
|
||||||
|
{'type':'ring', 'base':"hold", 'category':'holdem', 'limitType':'nl', 'sb':'0.50', 'bb':'1', 'currency':'EUR'}),
|
||||||
|
|
||||||
|
("""Everleaf Gaming Game #55198191
|
||||||
|
***** Hand history for game #55198191 *****
|
||||||
|
Blinds $0.50/$1 NL Hold'em - 2008/09/01 - 10:02:11
|
||||||
|
Table Speed Kuala
|
||||||
|
Seat 8 is the button
|
||||||
|
Total number of players: 10""",
|
||||||
|
{'type':'ring', 'base':"hold", 'category':'holdem', 'limitType':'nl', 'sb':'0.50', 'bb':'1', 'currency':'USD'}),
|
||||||
|
|
||||||
|
("""Everleaf Gaming Game #75065769
|
||||||
|
***** Hand history for game #75065769 *****
|
||||||
|
Blinds 10/20 NL Hold'em - 2009/02/25 - 17:30:32
|
||||||
|
Table 2
|
||||||
|
Seat 1 is the button
|
||||||
|
Total number of players: 10""",
|
||||||
|
{'type':'tour', 'base':"hold", 'category':'holdem', 'limitType':'nl', 'sb':'10', 'bb':'20', 'currency':'T$'}),
|
||||||
|
|
||||||
|
("""Everleaf Gaming Game #65087798
|
||||||
|
***** Hand history for game #65087798 *****
|
||||||
|
$0.25/$0.50 7 Card Stud - 2008/12/05 - 21:46:00
|
||||||
|
Table Plymouth""",
|
||||||
|
{'type':'ring', 'base':'stud', 'category':'studhi', 'limitType':'fl', 'sb':'0.25', 'bb':'0.50', 'currency':'USD'}),
|
||||||
|
|
||||||
|
("""Everleaf Gaming Game #65295370
|
||||||
|
***** Hand history for game #65295370 *****
|
||||||
|
Blinds $0.50/$1 PL Omaha - 2008/12/07 - 21:59:48
|
||||||
|
Table Guanajuato""",
|
||||||
|
{'type':'ring', 'base':'hold', 'category':'omahahi', 'limitType':'pl', 'sb':'0.50', 'bb':'1','currency':'USD'}),
|
||||||
|
|
||||||
|
)
|
||||||
|
for (header, info) in pairs:
|
||||||
|
yield checkGameInfo, hhc, header, info
|
||||||
|
|
||||||
|
|
25
pyfpdb/test_FullTilt.py
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
import FulltiltToFpdb
|
||||||
|
import py
|
||||||
|
|
||||||
|
# regression-test-files/fulltilt/nlhe/NLHE-6max-1.txt
|
||||||
|
# Sorrowful: start: $8.85 end: $14.70 total: $5.85
|
||||||
|
|
||||||
|
def checkGameInfo(hhc, header, info):
|
||||||
|
assert hhc.determineGameType(header) == info
|
||||||
|
|
||||||
|
def testGameInfo():
|
||||||
|
hhc = FulltiltToFpdb.Fulltilt(autostart=False)
|
||||||
|
pairs = (
|
||||||
|
("Full Tilt Poker Game #10777181585: Table Deerfly (deep 6) - $0.01/$0.02 - Pot Limit Omaha Hi - 2:24:44 ET - 2009/02/22",
|
||||||
|
{'type':'ring', 'base':'hold', 'category':'omahahi', 'limitType':'pl', 'sb':'0.01', 'bb':'0.02', 'currency':'USD'}),
|
||||||
|
("Full Tilt Poker Game #10773265574: Table Butte (6 max) - $0.01/$0.02 - Pot Limit Hold'em - 21:33:46 ET - 2009/02/21",
|
||||||
|
{'type':'ring', 'base':'hold', 'category':'holdem', 'limitType':'pl', 'sb':'0.01', 'bb':'0.02', 'currency':'USD'}),
|
||||||
|
("Full Tilt Poker Game #9403951181: Table CR - tay - $0.05/$0.10 - No Limit Hold'em - 9:40:20 ET - 2008/12/09",
|
||||||
|
{'type':'ring', 'base':'hold', 'category':'holdem', 'limitType':'nl', 'sb':'0.05', 'bb':'0.10', 'currency':'USD'}),
|
||||||
|
("Full Tilt Poker Game #10809877615: Table Danville - $0.50/$1 Ante $0.10 - Limit Razz - 21:47:27 ET - 2009/02/23",
|
||||||
|
{'type':'ring', 'base':'stud', 'category':'razz', 'limitType':'fl', 'sb':'0.50', 'bb':'1', 'currency':'USD'})
|
||||||
|
)
|
||||||
|
for (header, info) in pairs:
|
||||||
|
yield checkGameInfo, hhc, header, info
|
||||||
|
|
81
pyfpdb/test_PokerStars.py
Normal file
|
@ -0,0 +1,81 @@
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
import PokerStarsToFpdb
|
||||||
|
from Hand import *
|
||||||
|
import py
|
||||||
|
|
||||||
|
#regression-test-files/stars/badugi/ring-fl-badugi.txt
|
||||||
|
# s0rrow: input: $30.00 end: $22.65 total: ($7.35)
|
||||||
|
#regression-test-files/stars/plo/PLO-6max.txt
|
||||||
|
# s0rrow: input: $18.35 end: $0 total: ($18.35)
|
||||||
|
# Notes: last hand #25975302416 s0rrow aifp against 2 players
|
||||||
|
|
||||||
|
gametype = {'type':'ring', 'base':'draw', 'category':'badugi', 'limitType':'fl', 'sb':'0.25', 'bb':'0.50','currency':'USD'}
|
||||||
|
text = ""
|
||||||
|
|
||||||
|
hhc = PokerStarsToFpdb.PokerStars(autostart=False)
|
||||||
|
|
||||||
|
h = HoldemOmahaHand(None, "ASite", gametype, text, builtFrom = "Test")
|
||||||
|
h.addPlayer("1", "s0rrow", "100000")
|
||||||
|
|
||||||
|
hhc.compilePlayerRegexs(h)
|
||||||
|
|
||||||
|
|
||||||
|
def checkGameInfo(hhc, header, info):
|
||||||
|
assert hhc.determineGameType(header) == info
|
||||||
|
|
||||||
|
def testGameInfo():
|
||||||
|
hhc = PokerStarsToFpdb.PokerStars(autostart=False)
|
||||||
|
pairs = (
|
||||||
|
(u"PokerStars Game #20461877044: Hold'em No Limit ($1/$2) - 2008/09/16 18:58:01 ET",
|
||||||
|
{'type':'ring', 'base':"hold", 'category':'holdem', 'limitType':'nl', 'sb':'1', 'bb':'2', 'currency':'USD'}),
|
||||||
|
|
||||||
|
(u"PokerStars Game #5999635897: HORSE (Omaha Hi/Lo Limit, $2/$4) - 2006/08/21 - 13:59:19 (ET)",
|
||||||
|
{'type':'ring', 'base':'hold', 'category':'omahahilo', 'limitType':'fl', 'sb':'2', 'bb':'4','currency':'USD'}),
|
||||||
|
|
||||||
|
(u"PokerStars Game #25923772706: Badugi Limit ($0.25/$0.50) - 2009/03/13 16:40:58 ET",
|
||||||
|
{'type':'ring', 'base':'draw', 'category':'badugi', 'limitType':'fl', 'sb':'0.25', 'bb':'0.50','currency':'USD'}),
|
||||||
|
|
||||||
|
(u"PokerStars Game #22073591924: Hold'em No Limit ($0.50/$1.00) - 2008/11/16 1:22:21 CET [2008/11/15 19:22:21 ET]",
|
||||||
|
{'type':'ring', 'base':'hold', 'category':'holdem', 'limitType':'nl', 'sb':'0.50', 'bb':'1.00','currency':'USD'}),
|
||||||
|
|
||||||
|
(u"PokerStars Game #25974627364: Omaha Pot Limit ($0.05/$0.10) - 2009/03/15 0:29:00 ET",
|
||||||
|
{'type':'ring', 'base':'hold', 'category':'omahahi', 'limitType':'pl', 'sb':'0.05', 'bb':'0.10','currency':'USD'})
|
||||||
|
)
|
||||||
|
for (header, info) in pairs:
|
||||||
|
yield checkGameInfo, hhc, header, info
|
||||||
|
|
||||||
|
|
||||||
|
def testHandInfo():
|
||||||
|
text = u""""PokerStars Game #20461877044: Hold'em No Limit ($1/$2) - 2008/09/16 18:58:01 ET"""
|
||||||
|
hhc = PokerStarsToFpdb.PokerStars(autostart=False)
|
||||||
|
h = HoldemOmahaHand(None, "PokerStars", gametype, text, builtFrom = "Test")
|
||||||
|
hhc.readHandInfo(h)
|
||||||
|
assert h.handid == '20461877044'
|
||||||
|
assert h.sitename == 'PokerStars'
|
||||||
|
assert h.starttime == (2008, 9, 16, 18, 58, 1, 1, 260, -1)
|
||||||
|
|
||||||
|
text = u"""PokerStars Game #18707234955: Razz Limit ($0.50/$1.00) - 2008/07/09 - 21:41:43 (ET)
|
||||||
|
Table 'Lepus II' 8-max"""
|
||||||
|
hhc = PokerStarsToFpdb.PokerStars(autostart=False)
|
||||||
|
h = HoldemOmahaHand(None, "PokerStars", gametype, text, builtFrom = "Test")
|
||||||
|
hhc.readHandInfo(h)
|
||||||
|
assert h.handid == '18707234955'
|
||||||
|
assert h.sitename == 'PokerStars'
|
||||||
|
assert h.maxseats == 8
|
||||||
|
assert h.tablename == 'Lepus II'
|
||||||
|
assert h.starttime == (2008,7 , 9, 21, 41, 43, 2, 191, -1)
|
||||||
|
|
||||||
|
|
||||||
|
text = u"""PokerStars Game #22073591924: Hold'em No Limit ($0.50/$1.00) - 2008/11/16 1:22:21 CET [2008/11/15 19:22:21 ET]
|
||||||
|
Table 'Caia II' 6-max Seat #2 is the button"""
|
||||||
|
hhc = PokerStarsToFpdb.PokerStars(autostart=False)
|
||||||
|
h = HoldemOmahaHand(None, "PokerStars", gametype, text, builtFrom = "Test")
|
||||||
|
hhc.readHandInfo(h)
|
||||||
|
assert h.handid == '22073591924'
|
||||||
|
assert h.sitename == 'PokerStars'
|
||||||
|
assert h.maxseats == 6
|
||||||
|
assert h.tablename == 'Caia II'
|
||||||
|
assert h.buttonpos == '2' # TODO: should this be an int?
|
||||||
|
assert h.starttime == (2008,11 , 15, 19, 22, 21, 5, 320, -1)
|
||||||
|
|
||||||
|
|
40
pyfpdb/test_fpdb_simple.py
Executable file
|
@ -0,0 +1,40 @@
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
import fpdb_simple
|
||||||
|
import datetime
|
||||||
|
import py
|
||||||
|
|
||||||
|
def checkDateParse(header, site, result):
|
||||||
|
assert fpdb_simple.parseHandStartTime(header, site) == result
|
||||||
|
|
||||||
|
def testPokerStarsHHDate():
|
||||||
|
tuples = (
|
||||||
|
("PokerStars Game #21969660557: Hold'em No Limit ($0.50/$1.00) - 2008/11/12 10:00:48 CET [2008/11/12 4:00:48 ET]", "ps",
|
||||||
|
datetime.datetime(2008,11,12,15,00,48)),
|
||||||
|
("PokerStars Game #21969660557: Hold'em No Limit ($0.50/$1.00) - 2008/08/17 - 01:14:43 (ET)", "ps",
|
||||||
|
datetime.datetime(2008,8,17,6,14,43)),
|
||||||
|
("PokerStars Game #21969660557: Hold'em No Limit ($0.50/$1.00) - 2008/09/07 06:23:14 ET", "ps",
|
||||||
|
datetime.datetime(2008,9,7,11,23,14))
|
||||||
|
)
|
||||||
|
|
||||||
|
#def testFullTiltHHDate(self):
|
||||||
|
# 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"
|
||||||
|
# cash1 = "Full Tilt Poker Game #9403951181: Table CR - tay - $0.05/$0.10 - No Limit Hold'em - 9:40:20 ET - 2008/12/09"
|
||||||
|
# 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 = fpdb_simple.parseHandStartTime(sitngo1,"ftp")
|
||||||
|
# self.failUnless(result==datetime.datetime(2009,1,29,05,07,45),
|
||||||
|
# "Date incorrect, expected: 2009-01-29 05:07:45 got: " + str(result))
|
||||||
|
# result = fpdb_simple.parseHandStartTime(cash1,"ftp")
|
||||||
|
# self.failUnless(result==datetime.datetime(2008,12,9,14,40,20),
|
||||||
|
# "Date incorrect, expected: 2008-12-09 14:40:20 got: " + str(result))
|
||||||
|
# result = fpdb_simple.parseHandStartTime(cash2,"ftp")
|
||||||
|
# self.failUnless(result==datetime.datetime(2008,12,13,10,9,36),
|
||||||
|
# "Date incorrect, expected: 2008-12-13 10:09:36 got: " + str(result))
|
||||||
|
|
||||||
|
# def testTableDetection(self):
|
||||||
|
# result = Tables.clean_title("French (deep)")
|
||||||
|
# self.failUnless(result == "French", "French (deep) parsed incorrectly. Expected 'French' got: " + str(result))
|
||||||
|
# result = ("French (deep) - $0.25/$0.50 - No Limit Hold'em - Logged In As xxxx")
|
||||||
|
|
||||||
|
for (header, site, result) in tuples:
|
||||||
|
yield checkDateParse, header, site, result
|
|
@ -15,8 +15,19 @@
|
||||||
#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.
|
||||||
|
|
||||||
|
#get rid of extraneous stuff
|
||||||
rm regression-test/*.found.txt
|
rm regression-test/*.found.txt
|
||||||
rm regression-test/*.pyc
|
rm regression-test/*.pyc
|
||||||
rm pyfpdb/*.pyc
|
rm pyfpdb/*.pyc
|
||||||
|
|
||||||
git-add--interactive
|
# make the fpdb_$1.zip file for windows
|
||||||
|
echo "*** making zip file"
|
||||||
|
zip -r ../fpdb_$1.zip docs
|
||||||
|
zip -r ../fpdb_$1.zip packaging
|
||||||
|
zip -r ../fpdb_$1.zip pyfpdb
|
||||||
|
|
||||||
|
# now make the fpdb_$1.tar.bz2 file for linux
|
||||||
|
echo "*** making tar.bz2 file"
|
||||||
|
tar --recursion -cjf ../fpdb_$1.tar.bz2 *
|
||||||
|
|
||||||
|
|
|
@ -1,29 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
require 'header.php';
|
|
||||||
require 'sidebar.php';
|
|
||||||
|
|
||||||
?>
|
|
||||||
|
|
||||||
<div id="main">
|
|
||||||
|
|
||||||
<h1>Contact</h1>
|
|
||||||
|
|
||||||
<p>The best means of contact are on the <a href="http://sourceforge.net/projects/fpdb/">sourceforge page</a>: Use the bug, feature request or patch functions or just post in the forum. The forum requires a sourceforge account, but bug, feature request and patches don't seem to.</p>
|
|
||||||
<p>We also have a mailing list, to subscribe please <a href="https://lists.sourceforge.net/lists/listinfo/fpdb-main">click here</a>. This is used for development purposes and you can also ask for help using the mailing list.</p>
|
|
||||||
<p>To be informed of fpdb updates please visit <a href="https://sourceforge.net/project/showfiles.php?group_id=226872">the sf download page</a> and click on the little envelope with a plus sign in the line of the package that you want be informed off. For Windows user that will be both, Linux users should only subscribe to fpdb itself. This requires a sourceforge account, sorry.</p>
|
|
||||||
|
|
||||||
<p>Alternatively feel free to contact me directly:</p>
|
|
||||||
|
|
||||||
<p>mail: steffen(at)sycamoretest.info<br>
|
|
||||||
jabber/xmpp/Google Talk: steffen-laptop-temp(at)sycamoretest.info (don't email that)<br>
|
|
||||||
ICQ: 7806355<br>
|
|
||||||
MSN: steffen(at)sycamoretest.info</p>
|
|
||||||
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<?php
|
|
||||||
|
|
||||||
require 'footer.php';
|
|
||||||
|
|
||||||
?>
|
|
|
@ -1,8 +0,0 @@
|
||||||
db-backend=2
|
|
||||||
db-host=localhost
|
|
||||||
db-databaseName=fpdb
|
|
||||||
db-user=fpdb
|
|
||||||
db-password=enterYourPwHere
|
|
||||||
tv-combinedPostflop=True
|
|
||||||
bulkImport-defaultPath=default
|
|
||||||
tv-defaultPath=default
|
|
|
@ -1,65 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
$PAGE_TITLE = 'Abreviations';
|
|
||||||
|
|
||||||
require 'header.php';
|
|
||||||
require 'sidebar.php';
|
|
||||||
|
|
||||||
?>
|
|
||||||
|
|
||||||
<div id="main">
|
|
||||||
|
|
||||||
<h1>Abreviations</h1>
|
|
||||||
|
|
||||||
<p>HUD/table viewer<br>
|
|
||||||
================<br>
|
|
||||||
A3-7=3rd-7th street Complete/Raise percentage<br>
|
|
||||||
AF=Flop Bet/Raise percentage<br>
|
|
||||||
AT=River Bet/Raise percentage<br>
|
|
||||||
AR=Turn Bet/Raise percentage<br>
|
|
||||||
F3-7=3rd-7th street Fold percentage<br>
|
|
||||||
FF=Flop Fold percentage<br>
|
|
||||||
FR=River Fold percentage<br>
|
|
||||||
FT=Turn Fold percentage<br>
|
|
||||||
HD=Hands<br>
|
|
||||||
PF3B4B=Pre Flop 3Bet or 4Bet<br>
|
|
||||||
PFR=Pre Flop Raise<br>
|
|
||||||
Postf A=Postflop (ie. flop+turn+river) Aggression%<br>
|
|
||||||
Postf F=Postflop Fold %<br>
|
|
||||||
SD/F=Showdown/Flop=WtSD=How often player went to showdown when he saw the flop<br>
|
|
||||||
W$wsF=Won $ when he saw flop<br>
|
|
||||||
W$@SD=Won $ at showdown<br>
|
|
||||||
VPI3=Voluntary Put In on 3rd Street (ie. call+complete+raise)<br>
|
|
||||||
VPIP=Voluntary Put In Preflop (ie. call+raise)<br>
|
|
||||||
<br>
|
|
||||||
Other<br>
|
|
||||||
=====<br>
|
|
||||||
CLI=Command Line Interface (Shell, Terminal, "DOS-window")<br>
|
|
||||||
FTP=Full Tilt Poker<br>
|
|
||||||
GUI=Graphical User Interface (normal interface with buttons and menus)<br>
|
|
||||||
HUD=Heads-Up Display (shows stats directly in the poker software)<br>
|
|
||||||
PS=PokerStars<br>
|
|
||||||
MTT=Multi Table Tournament<br>
|
|
||||||
SnG=Sit and Go<br>
|
|
||||||
<br>
|
|
||||||
License<br>
|
|
||||||
=======<br>
|
|
||||||
Trademarks of third parties have been used under Fair Use or similar laws.<br>
|
|
||||||
<br>
|
|
||||||
Copyright 2008 Steffen Jobbagy-Felso<br>
|
|
||||||
Permission is granted to copy, distribute and/or modify this<br>
|
|
||||||
document under the terms of the GNU Free Documentation License,<br>
|
|
||||||
Version 1.2 as published by the Free Software Foundation; with<br>
|
|
||||||
no Invariant Sections, no Front-Cover Texts, and with no Back-Cover<br>
|
|
||||||
Texts. A copy of the license can be found in fdl-1.2.txt<br>
|
|
||||||
<br>
|
|
||||||
The program itself is licensed under AGPLv3, see agpl-3.0.txt<br>
|
|
||||||
</p>
|
|
||||||
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<?php
|
|
||||||
|
|
||||||
require 'footer.php';
|
|
||||||
|
|
||||||
?>
|
|
|
@ -1,23 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
$PAGE_TITLE = 'Abreviations';
|
|
||||||
|
|
||||||
require 'header.php';
|
|
||||||
require 'sidebar.php';
|
|
||||||
|
|
||||||
?>
|
|
||||||
|
|
||||||
<div id="main">
|
|
||||||
|
|
||||||
<h1>Benchmarks</h1>
|
|
||||||
|
|
||||||
<p>Check this page from time to time and they will come.</p>
|
|
||||||
|
|
||||||
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<?php
|
|
||||||
|
|
||||||
require 'footer.php';
|
|
||||||
|
|
||||||
?>
|
|
|
@ -1,61 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
$PAGE_TITLE = 'Git Instructions';
|
|
||||||
|
|
||||||
require 'header.php';
|
|
||||||
require 'sidebar.php';
|
|
||||||
|
|
||||||
?>
|
|
||||||
|
|
||||||
<div id="main">
|
|
||||||
|
|
||||||
<h1>Git Instructions</h1>
|
|
||||||
|
|
||||||
<p>Hi, welcome to my minimal git guide for fpdb devs!<br>
|
|
||||||
You can use a git version just as user as well of course, but as there are generally hardly tested it is not advised.<br>
|
|
||||||
I'll expand this on request, if you have any questions just send me a mail at steffen(at)sycamoretest.info. There's also a bunch of instructions at http://www.assembla.com/spaces/fpdb/trac_git_tool</p>
|
|
||||||
|
|
||||||
<h2>0. Getting it</h2>
|
|
||||||
<p>To get git for gentoo just do emerge git -av<br>
|
|
||||||
To get it for Windows go to http://code.google.com/p/msysgit/downloads/list and install it.
|
|
||||||
<h2>1. Cloning the fpdb git tree</h2>
|
|
||||||
<p>Just create a new directory (lets say ~/fpdb/ ), go into it and type:<br>
|
|
||||||
git clone git://git.assembla.com/fpdb.git</p>
|
|
||||||
<h2>2. Making your changes</h2>
|
|
||||||
<p>You can use whatever you want to do edit the files. I personally use nedit and occassionally Eclipse.</p>
|
|
||||||
<h2>3. Making a (local) commit</h2>
|
|
||||||
<p>Unlike in svn you don't need to be online to make your commits. First we need to tell git what to commit, so go to the root of your fpdb directory and type:<br>
|
|
||||||
git-add--interactive<br>
|
|
||||||
Now press u and enter. It will display a list of all changed files. If you want to commit all files just press * and enter twice to return to the main menu. If you want to commit only certain ones press the number of the file and enter and repeat until you have all the files. Then press enter again to return to the main menu.<br>
|
|
||||||
If you added any new files press a and Enter, then type the number of your new file and press Enter twice. Press q to leave git-add--interactive.<br>
|
|
||||||
Now create a file for your commit message (I call it since_last_commit.txt) but don't add this to the repository. In the first line of this file put a summary of your changes. Then give some details of your changes, try to mention anything non-trivial and definitely any user-visible bug fixes.<br>
|
|
||||||
Then run this:<br>
|
|
||||||
git-commit -F since_last_commit.txt <br>
|
|
||||||
<h2>4a. Pushing the changes to your own public git tree</h2>
|
|
||||||
<p>Do this OR 4b, not both.<br>
|
|
||||||
todo</p>
|
|
||||||
<h2>4b. Preparing changeset for emailing/uploading</h2>
|
|
||||||
<p>Do this OR 4a, not both.<br>
|
|
||||||
todo</p>
|
|
||||||
<h2>5. Pulling updates from the main tree</h2>
|
|
||||||
<p>todo</p>
|
|
||||||
<h2>License</h2>
|
|
||||||
<p>Trademarks of third parties have been used under Fair Use or similar laws.<br>
|
|
||||||
<br>
|
|
||||||
Copyright 2008 Steffen Jobbagy-Felso<br>
|
|
||||||
Permission is granted to copy, distribute and/or modify this<br>
|
|
||||||
document under the terms of the GNU Free Documentation License,<br>
|
|
||||||
Version 1.2 as published by the Free Software Foundation; with<br>
|
|
||||||
no Invariant Sections, no Front-Cover Texts, and with no Back-Cover<br>
|
|
||||||
Texts. A copy of the license can be found in fdl-1.2.txt<br>
|
|
||||||
<br>
|
|
||||||
The program itself is licensed under AGPLv3, see agpl-3.0.txt</p>
|
|
||||||
|
|
||||||
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<?php
|
|
||||||
|
|
||||||
require 'footer.php';
|
|
||||||
|
|
||||||
?>
|
|
|
@ -1,169 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
$PAGE_TITLE = 'Installing in Windows';
|
|
||||||
|
|
||||||
require 'header.php';
|
|
||||||
require 'sidebar.php';
|
|
||||||
|
|
||||||
?>
|
|
||||||
|
|
||||||
<div id="main">
|
|
||||||
|
|
||||||
<h2> How To Use the HUD</h2>
|
|
||||||
|
|
||||||
<h4>3 September, 2008</h4>
|
|
||||||
|
|
||||||
<h4>fpdb version alpha 3</h4>
|
|
||||||
|
|
||||||
<h3>Initial Configuration</h3>
|
|
||||||
|
|
||||||
<p>Install and configure the import/tracker program as detailed elsewhere. You should have this line in your default.conf file.</p>
|
|
||||||
|
|
||||||
<code>imp-callFpdbHud=True</code>
|
|
||||||
|
|
||||||
<p>When you downloaded fpdb you got an example HUD configuration file named HUD_config.xml.</p>
|
|
||||||
|
|
||||||
<p>1. Open the subdirectory where you installed fpdb.</p>
|
|
||||||
|
|
||||||
<p>2. Make a backup copy of HUD_config.xml.</p>
|
|
||||||
|
|
||||||
<p>3. Check that the db_user and db_pass parameters are the ones you specified during database setup. This line is near the bottom of your config file and specifies the database parameters to be used.</p>
|
|
||||||
|
|
||||||
<code><database db_name="fpdb" db_server="mysql" db_ip="localhost" db_user="fpdb" db_pass="fpdb" db_type="fpdb"></database></code>
|
|
||||||
|
|
||||||
<p>This should allow you to use the HUD with the stats and layout in the example configuration file.</p>
|
|
||||||
|
|
||||||
<h3>Running the HUD</h3>
|
|
||||||
|
|
||||||
<p>1. Open fpdb and select Auto Import from the menu. The fpdb main screen will change to show the autoimport dialog.</p>
|
|
||||||
|
|
||||||
<img src="img/docs.HudHowTo1.png" alt="Image of HUD" />
|
|
||||||
|
|
||||||
<p>Check that the path is pointing to your hand history subdirectory, if it is not, then click the browse button and select it. ?You can also adjust the interval between imports. Smaller intervals will get your updated HUD data more often, but might cause lag. If you experience lag, increase the interval.</p>
|
|
||||||
|
|
||||||
<p>2. Click "Start Autoimport" to start the import. fpdb will automatically start the HUD. When the HUD starts it will open a HUD main window.</p>
|
|
||||||
|
|
||||||
<img src="img/docs.HudHowTo2.png" alt="Image of HUD" />
|
|
||||||
|
|
||||||
<p>2. This window currently has no purpose other than providing a close button that will cause the HUD to exit.</p>
|
|
||||||
|
|
||||||
<p>3. Play a hand of poker (good luck). A few seconds after the completion of the hand the stat windows should overlay the poker client window.</p>
|
|
||||||
|
|
||||||
<img src="img/docs.HudHowTo3.png" alt="Image of HUD" />
|
|
||||||
|
|
||||||
<p>You will also see a small main window for each table that has a HUD. Clicking the close button on that window will kill the HUD stat windows for that table. The stat windows will not go away automatically when you close the table.</p>
|
|
||||||
|
|
||||||
<img src="img/docs.HudHowTo4.png" />
|
|
||||||
|
|
||||||
<p>4. Adjust the positions of the stat windows. By default, the stat windows are created without decorations (title bar, border, etc.). Double clicking on a stat will add the decorations to that stat window. You can then use the title bar to move the window and double click again to make the decorations disappear.</p>
|
|
||||||
|
|
||||||
<img src="img/docs.HudHowTo5.png" />
|
|
||||||
|
|
||||||
<img src="img/docs.HudHowTo6.png" />
|
|
||||||
|
|
||||||
<p>5. So play some poker: raise, bet, float, get all-in. You can find out what each stat is by hovering the mouse over the stat and looking at the tool tip. The tool tip also has the name of the player that the stat corresponds to, so it is useful in figuring out which stat window goes where if your windows are not in the right place. You can also get a pop up window with additional stats by single clicking on a stat.</p>
|
|
||||||
|
|
||||||
<img src="img/docs.HudHowTo7.png" />
|
|
||||||
|
|
||||||
<p>These windows do not automatically update when a new hand is imported, but they can be moved around the same way the stat window are moved. Single clicking anywhere on the popup will make it disappear.</p>
|
|
||||||
|
|
||||||
<h3>Configuring Stat Layouts</h3>
|
|
||||||
|
|
||||||
<p>OK, back to the HUD_config.xml file--saving a backup would be a good idea. Before you ask, yes, there will be a neat configuration function in the HUD, to make this quicker and easier. We thought you would prefer to have the HUD now rather than wait for us to write the configuration code.</p>
|
|
||||||
|
|
||||||
<p>1. Open your HUD_config.xml file in you text editor and scroll down to site entry for the layout you want to configure. For example, if you want to change a layout for Pokerstars, find the line that starts like this.</p>
|
|
||||||
|
|
||||||
<code><site site_name="PokerStars" ...</code>
|
|
||||||
|
|
||||||
<p>Below that line you will find several blocks of lines defining the stat layouts for tables with the various numbers of seats. For example the layout for 6-seated tables looks like this:</p>
|
|
||||||
|
|
||||||
<code><layout max="6" width="792" height="546" fav_seat="0><br>
|
|
||||||
<location seat="1" x="681" y="119"> </location><br>
|
|
||||||
<location seat="2" x="681" y="301"> </location><br>
|
|
||||||
<location seat="3" x="487" y="369"> </location><br>
|
|
||||||
<location seat="4" x="226" y="369"> </location><br>
|
|
||||||
<location seat="5" x="0" y="301"> </location><br>
|
|
||||||
<location seat="6" x="0" y="119"> </location><br>
|
|
||||||
</layout></code>
|
|
||||||
|
|
||||||
<p>The first line of this layout specifies that it is for a 6-max (max="6") table that has been sized to 792 x 546 (width="792" height="546"). The fav_seat parameter is not used at this time.</p>
|
|
||||||
|
|
||||||
<p>The next 6 lines specify where the stat windows are placed on the poker client window. The x and y positions are measured from the inside upper left of the poker client window. That is x = 0, y = 0 would be the first usable pixel to the right of the window border and below the title bar.</p>
|
|
||||||
|
|
||||||
<p>So if you are using the layout in the example above and decide that the stat window for seat 3 is being place 9 pixels too high, you would change the line for seat="3" to be:</p>
|
|
||||||
|
|
||||||
<code><location seat="3" x="487" y="378"> </location></code>
|
|
||||||
|
|
||||||
<p>If you use smaller or larger client windows you should correct the width and height parameters so that they are up-to-date when automatic resizing is implemented.</p>
|
|
||||||
|
|
||||||
<h3>Configuring the Stats Shown in the stat windows</h3>
|
|
||||||
|
|
||||||
<p>The definition of the stat window stats is in the "supported games" paragraph of the HUD_config.xml file. For example:</p>
|
|
||||||
|
|
||||||
<code><game game_name="studhilo" db="fpdb" rows="2" cols="3"><br>
|
|
||||||
<stat row="0" col="0" stat_name="vpip" tip="tip1" click="tog_decorate" popup="default"> </stat><br>
|
|
||||||
<stat row="0" col="1" stat_name="pfr" tip="tip1" click="tog_decorate" popup="default"> </stat><br>
|
|
||||||
<stat row="0" col="2" stat_name="ffreq_1" tip="tip1" click="tog_decorate" popup="default"> </stat><br>
|
|
||||||
<stat row="1" col="0" stat_name="n" tip="tip1" click="tog_decorate" popup="default"> </stat><br>
|
|
||||||
<stat row="1" col="1" stat_name="wtsd" tip="tip1" click="tog_decorate" popup="default"> </stat><br>
|
|
||||||
<stat row="1" col="2" stat_name="wmsd" tip="tip1" click="tog_decorate" popup="default"> </stat><br>
|
|
||||||
</game></code>
|
|
||||||
|
|
||||||
<p>The first line specifies the game that this stat paragraph is used for (game = "studhilo") and the number of rows and columns in the stat window. In this case we have specified 2 rows and 3 columns so we can have 2x3 = 6 stats. Rows and columns are numbered from 0, so the 3 columns are numbered 0, 1, and 2.</p>
|
|
||||||
|
|
||||||
<p>The subsequent lines in the stat paragraph specify which stats are displayed in the various parts of the window. In this example, vpip is displayed in col 0, row 0.</p>
|
|
||||||
|
|
||||||
<p>So to create stat windows with 4 columns of 2 rows you would change the cols parameter in the first line to cols = "4" and add 2 additional rows to specify the stats for row 2, col 3 and row 1, col 3.</p>
|
|
||||||
|
|
||||||
<p>The click and tip parameters in this paragraph are not currently used. The popup parameter is explained in the next section.</p>
|
|
||||||
|
|
||||||
<h3>Configuring Popup Windows</h3>
|
|
||||||
|
|
||||||
<p>Each stat location can display a different popup window when clicked. In the example just above, each of the stats has the "default" popup specified. You can see the definition of the default popup by scrolling farther down in your config file. It should look like this.</p>
|
|
||||||
|
|
||||||
<code><popup_windows><br>
|
|
||||||
<pu pu_name="default"><br>
|
|
||||||
<pu_stat pu_stat_name = "n"> </pu_stat><br>
|
|
||||||
<pu_stat pu_stat_name = "vpip"> </pu_stat><br>
|
|
||||||
<pu_stat pu_stat_name = "pfr"> </pu_stat><br>
|
|
||||||
...<br>
|
|
||||||
<pu_stat pu_stat_name = "ffreq_4"> </pu_stat><br>
|
|
||||||
</pu><br>
|
|
||||||
</popup_windows></code>
|
|
||||||
|
|
||||||
<p>You can create a new popup by making a new pu elelment, with a new name and a new list of stats. You then specify that popup name in the popup parameter in one or more of your stats.</p>
|
|
||||||
|
|
||||||
<h3>Currently Supported Stats</h3>
|
|
||||||
|
|
||||||
<dl>
|
|
||||||
<dt>a_freq_1</dt> <dd>Flop/4th aggression frequency.</dd>
|
|
||||||
<dt>a_freq_2</dt> <dd>Turn/5th aggression frequency.</dd>
|
|
||||||
<dt>a_freq_3</dt> <dd>River/6th aggression frequency.</dd>
|
|
||||||
<dt>a_freq_4</dt> <dd>7th street aggression frequency.</dd>
|
|
||||||
<dt>cb_1</dt> <dd>Flop continuation bet.</dd>
|
|
||||||
<dt>cb_2</dt> <dd>Turn continuation bet.</dd>
|
|
||||||
<dt>cb_3</dt> <dd>River continuation bet.</dd>
|
|
||||||
<dt>cb_4</dt> <dd>7th street continuation bet.</dd>
|
|
||||||
<dt>f_BB_steal</dt> <dd>Folded BB to steal.</dd>
|
|
||||||
<dt>f_SB_steal</dt> <dd>Folded SB to steal.</dd>
|
|
||||||
<dt>ffreq_1</dt> <dd>Flop/4th fold frequency.</dd>
|
|
||||||
<dt>ffreq_2</dt> <dd>Turn/5th fold frequency.</dd>
|
|
||||||
<dt>ffreq_3</dt> <dd>River/6th fold frequency.</dd>
|
|
||||||
<dt>ffreq_4</dt> <dd>7th fold frequency.</dd>
|
|
||||||
<dt>n</dt> <dd>Number of hands played.</dd>
|
|
||||||
<dt>pfr</dt> <dd>Preflop (3rd street) raise.</dd>
|
|
||||||
<dt>saw_f</dt> <dd>Saw flop/4th.</dd>
|
|
||||||
<dt>steal</dt> <dd>Steal %.</dd>
|
|
||||||
<dt>three_B_0</dt> <dd>Three bet preflop/3rd.</dd>
|
|
||||||
<dt>vpip</dt> <dd>Voluntarily put $ in the pot.</dd>
|
|
||||||
<dt>wmsd</dt> <dd>Won $ at showdown.</dd>
|
|
||||||
<dt>wtsd</dt> <dd>Went to SD when saw flop/4th.</dd>
|
|
||||||
<dt>WMsF</dt> <dd>Won $ when saw flop/4th.</dd>
|
|
||||||
</dl>
|
|
||||||
|
|
||||||
|
|
||||||
<?php
|
|
||||||
|
|
||||||
require 'footer.php';
|
|
||||||
|
|
||||||
?>
|
|
|
@ -1,85 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
$PAGE_TITLE = 'Installing in Gentoo';
|
|
||||||
|
|
||||||
require 'header.php';
|
|
||||||
require 'sidebar.php';
|
|
||||||
|
|
||||||
?>
|
|
||||||
|
|
||||||
<div id="main">
|
|
||||||
|
|
||||||
<h1>Installing in Gentoo Linux</h1>
|
|
||||||
|
|
||||||
<p>Last checked: 3 Aug 2008, git99<br><br>
|
|
||||||
|
|
||||||
These instructions are for Gentoo GNU/Linux, but if you adapt the steps installing and starting stuff it should work on any other OS as well.<br><br>
|
|
||||||
|
|
||||||
1. Install everything. Check if anything is already installed and if it is remove it from the command.<br><br>
|
|
||||||
|
|
||||||
For mysql:<br>
|
|
||||||
emerge mysql mysql-python pygtk -av<br>
|
|
||||||
/etc/init.d/mysql start<br>
|
|
||||||
rc-update add mysql default<br><br>
|
|
||||||
|
|
||||||
For postgresql:<br>
|
|
||||||
emerge postgresql pygresql pygtk <br>
|
|
||||||
/etc/init.d/postgresql start<br>
|
|
||||||
rc-update add postgresql default<br>
|
|
||||||
|
|
||||||
<br><br>
|
|
||||||
2. Manual configuration steps<br>
|
|
||||||
<br>
|
|
||||||
emerge --config mysql<br>
|
|
||||||
The --config step will ask you for the mysql root user - set this securely, we will create a seperate account for fpdb<br>
|
|
||||||
<br><br>
|
|
||||||
3. Create a mysql user and a database<br>
|
|
||||||
Now open a shell (aka command prompt aka DOS window):<br>
|
|
||||||
Click Start, then Run. In the opening window type "cmd" (without the inverted commas) and then click OK. A windows with a black background should open.<br><br>
|
|
||||||
|
|
||||||
Type (replacing yourPassword with the root password for MySQL you specified during installation):<br>
|
|
||||||
mysql --user=root --password=yourPassword<br><br>
|
|
||||||
|
|
||||||
It should say something like this:<br>
|
|
||||||
Welcome to the MySQL monitor. Commands end with ; or \g.<br>
|
|
||||||
Your MySQL connection id is 4<br>
|
|
||||||
Server version: 5.0.60-log Gentoo Linux mysql-5.0.60-r1<br>
|
|
||||||
<br>
|
|
||||||
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.<br>
|
|
||||||
<br>
|
|
||||||
mysql><br>
|
|
||||||
<br>
|
|
||||||
Now create the actual database. The default name is fpdb, I recommend you keep it. Type this:<br>
|
|
||||||
CREATE DATABASE fpdb;<br>
|
|
||||||
|
|
||||||
Next you need to create a user. I recommend you use the default fpdb. Type this (replacing newPassword with the password you want the fpdb user to have - this can, but for security shouldn't, be the same as the root mysql password):<br>
|
|
||||||
GRANT ALL PRIVILEGES ON fpdb.* TO 'fpdb'@'localhost' IDENTIFIED BY 'newPassword' WITH GRANT OPTION;<br><br>
|
|
||||||
|
|
||||||
Copy the .conf file from this directory to ~/.fpdb/profiles/default.conf and edit it according to what you configured just now, in particular you will definitely have to put in the password you configured. I know this is insecure, will fix it before stable release.<br>
|
|
||||||
<br>
|
|
||||||
4. Guided installation steps<br>
|
|
||||||
Run the GUI as described in readme-user and click the menu database -> recreate tables<br>
|
|
||||||
<br>
|
|
||||||
That's it! Now see readme-user.txt for usage instructions.<br>
|
|
||||||
<br>
|
|
||||||
License<br>
|
|
||||||
=======<br>
|
|
||||||
Trademarks of third parties have been used under Fair Use or similar laws.<br>
|
|
||||||
<br>
|
|
||||||
Copyright 2008 Steffen Jobbagy-Felso<br>
|
|
||||||
Permission is granted to copy, distribute and/or modify this<br>
|
|
||||||
document under the terms of the GNU Free Documentation License,<br>
|
|
||||||
Version 1.2 as published by the Free Software Foundation; with<br>
|
|
||||||
no Invariant Sections, no Front-Cover Texts, and with no Back-Cover<br>
|
|
||||||
Texts. A copy of the license can be found in fdl-1.2.txt<br>
|
|
||||||
<br>
|
|
||||||
The program itself is licensed under AGPLv3, see agpl-3.0.txt</p>
|
|
||||||
|
|
||||||
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<?php
|
|
||||||
|
|
||||||
require 'footer.php';
|
|
||||||
|
|
||||||
?>
|
|
|
@ -1,208 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
$PAGE_TITLE = 'Installing in Windows';
|
|
||||||
|
|
||||||
require 'header.php';
|
|
||||||
require 'sidebar.php';
|
|
||||||
|
|
||||||
?>
|
|
||||||
|
|
||||||
<div id="main">
|
|
||||||
|
|
||||||
<h1>Before You Begin</h1>
|
|
||||||
<p>Most people should install using the <a href="http://sourceforge.net/project/showfiles.php?group_id=226872">Installer</a>. These instructions have not been updated recently, but can serve as a guide to someone who knows what he is doing. Unless you have a special reason for installing manually, you really should be using the installer.</p>
|
|
||||||
|
|
||||||
<h1>Vista Users</h1>
|
|
||||||
<p>The installer does not install mysql properly on Microsoft Vista installations, due to the UAC. You should first install mysql using this <a href="http://port25.technet.com/videos/research/MySQL_Windows.pdf">how to (pdf)</a>. Then run the installer. The installer will detect the mysql installation and not reintstall.</p>
|
|
||||||
|
|
||||||
<h1>Installing in Windows</h1>
|
|
||||||
|
|
||||||
<div class="winInst">
|
|
||||||
<p>These instructions were made with Windows XP. They should also work with Windows NT / 2000 / 2003 and 2008. Please report any differences to gmic at users.sourceforge.net.
|
|
||||||
<p>If you're still using Win3/95/98/ME then you should switch to GNU/Linux, *BSD or WinXP.</p>
|
|
||||||
|
|
||||||
<div class="screenshot">
|
|
||||||
<img src="img/00.mySqlWebsite1.jpg" alt="windows install guide screenshot" />
|
|
||||||
<p><strong>1.</strong> Click <a href="http://dev.mysql.com/get/Downloads/MySQL-5.0/mysql-5.0.67-win32.zip/from/pick#mirrors">here</a> to open the <a href="http://dev.mysql.com/get/Downloads/MySQL-5.0/mysql-5.0.67-win32.zip/from/pick#mirrors">MySQL Download Page</a>. Click on the "No, thanks..." link to see the download links for the MySQL installer.</p>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="screenshot">
|
|
||||||
<img src="img/01.mySqlWebsite2.jpg" alt="windows install guide screenshot" />
|
|
||||||
<p><strong>2.</strong> Click on one of the HTTP or FTP download links to download the zip file (mysql-5.0.67-win32.zip).</p>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="screenshot">
|
|
||||||
<img src="img/02.mySqlSetup1.jpg" alt="windows install guide screenshot" />
|
|
||||||
<p><strong>3.</strong> Unzip the setup file to a folder of your choice and double-click on it. On the welcome screen click "Next".</p>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="screenshot">
|
|
||||||
<img src="img/03.mySqlSetup3.jpg" alt="windows install guide screenshot" />
|
|
||||||
<p><strong>4.</strong> As the setup type "Typical" should be selected. Then click "Next". On the following screen click "Install" and installation will begin.</p>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="screenshot">
|
|
||||||
<img src="img/04.mySqlSetup5.jpg" alt="windows install guide screenshot" />
|
|
||||||
<p><strong>5.</strong> Before the installation ends an ad for MySQL Enterprise edition will appear. Just click "Next" two times.</p>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="screenshot">
|
|
||||||
<img src="img/05.mySqlSetup7.jpg" alt="windows install guide screenshot" />
|
|
||||||
<p><strong>6.</strong> Now make sure that "Configure the MySQL Server now" is checked and click "Finish".</p>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="screenshot">
|
|
||||||
<img src="img/06.mySqlConfig1.jpg" alt="windows install guide screenshot" />
|
|
||||||
<p><strong>7.</strong> You are now looking at the MySQL Configuration Wizard. Click "Next".</p>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="screenshot">
|
|
||||||
<img src="img/07.mySqlConfig2.jpg" alt="windows install guide screenshot" />
|
|
||||||
<p><strong>8.</strong> Make sure "Detailed Configuration" is selected. Then click "Next. Now "Developer machine" should be selected. Click "Next".</p>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="screenshot">
|
|
||||||
<img src="img/08.mySqlConfig4.jpg" alt="windows install guide screenshot" />
|
|
||||||
<p><strong>9.</strong> On this screen "Multifunctional Database should be selected. Click "Next". On the next screen (InnoDB Tablespace) just click "Next".</p>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="screenshot">
|
|
||||||
<img src="img/09.mySqlConfig7.jpg" alt="windows install guide screenshot" />
|
|
||||||
<p><strong>10.</strong> Now "Decision Support" should be selected. Click "Next". Now make sure "Enable TCP/IP Networking" <strong>IS</strong> selected. Then click "Next".</p>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="screenshot">
|
|
||||||
<img src="img/10.mySqlConfig8.jpg" alt="windows install guide screenshot" />
|
|
||||||
<p><strong>11.</strong> Here "Standard Character Set" should be selected. Click "Next". Now make sure <strong>"Install As Windows Service"</strong> is selected.</p>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="screenshot">
|
|
||||||
<img src="img/11.mySqlConfig10.jpg" alt="windows install guide screenshot" />
|
|
||||||
<p><strong>12.</strong> Now choose a root password. This will <strong>NOT</strong> be the password for your poker database. Click "Next".</p>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="screenshot">
|
|
||||||
<img src="img/12.mySqlConfig11.jpg" alt="windows install guide screenshot" />
|
|
||||||
<p><strong>13.</strong> On this last screen of the Configuration Wizard just click "Execute." A few success messages will appear. Click "Finish".</p>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="screenshot">
|
|
||||||
<img src="img/13.run.jpg" alt="windows install guide screenshot" />
|
|
||||||
<p><strong>14.</strong> Now click the Windows Start Button and then click "Run". Click into the white space of the new window, type <code>cmd</code> and hit ENTER.</p>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="screenshot">
|
|
||||||
<img src="img/14.shellCdToMySql.jpg" alt="windows install guide screenshot" />
|
|
||||||
<p><strong>15.</strong> In the newly appeared console window type <code>cd "%PROGRAMFILES%\MySQL\MySQL Server 5.0\bin"</code> and hit ENTER.</p>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="screenshot">
|
|
||||||
<img src="img/15.shellMySqlRootLogin.jpg" alt="windows install guide screenshot" />
|
|
||||||
<p><strong>16.</strong> Type <code>mysql --user=root --password=yourPassword</code> and hit ENTER (replace <code>yourPassword</code> with your chosen root password).</p>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="screenshot">
|
|
||||||
<img src="img/16.shellMySqlPrompt.jpg" alt="windows install guide screenshot" />
|
|
||||||
<p><strong>17.</strong> A few lines followed by <code>mysql></code> will appear. This is the MySQL command prompt.</p>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="screenshot">
|
|
||||||
<img src="img/17.shellMySqlCreateDB.jpg" alt="windows install guide screenshot" />
|
|
||||||
<p><strong>18.</strong> We will now create your poker database. Type <code>CREATE DATABASE fpdb;</code> and hit ENTER. "Query OK" says we were successful.</p>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="screenshot">
|
|
||||||
<img src="img/18.shellMySqlCreateUser.jpg" alt="windows install guide screenshot" />
|
|
||||||
<p><strong>19.</strong> Type the following, <strong>replace</strong> <code>newPassword</code> with a password of your choice and hit ENTER:</p>
|
|
||||||
<p><code>GRANT ALL PRIVILEGES ON fpdb.* TO 'fpdb'@'localhost' IDENTIFIED BY 'newPassword' WITH GRANT OPTION;</code></p>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="screenshot">
|
|
||||||
<img src="img/19.shellMySqlUserCreated.jpg" alt="windows install guide screenshot" />
|
|
||||||
<p><strong>20.</strong> Again it says "Query OK". Type <code>exit</code> and hit ENTER to exit the MySQL prompt. <strong>Leave this window open.</strong> We will need it later.</p>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="screenshot">
|
|
||||||
<img src="img/20.pythonInst.jpg" alt="windows install guide screenshot" />
|
|
||||||
<p><strong>21.</strong> Click <a href="http://www.python.org/ftp/python/2.5.2/python-2.5.2.msi">here</a>, save the file python-2.5.2.msi where you want and double-click on it. In case of a warning window click "Execute".</p>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="screenshot">
|
|
||||||
<img src="img/21.pythonInst4.jpg" alt="windows install guide screenshot" />
|
|
||||||
<p><strong>22.</strong>Click "Next" three times. Python will install. Then click finish.</p>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="screenshot">
|
|
||||||
<img src="img/22.mySqlPythonInst1.jpg" alt="windows install guide screenshot" />
|
|
||||||
<p><strong>23.</strong> Click <a href="http://downloads.sourceforge.net/mysql-python/MySQL-python-1.2.2.win32-py2.5.exe?modtime=1173863337&big_mirror=0">here</a>, save MySQL-python-1.2.2.win32-py2.5.exe to a folder of your choice and double click it. In case of a warning window click "Execute". Click "Next" three times. The Python API for MySQL will install. Click "Finish".</p>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="screenshot">
|
|
||||||
<img src="img/23.shellMkDirGtk.jpg" alt="windows install guide screenshot" />
|
|
||||||
<p><strong>24.</strong> In the console window (which we left open) now type: <code>mkdir c:\gtk</code> and hit ENTER. Leave the window open again, we'll need it.</p>
|
|
||||||
<p>Now click <a href="http://ftp.gnome.org/pub/gnome/binaries/win32/gtk+/2.12/gtk+-bundle-2.12.11.zip">here</a> and save the gtk zip file gtk+-bundle-2.12.11.zip to a folder of your choice. Unzip its contents to C:\gtk</p>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="screenshot">
|
|
||||||
<img src="img/24.setGtkPath1.jpg" alt="windows install guide screenshot" />
|
|
||||||
<p><strong>25.</strong> Now <strong>right-click</strong> "My Computer" (on your Desktop) and click on "Properties". Now click on the tab "Advanced".</p>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="screenshot">
|
|
||||||
<img src="img/25.setGtkPath2.jpg" alt="windows install guide screenshot" />
|
|
||||||
<p><strong>26.</strong> Click the button "Environ Variables". In the lower list of the new window click on "Path" (possibly you need to scroll).</p>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="screenshot">
|
|
||||||
<img src="img/26.setGtkPath3.jpg" alt="windows install guide screenshot" />
|
|
||||||
<p><strong>27.</strong>Now click on the"Edit" button and a new window will pop up. To the value of the variable append <code>;C:\gtk\bin</code> Click Ok three times.</p>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="screenshot">
|
|
||||||
<img src="img/27.pycairoInst.jpg" alt="windows install guide screenshot" />
|
|
||||||
<p><strong>28.</strong> Click <a href="http://ftp.gnome.org/pub/GNOME/binaries/win32/pycairo/1.4/pycairo-1.4.12-1.win32-py2.5.exe">here</a>, save the file pycairo-1.4.12-1.win32-py2.5.exe to a folder of your choice and double click on it. In case of a warning window click "Execute". Now click "Next" three times. The pycairo graphics library API for Python will install. Click "Finish".</p>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="screenshot">
|
|
||||||
<img src="img/28.pygobjectInst.jpg" alt="windows install guide screenshot" />
|
|
||||||
<p><strong>29.</strong> Click <a href="http://ftp.gnome.org/pub/GNOME/binaries/win32/pygobject/2.14/pygobject-2.14.1-1.win32-py2.5.exe">here</a>, save the file pygobject-2.14.1-1.win32-py2.5.exe to a folder of your choice and double click on it. In case of a warning click "Execute". Now click "Next" three times. The Python Gobject API will install. Click "Finish".</p>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="screenshot">
|
|
||||||
<img src="img/29.pyGtkInst.jpg" alt="windows install guide screenshot" />
|
|
||||||
<p><strong>30.</strong> Click <a href="http://ftp.gnome.org/pub/GNOME/binaries/win32/pygtk/2.12/pygtk-2.12.1-2.win32-py2.5.exe">here</a>, save the file pygtk-2.12.1-2.win32-py2.5.exe to a folder of your choice and double click on it. In case of a warning click "Execute". Now click "Next" three times. The Python API for Gtk+ will install. Click "Finish".</p>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="screenshot"> <img src="img/30.shellMkDirProfiles.jpg" alt="windows install guide screenshot" />
|
|
||||||
<p><strong>31.</strong> In the console window now type: <code>mkdir "%homepath%\Application Data\fpdb"</code> and hit ENTER. Copy the file "default.conf" from the docs folder of your fpdb git to the directory C:\%homepath%\Application Data\fpdb\.</p>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="screenshot">
|
|
||||||
<img src="img/31.editDbProfile.jpg" alt="windows install guide screenshot" />
|
|
||||||
<p><strong>32.</strong> Now open the file "default.conf" in WordPad (Start > Programs > Accessoirs > WordPad) and replace the password in the <code>dbpassword</code> line with your chosen password for the fpdb user. </p>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="screenshot">
|
|
||||||
<img src="img/32.startFpdb.jpg" alt="windows install guide screenshot" />
|
|
||||||
<p><strong>33.</strong> Now start FPDB by double-clicking on the file fpdb.py in the folder fpdb. A console window should open up and shortly thereafter the fpdb application window should be visible. Click on the menu "Database" and select "Create or Recreate Tables".</p>
|
|
||||||
</div
|
|
||||||
|
|
||||||
<div class="screenshot">
|
|
||||||
<p><strong>Congratulations! Your fpdb installation is complete! Now you can use the bulk importer to import your hands into fpdb.</strong>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<p>A word on privelege separation: fpdb should not require root/Administrator rights to run. If it does it is a bug or serious misconfiguration, please let us know.</p>
|
|
||||||
<h4>License</h4>
|
|
||||||
<p>Trademarks of third parties have been used under Fair Use or similar laws.</p>
|
|
||||||
<p>Copyright 2008 Steffen Jobbagy-Felso</p>
|
|
||||||
<p>Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 as published by the Free Software Foundation; with no Invariant Sections, no Front-Cover Texts, and with no Back-Cover Texts. A copy of the license can be found in fdl-1.2.txt. The program itself is licensed under AGPLv3, see agpl-3.0.txt</p>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<?php
|
|
||||||
|
|
||||||
require 'footer.php';
|
|
||||||
|
|
||||||
?>
|
|
|
@ -1,84 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
$PAGE_TITLE = 'Overview';
|
|
||||||
|
|
||||||
require 'header.php';
|
|
||||||
require 'sidebar.php';
|
|
||||||
|
|
||||||
?>
|
|
||||||
|
|
||||||
<div id="main">
|
|
||||||
|
|
||||||
<h1>Overview</h1>
|
|
||||||
<p>
|
|
||||||
Summary<br>
|
|
||||||
=======<br>
|
|
||||||
A database program to track your online poker games, the behaviour of the other players and your winnings/losses. Supports Holdem, Omaha, Stud and Razz for cash games as well as SnG and MTT tournaments with more possibly coming in the future. Some of this is not yet working though, please see status.txt and known-bugs-and-planned-features.txt<br>
|
|
||||||
<br>
|
|
||||||
But you could send all my hand histories to yourself!<br>
|
|
||||||
=====================================================<br>
|
|
||||||
At the end of the day this comes down to a question of trust, but unlike Windows and the poker client software you don't have to trust fpdb blindly. You can:<br>
|
|
||||||
- Verify the source code yourself.<br>
|
|
||||||
- Convince or pay someone to verify the source code for you.<br>
|
|
||||||
- Use a personal firewall to completely block fpdb from the Internet<br>
|
|
||||||
- (for the uber-paranoid) Get yourself the free virtualisation software VirtualBox, set up a VM (virtual machine) to run fpdb but run the poker software on your real PC. Then cut the VM off the Internet, fpdb doesn't need it. If you have a PC made in the last few years this should run fast enough as well. Note that most Windows licenses do NOT permit you to use two Windows installations at once, even if they are on the same PC.<br>
|
|
||||||
<br>
|
|
||||||
Requirements<br>
|
|
||||||
============<br>
|
|
||||||
Software requirements are listed in requirements.txt<br>
|
|
||||||
As for hardware, my main test machine is a Pentium 3-M 800 with 256 RAM and Gentoo GNU/Linux<br>
|
|
||||||
(running the poker client through what most people will call emulation). So this<br>
|
|
||||||
program will have to work on that. If you run an even more ancient machine and<br>
|
|
||||||
its too slow let me know and I'll see what I can do :)<br>
|
|
||||||
<br>
|
|
||||||
Why Free Software?<br>
|
|
||||||
==================<br>
|
|
||||||
This program is released under the terms of the free/libre software license AGPL3 as released by the FSF. The AGPL3 protects your rights and those of the wider community. As Richard Stallman, one of the founders of the free software movement, put it: "Free software is a matter of liberty, not price. To understand the concept, you should think of free as in free speech, not as in free beer." (well, it is both really, like the right to vote used to be free)<br>
|
|
||||||
<br>
|
|
||||||
For example, a "pirated" copy of proprietary software X is free of charge, but you don't actually have a legal right to use it, you don't have any possibility to fix its bugs and you certainly don't have any legal right to share it with your friends. You also won't be able to get support, often not even security fixes. Actually, even if you pay hundreds of pounds for your program they deny your right to fix their errors for them. Imagine buying a car where you're not permitted (under threat of jail) to replace broken parts..<br>
|
|
||||||
<br>
|
|
||||||
With free/libre software (also known as open source software, or short FOSS or FLOSS) on the other hand you get all these freedoms:<br>
|
|
||||||
(note: the legally binding terms are in the license text, this is merely an amateur summary so normal people don't have to read pages of legalese)<br>
|
|
||||||
<br>
|
|
||||||
Freedom 0: The freedom to use: To run the program, for any purpose. Free of Charge.<br>
|
|
||||||
Freedom 1: The freedom to study and help yourself. This freedom guarantees your right to study and learn from the source code of the program, and to fix it if it is broken. If you're not a programmer yourself the developers will generally be happy to fix it for you, often even for free. Failing that you can always pay someone from the money you saved on not having to pay for it.<br>
|
|
||||||
Freedom 2: The freedom to be a decent human being and help your neighbour: I don't threaten you with lawsuits or jail time if you share with your friends and neighbours, subject to the very modest restrictions of the AGPL3.<br>
|
|
||||||
Freedom 3: The freedom to improve the program and release your improvements to the public (or parts thereof) so that the whole community benefits. Note that you are PERMITTED, but not REQUIRED to distribute your changes. If you do distribute your changes you must do so under the terms of the AGPL3 however.<br>
|
|
||||||
<br>
|
|
||||||
Note that this is the license - I retain full copyright over my code, including the right to change the license for future versions. I do not intend to do this however. In any case, any version I released under AGPL3 remains available under that license forever, or more accurately until my copyright expires at which point it goes into the public domain.<br>
|
|
||||||
<br>
|
|
||||||
I reject the concept of software patents as a crime and under the European Patent Agreement software patents - even if you mislabel them as "computer-implemented inventions" or whatever - are explicitly prohibited.<br>
|
|
||||||
<br>
|
|
||||||
Can I get/use this under a different license?<br>
|
|
||||||
=============================================<br>
|
|
||||||
The short answer: Maybe.<br>
|
|
||||||
The long one: As detailed, I fully support what the FSF does and aims to achieve with the GPL. However, I realise that many free software developers don't object to closed source, some don't even object to closed source profiteering of their charity, and I don't think I have any right to go and tell them they're wrong.<br>
|
|
||||||
So if anyone wishes to use all or part of my code in another free software/open source project with an AGPL3-incompatible license such as BSD then let me know and we'll figure out a solution that makes everyone happy.<br>
|
|
||||||
If you wish to use all or part of this in closed source let me know how much if anything that is worth to you and I'm sure we'll be able to reach an agreement. Note that you are NOT permitted to just use fpdb code in closed source development whether in-house or by an independent software developer, you will NEED an additionally agreement with me to get fpdb under different licensing conditions.<br>
|
|
||||||
<br>
|
|
||||||
<br>
|
|
||||||
License of this Document<br>
|
|
||||||
========================<br>
|
|
||||||
The views expressed in this document are those of Steffen Jobbagy-Felso, other members of the fpdb team and external contributors may or may not agree.<br>
|
|
||||||
<br>
|
|
||||||
Trademarks of third parties have been used under Fair Use or similar laws.<br>
|
|
||||||
<br>
|
|
||||||
Copyright 2008 Steffen Jobbagy-Felso<br>
|
|
||||||
Permission is granted to copy, distribute and/or modify this<br>
|
|
||||||
document under the terms of the GNU Free Documentation License,<br>
|
|
||||||
Version 1.2 as published by the Free Software Foundation; with<br>
|
|
||||||
no Invariant Sections, no Front-Cover Texts, and with no Back-Cover<br>
|
|
||||||
Texts. A copy of the license can be found in fdl-1.2.txt<br>
|
|
||||||
<br>
|
|
||||||
The program itself is licensed under AGPLv3, see agpl-3.0.txt<br>
|
|
||||||
</p>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<?php
|
|
||||||
|
|
||||||
require 'footer.php';
|
|
||||||
|
|
||||||
?>
|
|
|
@ -1,170 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
$PAGE_TITLE = 'Requirements';
|
|
||||||
|
|
||||||
require 'header.php';
|
|
||||||
require 'sidebar.php';
|
|
||||||
|
|
||||||
?>
|
|
||||||
|
|
||||||
<div id="main">
|
|
||||||
|
|
||||||
<h1>Requirements</h1>
|
|
||||||
<p>
|
|
||||||
I recommend using a free/libre operating system, meaning a GNU/Linux distribution or a BSD variant (e.g. Gentoo GNU/Linux or OpenBSD) for ethical and practical reasons. Would you buy a car where you're prohibited from opening the bonnet under threat of jail? If the answer is no you should by the same logic not use closed source software for real money Poker :)<br>
|
|
||||||
<br>
|
|
||||||
Unfortunately you will always need one piece of unfree software: The poker client itself. Although not a direct dependency of fpdb you obviously will have a hard time putting this to productive use without running some poker client. As far as I know, only unfree clients are available. If you know better please let me know!<br>
|
|
||||||
<br>
|
|
||||||
If you can be bothered please do contact your poker site(s) and ask them to release free/libre clients, even if it is only for Windows. But lets be realistic, the chance of a positive answer is very low. Also, even unfree Linux client would of course be a great step forward<br>
|
|
||||||
<br>
|
|
||||||
In Windows use of the environment installer is recommended, pls see our sf download page. For Gentoo Linux we have an ebuild and for Ubuntu Linux we have (partial) instructions. If you use a different Linux or a BSD and have trouble please IM, email or post in the forums. Fpdb has been reported to work on MacOSX, but installation of the requirements is relatively painful. Any instructions for people to use would be much appreciated.<br>
|
|
||||||
<br>
|
|
||||||
Make new entries in this format:<br>
|
|
||||||
<b>Program Name</b><br>
|
|
||||||
a. Optional?<br>
|
|
||||||
b. Required Version and Why<br>
|
|
||||||
c. Project Webpage<br>
|
|
||||||
d. License</p>
|
|
||||||
<h2>Database backend - MySQL</h2>
|
|
||||||
<p>These two are required if you want to use MySQL as backend, which is the recommended choice due to lack of testing and polish of PostgreSQL support.</p>
|
|
||||||
<p><b>MySQL</b><br>
|
|
||||||
a. Optional?<br>
|
|
||||||
Choose MySQL or PostgreSQL<br>
|
|
||||||
b. Required Version and Why<br>
|
|
||||||
At least 3.23 required due to mysql-python.<br>
|
|
||||||
I use 5.0.54 and 5.0.60-r1 (GNU/Linux) and 5.0.51b (Windows).<br>
|
|
||||||
c. Project Webpage<br>
|
|
||||||
http://www.mysql.com<br>
|
|
||||||
d. License<br>
|
|
||||||
GPL2<br>
|
|
||||||
<br>
|
|
||||||
<b>mysql-python</b><br>
|
|
||||||
a. Optional?<br>
|
|
||||||
Required if you want to use MySQL backend<br>
|
|
||||||
b. Required Version and Why<br>
|
|
||||||
I use 1.2.2 but I am not aware of any incompatibilities with older or newer versions, pls report success/failure.<br>
|
|
||||||
c. Project Webpage<br>
|
|
||||||
http://sourceforge.net/projects/mysql-python/<br>
|
|
||||||
d. License<br>
|
|
||||||
SF lists GNU General Public License (GPL), Python License (CNRI Python License), Zope Public License.<br>
|
|
||||||
Project states GPL without version in Pkg-info.</p>
|
|
||||||
|
|
||||||
<h2>Database backend - PostgreSQL</h2>
|
|
||||||
<p>These two are required if you want to use PostgreSQL as backend</p>
|
|
||||||
<p><b>PostgreSQL</b><br>
|
|
||||||
a. Optional?<br>
|
|
||||||
Choose MySQL or PostgreSQL<br>
|
|
||||||
b. Required Version and Why<br>
|
|
||||||
I use 8.0.15 (GNU/Linux) and 8.3.3 (Windows) but I am not aware of any incompatibilities<br>
|
|
||||||
with older or newer versions, pls report success/failure.<br>
|
|
||||||
c. Project Webpage<br>
|
|
||||||
http://www.postgresql.org<br>
|
|
||||||
d. License<br>
|
|
||||||
BSD License<br>
|
|
||||||
<br>
|
|
||||||
<b>psycopg</b><br>
|
|
||||||
a. Optional?<br>
|
|
||||||
Required if you want to use PostgreSQL backend<br>
|
|
||||||
b. Required Version and Why<br>
|
|
||||||
I use 2.0.2 but I am not aware of any incompatibilities with older or newer versions, pls report success/failure.<br>
|
|
||||||
c. Project Webpage<br>
|
|
||||||
http://initd.org/projects/psycopg2<br>
|
|
||||||
d. License<br>
|
|
||||||
GPL2 according to Gentoo's ebuilds<br>
|
|
||||||
<br>
|
|
||||||
<h2>Required for everyone</h2>
|
|
||||||
<p><b>Python</b><br>
|
|
||||||
a. Optional?<br>
|
|
||||||
Required.<br>
|
|
||||||
b. Required Version and Why<br>
|
|
||||||
I use 2.4.4 and 2.5.2 but I am not aware of any incompatibilities with older or newer versions, pls report success/failure.<br>
|
|
||||||
c. Project Webpage<br>
|
|
||||||
http://www.python.org<br>
|
|
||||||
d. License<br>
|
|
||||||
Python License<br>
|
|
||||||
<br>
|
|
||||||
<p><b>GTK+ and dependencies</b><br>
|
|
||||||
a. Optional?<br>
|
|
||||||
Required.<br>
|
|
||||||
b. Required Version and Why<br>
|
|
||||||
I use 2.12.9 but it should run with 2.10 or higher. That is needed as I used MessageDialog updates<br>
|
|
||||||
c. Project Webpage<br>
|
|
||||||
Main: http://www.gtk.org/<br>
|
|
||||||
API spec: http://library.gnome.org/devel/gtk/2.12/<br>
|
|
||||||
Windows DLs (get the bundle unless you know what you're doing): http://www.gtk.org/download-windows.html<br>
|
|
||||||
d. License<br>
|
|
||||||
LGPL2<br>
|
|
||||||
<br>
|
|
||||||
<b>PyCairo</b><br>
|
|
||||||
a. Optional?<br>
|
|
||||||
Required.<br>
|
|
||||||
b. Required Version and Why<br>
|
|
||||||
?<br>
|
|
||||||
c. Project Webpage<br>
|
|
||||||
main: http://www.pygtk.org<br>
|
|
||||||
d. License<br>
|
|
||||||
LGPL2.1<br>
|
|
||||||
<br>
|
|
||||||
<b>PyGObject</b><br>
|
|
||||||
a. Optional?<br>
|
|
||||||
Required.<br>
|
|
||||||
b. Required Version and Why<br>
|
|
||||||
?<br>
|
|
||||||
c. Project Webpage<br>
|
|
||||||
main: http://www.pygtk.org<br>
|
|
||||||
d. License<br>
|
|
||||||
LGPL2.1<br>
|
|
||||||
<br>
|
|
||||||
<b>PyGTK</b><br>
|
|
||||||
a. Optional?<br>
|
|
||||||
Required.<br>
|
|
||||||
b. Required Version and Why<br>
|
|
||||||
?<br>
|
|
||||||
c. Project Webpage<br>
|
|
||||||
main: http://www.pygtk.org<br>
|
|
||||||
d. License<br>
|
|
||||||
LGPL2.1</p>
|
|
||||||
<h2>Requirements for the graphing function</h2>
|
|
||||||
<p>These are only required if you wish to use the graphing function, and fpdb will otherwise function without them</p>
|
|
||||||
<p><b>Numpy</b><br>
|
|
||||||
a. Optional?<br>
|
|
||||||
Optional.<br>
|
|
||||||
b. Required Version and Why<br>
|
|
||||||
I use 1.0.4 but I am not aware of any incompatibilities with older or newer versions, pls report success/failure.<br>
|
|
||||||
c. Project Webpage<br>
|
|
||||||
http://numeric.scipy.org/<br>
|
|
||||||
d. License<br>
|
|
||||||
BSD according to Gentoo's ebuild<br>
|
|
||||||
<br>
|
|
||||||
<b>matplotlib</b><br>
|
|
||||||
a. Optional?<br>
|
|
||||||
Optional.<br>
|
|
||||||
b. Required Version and Why<br>
|
|
||||||
I use 0.91.2 but I am not aware of any incompatibilities with older or newer versions, pls report success/failure.<br>
|
|
||||||
c. Project Webpage<br>
|
|
||||||
http://matplotlib.sourceforge.net/<br>
|
|
||||||
d. License<br>
|
|
||||||
BSD according to Gentoo's ebuild</p>
|
|
||||||
|
|
||||||
License (of this file)<br>
|
|
||||||
=======<br>
|
|
||||||
Trademarks of third parties have been used under Fair Use or similar laws.<br>
|
|
||||||
<br>
|
|
||||||
Copyright 2008 Steffen Jobbagy-Felso<br>
|
|
||||||
Permission is granted to copy, distribute and/or modify this<br>
|
|
||||||
document under the terms of the GNU Free Documentation License,<br>
|
|
||||||
Version 1.2 as published by the Free Software Foundation; with<br>
|
|
||||||
no Invariant Sections, no Front-Cover Texts, and with no Back-Cover<br>
|
|
||||||
Texts. A copy of the license can be found in fdl-1.2.txt<br>
|
|
||||||
<br>
|
|
||||||
The program itself is licensed under AGPLv3, see agpl-3.0.txt</p>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<?php
|
|
||||||
|
|
||||||
require 'footer.php';
|
|
||||||
|
|
||||||
?>
|
|
|
@ -1,64 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
$PAGE_TITLE = 'Usage instructions';
|
|
||||||
|
|
||||||
require 'header.php';
|
|
||||||
require 'sidebar.php';
|
|
||||||
|
|
||||||
?>
|
|
||||||
|
|
||||||
<div id="main">
|
|
||||||
|
|
||||||
<h1>Usage instructions</h1>
|
|
||||||
|
|
||||||
<p>Before you do this make sure you setup the dependencies, the database, user, tables and config file.<br>
|
|
||||||
<br>
|
|
||||||
Running it<br>
|
|
||||||
==========<br>
|
|
||||||
If you have python setup properly you can execute it by double clicking pyfpdb/fpdb.py.<br>
|
|
||||||
<br>
|
|
||||||
Note however that all error messages are currently only printed if you call it from a shell. It'll be much easier to diagnose possible problems (which are likely in alpha stage) if you run it from a shell. In Windows XP it seems to automatically open a shell window with the fpdb window where you can see the command line output.<br>
|
|
||||||
<br>
|
|
||||||
In Linux/MacOS/*BSD, e.g. if its in /home/sycamore/fpdb/, do this:<br>
|
|
||||||
cd /home/sycamore/fpdb/pyfpdb<br>
|
|
||||||
python fpdb.py<br>
|
|
||||||
<br>
|
|
||||||
That will start the main GUI.<br>
|
|
||||||
<br>
|
|
||||||
Have a look at the menus, the stuff that is marked todo is not yet implemented.<br>
|
|
||||||
<br>
|
|
||||||
The main things are the bulk importer and the table viewer. To use the importer open it from the menu (import files and directories). You can set a few options at the bottom, then select a folder or single file in the main are and click Import. Please report any errors by one of the contacts listed in readme-overview.txt.<br>
|
|
||||||
Currently this will block the interface, but you can open another instance of this program e.g. if you wanna play whilst a big import is running. <br>
|
|
||||||
<br>
|
|
||||||
Please check the output at the shell for errors, if there are any please get in touch by one of the methods listed in readme-overview.txt<br>
|
|
||||||
<br>
|
|
||||||
Table Viewer (tv)<br>
|
|
||||||
=================v
|
|
||||||
To use the table viewer open it from the menu, select the hand history file of the table you're at, and click the Import&Read&Refresh button. The abbreviations there are explained in abbreviations.txt, but feel free to ask. Note that most poker software will only create the file once the first hand you payed to play is finished.<br>
|
|
||||||
In each column there is either just the number (hand count for current stake, range of seats and type of game) or a percentage and the number of hands that this percentage is based on. For example, in W$@SD (won $ at shodown) the number in brackets is how many showdowns that player has seen.<br>
|
|
||||||
<br>
|
|
||||||
Reimporting<br>
|
|
||||||
===========<br>
|
|
||||||
Currently on most updates a reimport of the whole database is required. To do this open fpdb, click the menu Database and select Create/Recreate tables. Then import all your history files again.<br>
|
|
||||||
<br>
|
|
||||||
License<br>
|
|
||||||
=======
|
|
||||||
Trademarks of third parties have been used under Fair Use or similar laws.<br>
|
|
||||||
<br>
|
|
||||||
Copyright 2008 Steffen Jobbagy-Felso<br>
|
|
||||||
Permission is granted to copy, distribute and/or modify this<br>
|
|
||||||
document under the terms of the GNU Free Documentation License,<br>
|
|
||||||
Version 1.2 as published by the Free Software Foundation; with<br>
|
|
||||||
no Invariant Sections, no Front-Cover Texts, and with no Back-Cover<br>
|
|
||||||
Texts. A copy of the license can be found in fdl-1.2.txt<br>
|
|
||||||
<br>
|
|
||||||
The program itself is licensed under AGPLv3, see agpl-3.0.txt</p>
|
|
||||||
|
|
||||||
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<?php
|
|
||||||
|
|
||||||
require 'footer.php';
|
|
||||||
|
|
||||||
?>
|
|
|
@ -1,37 +0,0 @@
|
||||||
<?php
|
|
||||||
$PAGE_TITLE='Documentation';
|
|
||||||
require 'header.php';
|
|
||||||
require 'sidebar.php';
|
|
||||||
|
|
||||||
?>
|
|
||||||
|
|
||||||
<div id="main">
|
|
||||||
|
|
||||||
<h1>Documentation</h1>
|
|
||||||
|
|
||||||
<ul>
|
|
||||||
<li><a href="docs-overview.php">Overview</a></li>
|
|
||||||
<li><a href="docs-requirements.php">Requirements</a></li>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
<ul>
|
|
||||||
<li><a href="docs-install-windows.php">Install in Windows</a></li>
|
|
||||||
<li><a href="docs-install-gentoo.php">Install in Gentoo Linux</a></li>
|
|
||||||
<li><a href="default.conf">Default configuration file</a> (read the installation instructions)</li>
|
|
||||||
<li><a href="docs-git-instructions.php">Git instructions</a></li>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
<ul>
|
|
||||||
<li><a href="docs-hudHowTo.php">HOW TO Use the HUD</a></li>
|
|
||||||
<li><a href="docs-usage.php">Usage instructions</a></li>
|
|
||||||
<li><a href="docs-abreviations.php">Abreviations</a></li>
|
|
||||||
<li><a href="docs-benchmarks.php">Benchmarks</a></li>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<?php
|
|
||||||
|
|
||||||
require 'footer.php';
|
|
||||||
|
|
||||||
?>
|
|
|
@ -1,47 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
$PAGE_TITLE = 'Features';
|
|
||||||
|
|
||||||
require 'header.php';
|
|
||||||
require 'sidebar.php';
|
|
||||||
|
|
||||||
?>
|
|
||||||
|
|
||||||
<div id="main">
|
|
||||||
|
|
||||||
<h1>Features</h1>
|
|
||||||
|
|
||||||
<p>Backend, Distribution<br>
|
|
||||||
=====================<br>
|
|
||||||
- Choice of MySQL/InnoDB or PostgreSQL. (not tested on PostgreSQL)<br>
|
|
||||||
- It is possible to run the database on one PC, the importer on another, and then access the database with the table viewer or HUD from a third PC. (note: do NOT do this unencrypted over an untrusted network like your employer's LAN or the Internet!)<br>
|
|
||||||
<br>
|
|
||||||
Site/Game Support<br>
|
|
||||||
=================<br>
|
|
||||||
- Initially only full support for PS, FTP coming soon<br>
|
|
||||||
- Supports Holdem, Omaha Hi and Omaha Hi/Lo. Stud and Razz coming soon.<br>
|
|
||||||
|
|
||||||
- Supports No Limit, Pot Limit, Fixed Limit NL, Cap NL and Cap PL<br>
|
|
||||||
Note that currently it does not display extra stats for NL/PL so usefulness is limited for these limit types. Suggestions welcome, I don't play these.<br>
|
|
||||||
- Supports ring/cash games, SnG/MTT coming soon<br>
|
|
||||||
<br>
|
|
||||||
Tableviewer (tv)<br>
|
|
||||||
===========<br>
|
|
||||||
Tv takes a history filename and loads the appropriate players' stats and displays them in a tabular format. These stats currently are:<br>
|
|
||||||
- VPIP, PFR and Preflop 3B/4B (3B/4B is not quite correct I think)<br>
|
|
||||||
|
|
||||||
- Raise and Fold % on flop, turn and river. Fold only counts hands when someone raised. This can be displayed per street or as one combined value each for aggression and folding.<br>
|
|
||||||
- Number of hands this is based on.<br>
|
|
||||||
- SD/F (aka WtSD, proportion of hands where player went to showdown after seeing flop)<br>
|
|
||||||
- W$wSF (Won $ when seen Flop)<br>
|
|
||||||
- W$@SD (Won $ at showdown)<br>
|
|
||||||
For all stats it also displays how many hands this particular is based on</p>
|
|
||||||
|
|
||||||
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<?php
|
|
||||||
|
|
||||||
require 'footer.php';
|
|
||||||
|
|
||||||
?>
|
|
|
@ -1 +0,0 @@
|
||||||
<div id="footer"> <a href="http://sourceforge.net"> <img src="http://sflogo.sourceforge.net/sflogo.php?group_id=226872&type=2"> </a> </div> </body> </html>
|
|
BIN
website/fpdb.png
Before Width: | Height: | Size: 26 KiB |
|
@ -1,17 +0,0 @@
|
||||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
|
|
||||||
|
|
||||||
<html>
|
|
||||||
|
|
||||||
<head>
|
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
|
||||||
<title>fpdb - The free poker database - <?php echo ($PAGE_TITLE) ?></title>
|
|
||||||
<meta name="description" content="Home of fpdb, an open source and free poker tracking software.">
|
|
||||||
<meta name="keywords" content="fpdb, freepokerdb, poker, tracking, software">
|
|
||||||
<link rel="stylesheet" type="text/css" href="style.css">
|
|
||||||
</head>
|
|
||||||
|
|
||||||
<body>
|
|
||||||
|
|
||||||
<div id="header">
|
|
||||||
<div id="logo"><img src="fpdb.png"></div>
|
|
||||||
</div>
|
|
Before Width: | Height: | Size: 11 KiB |
Before Width: | Height: | Size: 17 KiB |
Before Width: | Height: | Size: 13 KiB |
Before Width: | Height: | Size: 10 KiB |
Before Width: | Height: | Size: 10 KiB |
Before Width: | Height: | Size: 17 KiB |
Before Width: | Height: | Size: 17 KiB |
Before Width: | Height: | Size: 12 KiB |
Before Width: | Height: | Size: 16 KiB |
Before Width: | Height: | Size: 16 KiB |
Before Width: | Height: | Size: 15 KiB |
Before Width: | Height: | Size: 9.2 KiB |
Before Width: | Height: | Size: 9.1 KiB |
Before Width: | Height: | Size: 4.9 KiB |
Before Width: | Height: | Size: 13 KiB |
Before Width: | Height: | Size: 11 KiB |
Before Width: | Height: | Size: 8.8 KiB |
Before Width: | Height: | Size: 4.9 KiB |
Before Width: | Height: | Size: 20 KiB |
Before Width: | Height: | Size: 7.3 KiB |
Before Width: | Height: | Size: 12 KiB |
Before Width: | Height: | Size: 5.7 KiB |
Before Width: | Height: | Size: 13 KiB |
Before Width: | Height: | Size: 9.3 KiB |
Before Width: | Height: | Size: 14 KiB |
Before Width: | Height: | Size: 17 KiB |
Before Width: | Height: | Size: 14 KiB |
Before Width: | Height: | Size: 11 KiB |
Before Width: | Height: | Size: 12 KiB |
Before Width: | Height: | Size: 12 KiB |