Merge branch 'master' of git://git.assembla.com/fpdb
This commit is contained in:
commit
779befae18
18
Makefile
18
Makefile
|
@ -1,3 +1,17 @@
|
|||
#Copyright 2009-2010 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.
|
||||
|
||||
# Variable definitions
|
||||
VERSION = 0.20
|
||||
DATE = $(shell date +%Y%m%d)
|
||||
|
@ -9,3 +23,7 @@ all:
|
|||
snapshot:
|
||||
git tag $(VERSION)-$(DATE)
|
||||
git archive --prefix=fpdb-$(VERSION)-$(DATE)/ $(VERSION)-$(DATE) | gzip -9 > ../fpdb-$(VERSION)-$(DATE).tar.gz
|
||||
|
||||
release:
|
||||
git tag $(VERSION)
|
||||
git archive --prefix=fpdb-$(VERSION)/ $(VERSION) | gzip -9 > ../fpdb-$(VERSION).tar.gz
|
||||
|
|
35
THANKS.txt
35
THANKS.txt
|
@ -1,35 +0,0 @@
|
|||
=**Thanks - Contributors to FPDB**=
|
||||
|
||||
This page is to acknowledge the people developing and contributing to FPDB, be it with code, documentation, testing, forum support and everything else that is required to make an open source project work.
|
||||
|
||||
Most people have found the project though the software forum at [[http://forumserver.twoplustwo.com/45/software/|2+2]] so most references to 2+2 aliases
|
||||
|
||||
Sincere apologies to those not listed. FPDB started life in August 2008, but we only got around to putting together a proper contributers list in April 2009. Private messages and emails have been deleted so we dont have a full history of non-code based contributions
|
||||
|
||||
==**Developers**==
|
||||
Active:
|
||||
Steffen123 - The initial code drop and project lead.
|
||||
Eratosthenes - Initial HUD code drop, release manager
|
||||
Ekdikeo - Contributor - contributed Everleaf support and much HUD work
|
||||
Sorrow - Contributor - Graphing, import framework
|
||||
mcturnbull (2+2?) - Contributor - import framework
|
||||
|
||||
Inactive:
|
||||
Sqlcoder - SQL query guru - Graphing filters, Player Stats, Positional Stats queries + general sql optimisation work
|
||||
Bostik - Author of [[http://bostik.iki.fi/pokerstats/|PokerStats]] - Postgres linux work. PokerStats import code was the inspiration for the new framework. I'm sure well use more of his ideas in future.
|
||||
FIXME - Original windows installer/packager
|
||||
|
||||
==Documentation==
|
||||
FIXME - Original web site guy
|
||||
FIXME - Guy who wrote the Mac install page
|
||||
FIXME - Any other wiki editors.
|
||||
|
||||
==Other==
|
||||
Eleatic Stranger - Super tester and contributor - Our #1 tester. Tracks the git repo and works the code harder than anyone and gives great feedback and bug reports. Thankyou.
|
||||
Xaviax - Tester and honorary helpdesk - Another excellent tester tracking git, has responded to many queries in the fpdb thread on his own time.
|
||||
KayosD - Hand History donation - Carbon Poker
|
||||
freerollerjb - Hand History donation - Carbon Poker
|
||||
puru - Hand History donation - Carbon Poker
|
||||
freestailo - Hand History donation - Carbon Poker
|
||||
MoDDe (Sourceforge) - Hand History Donation - Betfair
|
||||
Jay10826 - Hand History donation - Ultimate Bet
|
|
@ -1,75 +0,0 @@
|
|||
This is partially outdated
|
||||
|
||||
File list
|
||||
=========
|
||||
.:
|
||||
docs/ Documentation files
|
||||
pyfpdb/ The main program (in python)
|
||||
setup/ Directory with files for setting up this program
|
||||
regression-test/ Directory with test data, query scripts (in python) and the regression test script (in bash)
|
||||
utils/ A couple of things that will migrate to the main prog soon
|
||||
viewer/ Directory with the GUI (in Java)
|
||||
|
||||
./docs:
|
||||
abbreviations.txt A list of abbreviations used and their meaning
|
||||
agpl-3.0.txt License of the program (everything under /code)
|
||||
benchmarks.txt Some benchmark results
|
||||
codingstyle.txt Some notes on formatting. Feel free to ignore.
|
||||
fdl-1.2.txt License of the documentation (the files in /)
|
||||
filelist.txt This file
|
||||
howto-import.txt Instructions on how to run the importer
|
||||
install-in-gentoo.txt Installation instructions for Gentoo GNU/Linux
|
||||
install-in-windows.txt Installation instructions for Windows
|
||||
readme-dev.txt Some notes, pointers and such for developers or anyone else interested in changing fpdb
|
||||
readme-overview.txt Some general info about this program - read that first
|
||||
readme-user.txt Instructions on how to use fpdb
|
||||
status.txt Details of support for poker types and sites
|
||||
tabledesign.html Table design with comments
|
||||
|
||||
./pyfpdb:
|
||||
fpdb.py The main GUI. This is what the user will start and use to access the other things.
|
||||
fpdb_import.py Main import program. Calls methods in the other files.
|
||||
Takes one hand history file as input. This is the file
|
||||
you execute, do not run the other ones individually.
|
||||
Except import_gui.py of course.
|
||||
fpdb_parse_logic.py Parses a holdem/omaha/razz/stud hand.
|
||||
fpdb_save_to_db.py Just methods to store the parsed data into SQL.
|
||||
Seperate file because these calls are very unwieldy.
|
||||
fpdb_simple.py Simple methods called by the other files. Most work is
|
||||
actually done in this file to make the other ones look
|
||||
much easier than they are.
|
||||
import_gui.py GUI interface to the importer (obselete)
|
||||
|
||||
./setup:
|
||||
insert-basedata.sql Fills sites and gametypes tables. Run this once after running the above.
|
||||
recreate-tables.sql File for mysql to recreate the tables. THIS WILL DELETE EXISTING TABLES!!!
|
||||
|
||||
./testdata:
|
||||
should be self explanatory
|
||||
|
||||
./utils:
|
||||
dump_db_basedata.py Prints the contents of the tables sites and gametypes
|
||||
fpdb_util_lib.py Helper methods for the utilities.
|
||||
get_DB_stats.py Prints some counts (like no. of players in the DB)
|
||||
get_player_stats.py Prints certain stats about players with CLI-passed constraints
|
||||
mysql-reset-tables.sh Reset tables for MySQL. THIS WILL DELETE EXISTING TABLES!!!
|
||||
print_hand.py Prints a hand in legible format.
|
||||
psql-interactive.sh *nix script to connect to a PostgreSQL database in
|
||||
interactive mode (note that we're currently only supporting MySQL)
|
||||
regression-test.sh Resets tables and checks manually verified hands for errors
|
||||
|
||||
./viewer:
|
||||
todo
|
||||
|
||||
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,79 +0,0 @@
|
|||
README.txt
|
||||
updated 22 February 2010, 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
|
||||
Triple Draw and Badugi
|
||||
Mixed Games -- HUD under development
|
||||
|
||||
Operating Systems:
|
||||
Linux and other Unix-like, using X
|
||||
Windows
|
||||
Mac OS/X -- no support for HUD
|
||||
|
||||
Databases:
|
||||
SQLite configured by default
|
||||
MySQL
|
||||
PostgreSQL
|
||||
|
||||
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 10 people have contributed code or patches. Others are welcome.
|
||||
|
||||
Source Code:
|
||||
If you received fpdb as the Windows compressed exe, then you did not
|
||||
receive souce code for fpdb or the included libraries. If you wish, you can
|
||||
obtain the source code here:
|
||||
|
||||
fpdb: see Downloads, above.
|
||||
python: http://python.org/
|
||||
gtk: http://www.gtk.org/download.html
|
||||
pygtk: http://www.pygtk.org/downloads.html
|
||||
psycopg2: http://initd.org/pub/software/psycopg/
|
||||
mysqldb: http://sourceforge.net/projects/mysql-python/files/
|
||||
sqlalchemy: http://www.sqlalchemy.org/download.html
|
||||
numpy: http://www.scipy.org/Download
|
||||
matplotlib: http://sourceforge.net/projects/matplotlib/files/
|
||||
|
||||
License
|
||||
=======
|
||||
Trademarks of third parties have been used under Fair Use or similar laws.
|
||||
|
||||
Copyright 2008 Steffen Jobbagy-Felso
|
||||
Copyright 2009,2010 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,93 +0,0 @@
|
|||
alpha2
|
||||
======
|
||||
Hi everyone,
|
||||
we are proud to announce the second alpha release of fpdb, the free/libre open source poker tracker. The biggest highlight is the HUD for Linux made by Ray (and perhaps Mac, not sure). But for everyone fpdb now also supports PS tournaments (SnG and MTT) and FTP ring games. There is also a new auto-importer though it currently only runs on one file per instance (but you can open multiple instances of fpdb).
|
||||
Fpdb also parses alot of new situations into the cache table for the HUD, most of which are already available through the Linux HUD. There have also been a large number of bugfixes for all kinds of things. For full details of the changes see the git commit comments.
|
||||
|
||||
You can download fpdb at https://sourceforge.net/project/showfiles.php?group_id=226872
|
||||
|
||||
Our website at http://fpdb.sourceforge.net/ will be updated shortly but in the meantime please note that the configuration file now resides in ~/.fpdb/default.conf on Linux/Mac and in C:\Documents and Settings\Application Data\fpdb\default.conf on Windows (on non-English Windows you have to translate the Documents and Settings, but not the Application data bit). Apart from that just follow the instructions on the site. I will be updating/improving the fpdb ebuild for Gentoo next week, please send me a PM or email if you would like a package for another Linux/BSD.
|
||||
|
||||
To use the HUD in Linux simply run the auto importer whilst having the table open. You will also have to rename HUD_config.xml.example to HUD_config.xml and edit the database parameters in there in addition to what is written in the install guide.
|
||||
|
||||
If you've been using fpdb alpha1 just delete the fpdb folder, follow the installation guide except for installing the dependencies, then run fpdb and run recreate tables. Note that you will have to reimport ALL your history files.
|
||||
|
||||
For external devs (in particular Youre Toast): The table design has gone through some changes, though most of it was just renaming to make a consistent naming scheme and to make it more flexible towards stud/razz type games. I do not expect to having to make any future changes to the existing fields but I cannot yet guarantee that. There will be some additional fields in particular in the HudCache table. Please let me know if you need any further fields. I realise my naming breaks the "database designer's convention" but for this project I feel ignoring this convention for the benefit of consistent naming between Python and SQL is ok.
|
||||
|
||||
|
||||
Any questions and comments please post here, send me a PM or email, post a feature request or bug report on sourceforge or use any of the other means of contact listed on our webpage.
|
||||
|
||||
Enjoy,
|
||||
The fpdb team
|
||||
|
||||
PS: I personally will be away Sun-Tue so I probably won't be responding to anything but feel free to message me anyways, but if you post here or at SF someone else might be able to help.
|
||||
|
||||
PPS: If you wanna know EXACTLY how this project is moving along follow the git tree over at [url]http://www.assembla.com/spaces/fpdb/trac_git_tool[/url]
|
||||
|
||||
|
||||
alpha1
|
||||
======
|
||||
Hi everyone,
|
||||
I am proud to announce the first release of my new poker tracking software fpdb (freepokerdb, very imaginative I know ;) ). You may wonder why I bothered when now with HM and PT3 there are at least two excellent packages to choose from.
|
||||
|
||||
Four main reasons:
|
||||
1. Fpdb is free/libre open source software. In short, this means you don't depend on me if sth. is wrong or you want something more in this program as you can freely change it yourself. You also don't have to pay anything for it. If you like it and think I deserve to be paid just drop me a mail ;)
|
||||
2. HM and PT3 only support holdem. Fpdb initially supports Holdem and Omaha, with Stud and Razz mostly implemented and coming soon.
|
||||
3. HM and PT3 run on Windows only, and for me at least did not work in wine even after installing Mono. Fpdb runs on any plattform that has the required software, which will cover roundabout 99.9% of PCs. Currently tested plattforms are Windows XP-x86 and Gentoo GNU/Linux-amd64 as well as -x86.
|
||||
You still need to run Windows or wine to run the actual poker client though.
|
||||
4. Fpdb won't irritate you with copy prevention measures.
|
||||
|
||||
To install it go to https://sourceforge.net/project/showfiles.php?group_id=226872 and download the zip or tar.bz2, unpack it, and follow the instructions in docs/install-in-* for your operating system (e.g. docs\install-in-windows.txt). Sourceforge lists the release files as source files, not as binary executables - this is correct, python will automagically compile as and when required.
|
||||
|
||||
This is alpha1, as the name indicates it is still at a very early stage. The importer and database are nearing completion but the GUI in particular is not very functional yet and the HUD is missing alltogether.
|
||||
|
||||
If anyone wishes to help with development that would be very very welcome and I've put a few notes in docs/readme-dev.txt in the download for what you could do. Or just start coding and send me the patches :)
|
||||
If you're not a programmer and you're not interested in learning it you can still help simply by trying it out and sending bug reports and feature requests. To avoid unrealistic expectations I'd like to state that it'll be a long time until fpdb reaches feature parity to established paid-for closed source software.
|
||||
|
||||
Feature List (short now, growing fast ;) ):
|
||||
|
||||
You can edit/add whatever you like, it's all python and SQL. The code should be fairly straightforward I think and I put some notes into readme-dev.txt but feel free to ask.
|
||||
|
||||
Backend, Distribution
|
||||
=====================
|
||||
- Choice of MySQL/InnoDB or PostgreSQL. (not tested on PostgreSQL)
|
||||
- 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!)
|
||||
|
||||
Site/Game Support
|
||||
=================
|
||||
- Initially only full support for PS, FTP coming soon
|
||||
- Supports Holdem, Omaha Hi and Omaha Hi/Lo. Stud and Razz coming soon.
|
||||
- Supports No Limit, Pot Limit, Fixed Limit NL, Cap NL and Cap PL
|
||||
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.
|
||||
- Supports ring/cash games, SnG/MTT coming soon
|
||||
|
||||
Tableviewer (tv)
|
||||
===========
|
||||
Tv takes a history filename and loads the appropriate players' stats and displays them in a tabular format. These stats currently are:
|
||||
- VPIP, PFR and Preflop 3B/4B (3B/4B is not quite correct I think)
|
||||
- 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.
|
||||
- Number of hands this is based on.
|
||||
- SD/F (aka WtSD, proportion of hands where player went to showdown after seeing flop)
|
||||
- W$wSF (Won $ when seen Flop)
|
||||
- W$@SD (Won $ at showdown)
|
||||
For all stats it also displays how many hands this particular is based on
|
||||
|
||||
|
||||
IMPORTANT: The database format WILL undergo more changes and at this point I am not planning to write a converter so please keep your history files so you can re-import when necessary. Independent of this you should always keep the original raw files in a safe place with any tracking software. Should you however end up loosing your files somehow let me know and I'll try to help.
|
||||
|
||||
Please send any feedback, feature requests/suggestions, bug reports and animal names to steffen@sycamoretest.info, pick one of the contact methods listed in readme-overview.txt, send me a PM here or reply to this post.
|
||||
|
||||
|
||||
|
||||
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
|
File diff suppressed because it is too large
Load Diff
|
@ -5,5 +5,5 @@ Exec=/usr/bin/fpdb
|
|||
Icon=fpdb-icon.png
|
||||
Terminal=true
|
||||
Type=Application
|
||||
Categories=Utility
|
||||
Categories=Utility;GTK;Application
|
||||
|
||||
|
|
339
gpl-2.0.txt
Normal file
339
gpl-2.0.txt
Normal file
|
@ -0,0 +1,339 @@
|
|||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 2, June 1991
|
||||
|
||||
Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
Preamble
|
||||
|
||||
The licenses for most software are designed to take away your
|
||||
freedom to share and change it. By contrast, the GNU General Public
|
||||
License is intended to guarantee your freedom to share and change free
|
||||
software--to make sure the software is free for all its users. This
|
||||
General Public License applies to most of the Free Software
|
||||
Foundation's software and to any other program whose authors commit to
|
||||
using it. (Some other Free Software Foundation software is covered by
|
||||
the GNU Lesser General Public License instead.) You can apply it to
|
||||
your programs, too.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
have the freedom to distribute copies of free software (and charge for
|
||||
this service if you wish), that you receive source code or can get it
|
||||
if you want it, that you can change the software or use pieces of it
|
||||
in new free programs; and that you know you can do these things.
|
||||
|
||||
To protect your rights, we need to make restrictions that forbid
|
||||
anyone to deny you these rights or to ask you to surrender the rights.
|
||||
These restrictions translate to certain responsibilities for you if you
|
||||
distribute copies of the software, or if you modify it.
|
||||
|
||||
For example, if you distribute copies of such a program, whether
|
||||
gratis or for a fee, you must give the recipients all the rights that
|
||||
you have. You must make sure that they, too, receive or can get the
|
||||
source code. And you must show them these terms so they know their
|
||||
rights.
|
||||
|
||||
We protect your rights with two steps: (1) copyright the software, and
|
||||
(2) offer you this license which gives you legal permission to copy,
|
||||
distribute and/or modify the software.
|
||||
|
||||
Also, for each author's protection and ours, we want to make certain
|
||||
that everyone understands that there is no warranty for this free
|
||||
software. If the software is modified by someone else and passed on, we
|
||||
want its recipients to know that what they have is not the original, so
|
||||
that any problems introduced by others will not reflect on the original
|
||||
authors' reputations.
|
||||
|
||||
Finally, any free program is threatened constantly by software
|
||||
patents. We wish to avoid the danger that redistributors of a free
|
||||
program will individually obtain patent licenses, in effect making the
|
||||
program proprietary. To prevent this, we have made it clear that any
|
||||
patent must be licensed for everyone's free use or not licensed at all.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
||||
|
||||
0. This License applies to any program or other work which contains
|
||||
a notice placed by the copyright holder saying it may be distributed
|
||||
under the terms of this General Public License. The "Program", below,
|
||||
refers to any such program or work, and a "work based on the Program"
|
||||
means either the Program or any derivative work under copyright law:
|
||||
that is to say, a work containing the Program or a portion of it,
|
||||
either verbatim or with modifications and/or translated into another
|
||||
language. (Hereinafter, translation is included without limitation in
|
||||
the term "modification".) Each licensee is addressed as "you".
|
||||
|
||||
Activities other than copying, distribution and modification are not
|
||||
covered by this License; they are outside its scope. The act of
|
||||
running the Program is not restricted, and the output from the Program
|
||||
is covered only if its contents constitute a work based on the
|
||||
Program (independent of having been made by running the Program).
|
||||
Whether that is true depends on what the Program does.
|
||||
|
||||
1. You may copy and distribute verbatim copies of the Program's
|
||||
source code as you receive it, in any medium, provided that you
|
||||
conspicuously and appropriately publish on each copy an appropriate
|
||||
copyright notice and disclaimer of warranty; keep intact all the
|
||||
notices that refer to this License and to the absence of any warranty;
|
||||
and give any other recipients of the Program a copy of this License
|
||||
along with the Program.
|
||||
|
||||
You may charge a fee for the physical act of transferring a copy, and
|
||||
you may at your option offer warranty protection in exchange for a fee.
|
||||
|
||||
2. You may modify your copy or copies of the Program or any portion
|
||||
of it, thus forming a work based on the Program, and copy and
|
||||
distribute such modifications or work under the terms of Section 1
|
||||
above, provided that you also meet all of these conditions:
|
||||
|
||||
a) You must cause the modified files to carry prominent notices
|
||||
stating that you changed the files and the date of any change.
|
||||
|
||||
b) You must cause any work that you distribute or publish, that in
|
||||
whole or in part contains or is derived from the Program or any
|
||||
part thereof, to be licensed as a whole at no charge to all third
|
||||
parties under the terms of this License.
|
||||
|
||||
c) If the modified program normally reads commands interactively
|
||||
when run, you must cause it, when started running for such
|
||||
interactive use in the most ordinary way, to print or display an
|
||||
announcement including an appropriate copyright notice and a
|
||||
notice that there is no warranty (or else, saying that you provide
|
||||
a warranty) and that users may redistribute the program under
|
||||
these conditions, and telling the user how to view a copy of this
|
||||
License. (Exception: if the Program itself is interactive but
|
||||
does not normally print such an announcement, your work based on
|
||||
the Program is not required to print an announcement.)
|
||||
|
||||
These requirements apply to the modified work as a whole. If
|
||||
identifiable sections of that work are not derived from the Program,
|
||||
and can be reasonably considered independent and separate works in
|
||||
themselves, then this License, and its terms, do not apply to those
|
||||
sections when you distribute them as separate works. But when you
|
||||
distribute the same sections as part of a whole which is a work based
|
||||
on the Program, the distribution of the whole must be on the terms of
|
||||
this License, whose permissions for other licensees extend to the
|
||||
entire whole, and thus to each and every part regardless of who wrote it.
|
||||
|
||||
Thus, it is not the intent of this section to claim rights or contest
|
||||
your rights to work written entirely by you; rather, the intent is to
|
||||
exercise the right to control the distribution of derivative or
|
||||
collective works based on the Program.
|
||||
|
||||
In addition, mere aggregation of another work not based on the Program
|
||||
with the Program (or with a work based on the Program) on a volume of
|
||||
a storage or distribution medium does not bring the other work under
|
||||
the scope of this License.
|
||||
|
||||
3. You may copy and distribute the Program (or a work based on it,
|
||||
under Section 2) in object code or executable form under the terms of
|
||||
Sections 1 and 2 above provided that you also do one of the following:
|
||||
|
||||
a) Accompany it with the complete corresponding machine-readable
|
||||
source code, which must be distributed under the terms of Sections
|
||||
1 and 2 above on a medium customarily used for software interchange; or,
|
||||
|
||||
b) Accompany it with a written offer, valid for at least three
|
||||
years, to give any third party, for a charge no more than your
|
||||
cost of physically performing source distribution, a complete
|
||||
machine-readable copy of the corresponding source code, to be
|
||||
distributed under the terms of Sections 1 and 2 above on a medium
|
||||
customarily used for software interchange; or,
|
||||
|
||||
c) Accompany it with the information you received as to the offer
|
||||
to distribute corresponding source code. (This alternative is
|
||||
allowed only for noncommercial distribution and only if you
|
||||
received the program in object code or executable form with such
|
||||
an offer, in accord with Subsection b above.)
|
||||
|
||||
The source code for a work means the preferred form of the work for
|
||||
making modifications to it. For an executable work, complete source
|
||||
code means all the source code for all modules it contains, plus any
|
||||
associated interface definition files, plus the scripts used to
|
||||
control compilation and installation of the executable. However, as a
|
||||
special exception, the source code distributed need not include
|
||||
anything that is normally distributed (in either source or binary
|
||||
form) with the major components (compiler, kernel, and so on) of the
|
||||
operating system on which the executable runs, unless that component
|
||||
itself accompanies the executable.
|
||||
|
||||
If distribution of executable or object code is made by offering
|
||||
access to copy from a designated place, then offering equivalent
|
||||
access to copy the source code from the same place counts as
|
||||
distribution of the source code, even though third parties are not
|
||||
compelled to copy the source along with the object code.
|
||||
|
||||
4. You may not copy, modify, sublicense, or distribute the Program
|
||||
except as expressly provided under this License. Any attempt
|
||||
otherwise to copy, modify, sublicense or distribute the Program is
|
||||
void, and will automatically terminate your rights under this License.
|
||||
However, parties who have received copies, or rights, from you under
|
||||
this License will not have their licenses terminated so long as such
|
||||
parties remain in full compliance.
|
||||
|
||||
5. You are not required to accept this License, since you have not
|
||||
signed it. However, nothing else grants you permission to modify or
|
||||
distribute the Program or its derivative works. These actions are
|
||||
prohibited by law if you do not accept this License. Therefore, by
|
||||
modifying or distributing the Program (or any work based on the
|
||||
Program), you indicate your acceptance of this License to do so, and
|
||||
all its terms and conditions for copying, distributing or modifying
|
||||
the Program or works based on it.
|
||||
|
||||
6. Each time you redistribute the Program (or any work based on the
|
||||
Program), the recipient automatically receives a license from the
|
||||
original licensor to copy, distribute or modify the Program subject to
|
||||
these terms and conditions. You may not impose any further
|
||||
restrictions on the recipients' exercise of the rights granted herein.
|
||||
You are not responsible for enforcing compliance by third parties to
|
||||
this License.
|
||||
|
||||
7. If, as a consequence of a court judgment or allegation of patent
|
||||
infringement or for any other reason (not limited to patent issues),
|
||||
conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot
|
||||
distribute so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you
|
||||
may not distribute the Program at all. For example, if a patent
|
||||
license would not permit royalty-free redistribution of the Program by
|
||||
all those who receive copies directly or indirectly through you, then
|
||||
the only way you could satisfy both it and this License would be to
|
||||
refrain entirely from distribution of the Program.
|
||||
|
||||
If any portion of this section is held invalid or unenforceable under
|
||||
any particular circumstance, the balance of the section is intended to
|
||||
apply and the section as a whole is intended to apply in other
|
||||
circumstances.
|
||||
|
||||
It is not the purpose of this section to induce you to infringe any
|
||||
patents or other property right claims or to contest validity of any
|
||||
such claims; this section has the sole purpose of protecting the
|
||||
integrity of the free software distribution system, which is
|
||||
implemented by public license practices. Many people have made
|
||||
generous contributions to the wide range of software distributed
|
||||
through that system in reliance on consistent application of that
|
||||
system; it is up to the author/donor to decide if he or she is willing
|
||||
to distribute software through any other system and a licensee cannot
|
||||
impose that choice.
|
||||
|
||||
This section is intended to make thoroughly clear what is believed to
|
||||
be a consequence of the rest of this License.
|
||||
|
||||
8. If the distribution and/or use of the Program is restricted in
|
||||
certain countries either by patents or by copyrighted interfaces, the
|
||||
original copyright holder who places the Program under this License
|
||||
may add an explicit geographical distribution limitation excluding
|
||||
those countries, so that distribution is permitted only in or among
|
||||
countries not thus excluded. In such case, this License incorporates
|
||||
the limitation as if written in the body of this License.
|
||||
|
||||
9. The Free Software Foundation may publish revised and/or new versions
|
||||
of the General Public License from time to time. Such new versions will
|
||||
be similar in spirit to the present version, but may differ in detail to
|
||||
address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the Program
|
||||
specifies a version number of this License which applies to it and "any
|
||||
later version", you have the option of following the terms and conditions
|
||||
either of that version or of any later version published by the Free
|
||||
Software Foundation. If the Program does not specify a version number of
|
||||
this License, you may choose any version ever published by the Free Software
|
||||
Foundation.
|
||||
|
||||
10. If you wish to incorporate parts of the Program into other free
|
||||
programs whose distribution conditions are different, write to the author
|
||||
to ask for permission. For software which is copyrighted by the Free
|
||||
Software Foundation, write to the Free Software Foundation; we sometimes
|
||||
make exceptions for this. Our decision will be guided by the two goals
|
||||
of preserving the free status of all derivatives of our free software and
|
||||
of promoting the sharing and reuse of software generally.
|
||||
|
||||
NO WARRANTY
|
||||
|
||||
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
|
||||
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
|
||||
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
|
||||
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
|
||||
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
|
||||
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
|
||||
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
|
||||
REPAIR OR CORRECTION.
|
||||
|
||||
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
|
||||
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
|
||||
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
|
||||
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
|
||||
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
|
||||
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
|
||||
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGES.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest
|
||||
possible use to the public, the best way to achieve this is to make it
|
||||
free software which everyone can redistribute and change under these terms.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest
|
||||
to attach them to the start of each source file to most effectively
|
||||
convey the exclusion of warranty; and each file should have at least
|
||||
the "copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the program's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
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.,
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If the program is interactive, make it output a short notice like this
|
||||
when it starts in an interactive mode:
|
||||
|
||||
Gnomovision version 69, Copyright (C) year name of author
|
||||
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||
This is free software, and you are welcome to redistribute it
|
||||
under certain conditions; type `show c' for details.
|
||||
|
||||
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||
parts of the General Public License. Of course, the commands you use may
|
||||
be called something other than `show w' and `show c'; they could even be
|
||||
mouse-clicks or menu items--whatever suits your program.
|
||||
|
||||
You should also get your employer (if you work as a programmer) or your
|
||||
school, if any, to sign a "copyright disclaimer" for the program, if
|
||||
necessary. Here is a sample; alter the names:
|
||||
|
||||
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
|
||||
`Gnomovision' (which makes passes at compilers) written by James Hacker.
|
||||
|
||||
<signature of Ty Coon>, 1 April 1989
|
||||
Ty Coon, President of Vice
|
||||
|
||||
This General Public License does not permit incorporating your program into
|
||||
proprietary programs. If your program is a subroutine library, you may
|
||||
consider it more useful to permit linking proprietary applications with the
|
||||
library. If this is what you want to do, use the GNU Lesser General
|
||||
Public License instead of this License.
|
674
gpl-3.0.txt
Normal file
674
gpl-3.0.txt
Normal file
|
@ -0,0 +1,674 @@
|
|||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 3, 29 June 2007
|
||||
|
||||
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
Preamble
|
||||
|
||||
The GNU General Public License is a free, copyleft license for
|
||||
software and other kinds of works.
|
||||
|
||||
The licenses for most software and other practical works are designed
|
||||
to take away your freedom to share and change the works. By contrast,
|
||||
the GNU General Public License is intended to guarantee your freedom to
|
||||
share and change all versions of a program--to make sure it remains free
|
||||
software for all its users. We, the Free Software Foundation, use the
|
||||
GNU General Public License for most of our software; it applies also to
|
||||
any other work released this way by its authors. You can apply it to
|
||||
your programs, too.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
have the freedom to distribute copies of free software (and charge for
|
||||
them if you wish), that you receive source code or can get it if you
|
||||
want it, that you can change the software or use pieces of it in new
|
||||
free programs, and that you know you can do these things.
|
||||
|
||||
To protect your rights, we need to prevent others from denying you
|
||||
these rights or asking you to surrender the rights. Therefore, you have
|
||||
certain responsibilities if you distribute copies of the software, or if
|
||||
you modify it: responsibilities to respect the freedom of others.
|
||||
|
||||
For example, if you distribute copies of such a program, whether
|
||||
gratis or for a fee, you must pass on to the recipients the same
|
||||
freedoms that you received. You must make sure that they, too, receive
|
||||
or can get the source code. And you must show them these terms so they
|
||||
know their rights.
|
||||
|
||||
Developers that use the GNU GPL protect your rights with two steps:
|
||||
(1) assert copyright on the software, and (2) offer you this License
|
||||
giving you legal permission to copy, distribute and/or modify it.
|
||||
|
||||
For the developers' and authors' protection, the GPL clearly explains
|
||||
that there is no warranty for this free software. For both users' and
|
||||
authors' sake, the GPL requires that modified versions be marked as
|
||||
changed, so that their problems will not be attributed erroneously to
|
||||
authors of previous versions.
|
||||
|
||||
Some devices are designed to deny users access to install or run
|
||||
modified versions of the software inside them, although the manufacturer
|
||||
can do so. This is fundamentally incompatible with the aim of
|
||||
protecting users' freedom to change the software. The systematic
|
||||
pattern of such abuse occurs in the area of products for individuals to
|
||||
use, which is precisely where it is most unacceptable. Therefore, we
|
||||
have designed this version of the GPL to prohibit the practice for those
|
||||
products. If such problems arise substantially in other domains, we
|
||||
stand ready to extend this provision to those domains in future versions
|
||||
of the GPL, as needed to protect the freedom of users.
|
||||
|
||||
Finally, every program is threatened constantly by software patents.
|
||||
States should not allow patents to restrict development and use of
|
||||
software on general-purpose computers, but in those that do, we wish to
|
||||
avoid the special danger that patents applied to a free program could
|
||||
make it effectively proprietary. To prevent this, the GPL assures that
|
||||
patents cannot be used to render the program non-free.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
TERMS AND CONDITIONS
|
||||
|
||||
0. Definitions.
|
||||
|
||||
"This License" refers to version 3 of the GNU General Public License.
|
||||
|
||||
"Copyright" also means copyright-like laws that apply to other kinds of
|
||||
works, such as semiconductor masks.
|
||||
|
||||
"The Program" refers to any copyrightable work licensed under this
|
||||
License. Each licensee is addressed as "you". "Licensees" and
|
||||
"recipients" may be individuals or organizations.
|
||||
|
||||
To "modify" a work means to copy from or adapt all or part of the work
|
||||
in a fashion requiring copyright permission, other than the making of an
|
||||
exact copy. The resulting work is called a "modified version" of the
|
||||
earlier work or a work "based on" the earlier work.
|
||||
|
||||
A "covered work" means either the unmodified Program or a work based
|
||||
on the Program.
|
||||
|
||||
To "propagate" a work means to do anything with it that, without
|
||||
permission, would make you directly or secondarily liable for
|
||||
infringement under applicable copyright law, except executing it on a
|
||||
computer or modifying a private copy. Propagation includes copying,
|
||||
distribution (with or without modification), making available to the
|
||||
public, and in some countries other activities as well.
|
||||
|
||||
To "convey" a work means any kind of propagation that enables other
|
||||
parties to make or receive copies. Mere interaction with a user through
|
||||
a computer network, with no transfer of a copy, is not conveying.
|
||||
|
||||
An interactive user interface displays "Appropriate Legal Notices"
|
||||
to the extent that it includes a convenient and prominently visible
|
||||
feature that (1) displays an appropriate copyright notice, and (2)
|
||||
tells the user that there is no warranty for the work (except to the
|
||||
extent that warranties are provided), that licensees may convey the
|
||||
work under this License, and how to view a copy of this License. If
|
||||
the interface presents a list of user commands or options, such as a
|
||||
menu, a prominent item in the list meets this criterion.
|
||||
|
||||
1. Source Code.
|
||||
|
||||
The "source code" for a work means the preferred form of the work
|
||||
for making modifications to it. "Object code" means any non-source
|
||||
form of a work.
|
||||
|
||||
A "Standard Interface" means an interface that either is an official
|
||||
standard defined by a recognized standards body, or, in the case of
|
||||
interfaces specified for a particular programming language, one that
|
||||
is widely used among developers working in that language.
|
||||
|
||||
The "System Libraries" of an executable work include anything, other
|
||||
than the work as a whole, that (a) is included in the normal form of
|
||||
packaging a Major Component, but which is not part of that Major
|
||||
Component, and (b) serves only to enable use of the work with that
|
||||
Major Component, or to implement a Standard Interface for which an
|
||||
implementation is available to the public in source code form. A
|
||||
"Major Component", in this context, means a major essential component
|
||||
(kernel, window system, and so on) of the specific operating system
|
||||
(if any) on which the executable work runs, or a compiler used to
|
||||
produce the work, or an object code interpreter used to run it.
|
||||
|
||||
The "Corresponding Source" for a work in object code form means all
|
||||
the source code needed to generate, install, and (for an executable
|
||||
work) run the object code and to modify the work, including scripts to
|
||||
control those activities. However, it does not include the work's
|
||||
System Libraries, or general-purpose tools or generally available free
|
||||
programs which are used unmodified in performing those activities but
|
||||
which are not part of the work. For example, Corresponding Source
|
||||
includes interface definition files associated with source files for
|
||||
the work, and the source code for shared libraries and dynamically
|
||||
linked subprograms that the work is specifically designed to require,
|
||||
such as by intimate data communication or control flow between those
|
||||
subprograms and other parts of the work.
|
||||
|
||||
The Corresponding Source need not include anything that users
|
||||
can regenerate automatically from other parts of the Corresponding
|
||||
Source.
|
||||
|
||||
The Corresponding Source for a work in source code form is that
|
||||
same work.
|
||||
|
||||
2. Basic Permissions.
|
||||
|
||||
All rights granted under this License are granted for the term of
|
||||
copyright on the Program, and are irrevocable provided the stated
|
||||
conditions are met. This License explicitly affirms your unlimited
|
||||
permission to run the unmodified Program. The output from running a
|
||||
covered work is covered by this License only if the output, given its
|
||||
content, constitutes a covered work. This License acknowledges your
|
||||
rights of fair use or other equivalent, as provided by copyright law.
|
||||
|
||||
You may make, run and propagate covered works that you do not
|
||||
convey, without conditions so long as your license otherwise remains
|
||||
in force. You may convey covered works to others for the sole purpose
|
||||
of having them make modifications exclusively for you, or provide you
|
||||
with facilities for running those works, provided that you comply with
|
||||
the terms of this License in conveying all material for which you do
|
||||
not control copyright. Those thus making or running the covered works
|
||||
for you must do so exclusively on your behalf, under your direction
|
||||
and control, on terms that prohibit them from making any copies of
|
||||
your copyrighted material outside their relationship with you.
|
||||
|
||||
Conveying under any other circumstances is permitted solely under
|
||||
the conditions stated below. Sublicensing is not allowed; section 10
|
||||
makes it unnecessary.
|
||||
|
||||
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
||||
|
||||
No covered work shall be deemed part of an effective technological
|
||||
measure under any applicable law fulfilling obligations under article
|
||||
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
||||
similar laws prohibiting or restricting circumvention of such
|
||||
measures.
|
||||
|
||||
When you convey a covered work, you waive any legal power to forbid
|
||||
circumvention of technological measures to the extent such circumvention
|
||||
is effected by exercising rights under this License with respect to
|
||||
the covered work, and you disclaim any intention to limit operation or
|
||||
modification of the work as a means of enforcing, against the work's
|
||||
users, your or third parties' legal rights to forbid circumvention of
|
||||
technological measures.
|
||||
|
||||
4. Conveying Verbatim Copies.
|
||||
|
||||
You may convey verbatim copies of the Program's source code as you
|
||||
receive it, in any medium, provided that you conspicuously and
|
||||
appropriately publish on each copy an appropriate copyright notice;
|
||||
keep intact all notices stating that this License and any
|
||||
non-permissive terms added in accord with section 7 apply to the code;
|
||||
keep intact all notices of the absence of any warranty; and give all
|
||||
recipients a copy of this License along with the Program.
|
||||
|
||||
You may charge any price or no price for each copy that you convey,
|
||||
and you may offer support or warranty protection for a fee.
|
||||
|
||||
5. Conveying Modified Source Versions.
|
||||
|
||||
You may convey a work based on the Program, or the modifications to
|
||||
produce it from the Program, in the form of source code under the
|
||||
terms of section 4, provided that you also meet all of these conditions:
|
||||
|
||||
a) The work must carry prominent notices stating that you modified
|
||||
it, and giving a relevant date.
|
||||
|
||||
b) The work must carry prominent notices stating that it is
|
||||
released under this License and any conditions added under section
|
||||
7. This requirement modifies the requirement in section 4 to
|
||||
"keep intact all notices".
|
||||
|
||||
c) You must license the entire work, as a whole, under this
|
||||
License to anyone who comes into possession of a copy. This
|
||||
License will therefore apply, along with any applicable section 7
|
||||
additional terms, to the whole of the work, and all its parts,
|
||||
regardless of how they are packaged. This License gives no
|
||||
permission to license the work in any other way, but it does not
|
||||
invalidate such permission if you have separately received it.
|
||||
|
||||
d) If the work has interactive user interfaces, each must display
|
||||
Appropriate Legal Notices; however, if the Program has interactive
|
||||
interfaces that do not display Appropriate Legal Notices, your
|
||||
work need not make them do so.
|
||||
|
||||
A compilation of a covered work with other separate and independent
|
||||
works, which are not by their nature extensions of the covered work,
|
||||
and which are not combined with it such as to form a larger program,
|
||||
in or on a volume of a storage or distribution medium, is called an
|
||||
"aggregate" if the compilation and its resulting copyright are not
|
||||
used to limit the access or legal rights of the compilation's users
|
||||
beyond what the individual works permit. Inclusion of a covered work
|
||||
in an aggregate does not cause this License to apply to the other
|
||||
parts of the aggregate.
|
||||
|
||||
6. Conveying Non-Source Forms.
|
||||
|
||||
You may convey a covered work in object code form under the terms
|
||||
of sections 4 and 5, provided that you also convey the
|
||||
machine-readable Corresponding Source under the terms of this License,
|
||||
in one of these ways:
|
||||
|
||||
a) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by the
|
||||
Corresponding Source fixed on a durable physical medium
|
||||
customarily used for software interchange.
|
||||
|
||||
b) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by a
|
||||
written offer, valid for at least three years and valid for as
|
||||
long as you offer spare parts or customer support for that product
|
||||
model, to give anyone who possesses the object code either (1) a
|
||||
copy of the Corresponding Source for all the software in the
|
||||
product that is covered by this License, on a durable physical
|
||||
medium customarily used for software interchange, for a price no
|
||||
more than your reasonable cost of physically performing this
|
||||
conveying of source, or (2) access to copy the
|
||||
Corresponding Source from a network server at no charge.
|
||||
|
||||
c) Convey individual copies of the object code with a copy of the
|
||||
written offer to provide the Corresponding Source. This
|
||||
alternative is allowed only occasionally and noncommercially, and
|
||||
only if you received the object code with such an offer, in accord
|
||||
with subsection 6b.
|
||||
|
||||
d) Convey the object code by offering access from a designated
|
||||
place (gratis or for a charge), and offer equivalent access to the
|
||||
Corresponding Source in the same way through the same place at no
|
||||
further charge. You need not require recipients to copy the
|
||||
Corresponding Source along with the object code. If the place to
|
||||
copy the object code is a network server, the Corresponding Source
|
||||
may be on a different server (operated by you or a third party)
|
||||
that supports equivalent copying facilities, provided you maintain
|
||||
clear directions next to the object code saying where to find the
|
||||
Corresponding Source. Regardless of what server hosts the
|
||||
Corresponding Source, you remain obligated to ensure that it is
|
||||
available for as long as needed to satisfy these requirements.
|
||||
|
||||
e) Convey the object code using peer-to-peer transmission, provided
|
||||
you inform other peers where the object code and Corresponding
|
||||
Source of the work are being offered to the general public at no
|
||||
charge under subsection 6d.
|
||||
|
||||
A separable portion of the object code, whose source code is excluded
|
||||
from the Corresponding Source as a System Library, need not be
|
||||
included in conveying the object code work.
|
||||
|
||||
A "User Product" is either (1) a "consumer product", which means any
|
||||
tangible personal property which is normally used for personal, family,
|
||||
or household purposes, or (2) anything designed or sold for incorporation
|
||||
into a dwelling. In determining whether a product is a consumer product,
|
||||
doubtful cases shall be resolved in favor of coverage. For a particular
|
||||
product received by a particular user, "normally used" refers to a
|
||||
typical or common use of that class of product, regardless of the status
|
||||
of the particular user or of the way in which the particular user
|
||||
actually uses, or expects or is expected to use, the product. A product
|
||||
is a consumer product regardless of whether the product has substantial
|
||||
commercial, industrial or non-consumer uses, unless such uses represent
|
||||
the only significant mode of use of the product.
|
||||
|
||||
"Installation Information" for a User Product means any methods,
|
||||
procedures, authorization keys, or other information required to install
|
||||
and execute modified versions of a covered work in that User Product from
|
||||
a modified version of its Corresponding Source. The information must
|
||||
suffice to ensure that the continued functioning of the modified object
|
||||
code is in no case prevented or interfered with solely because
|
||||
modification has been made.
|
||||
|
||||
If you convey an object code work under this section in, or with, or
|
||||
specifically for use in, a User Product, and the conveying occurs as
|
||||
part of a transaction in which the right of possession and use of the
|
||||
User Product is transferred to the recipient in perpetuity or for a
|
||||
fixed term (regardless of how the transaction is characterized), the
|
||||
Corresponding Source conveyed under this section must be accompanied
|
||||
by the Installation Information. But this requirement does not apply
|
||||
if neither you nor any third party retains the ability to install
|
||||
modified object code on the User Product (for example, the work has
|
||||
been installed in ROM).
|
||||
|
||||
The requirement to provide Installation Information does not include a
|
||||
requirement to continue to provide support service, warranty, or updates
|
||||
for a work that has been modified or installed by the recipient, or for
|
||||
the User Product in which it has been modified or installed. Access to a
|
||||
network may be denied when the modification itself materially and
|
||||
adversely affects the operation of the network or violates the rules and
|
||||
protocols for communication across the network.
|
||||
|
||||
Corresponding Source conveyed, and Installation Information provided,
|
||||
in accord with this section must be in a format that is publicly
|
||||
documented (and with an implementation available to the public in
|
||||
source code form), and must require no special password or key for
|
||||
unpacking, reading or copying.
|
||||
|
||||
7. Additional Terms.
|
||||
|
||||
"Additional permissions" are terms that supplement the terms of this
|
||||
License by making exceptions from one or more of its conditions.
|
||||
Additional permissions that are applicable to the entire Program shall
|
||||
be treated as though they were included in this License, to the extent
|
||||
that they are valid under applicable law. If additional permissions
|
||||
apply only to part of the Program, that part may be used separately
|
||||
under those permissions, but the entire Program remains governed by
|
||||
this License without regard to the additional permissions.
|
||||
|
||||
When you convey a copy of a covered work, you may at your option
|
||||
remove any additional permissions from that copy, or from any part of
|
||||
it. (Additional permissions may be written to require their own
|
||||
removal in certain cases when you modify the work.) You may place
|
||||
additional permissions on material, added by you to a covered work,
|
||||
for which you have or can give appropriate copyright permission.
|
||||
|
||||
Notwithstanding any other provision of this License, for material you
|
||||
add to a covered work, you may (if authorized by the copyright holders of
|
||||
that material) supplement the terms of this License with terms:
|
||||
|
||||
a) Disclaiming warranty or limiting liability differently from the
|
||||
terms of sections 15 and 16 of this License; or
|
||||
|
||||
b) Requiring preservation of specified reasonable legal notices or
|
||||
author attributions in that material or in the Appropriate Legal
|
||||
Notices displayed by works containing it; or
|
||||
|
||||
c) Prohibiting misrepresentation of the origin of that material, or
|
||||
requiring that modified versions of such material be marked in
|
||||
reasonable ways as different from the original version; or
|
||||
|
||||
d) Limiting the use for publicity purposes of names of licensors or
|
||||
authors of the material; or
|
||||
|
||||
e) Declining to grant rights under trademark law for use of some
|
||||
trade names, trademarks, or service marks; or
|
||||
|
||||
f) Requiring indemnification of licensors and authors of that
|
||||
material by anyone who conveys the material (or modified versions of
|
||||
it) with contractual assumptions of liability to the recipient, for
|
||||
any liability that these contractual assumptions directly impose on
|
||||
those licensors and authors.
|
||||
|
||||
All other non-permissive additional terms are considered "further
|
||||
restrictions" within the meaning of section 10. If the Program as you
|
||||
received it, or any part of it, contains a notice stating that it is
|
||||
governed by this License along with a term that is a further
|
||||
restriction, you may remove that term. If a license document contains
|
||||
a further restriction but permits relicensing or conveying under this
|
||||
License, you may add to a covered work material governed by the terms
|
||||
of that license document, provided that the further restriction does
|
||||
not survive such relicensing or conveying.
|
||||
|
||||
If you add terms to a covered work in accord with this section, you
|
||||
must place, in the relevant source files, a statement of the
|
||||
additional terms that apply to those files, or a notice indicating
|
||||
where to find the applicable terms.
|
||||
|
||||
Additional terms, permissive or non-permissive, may be stated in the
|
||||
form of a separately written license, or stated as exceptions;
|
||||
the above requirements apply either way.
|
||||
|
||||
8. Termination.
|
||||
|
||||
You may not propagate or modify a covered work except as expressly
|
||||
provided under this License. Any attempt otherwise to propagate or
|
||||
modify it is void, and will automatically terminate your rights under
|
||||
this License (including any patent licenses granted under the third
|
||||
paragraph of section 11).
|
||||
|
||||
However, if you cease all violation of this License, then your
|
||||
license from a particular copyright holder is reinstated (a)
|
||||
provisionally, unless and until the copyright holder explicitly and
|
||||
finally terminates your license, and (b) permanently, if the copyright
|
||||
holder fails to notify you of the violation by some reasonable means
|
||||
prior to 60 days after the cessation.
|
||||
|
||||
Moreover, your license from a particular copyright holder is
|
||||
reinstated permanently if the copyright holder notifies you of the
|
||||
violation by some reasonable means, this is the first time you have
|
||||
received notice of violation of this License (for any work) from that
|
||||
copyright holder, and you cure the violation prior to 30 days after
|
||||
your receipt of the notice.
|
||||
|
||||
Termination of your rights under this section does not terminate the
|
||||
licenses of parties who have received copies or rights from you under
|
||||
this License. If your rights have been terminated and not permanently
|
||||
reinstated, you do not qualify to receive new licenses for the same
|
||||
material under section 10.
|
||||
|
||||
9. Acceptance Not Required for Having Copies.
|
||||
|
||||
You are not required to accept this License in order to receive or
|
||||
run a copy of the Program. Ancillary propagation of a covered work
|
||||
occurring solely as a consequence of using peer-to-peer transmission
|
||||
to receive a copy likewise does not require acceptance. However,
|
||||
nothing other than this License grants you permission to propagate or
|
||||
modify any covered work. These actions infringe copyright if you do
|
||||
not accept this License. Therefore, by modifying or propagating a
|
||||
covered work, you indicate your acceptance of this License to do so.
|
||||
|
||||
10. Automatic Licensing of Downstream Recipients.
|
||||
|
||||
Each time you convey a covered work, the recipient automatically
|
||||
receives a license from the original licensors, to run, modify and
|
||||
propagate that work, subject to this License. You are not responsible
|
||||
for enforcing compliance by third parties with this License.
|
||||
|
||||
An "entity transaction" is a transaction transferring control of an
|
||||
organization, or substantially all assets of one, or subdividing an
|
||||
organization, or merging organizations. If propagation of a covered
|
||||
work results from an entity transaction, each party to that
|
||||
transaction who receives a copy of the work also receives whatever
|
||||
licenses to the work the party's predecessor in interest had or could
|
||||
give under the previous paragraph, plus a right to possession of the
|
||||
Corresponding Source of the work from the predecessor in interest, if
|
||||
the predecessor has it or can get it with reasonable efforts.
|
||||
|
||||
You may not impose any further restrictions on the exercise of the
|
||||
rights granted or affirmed under this License. For example, you may
|
||||
not impose a license fee, royalty, or other charge for exercise of
|
||||
rights granted under this License, and you may not initiate litigation
|
||||
(including a cross-claim or counterclaim in a lawsuit) alleging that
|
||||
any patent claim is infringed by making, using, selling, offering for
|
||||
sale, or importing the Program or any portion of it.
|
||||
|
||||
11. Patents.
|
||||
|
||||
A "contributor" is a copyright holder who authorizes use under this
|
||||
License of the Program or a work on which the Program is based. The
|
||||
work thus licensed is called the contributor's "contributor version".
|
||||
|
||||
A contributor's "essential patent claims" are all patent claims
|
||||
owned or controlled by the contributor, whether already acquired or
|
||||
hereafter acquired, that would be infringed by some manner, permitted
|
||||
by this License, of making, using, or selling its contributor version,
|
||||
but do not include claims that would be infringed only as a
|
||||
consequence of further modification of the contributor version. For
|
||||
purposes of this definition, "control" includes the right to grant
|
||||
patent sublicenses in a manner consistent with the requirements of
|
||||
this License.
|
||||
|
||||
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
||||
patent license under the contributor's essential patent claims, to
|
||||
make, use, sell, offer for sale, import and otherwise run, modify and
|
||||
propagate the contents of its contributor version.
|
||||
|
||||
In the following three paragraphs, a "patent license" is any express
|
||||
agreement or commitment, however denominated, not to enforce a patent
|
||||
(such as an express permission to practice a patent or covenant not to
|
||||
sue for patent infringement). To "grant" such a patent license to a
|
||||
party means to make such an agreement or commitment not to enforce a
|
||||
patent against the party.
|
||||
|
||||
If you convey a covered work, knowingly relying on a patent license,
|
||||
and the Corresponding Source of the work is not available for anyone
|
||||
to copy, free of charge and under the terms of this License, through a
|
||||
publicly available network server or other readily accessible means,
|
||||
then you must either (1) cause the Corresponding Source to be so
|
||||
available, or (2) arrange to deprive yourself of the benefit of the
|
||||
patent license for this particular work, or (3) arrange, in a manner
|
||||
consistent with the requirements of this License, to extend the patent
|
||||
license to downstream recipients. "Knowingly relying" means you have
|
||||
actual knowledge that, but for the patent license, your conveying the
|
||||
covered work in a country, or your recipient's use of the covered work
|
||||
in a country, would infringe one or more identifiable patents in that
|
||||
country that you have reason to believe are valid.
|
||||
|
||||
If, pursuant to or in connection with a single transaction or
|
||||
arrangement, you convey, or propagate by procuring conveyance of, a
|
||||
covered work, and grant a patent license to some of the parties
|
||||
receiving the covered work authorizing them to use, propagate, modify
|
||||
or convey a specific copy of the covered work, then the patent license
|
||||
you grant is automatically extended to all recipients of the covered
|
||||
work and works based on it.
|
||||
|
||||
A patent license is "discriminatory" if it does not include within
|
||||
the scope of its coverage, prohibits the exercise of, or is
|
||||
conditioned on the non-exercise of one or more of the rights that are
|
||||
specifically granted under this License. You may not convey a covered
|
||||
work if you are a party to an arrangement with a third party that is
|
||||
in the business of distributing software, under which you make payment
|
||||
to the third party based on the extent of your activity of conveying
|
||||
the work, and under which the third party grants, to any of the
|
||||
parties who would receive the covered work from you, a discriminatory
|
||||
patent license (a) in connection with copies of the covered work
|
||||
conveyed by you (or copies made from those copies), or (b) primarily
|
||||
for and in connection with specific products or compilations that
|
||||
contain the covered work, unless you entered into that arrangement,
|
||||
or that patent license was granted, prior to 28 March 2007.
|
||||
|
||||
Nothing in this License shall be construed as excluding or limiting
|
||||
any implied license or other defenses to infringement that may
|
||||
otherwise be available to you under applicable patent law.
|
||||
|
||||
12. No Surrender of Others' Freedom.
|
||||
|
||||
If conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot convey a
|
||||
covered work so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you may
|
||||
not convey it at all. For example, if you agree to terms that obligate you
|
||||
to collect a royalty for further conveying from those to whom you convey
|
||||
the Program, the only way you could satisfy both those terms and this
|
||||
License would be to refrain entirely from conveying the Program.
|
||||
|
||||
13. Use with the GNU Affero General Public License.
|
||||
|
||||
Notwithstanding any other provision of this License, you have
|
||||
permission to link or combine any covered work with a work licensed
|
||||
under version 3 of the GNU Affero General Public License into a single
|
||||
combined work, and to convey the resulting work. The terms of this
|
||||
License will continue to apply to the part which is the covered work,
|
||||
but the special requirements of the GNU Affero General Public License,
|
||||
section 13, concerning interaction through a network will apply to the
|
||||
combination as such.
|
||||
|
||||
14. Revised Versions of this License.
|
||||
|
||||
The Free Software Foundation may publish revised and/or new versions of
|
||||
the GNU General Public License from time to time. Such new versions will
|
||||
be similar in spirit to the present version, but may differ in detail to
|
||||
address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the
|
||||
Program specifies that a certain numbered version of the GNU General
|
||||
Public License "or any later version" applies to it, you have the
|
||||
option of following the terms and conditions either of that numbered
|
||||
version or of any later version published by the Free Software
|
||||
Foundation. If the Program does not specify a version number of the
|
||||
GNU General Public License, you may choose any version ever published
|
||||
by the Free Software Foundation.
|
||||
|
||||
If the Program specifies that a proxy can decide which future
|
||||
versions of the GNU General Public License can be used, that proxy's
|
||||
public statement of acceptance of a version permanently authorizes you
|
||||
to choose that version for the Program.
|
||||
|
||||
Later license versions may give you additional or different
|
||||
permissions. However, no additional obligations are imposed on any
|
||||
author or copyright holder as a result of your choosing to follow a
|
||||
later version.
|
||||
|
||||
15. Disclaimer of Warranty.
|
||||
|
||||
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
|
||||
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
|
||||
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
|
||||
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
|
||||
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
|
||||
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
|
||||
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||
|
||||
16. Limitation of Liability.
|
||||
|
||||
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
|
||||
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
|
||||
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
|
||||
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
|
||||
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
|
||||
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
|
||||
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
|
||||
SUCH DAMAGES.
|
||||
|
||||
17. Interpretation of Sections 15 and 16.
|
||||
|
||||
If the disclaimer of warranty and limitation of liability provided
|
||||
above cannot be given local legal effect according to their terms,
|
||||
reviewing courts shall apply local law that most closely approximates
|
||||
an absolute waiver of all civil liability in connection with the
|
||||
Program, unless a warranty or assumption of liability accompanies a
|
||||
copy of the Program in return for a fee.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest
|
||||
possible use to the public, the best way to achieve this is to make it
|
||||
free software which everyone can redistribute and change under these terms.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest
|
||||
to attach them to the start of each source file to most effectively
|
||||
state the exclusion of warranty; and each file should have at least
|
||||
the "copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the program's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If the program does terminal interaction, make it output a short
|
||||
notice like this when it starts in an interactive mode:
|
||||
|
||||
<program> Copyright (C) <year> <name of author>
|
||||
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||
This is free software, and you are welcome to redistribute it
|
||||
under certain conditions; type `show c' for details.
|
||||
|
||||
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||
parts of the General Public License. Of course, your program's commands
|
||||
might be different; for a GUI interface, you would use an "about box".
|
||||
|
||||
You should also get your employer (if you work as a programmer) or school,
|
||||
if any, to sign a "copyright disclaimer" for the program, if necessary.
|
||||
For more information on this, and how to apply and follow the GNU GPL, see
|
||||
<http://www.gnu.org/licenses/>.
|
||||
|
||||
The GNU General Public License does not permit incorporating your program
|
||||
into proprietary programs. If your program is a subroutine library, you
|
||||
may consider it more useful to permit linking proprietary applications with
|
||||
the library. If this is what you want to do, use the GNU Lesser General
|
||||
Public License instead of this License. But first, please read
|
||||
<http://www.gnu.org/philosophy/why-not-lgpl.html>.
|
22
mit.txt
Normal file
22
mit.txt
Normal file
|
@ -0,0 +1,22 @@
|
|||
This license applies to the pytz files distributed with fpdb's Windows installer
|
||||
|
||||
Copyright (c) Stuart Bishop <stuart@stuartbishop.net>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
"Software"), to deal in the Software without restriction, including
|
||||
without limitation the rights to use, copy, modify, merge, publish,
|
||||
distribute, sublicense, and/or sell copies of the Software, and to
|
||||
permit persons to whom the Software is furnished to do so, subject to
|
||||
the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be
|
||||
included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
@ -1,3 +1,50 @@
|
|||
free-poker-tools (0.20.902-1) unstable; urgency=low
|
||||
|
||||
* New snapshot release; .901 was broken for FTP
|
||||
|
||||
-- Mika Bostrom <bostik@iki.fi> Sat, 24 Jul 2010 09:05:57 +0300
|
||||
|
||||
free-poker-tools (0.20.901-1) unstable; urgency=low
|
||||
|
||||
* Snapshot release before oncoming 0.21
|
||||
|
||||
-- Mika Bostrom <bostik@iki.fi> Thu, 22 Jul 2010 23:32:47 +0300
|
||||
|
||||
free-poker-tools (0.20.1-1) unstable; urgency=low
|
||||
|
||||
* 0.20.1 release
|
||||
|
||||
-- Mika Bostrom <bostik@iki.fi> Thu, 22 Jul 2010 08:47:39 +0300
|
||||
|
||||
free-poker-tools (0.20-2) unstable; urgency=low
|
||||
|
||||
* Fix executable script shebangs: there is no /usr/bin/python2 (nor
|
||||
/usr/bin/python3) symlink on Debian or Ubuntu
|
||||
|
||||
-- Mika Bostrom <bostik+fpdb@bostik.iki.fi> Thu, 08 Jul 2010 21:29:40 +0300
|
||||
|
||||
free-poker-tools (0.20-1) unstable; urgency=low
|
||||
|
||||
* 0.20 release
|
||||
|
||||
-- Mika Bostrom <bostik+fpdb@bostik.iki.fi> Thu, 08 Jul 2010 11:25:36 +0300
|
||||
|
||||
free-poker-tools (0.20~git20100630) unstable; urgency=low
|
||||
|
||||
* Snapshot release
|
||||
* Executable names have been changed to accommodate for some win32
|
||||
trouble cases; install these files manually to build-tree
|
||||
* Improved statistics
|
||||
|
||||
-- Mika Bostrom <bostik+fpdb@bostik.iki.fi> Wed, 16 Jun 2010 08:10:00 +0300
|
||||
|
||||
free-poker-tools (0.20~git20100305) unstable; urgency=low
|
||||
|
||||
* New snapshot
|
||||
* Version bumped to 0.20
|
||||
|
||||
-- Mika Bostrom <bostik+fpdb@bostik.iki.fi> Fri, 05 Mar 2010 08:38:52 +0200
|
||||
|
||||
free-poker-tools (0.12~git20100122) unstable; urgency=low
|
||||
|
||||
* New snapshot release with reworked import code
|
||||
|
|
|
@ -2,6 +2,6 @@ This package was debianised by Mika Bostrom <bostik+fpdb@bostik.iki.fi>
|
|||
|
||||
Upstream authors: ...
|
||||
|
||||
License: AGPL
|
||||
License: AGPL3; partially GPL2 or higher
|
||||
|
||||
Copyright (C) 2008- The FPDB developers
|
||||
Copyright (C) 2008-2010 The FPDB developers
|
||||
|
|
|
@ -1 +1 @@
|
|||
/usr/share/pyshared/fpdb/fpdb.py /usr/bin/fpdb
|
||||
/usr/share/pyshared/fpdb/fpdb.pyw /usr/bin/fpdb
|
||||
|
|
|
@ -3,4 +3,4 @@
|
|||
# When installed into .../fpdb/ the script gets mode 644
|
||||
# Note: "dh_fixperms -Xfpdb.py" did not work, hence this hack
|
||||
chmod 755 /usr/bin/fpdb
|
||||
chmod 755 /usr/share/pyshared/fpdb/HUD_main.py
|
||||
chmod 755 /usr/share/pyshared/fpdb/HUD_main.pyw
|
||||
|
|
|
@ -23,6 +23,13 @@ install: build
|
|||
dh_installdirs
|
||||
#
|
||||
python setup.py install --root=debian/$(PACKAGE) --prefix=/usr --no-compile
|
||||
# Copy *.pyw manually in packaging tree
|
||||
cp pyfpdb/*.pyw debian/$(PACKAGE)/usr/lib/python2.6/site-packages/fpdb/
|
||||
# Remove scripts that are only useful in win32
|
||||
rm debian/$(PACKAGE)/usr/lib/python2.6/site-packages/fpdb//windows_make_bats.py
|
||||
rm debian/$(PACKAGE)/usr/lib/python2.6/site-packages/fpdb/makeexe.py
|
||||
rm debian/$(PACKAGE)/usr/lib/python2.6/site-packages/fpdb/py2exe_setup.py
|
||||
|
||||
|
||||
binary-indep: build install
|
||||
dh_testdir
|
||||
|
|
60
packaging/gentoo/current_stable.ebuild
Normal file
60
packaging/gentoo/current_stable.ebuild
Normal file
|
@ -0,0 +1,60 @@
|
|||
# Copyright 1999-2010 Gentoo Foundation
|
||||
# Distributed under the terms of the GNU General Public License v2
|
||||
# created by Steffen Schaumburg, steffen@schaumburger.info
|
||||
|
||||
inherit eutils
|
||||
inherit games
|
||||
|
||||
EAPI="2"
|
||||
NEED_PYTHON=2.5
|
||||
|
||||
DESCRIPTION="A free/open source tracker/HUD for use with online poker"
|
||||
HOMEPAGE="http://fpdb.wiki.sourceforge.net/"
|
||||
SRC_URI="mirror://sourceforge/${PN}/${PV}/${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="graph mysql postgres sqlite"
|
||||
RDEPEND="
|
||||
mysql? ( virtual/mysql
|
||||
dev-python/mysql-python )
|
||||
postgres? ( dev-db/postgresql-server
|
||||
dev-python/psycopg )
|
||||
sqlite? ( dev-lang/python[sqlite]
|
||||
dev-python/numpy )
|
||||
>=x11-libs/gtk+-2.10
|
||||
dev-python/pygtk
|
||||
graph? ( dev-python/numpy
|
||||
dev-python/matplotlib[gtk] )
|
||||
dev-python/python-xlib
|
||||
dev-python/pytz"
|
||||
DEPEND="${RDEPEND}"
|
||||
|
||||
src_install() {
|
||||
insinto "${GAMES_DATADIR}"/${PN}
|
||||
doins -r gfx
|
||||
doins -r pyfpdb
|
||||
doins readme.txt
|
||||
|
||||
exeinto "${GAMES_DATADIR}"/${PN}
|
||||
doexe run_fpdb.py
|
||||
|
||||
dodir "${GAMES_BINDIR}"
|
||||
dosym "${GAMES_DATADIR}"/${PN}/run_fpdb.py "${GAMES_BINDIR}"/${PN}
|
||||
|
||||
newicon gfx/fpdb-icon.png ${PN}.png
|
||||
make_desktop_entry ${PN}
|
||||
|
||||
prepgamesdirs
|
||||
fperms +x "${GAMES_DATADIR}"/${PN}/pyfpdb/*.pyw
|
||||
}
|
||||
|
||||
pkg_postinst() {
|
||||
games_pkg_postinst
|
||||
elog "Note that if you really want to use mysql or postgresql you will have to create"
|
||||
elog "the database and user yourself and enter it into the fpdb config."
|
||||
elog "You can find the instructions on the project's website."
|
||||
}
|
60
packaging/gentoo/current_testing.ebuild
Normal file
60
packaging/gentoo/current_testing.ebuild
Normal file
|
@ -0,0 +1,60 @@
|
|||
# Copyright 1999-2010 Gentoo Foundation
|
||||
# Distributed under the terms of the GNU General Public License v2
|
||||
# created by Steffen Schaumburg, steffen@schaumburger.info
|
||||
|
||||
inherit eutils
|
||||
inherit games
|
||||
|
||||
EAPI="2"
|
||||
NEED_PYTHON=2.5
|
||||
|
||||
DESCRIPTION="A free/open source tracker/HUD for use with online poker"
|
||||
HOMEPAGE="http://fpdb.wiki.sourceforge.net/"
|
||||
SRC_URI="mirror://sourceforge/${PN}/Snapshots/${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="graph mysql postgres sqlite"
|
||||
RDEPEND="
|
||||
mysql? ( virtual/mysql
|
||||
dev-python/mysql-python )
|
||||
postgres? ( dev-db/postgresql-server
|
||||
dev-python/psycopg )
|
||||
sqlite? ( dev-lang/python[sqlite]
|
||||
dev-python/numpy )
|
||||
>=x11-libs/gtk+-2.10
|
||||
dev-python/pygtk
|
||||
graph? ( dev-python/numpy
|
||||
dev-python/matplotlib[gtk] )
|
||||
dev-python/python-xlib
|
||||
dev-python/pytz"
|
||||
DEPEND="${RDEPEND}"
|
||||
|
||||
src_install() {
|
||||
insinto "${GAMES_DATADIR}"/${PN}
|
||||
doins -r gfx
|
||||
doins -r pyfpdb
|
||||
doins readme.txt
|
||||
|
||||
exeinto "${GAMES_DATADIR}"/${PN}
|
||||
doexe run_fpdb.py
|
||||
|
||||
dodir "${GAMES_BINDIR}"
|
||||
dosym "${GAMES_DATADIR}"/${PN}/run_fpdb.py "${GAMES_BINDIR}"/${PN}
|
||||
|
||||
newicon gfx/fpdb-icon.png ${PN}.png
|
||||
make_desktop_entry ${PN}
|
||||
|
||||
prepgamesdirs
|
||||
fperms +x "${GAMES_DATADIR}"/${PN}/pyfpdb/*.pyw
|
||||
}
|
||||
|
||||
pkg_postinst() {
|
||||
games_pkg_postinst
|
||||
elog "Note that if you really want to use mysql or postgresql you will have to create"
|
||||
elog "the database and user yourself and enter it into the fpdb config."
|
||||
elog "You can find the instructions on the project's website."
|
||||
}
|
|
@ -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-0.10.ebuild,v 1.0 2009/1/30 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 " "
|
||||
}
|
5
packaging/gentoo/readme.txt
Normal file
5
packaging/gentoo/readme.txt
Normal file
|
@ -0,0 +1,5 @@
|
|||
If you want to run a stable version please use current_stable.ebuild
|
||||
If you want to run a testing version please use current_testing.ebuild
|
||||
|
||||
To use the ebuild please simply copy it into your local portage tree and rename it to fpdb-version.ebuild, for example fpdb-0.20.1.ebuild or fpdb-0.20.902.ebuild.
|
||||
Here's a little howto on how to utilise 3rd party ebuilds such as this one: http://www.gentoo-wiki.info/HOWTO_Installing_3rd_Party_Ebuilds
|
134
packaging/windows/MySqlPython1.2.2WalkthroughPython26.txt
Normal file
134
packaging/windows/MySqlPython1.2.2WalkthroughPython26.txt
Normal file
|
@ -0,0 +1,134 @@
|
|||
Create MySqlPython version 1.2.2 windows installer for Python26
|
||||
|
||||
This walkthrough is derived from excellent installation instructions released under GNU Free Documentation License 1.2. The original work is here ... http://www.bcspcsonline.com/wiki/index.php?title=MySQL-5.1.34_Python-2.6_Module_Build_Instructions The Wiki author appears to be "Irondesk"
|
||||
|
||||
This version by Gimick on 29th June 2010
|
||||
Content is available under GNU Free Documentation License 1.2
|
||||
|
||||
Step 0 Get a fresh XP installation
|
||||
----------------------------------
|
||||
|
||||
0.1/ Using XPhome 32bit
|
||||
|
||||
|
||||
Step 1, VisualStudio 2008 express install
|
||||
-----------------------------------------
|
||||
|
||||
1.1/ Get the ISO CD from here ... http://www.microsoft.com/express/Downloads/#2008-All
|
||||
|
||||
1.2/ Run and install Visual C++ only, don't bother with the additional packages offered
|
||||
|
||||
This package will run 30 days before registration is needed
|
||||
|
||||
|
||||
Step 2, setup Mysql Server
|
||||
--------------------------
|
||||
|
||||
2.1/ Install MySQL server runtime ... http://downloads.mysql.com/archives/mysql-5.1/mysql-5.1.34-win32.msi
|
||||
|
||||
Choose Typical, choose configure, choose Standard Configuration, choose all defaults, supply admin username/password.
|
||||
|
||||
|
||||
Step 3, more installs
|
||||
----------------------
|
||||
|
||||
3.1/ install the following in sequence (accept all default options) there should be no errors !
|
||||
|
||||
Python 2.6.5 ... http://www.python.org/ftp/python/2.6.5/python-2.6.5.msi
|
||||
7zip 914 ... http://sourceforge.net/projects/sevenzip/files/7-Zip/9.14/7z914.exe/download
|
||||
|
||||
|
||||
Step 4, grab Mysql server Source
|
||||
--------------------------------
|
||||
|
||||
4.1/ Download ... http://downloads.mysql.com/archives/mysql-5.1/mysql-noinstall-5.1.34-win32.zip
|
||||
4.2/ Unpacking Desktop\mysqlsource (use 7zip)
|
||||
4.3/ Copy the following source directories to the MySql installation:
|
||||
|
||||
dos> xcopy Desktop\mysqlsource\mysql-5.1.34-win32\data\* "c:\Program Files\MySQL\MySQL Server 5.1\data" /I/E/F/H
|
||||
dos> xcopy Desktop\mysqlsource\mysql-5.1.34-win32\Embedded\* "c:\Program Files\MySQL\MySQL Server 5.1\Embedded" /I/E/F/H
|
||||
dos> xcopy Desktop\mysqlsource\mysql-5.1.34-win32\include\* "c:\Program Files\MySQL\MySQL Server 5.1\include" /I/E/F/H
|
||||
dos> xcopy Desktop\mysqlsource\mysql-5.1.34-win32\lib\* "c:\Program Files\MySQL\MySQL Server 5.1\lib" /I/E/F/H
|
||||
dos> xcopy Desktop\mysqlsource\mysql-5.1.34-win32\mysql-test\* "c:\Program Files\MySQL\MySQL Server 5.1\mysql-test" /I/E/F/H
|
||||
dos> xcopy Desktop\mysqlsource\mysql-5.1.34-win32\sql-bench\* "c:\Program Files\MySQL\MySQL Server 5.1\sql-bench" /I/E/F/H
|
||||
|
||||
4.4/ You can delete Destop\mysqlsource, is no longer needed.
|
||||
|
||||
|
||||
Step 5, grab Mysql-python source
|
||||
--------------------------------
|
||||
|
||||
5.1/ get download
|
||||
MySql for python ... http://sourceforge.net/projects/mysql-python/files/mysql-python/1.2.2/MySQL-python-1.2.2.tar.gz/download
|
||||
|
||||
5.2/ extract MySQL-python-1.2.2 directory to the Desktop using 7zip
|
||||
(note: use 7zip, open the gz, then open the tar, then extract the directory found inside there)
|
||||
|
||||
Desktop\MySQL-python-1.2.2 should now exist
|
||||
|
||||
|
||||
Step 6, get python build tools
|
||||
------------------------------
|
||||
|
||||
6.1/ get Easy Setup installer
|
||||
Easy setup installer ... http://peak.telecommunity.com/dist/ez_setup.py
|
||||
|
||||
6.2/ Check the DEFAULT VERSION specified in Easy Setup and get the corresponding setuptools (version c11 in this case)
|
||||
Setuptools version 11 ... http://pypi.python.org/packages/2.6/s/setuptools/setuptools-0.6c11-py2.6.egg
|
||||
|
||||
6.3/ Put both of these files into Desktop\MySQL-python-1.2.2, overwriting any existing files
|
||||
|
||||
|
||||
Step 7, install the build tool
|
||||
------------------------------
|
||||
|
||||
dos> cd Desktop\MySQL-python-1.2.2
|
||||
dos> c:\Python26\python.exe ez_setup.py setuptools-0.6c11-py2.6.egg
|
||||
|
||||
|
||||
Step 8, Tweak the configuration
|
||||
-------------------------------
|
||||
|
||||
dos> cd Desktop\MySQL-python-1.2.2
|
||||
|
||||
8.1/ dos> write site.cfg
|
||||
|
||||
Change registry_key = SOFTWARE\MySQL AB\MySQL Server 5.0
|
||||
to registry_key = SOFTWARE\MySQL AB\MySQL Server 5.1
|
||||
|
||||
8.2/ dos> write _mysql.c
|
||||
|
||||
Find the following lines
|
||||
|
||||
...
|
||||
#include <windows.h>
|
||||
#include <config-win.h>
|
||||
...
|
||||
|
||||
Insert an additional winsock2 line
|
||||
|
||||
...
|
||||
#include <winsock2.h>
|
||||
#include <windows.h>
|
||||
#include <config-win.h>
|
||||
...
|
||||
|
||||
|
||||
Step 9, build
|
||||
-------------
|
||||
|
||||
dos> cd Desktop\MySQL-python-1.2.2
|
||||
|
||||
9.1/ dos> c:\python26\python.exe setup.py build
|
||||
|
||||
* Note: You will probably get a bunch of warnings and maybe a manifest error, these are ok as long as there are no errors in compiling or linking.
|
||||
* Note: This will generate the "MySQL-python-1.2.2/build" folder
|
||||
|
||||
9.2/ dos> c:\python26\python.exe setup.py bdist_wininst
|
||||
|
||||
|
||||
Step 10, done
|
||||
-------------
|
||||
|
||||
10.1/ the \dist directory will contain MySQL-python-1.2.2.win32-py2.6.exe !!!!!
|
||||
10.2/ rename to MySQL-python-1.2.2.win32-py2.6-fpdb0.20.exe
|
125
packaging/windows/MySqlPython1.2.3WalkthroughPython26.txt
Normal file
125
packaging/windows/MySqlPython1.2.3WalkthroughPython26.txt
Normal file
|
@ -0,0 +1,125 @@
|
|||
Create MySqlPython version 1.2.3 windows installer for Python26
|
||||
|
||||
This walkthrough is derived from excellent installation instructions released under GNU Free Documentation License 1.2. The original work is here ... http://www.bcspcsonline.com/wiki/index.php?title=MySQL-5.1.34_Python-2.6_Module_Build_Instructions The Wiki author appears to be "Irondesk"
|
||||
|
||||
This version by Gimick on 29th June 2010
|
||||
Content is available under GNU Free Documentation License 1.2
|
||||
|
||||
Premamble
|
||||
---------
|
||||
|
||||
|
||||
The FPDB exe needs to build against the MySql-Python project. Unfortunately, for python 2.6 there is no official installer for windows, and none is ever likely to be provided.
|
||||
|
||||
Community builds are available, but to reduce third-party dependencies, we will build our own here.
|
||||
|
||||
Step 0 Get a fresh XP installation
|
||||
----------------------------------
|
||||
|
||||
0.1/ Using XPhome 32bit
|
||||
|
||||
|
||||
Step 1, VisualStudio 2008 express install
|
||||
-----------------------------------------
|
||||
|
||||
1.1/ Get the ISO CD from here ... http://www.microsoft.com/express/Downloads/#2008-All
|
||||
|
||||
1.2/ Run and install Visual C++ only, don't bother with the additional packages offered
|
||||
|
||||
This package will run 30 days before registration is needed
|
||||
|
||||
|
||||
Step 2, setup Mysql Server
|
||||
--------------------------
|
||||
|
||||
2.1/ Install MySQL server runtime ... http://downloads.mysql.com/archives/mysql-5.1/mysql-5.1.34-win32.msi
|
||||
|
||||
Choose Typical, choose configure, choose Standard Configuration, choose all defaults, supply admin username/password.
|
||||
|
||||
|
||||
Step 3, more installs
|
||||
----------------------
|
||||
|
||||
3.1/ install the following in sequence (accept all default options) there should be no errors !
|
||||
|
||||
Python 2.6.5 ... http://www.python.org/ftp/python/2.6.5/python-2.6.5.msi
|
||||
7zip 914 ... http://sourceforge.net/projects/sevenzip/files/7-Zip/9.14/7z914.exe/download
|
||||
|
||||
|
||||
Step 4, grab Mysql server Source
|
||||
--------------------------------
|
||||
|
||||
4.1/ Download ... http://downloads.mysql.com/archives/mysql-5.1/mysql-noinstall-5.1.34-win32.zip
|
||||
4.2/ Unpacking Desktop\mysqlsource (use 7zip)
|
||||
4.3/ Copy the following source directories to the MySql installation:
|
||||
|
||||
dos> xcopy Desktop\mysqlsource\mysql-5.1.34-win32\data\* "c:\Program Files\MySQL\MySQL Server 5.1\data" /I/E/F/H
|
||||
dos> xcopy Desktop\mysqlsource\mysql-5.1.34-win32\Embedded\* "c:\Program Files\MySQL\MySQL Server 5.1\Embedded" /I/E/F/H
|
||||
dos> xcopy Desktop\mysqlsource\mysql-5.1.34-win32\include\* "c:\Program Files\MySQL\MySQL Server 5.1\include" /I/E/F/H
|
||||
dos> xcopy Desktop\mysqlsource\mysql-5.1.34-win32\lib\* "c:\Program Files\MySQL\MySQL Server 5.1\lib" /I/E/F/H
|
||||
dos> xcopy Desktop\mysqlsource\mysql-5.1.34-win32\mysql-test\* "c:\Program Files\MySQL\MySQL Server 5.1\mysql-test" /I/E/F/H
|
||||
dos> xcopy Desktop\mysqlsource\mysql-5.1.34-win32\sql-bench\* "c:\Program Files\MySQL\MySQL Server 5.1\sql-bench" /I/E/F/H
|
||||
|
||||
4.4/ You can delete Destop\mysqlsource, is no longer needed.
|
||||
|
||||
|
||||
Step 5, grab Mysql-python source
|
||||
--------------------------------
|
||||
|
||||
5.1/ get download
|
||||
MySql for python ... http://sourceforge.net/projects/mysql-python/files/mysql-python/1.2.2/MySQL-python-1.2.3.tar.gz/download
|
||||
|
||||
5.2/ extract MySQL-python-1.2.3 directory to the Desktop using 7zip
|
||||
(note: use 7zip, open the gz, then open the tar, then extract the directory found inside there)
|
||||
|
||||
Desktop\MySQL-python-1.2.3 should now exist
|
||||
|
||||
|
||||
Step 6, get python build tools
|
||||
------------------------------
|
||||
|
||||
6.1/ get Easy Setup installer
|
||||
Easy setup installer ... http://peak.telecommunity.com/dist/ez_setup.py
|
||||
|
||||
6.2/ Check the DEFAULT VERSION specified in Easy Setup and get the corresponding setuptools (version c11 in this case)
|
||||
Setuptools version 11 ... http://pypi.python.org/packages/2.6/s/setuptools/setuptools-0.6c11-py2.6.egg
|
||||
|
||||
6.3/ Put both of these files into Desktop\MySQL-python-1.2.3, overwriting any existing files
|
||||
|
||||
|
||||
Step 7, install the build tool
|
||||
------------------------------
|
||||
|
||||
dos> cd Desktop\MySQL-python-1.2.3
|
||||
dos> c:\Python26\python.exe ez_setup.py setuptools-0.6c11-py2.6.egg
|
||||
|
||||
|
||||
Step 8, Tweak the configuration
|
||||
-------------------------------
|
||||
|
||||
dos> cd Desktop\MySQL-python-1.2.3
|
||||
|
||||
8.1/ dos> write site.cfg
|
||||
|
||||
Change registry_key = SOFTWARE\MySQL AB\MySQL Server 5.0
|
||||
to registry_key = SOFTWARE\MySQL AB\MySQL Server 5.1
|
||||
|
||||
|
||||
Step 9, build
|
||||
-------------
|
||||
|
||||
dos> cd Desktop\MySQL-python-1.2.3
|
||||
|
||||
9.1/ dos> c:\python26\python.exe setup.py build
|
||||
|
||||
* Note: You will probably get a bunch of warnings and maybe a manifest error, these are ok as long as there are no errors in compiling or linking.
|
||||
* Note: This will generate the "MySQL-python-1.2.3/build" folder
|
||||
|
||||
9.2/ dos> c:\python26\python.exe setup.py bdist_wininst
|
||||
|
||||
|
||||
Step 10, done
|
||||
-------------
|
||||
|
||||
10.1/ the \dist directory will contain MySQL-python-1.2.3.win32-py2.6.exe !!!!!
|
||||
10.2/ rename to MySQL-python-1.2.3.win32-py2.6-fpdb0.20.exe
|
|
@ -1,3 +1,18 @@
|
|||
; Copyright 2008-2010 Michael
|
||||
; 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.
|
||||
|
||||
|
||||
;"%programfiles%\MySQL\MySQL Server 5.0\bin\mysqld" --remove
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
; Includes
|
||||
|
|
239
packaging/windows/py2exeWalkthroughPython26.txt
Normal file
239
packaging/windows/py2exeWalkthroughPython26.txt
Normal file
|
@ -0,0 +1,239 @@
|
|||
PY2EXE walkthrough for Python 2.6 & FPDB 0.20
|
||||
created on 22nd June 2010 by Gimick
|
||||
|
||||
This walkthrough is derived from comments in the py2exe script made by Ray and SqlCoder
|
||||
Additional information, formatting, updating to Python 2.6 and sequencing added by Gimick
|
||||
Content is available under the the GNU Affero General Public License version 3
|
||||
|
||||
|
||||
|
||||
Step 0 Get a fresh XP installation
|
||||
----------------------------------
|
||||
|
||||
0.1/ Using XPhome or Pro 32bit
|
||||
|
||||
0.2/ Ensure the CPU supports SSE2 instruction set or better.
|
||||
|
||||
|
||||
Step 1, dependency install
|
||||
--------------------------
|
||||
|
||||
1.1/ install the following in sequence (accept all default options) there should be no errors !
|
||||
|
||||
Python 2.6.5 ... http://www.python.org/ftp/python/2.6.5/python-2.6.5.msi
|
||||
pywin 214 ... http://sourceforge.net/projects/pywin32/files/pywin32/Build%20214/pywin32-214.win32-py2.6.exe/download
|
||||
matplotlib 0.99.3 ... http://sourceforge.net/projects/matplotlib/files/matplotlib/matplotlib-0.99.3/matplotlib-0.99.3.win32-py2.6.exe/download
|
||||
pygtk 2.16.0 ... http://ftp.gnome.org/pub/GNOME/binaries/win32/pygtk/2.16/pygtk-2.16.0.win32-py2.6.exe
|
||||
pycairo 1.8.6 ... http://ftp.gnome.org/pub/GNOME/binaries/win32/pycairo/1.8/pycairo-1.8.6.win32-py2.6.exe
|
||||
pyGobject 2.20.0 ... http://ftp.gnome.org/pub/GNOME/binaries/win32/pygobject/2.20/pygobject-2.20.0.win32-py2.6.exe
|
||||
py2exe 0.6.9 ... http://sourceforge.net/projects/py2exe/files/py2exe/0.6.9/py2exe-0.6.9.win32-py2.6.exe/download
|
||||
psycopg2 ... http://www.stickpeople.com/projects/python/win-psycopg/psycopg2-2.2.1.win32-py2.6-pg8.4.3-release.exe
|
||||
(Note: stickpeople is the offical repository, not a community build)
|
||||
|
||||
|
||||
1.2/ MySQL
|
||||
|
||||
MySQL-python-1.2.3.win32-py2.6-fpdb0.20.exe ... http://www.mediafire.com/file/iodnnnznmj1/MySQL-python-1.2.3.win32-py2.6-fpdb0.20.exe
|
||||
|
||||
This is an intaller built from source by gimick. There are no official mysql-python2.6 builds for windows.
|
||||
|
||||
Community builds are also available from some developers. see www.codegood.com for example.
|
||||
|
||||
|
||||
1.3/ pytz fixup to work in an executable package
|
||||
|
||||
pytz needs runtime access to timezone definition files. pytz is hard-coded to search in the directory from which the pytz .py modules are being run.
|
||||
In a py2exe package, this directory is actually a library.zip container file, so windows cannot find the timezone definitions, and will crash the app.
|
||||
|
||||
We need to make a one-line change to pytz to search in the current working directory (which is not a container), and not the application directory.
|
||||
The py2exe script copies the timezone datafiles into the package folder pyfpdb/zoneinfo.
|
||||
|
||||
Thanks to Jeff Peck <peck.jeff <at> gmail.com> on the py2exe mailing list for documenting this problem and solution.
|
||||
|
||||
1.3.1/ Navigate to C:\Python26\Lib\site-packages\pytz
|
||||
1.3.2/ Edit __init__.py
|
||||
1.3.3/ At line 55 replace the following line(s):
|
||||
|
||||
filename = os.path.join(os.path.dirname(__file__),
|
||||
'zoneinfo', *name_parts)
|
||||
|
||||
with this line:
|
||||
|
||||
filename = os.path.join(os.getcwd(), 'zoneinfo', *name_parts)
|
||||
|
||||
1.3.4/ Save and exit
|
||||
|
||||
|
||||
|
||||
Step 2 Setup GTK
|
||||
-----------------
|
||||
|
||||
There are quite a few GTK packages needed, and rather than install them individually, I used the official AllinOne from the GTK project.
|
||||
|
||||
2,1/ Create a new folder c:\GTK
|
||||
|
||||
2.2/ Extract the following zip file into c:\GTK
|
||||
|
||||
GTK+ all in one 2.20.0 ... http://ftp.gnome.org/pub/gnome/binaries/win32/gtk+/2.20/gtk+-bundle_2.20.0-20100406_win32.zip
|
||||
|
||||
2.3/ If everything has worked, you should have c:\GTK\bin \etc \lib \src and so on created.
|
||||
|
||||
|
||||
Step 3 Set GTK into the PATH variable
|
||||
-------------------------------------
|
||||
|
||||
The path for GTK isn't set by default, so need to let the o/s know where the GTK stuff is.
|
||||
|
||||
3.1/ Rightclick on mycomputer to show system properties
|
||||
3.2/ select advanced/environment Variables
|
||||
3.3/ in "system variables" NOT "user variables" do the following
|
||||
3.3.1/ create a new item as name: GTK_BASEPATH value: c:\GTK
|
||||
3.3.2/ edit the item "path", press home to get to the first character and insert the following text, (no quotes, including semicolon) %GTK_BASEPATH%\bin;
|
||||
|
||||
3.4/ to check, open command prompt and do:
|
||||
|
||||
dos>path ... system should respond with ... PATH=c:\GTK\bin;C:\WIN........
|
||||
|
||||
3.5/ Give it a spin to test (hopefully an application will start, if not, something has gone wrong)
|
||||
|
||||
dos> gtk-demo
|
||||
|
||||
|
||||
Step 4 Get the fpdb GIT tree
|
||||
----------------------------
|
||||
|
||||
4.1/ Best to take a copy to work with; following steps will assume that the fpdb folder is on the Desktop
|
||||
|
||||
|
||||
5.3/ Install correct Numpy for this build
|
||||
-----------------------------------------
|
||||
|
||||
Numpy needs special handling, as by default it will install an optimised version for the SSE level of your CPU (SSE3, SSE2 or noSSE). This means that the completed package will not run on an older CPU.
|
||||
|
||||
For this reason, do not just run the installer downloaded.
|
||||
|
||||
5.3.1/ download the package to the Desktop
|
||||
|
||||
numpy 1.4.1 ... http://sourceforge.net/projects/numpy/files/NumPy/1.4.1/numpy-1.4.1-win32-superpack-python2.6.exe/download
|
||||
|
||||
5.3.2/ remove any existing numpy installation
|
||||
|
||||
Go to the control panel and uninstall "Python2.6 numpy-1.4.1"
|
||||
|
||||
5.3.3/ If you are wanting to build a package which works on all CPU's, install noSSE as follows:
|
||||
|
||||
dos> cd Desktop
|
||||
dos> numpy-1.4.1-win32-superpack-python2.6.exe /arch nosse
|
||||
|
||||
5.3.4/ If you are wanting to build a package which works on SSE2 and better CPU's, install SSE2 as follows:
|
||||
|
||||
dos> cd Desktop
|
||||
dos> numpy-1.4.1-win32-superpack-python2.6.exe /arch sse2
|
||||
|
||||
5.3.4/ At the end of the installation, click on "show details" to confirm the installation.
|
||||
|
||||
For no SSE:
|
||||
|
||||
"Target CPU handles SSE2"
|
||||
"Target CPU handles SSE3"
|
||||
"nosse install (arch value: nosse)"
|
||||
"Install NO SSE"
|
||||
Extract: numpy-1.4.1-nosse.exe... 100%
|
||||
Execute: "C:\DOCUME~1\user\LOCALS~1\Temp\numpy-1.4.1-nosse.exe"
|
||||
Completed
|
||||
|
||||
For SSE2:
|
||||
|
||||
"Target CPU handles SSE2"
|
||||
"Target CPU handles SSE3"
|
||||
"sse2 install (arch value: sse2)"
|
||||
"Install SSE 2"
|
||||
Extract: numpy-1.4.1-sse2.exe... 100%
|
||||
Execute: "C:\DOCUME~1\user\LOCALS~1\Temp\numpy-1.4.1-sse2.exe"
|
||||
Completed
|
||||
|
||||
|
||||
Step 6 Run py2exe to generate fpdb.exe
|
||||
--------------------------------------
|
||||
|
||||
6.1/ Run the script to create the fpdb.exe bundle
|
||||
|
||||
dos> cd Desktop\fpdb\pyfpdb
|
||||
dos> c:\python26\python.exe py2exe_setup.py py2exe
|
||||
|
||||
wait a while, watch lots of copying and whatever.
|
||||
|
||||
6.2/ You should next get prompted for the GTK folder.
|
||||
c:\GTK
|
||||
|
||||
6.3/ If there are no errors reported, it has probably worked, we will test soon.
|
||||
|
||||
Build notes:
|
||||
|
||||
There is a warning about dll's not included "umath.pyd - c:\Python26\lib\site-packages\numpy\core\umath.pyd" - reason for this is not understood at present. (Umath is apparently included in the built package).
|
||||
|
||||
|
||||
Step 7 not currently used
|
||||
-------------------------
|
||||
|
||||
Has been deleted
|
||||
|
||||
|
||||
Step 8 Drag out the completed bundle
|
||||
------------------------------------
|
||||
|
||||
py2exe creates a new folder for the created software bundle, drag this out to the desktop for ease of working.
|
||||
As far as I know you cannot rerun the build if the fpdb-yyyymmdd-exe exists in the tree, so dragging this out
|
||||
also allows the build to re-run at step 6.
|
||||
|
||||
8.1/ Drag Desktop\fpdb\pyfpdb\fpdb-yyyymmdd-exe to Desktop\
|
||||
|
||||
|
||||
Step 9 Initial run
|
||||
------------------
|
||||
|
||||
9.1/ Open the Desktop\fpdb-yyyymmdd-exe folder
|
||||
9.2/ In explorer...tools...folder options...View uncheck "Hide extensions for known file types"
|
||||
9.3/ Double click run_fpdb.bat
|
||||
9.4/ check the contents of pyfpdb\fpdb.exe.log, deal with any errors thrown
|
||||
|
||||
9.5/ hopefully, fpdb will run
|
||||
9.6/ Try out a few options, deal with any errors reported
|
||||
|
||||
Observe that the msvcp90.dll was provided by the python runtime package, so we don't have to install the separate package from Microsoft. End-users will, however need the dependency.
|
||||
|
||||
|
||||
Step 11 pruning
|
||||
---------------
|
||||
|
||||
11.1/ The generated folder is 100+MB and can be pruned by removing the following directories:
|
||||
|
||||
pyfpdb/lib/glib-2.0
|
||||
pyfpdb/lib/pkgconfig
|
||||
pyfpdb/share/aclocal
|
||||
pyfpdb/share/doc
|
||||
pyfpdb/share/glib-2.0
|
||||
pyfpdb/share/gtk-2.0
|
||||
pyfpdb/share/gtk-doc
|
||||
pyfpdb/share/locale
|
||||
pyfpdb/share/man
|
||||
|
||||
|
||||
Step 12 rename folder
|
||||
---------------------
|
||||
|
||||
Rename the folder to something meaningful to the community. If you have built for NoSSE, append anyCPU to the directory name.
|
||||
|
||||
|
||||
Step 13 Compress to executable archive
|
||||
--------------------------------------
|
||||
|
||||
13.1/ Download and install 7zip 914 ... http://sourceforge.net/projects/sevenzip/files/7-Zip/9.14/7z914.exe/download
|
||||
13.2/ Rightclick on fpdb executable folder, select 7zip Add to archive... select SFX archive option switch
|
||||
13.3/ Test the created exe file
|
||||
|
||||
Step 14 If you need to build again for a different SSE level
|
||||
------------------------------------------------------------
|
||||
|
||||
Go back to step 5 and run again.
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# Copyright 2008, Carl Gherardi
|
||||
# Copyright 2008-2010, 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
|
||||
|
@ -178,7 +178,7 @@ class Absolute(HandHistoryConverter):
|
|||
# TODO: (1-on-1) does have that info in the game type line
|
||||
if self.HORSEHand:
|
||||
hand.maxseats = 8
|
||||
hand.starttime = datetime.datetime.strptime(m.group('DATETIME'), "%Y-%m-%d %H:%M:%S")
|
||||
hand.startTime = datetime.datetime.strptime(m.group('DATETIME'), "%Y-%m-%d %H:%M:%S")
|
||||
return
|
||||
|
||||
def readPlayerStacks(self, hand):
|
||||
|
|
|
@ -1,4 +1,20 @@
|
|||
#!/usr/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
#Copyright 2009-2010 Grigorij Indigirkin
|
||||
#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.
|
||||
|
||||
from decimal import Decimal
|
||||
|
||||
from sqlalchemy import types
|
||||
|
|
|
@ -1,4 +1,20 @@
|
|||
#!/usr/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
#Copyright 2009-2010 Grigorij Indigirkin
|
||||
#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.
|
||||
|
||||
"""@package AlchemyMappings
|
||||
This package contains all classes to be mapped and mappers themselves
|
||||
"""
|
||||
|
@ -34,8 +50,8 @@ class Gametype(MappedBase):
|
|||
@staticmethod
|
||||
def get_or_create(session, siteId, gametype):
|
||||
map = zip(
|
||||
['type', 'base', 'category', 'limitType', 'smallBlind', 'bigBlind', 'smallBet', 'bigBet'],
|
||||
['type', 'base', 'category', 'limitType', 'sb', 'bb', 'dummy', 'dummy', ])
|
||||
['type', 'base', 'category', 'limitType', 'smallBlind', 'bigBlind', 'smallBet', 'bigBet', 'currency'],
|
||||
['type', 'base', 'category', 'limitType', 'sb', 'bb', 'dummy', 'dummy', 'currency'])
|
||||
gametype = dict([(new, gametype.get(old)) for new, old in map ])
|
||||
|
||||
hilo = "h"
|
||||
|
@ -152,8 +168,8 @@ class HandInternal(DerivedStats):
|
|||
'speed': 'speed',
|
||||
'maxSeats': 'maxseats',
|
||||
'knockout': 'isKO',
|
||||
'rebuyOrAddon': 'isRebuy',
|
||||
'headsUp': 'isHU',
|
||||
'rebuy': 'isRebuy',
|
||||
'addOn': 'isAddOn',
|
||||
'shootout': 'isShootout',
|
||||
'matrix': 'isMatrix',
|
||||
'sng': 'isSNG',
|
||||
|
@ -177,15 +193,15 @@ class HandInternal(DerivedStats):
|
|||
setattr(tour, col, hand_val)
|
||||
elif col == 'koBounty':
|
||||
setattr(tour, col, max(db_val, hand_val))
|
||||
elif col == 'tourStartTime' and hand.handStart:
|
||||
setattr(tour, col, min(db_val, hand.handStart))
|
||||
elif col == 'tourStartTime' and hand.startTime:
|
||||
setattr(tour, col, min(db_val, hand.startTime))
|
||||
|
||||
if tour.entries is None and tour_type.sng:
|
||||
tour.entries = tour_type.maxSeats
|
||||
|
||||
# fetch and update tourney players
|
||||
for hp in self.handPlayers:
|
||||
tp = TourneyPlayer.get_or_create(session, tour.id, hp.playerId)
|
||||
tp = TourneysPlayer.get_or_create(session, tour.id, hp.playerId)
|
||||
# FIXME: other TourneysPlayers should be added here
|
||||
|
||||
session.flush()
|
||||
|
@ -340,18 +356,20 @@ class HandPlayer(MappedBase):
|
|||
class Site(object):
|
||||
"""Class reflecting Players db table"""
|
||||
INITIAL_DATA = [
|
||||
(1 , 'Full Tilt Poker','USD'),
|
||||
(2 , 'PokerStars', 'USD'),
|
||||
(3 , 'Everleaf', 'USD'),
|
||||
(4 , 'Win2day', 'USD'),
|
||||
(5 , 'OnGame', 'USD'),
|
||||
(6 , 'UltimateBet', 'USD'),
|
||||
(7 , 'Betfair', 'USD'),
|
||||
(8 , 'Absolute', 'USD'),
|
||||
(9 , 'PartyPoker', 'USD'),
|
||||
(10, 'Partouche', 'EUR'),
|
||||
(1 , 'Full Tilt Poker','FT'),
|
||||
(2 , 'PokerStars', 'PS'),
|
||||
(3 , 'Everleaf', 'EV'),
|
||||
(4 , 'Win2day', 'W2'),
|
||||
(5 , 'OnGame', 'OG'),
|
||||
(6 , 'UltimateBet', 'UB'),
|
||||
(7 , 'Betfair', 'BF'),
|
||||
(8 , 'Absolute', 'AB'),
|
||||
(9 , 'PartyPoker', 'PP'),
|
||||
(10, 'Partouche', 'PA'),
|
||||
(11, 'Carbon', 'CA'),
|
||||
(12, 'PKR', 'PK'),
|
||||
]
|
||||
INITIAL_DATA_KEYS = ('id', 'name', 'currency')
|
||||
INITIAL_DATA_KEYS = ('id', 'name', 'code')
|
||||
|
||||
INITIAL_DATA_DICTS = [ dict(zip(INITIAL_DATA_KEYS, datum)) for datum in INITIAL_DATA ]
|
||||
|
||||
|
@ -372,7 +390,7 @@ class Tourney(MappedBase):
|
|||
|
||||
|
||||
class TourneyType(MappedBase):
|
||||
"""Class reflecting TourneysType db table"""
|
||||
"""Class reflecting TourneyType db table"""
|
||||
|
||||
@classmethod
|
||||
def get_or_create(cls, session, **kwargs):
|
||||
|
@ -380,12 +398,12 @@ class TourneyType(MappedBase):
|
|||
|
||||
Required kwargs:
|
||||
buyin fee speed maxSeats knockout
|
||||
rebuyOrAddon headsUp shootout matrix sng
|
||||
rebuy addOn shootout matrix sng currency
|
||||
"""
|
||||
return get_or_create(cls, session, **kwargs)[0]
|
||||
|
||||
|
||||
class TourneyPlayer(MappedBase):
|
||||
class TourneysPlayer(MappedBase):
|
||||
"""Class reflecting TourneysPlayers db table"""
|
||||
|
||||
@classmethod
|
||||
|
@ -437,7 +455,7 @@ mapper (Gametype, gametypes_table, properties={
|
|||
})
|
||||
mapper (Player, players_table, properties={
|
||||
'playerHands': relation(HandPlayer, backref='player'),
|
||||
'playerTourney': relation(TourneyPlayer, backref='player'),
|
||||
'playerTourney': relation(TourneysPlayer, backref='player'),
|
||||
})
|
||||
mapper (Site, sites_table, properties={
|
||||
'gametypes': relation(Gametype, backref = 'site'),
|
||||
|
@ -455,7 +473,7 @@ mapper (Tourney, tourneys_table)
|
|||
mapper (TourneyType, tourney_types_table, properties={
|
||||
'tourneys': relation(Tourney, backref='type'),
|
||||
})
|
||||
mapper (TourneyPlayer, tourneys_players_table)
|
||||
mapper (TourneysPlayer, tourneys_players_table)
|
||||
|
||||
class LambdaKeyDict(defaultdict):
|
||||
"""Operates like defaultdict but passes key argument to the factory function"""
|
||||
|
|
|
@ -1,4 +1,20 @@
|
|||
#!/usr/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
#Copyright 2009-2010 Grigorij Indigirkin
|
||||
#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.
|
||||
|
||||
"""@package AlchemyTables
|
||||
Contains all sqlalchemy tables
|
||||
"""
|
||||
|
@ -29,6 +45,7 @@ autorates_table = Table('Autorates', metadata,
|
|||
gametypes_table = Table('Gametypes', metadata,
|
||||
Column('id', SmallInteger, primary_key=True),
|
||||
Column('siteId', SmallInteger, ForeignKey("Sites.id"), nullable=False), # SMALLINT
|
||||
Column('currency', String(4), nullable=False), # varchar(4) NOT NULL
|
||||
Column('type', String(4), nullable=False), # char(4) NOT NULL
|
||||
Column('base', String(4), nullable=False), # char(4) NOT NULL
|
||||
Column('category', String(9), nullable=False), # varchar(9) NOT NULL
|
||||
|
@ -48,7 +65,7 @@ hands_table = Table('Hands', metadata,
|
|||
Column('tableName', String(30), nullable=False),
|
||||
Column('siteHandNo', BigIntColumn, nullable=False),
|
||||
Column('gametypeId', SmallInteger, ForeignKey('Gametypes.id'), nullable=False),
|
||||
Column('handStart', DateTime, nullable=False),
|
||||
Column('startTime', DateTime, nullable=False),
|
||||
Column('importTime', DateTime, nullable=False),
|
||||
Column('seats', SmallInteger, nullable=False),
|
||||
Column('maxSeats', SmallInteger, nullable=False),
|
||||
|
@ -338,7 +355,7 @@ settings_table = Table('Settings', metadata,
|
|||
sites_table = Table('Sites', metadata,
|
||||
Column('id', SmallInteger, primary_key=True),
|
||||
Column('name', String(32), nullable=False), # varchar(32) NOT NULL
|
||||
Column('currency', String(3), nullable=False), # char(3) NOT NULL
|
||||
Column('code', String(2), nullable=False), # char(2) NOT NULL
|
||||
mysql_charset='utf8',
|
||||
mysql_engine='InnoDB',
|
||||
)
|
||||
|
@ -352,17 +369,11 @@ tourneys_table = Table('Tourneys', metadata,
|
|||
Column('prizepool', Integer), # INT NOT NULL
|
||||
Column('tourStartTime', DateTime), # DATETIME NOT NULL
|
||||
Column('tourEndTime', DateTime), # DATETIME
|
||||
Column('buyinChips', Integer), # INT
|
||||
Column('tourneyName', String(40)), # varchar(40)
|
||||
# Mask use : 1=Positionnal Winnings|2=Match1|4=Match2|...|pow(2,n)=Matchn
|
||||
Column('matrixIdProcessed',SmallInteger, default=0), # TINYINT UNSIGNED DEFAULT 0
|
||||
Column('rebuyChips', Integer, default=0), # INT DEFAULT 0
|
||||
Column('addonChips', Integer, default=0), # INT DEFAULT 0
|
||||
Column('rebuyAmount', MoneyColumn, default=0), # INT DEFAULT 0
|
||||
Column('addonAmount', MoneyColumn, default=0), # INT DEFAULT 0
|
||||
Column('totalRebuys', Integer, default=0), # INT DEFAULT 0
|
||||
Column('totalAddons', Integer, default=0), # INT DEFAULT 0
|
||||
Column('koBounty', Integer, default=0), # INT DEFAULT 0
|
||||
Column('totalRebuyCount', Integer, default=0), # INT DEFAULT 0
|
||||
Column('totalAddOnCount', Integer, default=0), # INT DEFAULT 0
|
||||
Column('comment', Text), # TEXT
|
||||
Column('commentTs', DateTime), # DATETIME
|
||||
mysql_charset='utf8',
|
||||
|
@ -374,36 +385,46 @@ Index('siteTourneyNo', tourneys_table.c.siteTourneyNo, tourneys_table.c.tourneyT
|
|||
tourney_types_table = Table('TourneyTypes', metadata,
|
||||
Column('id', Integer, primary_key=True),
|
||||
Column('siteId', SmallInteger, ForeignKey("Sites.id"), nullable=False),
|
||||
Column('currency', String(4), nullable=False), # varchar(4) NOT NULL
|
||||
Column('buyin', Integer, nullable=False), # INT NOT NULL
|
||||
Column('fee', Integer, nullable=False, default=0), # INT NOT NULL
|
||||
Column('fee', Integer, nullable=False), # INT NOT NULL
|
||||
Column('buyInChips', Integer, nullable=False), # INT NOT NULL
|
||||
Column('maxSeats', Boolean, nullable=False, default=-1), # INT NOT NULL DEFAULT -1
|
||||
Column('rebuy', Boolean, nullable=False, default=False), # BOOLEAN NOT NULL DEFAULT False
|
||||
Column('rebuyCost', Integer), # INT
|
||||
Column('rebuyChips', Integer), # INT
|
||||
Column('addOn', Boolean, nullable=False, default=False), # BOOLEAN NOT NULL DEFAULT False
|
||||
Column('addOnCost', Integer), # INT
|
||||
Column('addOnChips', Integer), # INT
|
||||
Column('knockout', Boolean, nullable=False, default=False), # BOOLEAN NOT NULL DEFAULT False
|
||||
Column('rebuyOrAddon', Boolean, nullable=False, default=False), # BOOLEAN NOT NULL DEFAULT False
|
||||
Column('koBounty', Integer), # INT
|
||||
Column('speed', String(10)), # varchar(10)
|
||||
Column('headsUp', Boolean, nullable=False, default=False), # BOOLEAN NOT NULL DEFAULT False
|
||||
Column('shootout', Boolean, nullable=False, default=False), # BOOLEAN NOT NULL DEFAULT False
|
||||
Column('matrix', Boolean, nullable=False, default=False), # BOOLEAN NOT NULL DEFAULT False
|
||||
Column('sng', Boolean, nullable=False, default=False), # BOOLEAN NOT NULL DEFAULT False
|
||||
Column('satellite', Boolean, nullable=False, default=False), # BOOLEAN NOT NULL DEFAULT False
|
||||
Column('doubleOrNothing', Boolean, nullable=False, default=False), # BOOLEAN NOT NULL DEFAULT False
|
||||
Column('guarantee', Integer, nullable=False, default=0), # INT NOT NULL DEFAULT 0
|
||||
mysql_charset='utf8',
|
||||
mysql_engine='InnoDB',
|
||||
)
|
||||
Index('tourneyTypes_all',
|
||||
tourney_types_table.c.siteId, tourney_types_table.c.buyin, tourney_types_table.c.fee,
|
||||
tourney_types_table.c.maxSeats, tourney_types_table.c.knockout, tourney_types_table.c.rebuyOrAddon,
|
||||
tourney_types_table.c.speed, tourney_types_table.c.headsUp, tourney_types_table.c.shootout,
|
||||
tourney_types_table.c.matrix, tourney_types_table.c.sng)
|
||||
tourney_types_table.c.maxSeats, tourney_types_table.c.knockout, tourney_types_table.c.rebuy,
|
||||
tourney_types_table.c.addOn, tourney_types_table.c.speed,
|
||||
tourney_types_table.c.shootout, tourney_types_table.c.matrix, tourney_types_table.c.sng)
|
||||
|
||||
|
||||
tourneys_players_table = Table('TourneysPlayers', metadata,
|
||||
Column('id', BigIntColumn, primary_key=True),
|
||||
Column('tourneyId', Integer, ForeignKey("Tourneys.id"), nullable=False),
|
||||
Column('playerId', Integer, ForeignKey("Players.id"), nullable=False),
|
||||
Column('payinAmount', Integer), # INT NOT NULL
|
||||
Column('rank', Integer), # INT NOT NULL
|
||||
Column('winnings', Integer), # INT NOT NULL
|
||||
Column('nbRebuys', Integer, default=0), # INT DEFAULT 0
|
||||
Column('nbAddons', Integer, default=0), # INT DEFAULT 0
|
||||
Column('nbKO', Integer, default=0), # INT DEFAULT 0
|
||||
Column('winningsCurrency', Text), # TEXT
|
||||
Column('rebuyCount', Integer, default=0), # INT DEFAULT 0
|
||||
Column('addOnCount', Integer, default=0), # INT DEFAULT 0
|
||||
Column('koCount', Integer, default=0), # INT DEFAULT 0
|
||||
Column('comment', Text), # TEXT
|
||||
Column('commentTs', DateTime), # DATETIME
|
||||
mysql_charset='utf8',
|
||||
|
|
35
pyfpdb/Anonymise.py
Normal file → Executable file
35
pyfpdb/Anonymise.py
Normal file → Executable file
|
@ -1,10 +1,30 @@
|
|||
#!/usr/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
#Copyright 2009-2010 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.
|
||||
|
||||
import os
|
||||
import re
|
||||
import codecs
|
||||
import Options
|
||||
import HandHistoryConverter
|
||||
import Configuration
|
||||
import sys
|
||||
|
||||
(options, argv) = Options.fpdb_options()
|
||||
config = Configuration.Config()
|
||||
|
||||
filter = options.hhc
|
||||
|
||||
|
@ -13,7 +33,7 @@ filter_name = filter.replace("ToFpdb", "")
|
|||
mod = __import__(filter)
|
||||
obj = getattr(mod, filter_name, None)
|
||||
|
||||
hhc = obj(autostart=False)
|
||||
hhc = obj(config, autostart=False)
|
||||
|
||||
if os.path.exists(options.infile):
|
||||
in_fh = codecs.open(options.infile, 'r', "utf8")
|
||||
|
@ -25,13 +45,24 @@ else:
|
|||
|
||||
m = hhc.re_PlayerInfo.finditer(filecontents)
|
||||
|
||||
outfile = options.infile+".anon"
|
||||
print "Output being written to", outfile
|
||||
|
||||
savestdout = sys.stdout
|
||||
fsock = open(outfile,"w")
|
||||
sys.stdout = fsock
|
||||
|
||||
players = []
|
||||
for a in m:
|
||||
players = players + [a.group('PNAME')]
|
||||
|
||||
uniq = set(players)
|
||||
|
||||
for i, name in enumerate(uniq, 1):
|
||||
for i, name in enumerate(uniq):
|
||||
filecontents = filecontents.replace(name, 'Player%d' %i)
|
||||
|
||||
print filecontents
|
||||
|
||||
sys.stdout = savestdout
|
||||
fsock.close()
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# Copyright 2008, Carl Gherardi
|
||||
# Copyright 2008-2010, 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
|
||||
|
@ -105,7 +105,7 @@ class Betfair(HandHistoryConverter):
|
|||
logging.debug("HID %s, Table %s" % (m.group('HID'), m.group('TABLE')))
|
||||
hand.handid = m.group('HID')
|
||||
hand.tablename = m.group('TABLE')
|
||||
hand.starttime = datetime.datetime.strptime(m.group('DATETIME'), "%A, %B %d, %H:%M:%S GMT %Y")
|
||||
hand.startTime = datetime.datetime.strptime(m.group('DATETIME'), "%A, %B %d, %H:%M:%S GMT %Y")
|
||||
#hand.buttonpos = int(m.group('BUTTON'))
|
||||
|
||||
def readPlayerStacks(self, hand):
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
|
||||
# This code is based heavily on EverleafToFpdb.py, by Carl Gherardi
|
||||
#
|
||||
# OUTSTANDING MATTERS
|
||||
# TODO:
|
||||
#
|
||||
# -- No siteID assigned
|
||||
# -- No support for games other than NL hold 'em cash. Hand histories for other
|
||||
|
@ -79,7 +79,7 @@ class Carbon(HandHistoryConverter):
|
|||
#re_Antes = ???
|
||||
#re_BringIn = ???
|
||||
re_HeroCards = re.compile(r'<cards type="HOLE" cards="(?P<CARDS>.+)" player="(?P<PSEAT>[0-9])"', re.MULTILINE)
|
||||
re_Action = re.compile(r'<event sequence="[0-9]+" type="(?P<ATYPE>FOLD|CHECK|CALL|BET|RAISE|ALL_IN|SIT_OUT)" player="(?P<PSEAT>[0-9])"( amount="(?P<BET>[.0-9]+)")?/>', re.MULTILINE)
|
||||
re_Action = re.compile(r'<event sequence="[0-9]+" type="(?P<ATYPE>FOLD|CHECK|CALL|BET|RAISE|ALL_IN|SIT_OUT)" (?P<TIMESTAMP>timestamp="[0-9]+" )?player="(?P<PSEAT>[0-9])"( amount="(?P<BET>[.0-9]+)")?/>', re.MULTILINE)
|
||||
re_ShowdownAction = re.compile(r'<cards type="SHOWN" cards="(?P<CARDS>..,..)" player="(?P<PSEAT>[0-9])"/>', re.MULTILINE)
|
||||
re_CollectPot = re.compile(r'<winner amount="(?P<POT>[.0-9]+)" uncalled="(true|false)" potnumber="[0-9]+" player="(?P<PSEAT>[0-9])"', re.MULTILINE)
|
||||
re_SitsOut = re.compile(r'<event sequence="[0-9]+" type="SIT_OUT" player="(?P<PSEAT>[0-9])"/>', re.MULTILINE)
|
||||
|
@ -156,7 +156,7 @@ or None if we fail to get the info """
|
|||
hand.handid = m.group('HID1') + m.group('HID2')
|
||||
hand.tablename = m.group('TABLE')[:-1]
|
||||
hand.maxseats = 2 # This value may be increased as necessary
|
||||
hand.starttime = datetime.datetime.strptime(m.group('DATETIME')[:12],
|
||||
hand.startTime = datetime.datetime.strptime(m.group('DATETIME')[:12],
|
||||
'%Y%m%d%H%M')
|
||||
# Check that the hand is complete up to the awarding of the pot; if
|
||||
# not, the hand is unparseable
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#!/usr/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
#Copyright 2008 Carl Gherardi
|
||||
#Copyright 2008-2010 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.
|
||||
|
@ -12,8 +13,7 @@
|
|||
#
|
||||
#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.
|
||||
#In the "official" distribution you can find the license in agpl-3.0.txt.
|
||||
|
||||
|
||||
# From fpdb_simple
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
#!/usr/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
#Copyright 2010 Mika Bostrom
|
||||
#This program is free software: you can redistribute it and/or modify
|
||||
|
@ -12,8 +13,7 @@
|
|||
#
|
||||
#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.
|
||||
#In the "official" distribution you can find the license in agpl-3.0.txt.
|
||||
|
||||
# Error logging
|
||||
import sys
|
||||
|
@ -26,7 +26,9 @@ import Configuration
|
|||
|
||||
encoder_to_utf = codecs.lookup('utf-8')
|
||||
encoder_to_sys = codecs.lookup(Configuration.LOCALE_ENCODING)
|
||||
coder_hex = codecs.lookup('hex_codec')
|
||||
|
||||
hex_coding = False #FIXME: Should only be on if db is not UTF8 - test in Database.py?
|
||||
# I'm saving a few cycles with this one
|
||||
not_needed1, not_needed2, not_needed3 = False, False, False
|
||||
if Configuration.LOCALE_ENCODING == 'UTF8':
|
||||
|
@ -75,3 +77,19 @@ def to_gui(s):
|
|||
except UnicodeEncodeError:
|
||||
sys.stderr.write('Could not encode: "%s"\n' % s)
|
||||
raise
|
||||
|
||||
def to_hex(s):
|
||||
try:
|
||||
out = coder_hex.encode(s)[0]
|
||||
return out
|
||||
except UnicodeDecodeError:
|
||||
sys.stderr.write('Could not convert: "%s"\n' % s)
|
||||
return s
|
||||
|
||||
def from_hex(s):
|
||||
try:
|
||||
out = coder_hex.decode(s)[0]
|
||||
return out
|
||||
except UnicodeDecodeError:
|
||||
sys.stderr.write('Could not convert: "%s"\n' % s)
|
||||
return s
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
Handles HUD configuration files.
|
||||
"""
|
||||
# Copyright 2008, 2009, Ray E. Barker
|
||||
# Copyright 2008-2010, Ray E. Barker
|
||||
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
|
@ -32,6 +32,7 @@ import string
|
|||
import traceback
|
||||
import shutil
|
||||
import locale
|
||||
import re
|
||||
import xml.dom.minidom
|
||||
from xml.dom.minidom import Node
|
||||
|
||||
|
@ -51,8 +52,13 @@ def get_default_config_path():
|
|||
if os.name == 'posix':
|
||||
config_path = os.path.join(os.path.expanduser("~"), '.fpdb')
|
||||
elif os.name == 'nt':
|
||||
config_path = os.path.join(os.environ["APPDATA"], 'fpdb')
|
||||
config_path = os.path.join(unicode(os.environ[u"APPDATA"], "latin-1"), u"fpdb")
|
||||
#print u"path after joining in get_default_config_path:",config_path
|
||||
else: config_path = False
|
||||
|
||||
try: os.mkdir(config_path)
|
||||
except: pass
|
||||
|
||||
return config_path
|
||||
|
||||
def get_exec_path():
|
||||
|
@ -109,7 +115,7 @@ def get_logger(file_name, config = "config", fallback = False, log_dir=None, log
|
|||
(conf_file,copied) = get_config(file_name, fallback = fallback)
|
||||
|
||||
if log_dir is None:
|
||||
log_dir = os.path.join(get_exec_path(), 'log')
|
||||
log_dir = os.path.join(get_exec_path(), u'log')
|
||||
#print "\nget_logger: checking log_dir:", log_dir
|
||||
check_dir(log_dir)
|
||||
if log_file is None:
|
||||
|
@ -146,7 +152,7 @@ def check_dir(path, create = True):
|
|||
msg = "Creating directory: '%s'" % (path)
|
||||
print msg
|
||||
log.info(msg)
|
||||
os.mkdir(path)
|
||||
os.mkdir(path)#, "utf-8"))
|
||||
else:
|
||||
return False
|
||||
|
||||
|
@ -248,6 +254,8 @@ class Site:
|
|||
self.enabled = string_to_bool(node.getAttribute("enabled"), default=True)
|
||||
self.xpad = node.getAttribute("xpad")
|
||||
self.ypad = node.getAttribute("ypad")
|
||||
self.xshift = node.getAttribute("xshift")
|
||||
self.yshift = node.getAttribute("yshift")
|
||||
self.layout = {}
|
||||
|
||||
print "Loading site", self.site_name
|
||||
|
@ -259,6 +267,8 @@ class Site:
|
|||
# Site defaults
|
||||
self.xpad = 1 if self.xpad == "" else int(self.xpad)
|
||||
self.ypad = 0 if self.ypad == "" else int(self.ypad)
|
||||
self.xshift = 1 if self.xshift == "" else int(self.xshift)
|
||||
self.yshift = 0 if self.yshift == "" else int(self.yshift)
|
||||
self.font_size = 7 if self.font_size == "" else int(self.font_size)
|
||||
self.hudopacity = 1.0 if self.hudopacity == "" else float(self.hudopacity)
|
||||
|
||||
|
@ -296,12 +306,18 @@ class Game:
|
|||
self.cols = int( node.getAttribute("cols") )
|
||||
self.xpad = node.getAttribute("xpad")
|
||||
self.ypad = node.getAttribute("ypad")
|
||||
self.xshift = node.getAttribute("xshift")
|
||||
self.yshift = node.getAttribute("yshift")
|
||||
|
||||
# Defaults
|
||||
if self.xpad == "": self.xpad = 1
|
||||
else: self.xpad = int(self.xpad)
|
||||
if self.ypad == "": self.ypad = 0
|
||||
else: self.ypad = int(self.ypad)
|
||||
if self.xshift == "": self.xshift = 1
|
||||
else: self.xshift = int(self.xshift)
|
||||
if self.yshift == "": self.yshift = 0
|
||||
else: self.yshift = int(self.yshift)
|
||||
|
||||
aux_text = node.getAttribute("aux")
|
||||
aux_list = aux_text.split(',')
|
||||
|
@ -334,6 +350,8 @@ class Game:
|
|||
temp = temp + " cols = %d\n" % self.cols
|
||||
temp = temp + " xpad = %d\n" % self.xpad
|
||||
temp = temp + " ypad = %d\n" % self.ypad
|
||||
temp = temp + " xshift = %d\n" % self.xshift
|
||||
temp = temp + " yshift = %d\n" % self.yshift
|
||||
temp = temp + " aux = %s\n" % self.aux
|
||||
|
||||
for stat in self.stats.keys():
|
||||
|
@ -344,6 +362,7 @@ class Game:
|
|||
class Database:
|
||||
def __init__(self, node):
|
||||
self.db_name = node.getAttribute("db_name")
|
||||
self.db_desc = node.getAttribute("db_desc")
|
||||
self.db_server = node.getAttribute("db_server").lower()
|
||||
self.db_ip = node.getAttribute("db_ip")
|
||||
self.db_user = node.getAttribute("db_user")
|
||||
|
@ -412,6 +431,7 @@ class Import:
|
|||
self.interval = node.getAttribute("interval")
|
||||
self.callFpdbHud = node.getAttribute("callFpdbHud")
|
||||
self.hhArchiveBase = node.getAttribute("hhArchiveBase")
|
||||
self.hhBulkPath = node.getAttribute("hhBulkPath")
|
||||
self.saveActions = string_to_bool(node.getAttribute("saveActions"), default=True)
|
||||
self.fastStoreHudCache = string_to_bool(node.getAttribute("fastStoreHudCache"), default=False)
|
||||
self.saveStarsHH = string_to_bool(node.getAttribute("saveStarsHH"), default=False)
|
||||
|
@ -420,6 +440,21 @@ class Import:
|
|||
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 Email:
|
||||
def __init__(self, node):
|
||||
self.node = node
|
||||
self.host= node.getAttribute("host")
|
||||
self.username = node.getAttribute("username")
|
||||
self.password = node.getAttribute("password")
|
||||
self.useSsl = node.getAttribute("useSsl")
|
||||
self.folder = node.getAttribute("folder")
|
||||
self.siteName = node.getAttribute("siteName")
|
||||
self.fetchType = node.getAttribute("fetchType")
|
||||
|
||||
def __str__(self):
|
||||
return " host = %s\n username = %s\n password = %s\n useSsl = %s\n folder = %s\n" \
|
||||
% (self.host, self.username, self.password, self.useSsl, self.folder)
|
||||
|
||||
class HudUI:
|
||||
def __init__(self, node):
|
||||
self.node = node
|
||||
|
@ -452,6 +487,59 @@ class Tv:
|
|||
return (" combinedStealFold = %s\n combined2B3B = %s\n combinedPostflop = %s\n" %
|
||||
(self.combinedStealFold, self.combined2B3B, self.combinedPostflop) )
|
||||
|
||||
class General(dict):
|
||||
def __init__(self):
|
||||
super(General, self).__init__()
|
||||
|
||||
def add_elements(self, node):
|
||||
# day_start - number n where 0.0 <= n < 24.0 representing start of day for user
|
||||
# e.g. user could set to 4.0 for day to start at 4am local time
|
||||
# [ HH_bulk_path was here - now moved to import section ]
|
||||
for (name, value) in node.attributes.items():
|
||||
log.debug("config.general: adding %s = %s" % (name,value))
|
||||
self[name] = value
|
||||
|
||||
def __str__(self):
|
||||
s = ""
|
||||
for k in self:
|
||||
s = s + " %s = %s\n" % (k, self[k])
|
||||
return(s)
|
||||
|
||||
class GUICashStats(list):
|
||||
"""<gui_cash_stats>
|
||||
<col col_name="game" col_title="Game" disp_all="True" disp_posn="True" field_format="%s" field_type="str" xalignment="0.0" />
|
||||
...
|
||||
</gui_cash_stats>
|
||||
"""
|
||||
def __init__(self):
|
||||
super(GUICashStats, self).__init__()
|
||||
|
||||
def add_elements(self, node):
|
||||
# is this needed?
|
||||
for child in node.childNodes:
|
||||
if child.nodeType == child.ELEMENT_NODE:
|
||||
col_name, col_title, disp_all, disp_posn, field_format, field_type, xalignment=None, None, True, True, "%s", "str", 0.0
|
||||
|
||||
if child.hasAttribute('col_name'): col_name = child.getAttribute('col_name')
|
||||
if child.hasAttribute('col_title'): col_title = child.getAttribute('col_title')
|
||||
if child.hasAttribute('disp_all'): disp_all = string_to_bool(child.getAttribute('disp_all'))
|
||||
if child.hasAttribute('disp_posn'): disp_posn = string_to_bool(child.getAttribute('disp_posn'))
|
||||
if child.hasAttribute('field_format'): field_format = child.getAttribute('field_format')
|
||||
if child.hasAttribute('field_type'): field_type = child.getAttribute('field_type')
|
||||
try:
|
||||
if child.hasAttribute('xalignment'): xalignment = float(child.getAttribute('xalignment'))
|
||||
except ValueError:
|
||||
print "bad number in xalignment was ignored"
|
||||
log.info("bad number in xalignment was ignored")
|
||||
|
||||
self.append( [col_name, col_title, disp_all, disp_posn, field_format, field_type, xalignment] )
|
||||
|
||||
# def __str__(self):
|
||||
# s = ""
|
||||
# for l in self:
|
||||
# s = s + " %s = %s\n" % (k, self[k])
|
||||
# return(s)
|
||||
|
||||
class Config:
|
||||
def __init__(self, file = None, dbname = ''):
|
||||
# "file" is a path to an xml file with the fpdb/HUD configuration
|
||||
|
@ -472,9 +560,9 @@ class Config:
|
|||
self.dir_self = get_exec_path()
|
||||
# self.dir_config = os.path.dirname(self.file)
|
||||
self.dir_config = get_default_config_path()
|
||||
self.dir_log = os.path.join(self.dir_config, 'log')
|
||||
self.dir_database = os.path.join(self.dir_config, 'database')
|
||||
self.log_file = os.path.join(self.dir_log, 'fpdb-log.txt')
|
||||
self.dir_log = os.path.join(self.dir_config, u'log')
|
||||
self.dir_database = os.path.join(self.dir_config, u'database')
|
||||
self.log_file = os.path.join(self.dir_log, u'fpdb-log.txt')
|
||||
log = get_logger("logging.conf", "config", log_dir=self.dir_log)
|
||||
|
||||
# Parse even if there was no real config file found and we are using the example
|
||||
|
@ -506,7 +594,14 @@ class Config:
|
|||
self.popup_windows = {}
|
||||
self.db_selected = None # database the user would like to use
|
||||
self.tv = None
|
||||
self.general = General()
|
||||
self.gui_cash_stats = GUICashStats()
|
||||
|
||||
for gen_node in doc.getElementsByTagName("general"):
|
||||
self.general.add_elements(node=gen_node) # add/overwrite elements in self.general
|
||||
|
||||
for gcs_node in doc.getElementsByTagName("gui_cash_stats"):
|
||||
self.gui_cash_stats.add_elements(node=gcs_node) # add/overwrite elements in self.gui_cash_stats
|
||||
|
||||
# s_sites = doc.getElementsByTagName("supported_sites")
|
||||
for site_node in doc.getElementsByTagName("site"):
|
||||
|
@ -558,6 +653,10 @@ class Config:
|
|||
imp = Import(node = imp_node)
|
||||
self.imp = imp
|
||||
|
||||
for email_node in doc.getElementsByTagName("email"):
|
||||
email = Email(node = email_node)
|
||||
self.email = email
|
||||
|
||||
for hui_node in doc.getElementsByTagName('hud_ui'):
|
||||
hui = HudUI(node = hui_node)
|
||||
self.ui = hui
|
||||
|
@ -603,6 +702,14 @@ class Config:
|
|||
if site_node.getAttribute("site_name") == site:
|
||||
return site_node
|
||||
|
||||
def getGameNode(self,gameName):
|
||||
"""returns DOM game node for a given game"""
|
||||
for gameNode in self.doc.getElementsByTagName("game"):
|
||||
#print "getGameNode gameNode:",gameNode
|
||||
if gameNode.getAttribute("game_name") == gameName:
|
||||
return gameNode
|
||||
#end def getGameNode
|
||||
|
||||
def get_aux_node(self, aux):
|
||||
for aux_node in self.doc.getElementsByTagName("aw"):
|
||||
if aux_node.getAttribute("name") == aux:
|
||||
|
@ -640,7 +747,34 @@ class Config:
|
|||
pass
|
||||
|
||||
with open(file, 'w') as f:
|
||||
self.doc.writexml(f)
|
||||
#self.doc.writexml(f)
|
||||
f.write( self.wrap_long_lines( self.doc.toxml() ) )
|
||||
|
||||
def wrap_long_lines(self, s):
|
||||
lines = [ self.wrap_long_line(l) for l in s.splitlines() ]
|
||||
return('\n'.join(lines) + '\n')
|
||||
|
||||
def wrap_long_line(self, l):
|
||||
if 'config_wrap_len' in self.general:
|
||||
wrap_len = int(self.general['config_wrap_len'])
|
||||
else:
|
||||
wrap_len = -1 # < 0 means no wrap
|
||||
|
||||
if wrap_len >= 0 and len(l) > wrap_len:
|
||||
m = re.compile('\s+\S+\s+')
|
||||
mo = m.match(l)
|
||||
if mo:
|
||||
indent_len = mo.end()
|
||||
#print "indent = %s (%s)" % (indent_len, l[0:indent_len])
|
||||
indent = '\n' + ' ' * indent_len
|
||||
m = re.compile('(\S+="[^"]+"\s+)')
|
||||
parts = [x for x in m.split(l[indent_len:]) if x]
|
||||
if len(parts) > 1:
|
||||
#print "parts =", parts
|
||||
l = l[0:indent_len] + indent.join(parts)
|
||||
return(l)
|
||||
else:
|
||||
return(l)
|
||||
|
||||
def edit_layout(self, site_name, max, width = None, height = None,
|
||||
fav_seat = None, locations = None):
|
||||
|
@ -655,6 +789,49 @@ class Config:
|
|||
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] )
|
||||
|
||||
def editStats(self, gameName, statArray):
|
||||
"""replaces stat selection for the given gameName with the given statArray"""
|
||||
gameNode = self.getGameNode(gameName)
|
||||
statNodes = gameNode.getElementsByTagName("stat")
|
||||
|
||||
for node in statNodes:
|
||||
gameNode.removeChild(node)
|
||||
|
||||
gameNode.setAttribute("rows", str(len(statArray)))
|
||||
gameNode.setAttribute("cols", str(len(statArray[0])))
|
||||
|
||||
for rowNumber in range(len(statArray)):
|
||||
for columnNumber in range(len(statArray[rowNumber])):
|
||||
newStat=self.doc.createElement("stat")
|
||||
|
||||
newAttrStatName=self.doc.createAttribute("stat_name")
|
||||
newStat.setAttributeNode(newAttrStatName)
|
||||
newStat.setAttribute("stat_name", statArray[rowNumber][columnNumber])
|
||||
|
||||
newAttrStatName=self.doc.createAttribute("row")
|
||||
newStat.setAttributeNode(newAttrStatName)
|
||||
newStat.setAttribute("row", str(rowNumber))
|
||||
|
||||
newAttrStatName=self.doc.createAttribute("col")
|
||||
newStat.setAttributeNode(newAttrStatName)
|
||||
newStat.setAttribute("col", str(columnNumber))
|
||||
|
||||
newAttrStatName=self.doc.createAttribute("click")
|
||||
newStat.setAttributeNode(newAttrStatName)
|
||||
newStat.setAttribute("click", "tog_decorate")
|
||||
|
||||
newAttrStatName=self.doc.createAttribute("popup")
|
||||
newStat.setAttributeNode(newAttrStatName)
|
||||
newStat.setAttribute("popup", "default")
|
||||
|
||||
newAttrStatName=self.doc.createAttribute("tip")
|
||||
newStat.setAttributeNode(newAttrStatName)
|
||||
newStat.setAttribute("tip", "tip1")
|
||||
|
||||
gameNode.appendChild(newStat)
|
||||
statNodes = gameNode.getElementsByTagName("stat")
|
||||
#end def editStats
|
||||
|
||||
def edit_aux_layout(self, aux_name, max, width = None, height = None, locations = None):
|
||||
aux_node = self.get_aux_node(aux_name)
|
||||
layout_node = self.get_layout_node(aux_node, max)
|
||||
|
@ -685,6 +862,9 @@ class Config:
|
|||
try: db['db-databaseName'] = name
|
||||
except: pass
|
||||
|
||||
try: db['db-desc'] = self.supported_databases[name].db_desc
|
||||
except: pass
|
||||
|
||||
try: db['db-host'] = self.supported_databases[name].db_ip
|
||||
except: pass
|
||||
|
||||
|
@ -702,20 +882,29 @@ class Config:
|
|||
return db
|
||||
|
||||
def set_db_parameters(self, db_name = 'fpdb', db_ip = None, db_user = None,
|
||||
db_pass = None, db_server = None):
|
||||
db_pass = None, db_desc = None, db_server = None,
|
||||
default = "False"):
|
||||
db_node = self.get_db_node(db_name)
|
||||
default = default.lower()
|
||||
defaultb = string_to_bool(default, False)
|
||||
if db_node != None:
|
||||
if db_desc is not None: db_node.setAttribute("db_desc", db_desc)
|
||||
if db_ip is not None: db_node.setAttribute("db_ip", db_ip)
|
||||
if db_user is not None: db_node.setAttribute("db_user", db_user)
|
||||
if db_pass is not None: db_node.setAttribute("db_pass", db_pass)
|
||||
if db_server is not None: db_node.setAttribute("db_server", db_server)
|
||||
if db_type is not None: db_node.setAttribute("db_type", db_type)
|
||||
if defaultb: db_node.setAttribute("default", default)
|
||||
elif db_node.hasAttribute("default"):
|
||||
db_node.removeAttribute("default")
|
||||
if self.supported_databases.has_key(db_name):
|
||||
if db_desc is not None: self.supported_databases[db_name].dp_desc = db_desc
|
||||
if db_ip is not None: self.supported_databases[db_name].dp_ip = db_ip
|
||||
if db_user is not None: self.supported_databases[db_name].dp_user = db_user
|
||||
if db_pass is not None: self.supported_databases[db_name].dp_pass = db_pass
|
||||
if db_server is not None: self.supported_databases[db_name].dp_server = db_server
|
||||
if db_type is not None: self.supported_databases[db_name].dp_type = db_type
|
||||
self.supported_databases[db_name].db_selected = defaultb
|
||||
if defaultb:
|
||||
self.db_selected = db_name
|
||||
return
|
||||
|
||||
def get_backend(self, name):
|
||||
|
@ -818,9 +1007,14 @@ class Config:
|
|||
try: imp['interval'] = self.imp.interval
|
||||
except: imp['interval'] = 10
|
||||
|
||||
# hhArchiveBase is the temp store for part-processed hand histories - should be redundant eventually
|
||||
try: imp['hhArchiveBase'] = self.imp.hhArchiveBase
|
||||
except: imp['hhArchiveBase'] = "~/.fpdb/HandHistories/"
|
||||
|
||||
# hhBulkPath is the default location for bulk imports (if set)
|
||||
try: imp['hhBulkPath'] = self.imp.hhBulkPath
|
||||
except: imp['hhBulkPath'] = ""
|
||||
|
||||
try: imp['saveActions'] = self.imp.saveActions
|
||||
except: imp['saveActions'] = True
|
||||
|
||||
|
@ -839,6 +1033,8 @@ class Config:
|
|||
path = os.path.expanduser(self.supported_sites[site].HH_path)
|
||||
assert(os.path.isdir(path) or os.path.isfile(path)) # maybe it should try another site?
|
||||
paths['hud-defaultPath'] = paths['bulkImport-defaultPath'] = path
|
||||
if self.imp.hhBulkPath:
|
||||
paths['bulkImport-defaultPath'] = self.imp.hhBulkPath
|
||||
except AssertionError:
|
||||
paths['hud-defaultPath'] = paths['bulkImport-defaultPath'] = "** ERROR DEFAULT PATH IN CONFIG DOES NOT EXIST **"
|
||||
return paths
|
||||
|
@ -922,6 +1118,8 @@ class Config:
|
|||
parms["enabled"] = self.supported_sites[site].enabled
|
||||
parms["xpad"] = self.supported_sites[site].xpad
|
||||
parms["ypad"] = self.supported_sites[site].ypad
|
||||
parms["xshift"] = self.supported_sites[site].xshift
|
||||
parms["yshift"] = self.supported_sites[site].yshift
|
||||
return parms
|
||||
|
||||
def set_site_parameters(self, site_name, converter = None, decoder = None,
|
||||
|
@ -973,20 +1171,28 @@ class Config:
|
|||
param['cols'] = self.supported_games[name].cols
|
||||
param['xpad'] = self.supported_games[name].xpad
|
||||
param['ypad'] = self.supported_games[name].ypad
|
||||
param['xshift'] = self.supported_games[name].xshift
|
||||
param['yshift'] = self.supported_games[name].yshift
|
||||
param['aux'] = self.supported_games[name].aux
|
||||
return param
|
||||
|
||||
def get_supported_games(self):
|
||||
"""Get the list of supported games."""
|
||||
sg = []
|
||||
for game in c.supported_games.keys():
|
||||
sg.append(c.supported_games[game].game_name)
|
||||
for game in self.supported_games.keys():
|
||||
sg.append(self.supported_games[game].game_name)
|
||||
return sg
|
||||
|
||||
def execution_path(self, filename):
|
||||
"""Join the fpdb path to filename."""
|
||||
return os.path.join(os.path.dirname(inspect.getfile(sys._getframe(0))), filename)
|
||||
|
||||
def get_general_params(self):
|
||||
return( self.general )
|
||||
|
||||
def get_gui_cash_stat_params(self):
|
||||
return( self.gui_cash_stats )
|
||||
|
||||
if __name__== "__main__":
|
||||
c = Config()
|
||||
|
||||
|
@ -1060,6 +1266,8 @@ if __name__== "__main__":
|
|||
|
||||
print "start up path = ", c.execution_path("")
|
||||
|
||||
print "gui_cash_stats =", c.gui_cash_stats
|
||||
|
||||
try:
|
||||
from xml.dom.ext import PrettyPrint
|
||||
for site_node in c.doc.getElementsByTagName("site"):
|
||||
|
|
|
@ -1,9 +1,10 @@
|
|||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
"""Database.py
|
||||
|
||||
Create and manage the database objects.
|
||||
"""
|
||||
# Copyright 2008, Ray E. Barker
|
||||
# Copyright 2008-2010, 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
|
||||
|
@ -21,7 +22,7 @@ Create and manage the database objects.
|
|||
|
||||
########################################################################
|
||||
|
||||
# ToDo: - rebuild indexes / vacuum option
|
||||
# TODO: - rebuild indexes / vacuum option
|
||||
# - check speed of get_stats_from_hand() - add log info
|
||||
# - check size of db, seems big? (mysql)
|
||||
# - investigate size of mysql db (200K for just 7K hands? 2GB for 140K hands?)
|
||||
|
@ -52,7 +53,6 @@ log = logging.getLogger("db")
|
|||
# FreePokerTools modules
|
||||
import SQL
|
||||
import Card
|
||||
import Tourney
|
||||
import Charset
|
||||
from Exceptions import *
|
||||
import Configuration
|
||||
|
@ -74,7 +74,7 @@ except ImportError:
|
|||
use_numpy = False
|
||||
|
||||
|
||||
DB_VERSION = 119
|
||||
DB_VERSION = 140
|
||||
|
||||
|
||||
# Variance created as sqlite has a bunch of undefined aggregate functions.
|
||||
|
@ -140,12 +140,13 @@ class Database:
|
|||
, {'tab':'TourneysPlayers', 'col':'playerId', 'drop':0}
|
||||
#, {'tab':'TourneysPlayers', 'col':'tourneyId', 'drop':0} unique indexes not dropped
|
||||
, {'tab':'TourneyTypes', 'col':'siteId', 'drop':0}
|
||||
, {'tab':'Backings', 'col':'tourneysPlayerId', 'drop':0}
|
||||
, {'tab':'Backings', 'col':'playerId', 'drop':0}
|
||||
]
|
||||
, [ # indexes for sqlite (list index 4)
|
||||
{'tab':'Hands', 'col':'gametypeId', 'drop':0}
|
||||
, {'tab':'HandsPlayers', 'col':'handId', 'drop':0}
|
||||
, {'tab':'HandsPlayers', 'col':'playerId', 'drop':0}
|
||||
, {'tab':'HandsPlayers', 'col':'tourneyTypeId', 'drop':0}
|
||||
, {'tab':'HandsPlayers', 'col':'tourneysPlayersId', 'drop':0}
|
||||
, {'tab':'HudCache', 'col':'gametypeId', 'drop':1}
|
||||
, {'tab':'HudCache', 'col':'playerId', 'drop':0}
|
||||
|
@ -154,6 +155,8 @@ class Database:
|
|||
, {'tab':'Tourneys', 'col':'tourneyTypeId', 'drop':1}
|
||||
, {'tab':'TourneysPlayers', 'col':'playerId', 'drop':0}
|
||||
, {'tab':'TourneyTypes', 'col':'siteId', 'drop':0}
|
||||
, {'tab':'Backings', 'col':'tourneysPlayerId', 'drop':0}
|
||||
, {'tab':'Backings', 'col':'playerId', 'drop':0}
|
||||
]
|
||||
]
|
||||
|
||||
|
@ -164,7 +167,6 @@ class Database:
|
|||
{'fktab':'Hands', 'fkcol':'gametypeId', 'rtab':'Gametypes', 'rcol':'id', 'drop':1}
|
||||
, {'fktab':'HandsPlayers', 'fkcol':'handId', 'rtab':'Hands', 'rcol':'id', 'drop':1}
|
||||
, {'fktab':'HandsPlayers', 'fkcol':'playerId', 'rtab':'Players', 'rcol':'id', 'drop':1}
|
||||
, {'fktab':'HandsPlayers', 'fkcol':'tourneyTypeId', 'rtab':'TourneyTypes', 'rcol':'id', 'drop':1}
|
||||
, {'fktab':'HandsPlayers', 'fkcol':'tourneysPlayersId','rtab':'TourneysPlayers','rcol':'id', 'drop':1}
|
||||
, {'fktab':'HandsActions', 'fkcol':'handsPlayerId', 'rtab':'HandsPlayers', 'rcol':'id', 'drop':1}
|
||||
, {'fktab':'HudCache', 'fkcol':'gametypeId', 'rtab':'Gametypes', 'rcol':'id', 'drop':1}
|
||||
|
@ -193,7 +195,7 @@ class Database:
|
|||
# alter table t add constraint c foreign key (fkcol) references tab(rcol)
|
||||
# (fkcol is used for foreigh key name)
|
||||
|
||||
# mysql to list indexes:
|
||||
# mysql to list indexes: (CG - "LIST INDEXES" should work too)
|
||||
# SELECT table_name, index_name, non_unique, column_name
|
||||
# FROM INFORMATION_SCHEMA.STATISTICS
|
||||
# WHERE table_name = 'tbl_name'
|
||||
|
@ -223,6 +225,7 @@ class Database:
|
|||
# Note: index names must be unique across a schema
|
||||
# CREATE INDEX idx ON tab(col)
|
||||
# DROP INDEX idx
|
||||
# SELECT * FROM PG_INDEXES
|
||||
|
||||
# SQLite notes:
|
||||
|
||||
|
@ -289,6 +292,30 @@ class Database:
|
|||
self.connection.rollback() # make sure any locks taken so far are released
|
||||
#end def __init__
|
||||
|
||||
def dumpDatabase(self):
|
||||
result="fpdb database dump\nDB version=" + str(DB_VERSION)+"\n\n"
|
||||
|
||||
tables=self.cursor.execute(self.sql.query['list_tables'])
|
||||
tables=self.cursor.fetchall()
|
||||
for table in tables:
|
||||
table=table[0]
|
||||
|
||||
print "table:", table
|
||||
result+="###################\nTable "+table+"\n###################\n"
|
||||
rows=self.cursor.execute(self.sql.query['get'+table])
|
||||
rows=self.cursor.fetchall()
|
||||
columnNames=self.cursor.description
|
||||
if not rows:
|
||||
result+="empty table\n"
|
||||
else:
|
||||
for row in rows:
|
||||
for columnNumber in range(len(columnNames)):
|
||||
result+=(" "+columnNames[columnNumber][0]+"="+str(row[columnNumber])+"\n")
|
||||
result+="\n"
|
||||
result+="\n"
|
||||
return result
|
||||
#end def dumpDatabase
|
||||
|
||||
# could be used by hud to change hud style
|
||||
def set_hud_style(self, style):
|
||||
self.hud_style = style
|
||||
|
@ -488,6 +515,7 @@ class Database:
|
|||
self.connection.commit()
|
||||
self.cursor.close()
|
||||
self.connection.close()
|
||||
self.__connected = False
|
||||
|
||||
def reconnect(self, due_to_error=False):
|
||||
"""Reconnects the DB"""
|
||||
|
@ -552,6 +580,24 @@ class Database:
|
|||
c.execute(self.sql.query['get_hand_info'], new_hand_id)
|
||||
return c.fetchall()
|
||||
|
||||
def getHandCount(self):
|
||||
c = self.connection.cursor()
|
||||
c.execute(self.sql.query['getHandCount'])
|
||||
return c.fetchone()[0]
|
||||
#end def getHandCount
|
||||
|
||||
def getTourneyCount(self):
|
||||
c = self.connection.cursor()
|
||||
c.execute(self.sql.query['getTourneyCount'])
|
||||
return c.fetchone()[0]
|
||||
#end def getTourneyCount
|
||||
|
||||
def getTourneyTypeCount(self):
|
||||
c = self.connection.cursor()
|
||||
c.execute(self.sql.query['getTourneyTypeCount'])
|
||||
return c.fetchone()[0]
|
||||
#end def getTourneyCount
|
||||
|
||||
def get_actual_seat(self, hand_id, name):
|
||||
c = self.connection.cursor()
|
||||
c.execute(self.sql.query['get_actual_seat'], (hand_id, name))
|
||||
|
@ -801,11 +847,12 @@ class Database:
|
|||
#print "session stat_dict =", stat_dict
|
||||
#return stat_dict
|
||||
|
||||
def get_player_id(self, config, site, player_name):
|
||||
def get_player_id(self, config, siteName, playerName):
|
||||
c = self.connection.cursor()
|
||||
#print "get_player_id: player_name =", player_name, type(player_name)
|
||||
p_name = Charset.to_utf8(player_name)
|
||||
c.execute(self.sql.query['get_player_id'], (p_name, site))
|
||||
siteNameUtf = Charset.to_utf8(siteName)
|
||||
playerNameUtf = unicode(playerName)
|
||||
#print "db.get_player_id siteName",siteName,"playerName",playerName
|
||||
c.execute(self.sql.query['get_player_id'], (playerNameUtf, siteNameUtf))
|
||||
row = c.fetchone()
|
||||
if row:
|
||||
return row[0]
|
||||
|
@ -904,6 +951,7 @@ class Database:
|
|||
# hmmm, tested by commenting out rollback in grapher. lock seems to work but
|
||||
# then drop still hangs :-( does work in some tests though??
|
||||
# will leave code here for now pending further tests/enhancement ...
|
||||
c.execute("BEGIN TRANSACTION")
|
||||
c.execute( "lock table %s in exclusive mode nowait" % (fk['fktab'],) )
|
||||
#print "after lock, status:", c.statusmessage
|
||||
#print "alter table %s drop constraint %s_%s_fkey" % (fk['fktab'], fk['fktab'], fk['fkcol'])
|
||||
|
@ -914,6 +962,7 @@ class Database:
|
|||
if "does not exist" not in str(sys.exc_value):
|
||||
print "warning: drop pg fk %s_%s_fkey failed: %s, continuing ..." \
|
||||
% (fk['fktab'], fk['fkcol'], str(sys.exc_value).rstrip('\n') )
|
||||
c.execute("END TRANSACTION")
|
||||
except:
|
||||
print "warning: constraint %s_%s_fkey not dropped: %s, continuing ..." \
|
||||
% (fk['fktab'],fk['fkcol'], str(sys.exc_value).rstrip('\n'))
|
||||
|
@ -937,6 +986,7 @@ class Database:
|
|||
print "dropping pg index ", idx['tab'], idx['col']
|
||||
try:
|
||||
# try to lock table to see if index drop will work:
|
||||
c.execute("BEGIN TRANSACTION")
|
||||
c.execute( "lock table %s in exclusive mode nowait" % (idx['tab'],) )
|
||||
#print "after lock, status:", c.statusmessage
|
||||
try:
|
||||
|
@ -948,6 +998,7 @@ class Database:
|
|||
if "does not exist" not in str(sys.exc_value):
|
||||
print "warning: drop index %s_%s_idx failed: %s, continuing ..." \
|
||||
% (idx['tab'],idx['col'], str(sys.exc_value).rstrip('\n'))
|
||||
c.execute("END TRANSACTION")
|
||||
except:
|
||||
print "warning: index %s_%s_idx not dropped %s, continuing ..." \
|
||||
% (idx['tab'],idx['col'], str(sys.exc_value).rstrip('\n'))
|
||||
|
@ -1061,6 +1112,7 @@ class Database:
|
|||
"""(Re-)creates the tables of the current DB"""
|
||||
|
||||
self.drop_tables()
|
||||
self.resetPlayerIDs()
|
||||
self.create_tables()
|
||||
self.createAllIndexes()
|
||||
self.commit()
|
||||
|
@ -1075,7 +1127,7 @@ class Database:
|
|||
c = self.get_cursor()
|
||||
c.execute(self.sql.query['createSettingsTable'])
|
||||
|
||||
log.debug(self.sql.query['createSitesTable'])
|
||||
log.debug("Creating tables")
|
||||
c.execute(self.sql.query['createSitesTable'])
|
||||
c.execute(self.sql.query['createGametypesTable'])
|
||||
c.execute(self.sql.query['createPlayersTable'])
|
||||
|
@ -1087,8 +1139,10 @@ class Database:
|
|||
c.execute(self.sql.query['createHandsPlayersTable'])
|
||||
c.execute(self.sql.query['createHandsActionsTable'])
|
||||
c.execute(self.sql.query['createHudCacheTable'])
|
||||
c.execute(self.sql.query['createBackingsTable'])
|
||||
|
||||
# create unique indexes:
|
||||
# Create unique indexes:
|
||||
log.debug("Creating unique indexes")
|
||||
c.execute(self.sql.query['addTourneyIndex'])
|
||||
c.execute(self.sql.query['addHandsIndex'])
|
||||
c.execute(self.sql.query['addPlayersIndex'])
|
||||
|
@ -1162,7 +1216,8 @@ class Database:
|
|||
self.connection.set_isolation_level(0) # allow table/index operations to work
|
||||
for idx in self.indexes[self.backend]:
|
||||
if self.backend == self.MYSQL_INNODB:
|
||||
print "creating mysql index ", idx['tab'], idx['col']
|
||||
print "Creating mysql index %s %s" %(idx['tab'], idx['col'])
|
||||
log.debug("Creating mysql index %s %s" %(idx['tab'], idx['col']))
|
||||
try:
|
||||
s = "create index %s on %s(%s)" % (idx['col'],idx['tab'],idx['col'])
|
||||
self.get_cursor().execute(s)
|
||||
|
@ -1170,13 +1225,15 @@ class Database:
|
|||
print " create idx failed: " + str(sys.exc_info())
|
||||
elif self.backend == self.PGSQL:
|
||||
# mod to use tab_col for index name?
|
||||
print "creating pg index ", idx['tab'], idx['col']
|
||||
print "Creating pgsql index %s %s" %(idx['tab'], idx['col'])
|
||||
log.debug("Creating pgsql index %s %s" %(idx['tab'], idx['col']))
|
||||
try:
|
||||
s = "create index %s_%s_idx on %s(%s)" % (idx['tab'], idx['col'], idx['tab'], idx['col'])
|
||||
self.get_cursor().execute(s)
|
||||
except:
|
||||
print " create idx failed: " + str(sys.exc_info())
|
||||
elif self.backend == self.SQLITE:
|
||||
print "Creating sqlite index %s %s" %(idx['tab'], idx['col'])
|
||||
log.debug("Creating sqlite index %s %s" %(idx['tab'], idx['col']))
|
||||
try:
|
||||
s = "create index %s_%s_idx on %s(%s)" % (idx['tab'], idx['col'], idx['tab'], idx['col'])
|
||||
|
@ -1184,7 +1241,7 @@ class Database:
|
|||
except:
|
||||
log.debug("Create idx failed: " + str(sys.exc_info()))
|
||||
else:
|
||||
print "Only MySQL, Postgres and SQLite supported so far"
|
||||
print "Unknown database: MySQL, Postgres and SQLite supported"
|
||||
return -1
|
||||
if self.backend == self.PGSQL:
|
||||
self.connection.set_isolation_level(1) # go back to normal isolation level
|
||||
|
@ -1215,8 +1272,15 @@ class Database:
|
|||
% (idx['tab'],idx['col']) )
|
||||
except:
|
||||
print " drop idx failed: " + str(sys.exc_info())
|
||||
elif self.backend == self.SQLITE:
|
||||
print "Dropping sqlite index ", idx['tab'], idx['col']
|
||||
try:
|
||||
self.get_cursor().execute( "drop index %s_%s_idx"
|
||||
% (idx['tab'],idx['col']) )
|
||||
except:
|
||||
print " drop idx failed: " + str(sys.exc_info())
|
||||
else:
|
||||
print "Only MySQL and Postgres supported so far"
|
||||
print "Only MySQL, Postgres and SQLITE supported, what are you trying to use?"
|
||||
return -1
|
||||
if self.backend == self.PGSQL:
|
||||
self.connection.set_isolation_level(1) # go back to normal isolation level
|
||||
|
@ -1307,6 +1371,7 @@ class Database:
|
|||
# hmmm, tested by commenting out rollback in grapher. lock seems to work but
|
||||
# then drop still hangs :-( does work in some tests though??
|
||||
# will leave code here for now pending further tests/enhancement ...
|
||||
c.execute("BEGIN TRANSACTION")
|
||||
c.execute( "lock table %s in exclusive mode nowait" % (fk['fktab'],) )
|
||||
#print "after lock, status:", c.statusmessage
|
||||
#print "alter table %s drop constraint %s_%s_fkey" % (fk['fktab'], fk['fktab'], fk['fkcol'])
|
||||
|
@ -1317,6 +1382,7 @@ class Database:
|
|||
if "does not exist" not in str(sys.exc_value):
|
||||
print "warning: drop pg fk %s_%s_fkey failed: %s, continuing ..." \
|
||||
% (fk['fktab'], fk['fkcol'], str(sys.exc_value).rstrip('\n') )
|
||||
c.execute("END TRANSACTION")
|
||||
except:
|
||||
print "warning: constraint %s_%s_fkey not dropped: %s, continuing ..." \
|
||||
% (fk['fktab'],fk['fkcol'], str(sys.exc_value).rstrip('\n'))
|
||||
|
@ -1331,29 +1397,18 @@ class Database:
|
|||
def fillDefaultData(self):
|
||||
c = self.get_cursor()
|
||||
c.execute("INSERT INTO Settings (version) VALUES (%s);" % (DB_VERSION))
|
||||
c.execute("INSERT INTO Sites (name,currency) VALUES ('Full Tilt Poker', 'USD')")
|
||||
c.execute("INSERT INTO Sites (name,currency) VALUES ('PokerStars', 'USD')")
|
||||
c.execute("INSERT INTO Sites (name,currency) VALUES ('Everleaf', 'USD')")
|
||||
c.execute("INSERT INTO Sites (name,currency) VALUES ('Win2day', 'USD')")
|
||||
c.execute("INSERT INTO Sites (name,currency) VALUES ('OnGame', 'USD')")
|
||||
c.execute("INSERT INTO Sites (name,currency) VALUES ('UltimateBet', 'USD')")
|
||||
c.execute("INSERT INTO Sites (name,currency) VALUES ('Betfair', 'USD')")
|
||||
c.execute("INSERT INTO Sites (name,currency) VALUES ('Absolute', 'USD')")
|
||||
c.execute("INSERT INTO Sites (name,currency) VALUES ('PartyPoker', 'USD')")
|
||||
c.execute("INSERT INTO Sites (name,currency) VALUES ('Partouche', 'EUR')")
|
||||
c.execute("INSERT INTO Sites (name,currency) VALUES ('Carbon', 'USD')")
|
||||
c.execute("INSERT INTO Sites (name,currency) VALUES ('PKR', 'USD')")
|
||||
if self.backend == self.SQLITE:
|
||||
c.execute("INSERT INTO TourneyTypes (id, siteId, buyin, fee) VALUES (NULL, 1, 0, 0);")
|
||||
elif self.backend == self.PGSQL:
|
||||
c.execute("""insert into TourneyTypes(siteId, buyin, fee, maxSeats, knockout
|
||||
,rebuyOrAddon, speed, headsUp, shootout, matrix)
|
||||
values (1, 0, 0, 0, False, False, null, False, False, False);""")
|
||||
elif self.backend == self.MYSQL_INNODB:
|
||||
c.execute("""insert into TourneyTypes(id, siteId, buyin, fee, maxSeats, knockout
|
||||
,rebuyOrAddon, speed, headsUp, shootout, matrix)
|
||||
values (DEFAULT, 1, 0, 0, 0, False, False, null, False, False, False);""")
|
||||
|
||||
c.execute("INSERT INTO Sites (name,code) VALUES ('Full Tilt Poker', 'FT')")
|
||||
c.execute("INSERT INTO Sites (name,code) VALUES ('PokerStars', 'PS')")
|
||||
c.execute("INSERT INTO Sites (name,code) VALUES ('Everleaf', 'EV')")
|
||||
c.execute("INSERT INTO Sites (name,code) VALUES ('Win2day', 'W2')")
|
||||
c.execute("INSERT INTO Sites (name,code) VALUES ('OnGame', 'OG')")
|
||||
c.execute("INSERT INTO Sites (name,code) VALUES ('UltimateBet', 'UB')")
|
||||
c.execute("INSERT INTO Sites (name,code) VALUES ('Betfair', 'BF')")
|
||||
c.execute("INSERT INTO Sites (name,code) VALUES ('Absolute', 'AB')")
|
||||
c.execute("INSERT INTO Sites (name,code) VALUES ('PartyPoker', 'PP')")
|
||||
c.execute("INSERT INTO Sites (name,code) VALUES ('Partouche', 'PA')")
|
||||
c.execute("INSERT INTO Sites (name,code) VALUES ('Carbon', 'CA')")
|
||||
c.execute("INSERT INTO Sites (name,code) VALUES ('PKR', 'PK')")
|
||||
#end def fillDefaultData
|
||||
|
||||
def rebuild_indexes(self, start=None):
|
||||
|
@ -1361,6 +1416,7 @@ class Database:
|
|||
self.createAllIndexes()
|
||||
self.dropAllForeignKeys()
|
||||
self.createAllForeignKeys()
|
||||
#end def rebuild_indexes
|
||||
|
||||
def rebuild_hudcache(self, h_start=None, v_start=None):
|
||||
"""clears hudcache and rebuilds from the individual handsplayers records"""
|
||||
|
@ -1390,9 +1446,9 @@ class Database:
|
|||
where = ""
|
||||
else:
|
||||
where = "where ( hp.playerId not in " + str(tuple(self.hero_ids.values())) \
|
||||
+ " and h.handStart > '" + v_start + "')" \
|
||||
+ " and h.startTime > '" + v_start + "')" \
|
||||
+ " or ( hp.playerId in " + str(tuple(self.hero_ids.values())) \
|
||||
+ " and h.handStart > '" + h_start + "')"
|
||||
+ " and h.startTime > '" + h_start + "')"
|
||||
rebuild_sql = self.sql.query['rebuildHudCache'].replace('<where_clause>', where)
|
||||
|
||||
self.get_cursor().execute(self.sql.query['clearHudCache'])
|
||||
|
@ -1507,9 +1563,9 @@ class Database:
|
|||
p['tableName'],
|
||||
p['gameTypeId'],
|
||||
p['siteHandNo'],
|
||||
0, # tourneyId: 0 means not a tourney hand
|
||||
p['handStart'],
|
||||
datetime.today(), #importtime
|
||||
p['tourneyId'],
|
||||
p['startTime'],
|
||||
datetime.utcnow(), #importtime
|
||||
p['seats'],
|
||||
p['maxSeats'],
|
||||
p['texture'],
|
||||
|
@ -1546,6 +1602,7 @@ class Database:
|
|||
pids[p],
|
||||
pdata[p]['startCash'],
|
||||
pdata[p]['seatNo'],
|
||||
pdata[p]['sitout'],
|
||||
pdata[p]['card1'],
|
||||
pdata[p]['card2'],
|
||||
pdata[p]['card3'],
|
||||
|
@ -1588,7 +1645,7 @@ class Database:
|
|||
pdata[p]['street3Bets'],
|
||||
pdata[p]['street4Bets'],
|
||||
pdata[p]['position'],
|
||||
pdata[p]['tourneyTypeId'],
|
||||
pdata[p]['tourneysPlayersIds'],
|
||||
pdata[p]['startCards'],
|
||||
pdata[p]['street0_3BChance'],
|
||||
pdata[p]['street0_3BDone'],
|
||||
|
@ -1600,8 +1657,8 @@ class Database:
|
|||
pdata[p]['foldToOtherRaisedStreet2'],
|
||||
pdata[p]['foldToOtherRaisedStreet3'],
|
||||
pdata[p]['foldToOtherRaisedStreet4'],
|
||||
pdata[p]['stealAttemptChance'],
|
||||
pdata[p]['stealAttempted'],
|
||||
pdata[p]['raiseFirstInChance'],
|
||||
pdata[p]['raisedFirstIn'],
|
||||
pdata[p]['foldBbToStealChance'],
|
||||
pdata[p]['foldedBbToSteal'],
|
||||
pdata[p]['foldSbToStealChance'],
|
||||
|
@ -1621,7 +1678,12 @@ class Database:
|
|||
pdata[p]['street3CheckCallRaiseChance'],
|
||||
pdata[p]['street3CheckCallRaiseDone'],
|
||||
pdata[p]['street4CheckCallRaiseChance'],
|
||||
pdata[p]['street4CheckCallRaiseDone']
|
||||
pdata[p]['street4CheckCallRaiseDone'],
|
||||
pdata[p]['street0Raises'],
|
||||
pdata[p]['street1Raises'],
|
||||
pdata[p]['street2Raises'],
|
||||
pdata[p]['street3Raises'],
|
||||
pdata[p]['street4Raises']
|
||||
) )
|
||||
|
||||
q = self.sql.query['store_hands_players']
|
||||
|
@ -1650,7 +1712,7 @@ class Database:
|
|||
#print "DEBUG: %s %s %s" %(hid, pids, pdata)
|
||||
inserts = []
|
||||
for p in pdata:
|
||||
line = [0]*61
|
||||
line = [0]*76
|
||||
|
||||
line[0] = 1 # HDs
|
||||
if pdata[p]['street0VPI']: line[1] = 1
|
||||
|
@ -1676,8 +1738,8 @@ class Database:
|
|||
if pdata[p]['foldToOtherRaisedStreet4']: line[21] = 1
|
||||
line[22] = pdata[p]['wonWhenSeenStreet1']
|
||||
line[23] = pdata[p]['wonAtSD']
|
||||
if pdata[p]['stealAttemptChance']: line[24] = 1
|
||||
if pdata[p]['stealAttempted']: line[25] = 1
|
||||
if pdata[p]['raiseFirstInChance']: line[24] = 1
|
||||
if pdata[p]['raisedFirstIn']: line[25] = 1
|
||||
if pdata[p]['foldBbToStealChance']: line[26] = 1
|
||||
if pdata[p]['foldedBbToSteal']: line[27] = 1
|
||||
if pdata[p]['foldSbToStealChance']: line[28] = 1
|
||||
|
@ -1707,13 +1769,29 @@ class Database:
|
|||
if pdata[p]['street3CheckCallRaiseDone']: line[52] = 1
|
||||
if pdata[p]['street4CheckCallRaiseChance']: line[53] = 1
|
||||
if pdata[p]['street4CheckCallRaiseDone']: line[54] = 1
|
||||
line[55] = gid # gametypeId
|
||||
line[56] = pids[p] # playerId
|
||||
line[57] = len(pids) # activeSeats
|
||||
if pdata[p]['street0Calls']: line[55] = 1
|
||||
if pdata[p]['street1Calls']: line[56] = 1
|
||||
if pdata[p]['street2Calls']: line[57] = 1
|
||||
if pdata[p]['street3Calls']: line[58] = 1
|
||||
if pdata[p]['street4Calls']: line[59] = 1
|
||||
if pdata[p]['street0Bets']: line[60] = 1
|
||||
if pdata[p]['street1Bets']: line[61] = 1
|
||||
if pdata[p]['street2Bets']: line[62] = 1
|
||||
if pdata[p]['street3Bets']: line[63] = 1
|
||||
if pdata[p]['street4Bets']: line[64] = 1
|
||||
if pdata[p]['street0Raises']: line[65] = 1
|
||||
if pdata[p]['street1Raises']: line[66] = 1
|
||||
if pdata[p]['street2Raises']: line[67] = 1
|
||||
if pdata[p]['street3Raises']: line[68] = 1
|
||||
if pdata[p]['street4Raises']: line[69] = 1
|
||||
|
||||
line[70] = gid # gametypeId
|
||||
line[71] = pids[p] # playerId
|
||||
line[72] = len(pids) # activeSeats
|
||||
pos = {'B':'B', 'S':'S', 0:'D', 1:'C', 2:'M', 3:'M', 4:'M', 5:'E', 6:'E', 7:'E', 8:'E', 9:'E' }
|
||||
line[58] = pos[pdata[p]['position']]
|
||||
line[59] = pdata[p]['tourneyTypeId']
|
||||
line[60] = styleKey # styleKey
|
||||
line[73] = pos[pdata[p]['position']]
|
||||
line[74] = pdata[p]['tourneyTypeId']
|
||||
line[75] = styleKey # styleKey
|
||||
inserts.append(line)
|
||||
|
||||
|
||||
|
@ -1750,7 +1828,7 @@ class Database:
|
|||
def getGameTypeId(self, siteid, game):
|
||||
c = self.get_cursor()
|
||||
#FIXME: Fixed for NL at the moment
|
||||
c.execute(self.sql.query['getGametypeNL'], (siteid, game['type'], game['category'], game['limitType'],
|
||||
c.execute(self.sql.query['getGametypeNL'], (siteid, game['type'], game['category'], game['limitType'], game['currency'],
|
||||
int(Decimal(game['sb'])*100), int(Decimal(game['bb'])*100)))
|
||||
tmp = c.fetchone()
|
||||
if (tmp == None):
|
||||
|
@ -1759,10 +1837,14 @@ class Database:
|
|||
hilo = "s"
|
||||
elif game['category'] in ['razz','27_3draw','badugi']:
|
||||
hilo = "l"
|
||||
tmp = self.insertGameTypes( (siteid, game['type'], game['base'], game['category'], game['limitType'], hilo,
|
||||
tmp = self.insertGameTypes( (siteid, game['currency'], game['type'], game['base'], game['category'], game['limitType'], hilo,
|
||||
int(Decimal(game['sb'])*100), int(Decimal(game['bb'])*100), 0, 0) )
|
||||
#FIXME: recognise currency
|
||||
return tmp[0]
|
||||
|
||||
def resetPlayerIDs(self):
|
||||
self.pcache = None
|
||||
|
||||
def getSqlPlayerIDs(self, pnames, siteid):
|
||||
result = {}
|
||||
if(self.pcache == None):
|
||||
|
@ -1820,48 +1902,6 @@ class Database:
|
|||
# Finish of NEWIMPORT CODE
|
||||
#################################
|
||||
|
||||
|
||||
|
||||
def store_tourneys_players(self, tourney_id, player_ids, payin_amounts, ranks, winnings):
|
||||
try:
|
||||
result=[]
|
||||
cursor = self.get_cursor()
|
||||
#print "in store_tourneys_players. tourney_id:",tourney_id
|
||||
#print "player_ids:",player_ids
|
||||
#print "payin_amounts:",payin_amounts
|
||||
#print "ranks:",ranks
|
||||
#print "winnings:",winnings
|
||||
for i in xrange(len(player_ids)):
|
||||
try:
|
||||
cursor.execute("savepoint ins_tplayer")
|
||||
cursor.execute("""INSERT INTO TourneysPlayers
|
||||
(tourneyId, playerId, payinAmount, rank, winnings) VALUES (%s, %s, %s, %s, %s)""".replace('%s', self.sql.query['placeholder']),
|
||||
(tourney_id, player_ids[i], payin_amounts[i], ranks[i], winnings[i]))
|
||||
|
||||
tmp = self.get_last_insert_id(cursor)
|
||||
result.append(tmp)
|
||||
#print "created new tourneys_players.id:", tmp
|
||||
except:
|
||||
cursor.execute("rollback to savepoint ins_tplayer")
|
||||
cursor.execute("SELECT id FROM TourneysPlayers WHERE tourneyId=%s AND playerId+0=%s".replace('%s', self.sql.query['placeholder'])
|
||||
,(tourney_id, player_ids[i]))
|
||||
tmp = cursor.fetchone()
|
||||
#print "tried SELECTing tourneys_players.id:", tmp
|
||||
try:
|
||||
len(tmp)
|
||||
result.append(tmp[0])
|
||||
except:
|
||||
print "tplayer id not found for tourney,player %s,%s" % (tourney_id, player_ids[i])
|
||||
pass
|
||||
except:
|
||||
raise FpdbError( "store_tourneys_players error: " + str(sys.exc_value) )
|
||||
|
||||
cursor.execute("release savepoint ins_tplayer")
|
||||
#print "store_tourneys_players returning", result
|
||||
return result
|
||||
#end def store_tourneys_players
|
||||
|
||||
|
||||
# read HandToWrite objects from q and insert into database
|
||||
def insert_queue_hands(self, q, maxwait=10, commitEachHand=True):
|
||||
n,fails,maxTries,firstWait = 0,0,4,0.1
|
||||
|
@ -1937,59 +1977,145 @@ class Database:
|
|||
print "***Error sending finish: "+err[2]+"("+str(err[1])+"): "+str(sys.exc_info()[1])
|
||||
# end def send_finish_msg():
|
||||
|
||||
def tRecogniseTourneyType(self, tourney):
|
||||
log.debug("Database.tRecogniseTourneyType")
|
||||
typeId = 1
|
||||
def createTourneyType(self, hand):#note: this method is used on Hand and TourneySummary objects
|
||||
tourneyTypeId = 1
|
||||
|
||||
# Check if Tourney exists, and if so retrieve TTypeId : in that case, check values of the ttype
|
||||
cursor = self.get_cursor()
|
||||
cursor.execute (self.sql.query['getTourneyTypeIdByTourneyNo'].replace('%s', self.sql.query['placeholder']),
|
||||
(tourney.tourNo, tourney.siteId)
|
||||
(hand.tourNo, hand.siteId)
|
||||
)
|
||||
result=cursor.fetchone()
|
||||
#print "result of fetching TT by number and site:",result
|
||||
|
||||
expectedValues = { 1 : "buyin", 2 : "fee", 4 : "isKO", 5 : "isRebuy", 6 : "speed",
|
||||
7 : "isHU", 8 : "isShootout", 9 : "isMatrix" }
|
||||
typeIdMatch = True
|
||||
|
||||
try:
|
||||
len(result)
|
||||
typeId = result[0]
|
||||
log.debug("Tourney found in db with Tourney_Type_ID = %d" % typeId)
|
||||
for ev in expectedValues :
|
||||
if ( getattr( tourney, expectedValues.get(ev) ) <> result[ev] ):
|
||||
log.debug("TypeId mismatch : wrong %s : Tourney=%s / db=%s" % (expectedValues.get(ev), getattr( tourney, expectedValues.get(ev)), result[ev]) )
|
||||
typeIdMatch = False
|
||||
#break
|
||||
except:
|
||||
# Tourney not found : a TourneyTypeId has to be found or created for that specific tourney
|
||||
typeIdMatch = False
|
||||
|
||||
if typeIdMatch == False :
|
||||
# Check for an existing TTypeId that matches tourney info (buyin/fee, knockout, rebuy, speed, matrix, shootout)
|
||||
# if not found create it
|
||||
log.debug("Searching for a TourneyTypeId matching TourneyType data")
|
||||
if result:
|
||||
tourneyTypeId = result[0]
|
||||
else:
|
||||
# Check for an existing TTypeId that matches tourney info, if not found create it
|
||||
#print "info that we use to get TT by detail:", hand.siteId, hand.buyinCurrency, hand.buyin, hand.fee, hand.gametype['category'], hand.gametype['limitType'], hand.isKO, hand.isRebuy, hand.isAddOn, hand.speed, hand.isShootout, hand.isMatrix
|
||||
#print "the query:",self.sql.query['getTourneyTypeId'].replace('%s', self.sql.query['placeholder'])
|
||||
cursor.execute (self.sql.query['getTourneyTypeId'].replace('%s', self.sql.query['placeholder']),
|
||||
(tourney.siteId, tourney.buyin, tourney.fee, tourney.isKO,
|
||||
tourney.isRebuy, tourney.speed, tourney.isHU, tourney.isShootout, tourney.isMatrix)
|
||||
(hand.siteId, hand.buyinCurrency, hand.buyin, hand.fee, hand.gametype['category'], hand.gametype['limitType'], hand.isKO,
|
||||
hand.isRebuy, hand.isAddOn, hand.speed, hand.isShootout, hand.isMatrix) #TODO: add koamount
|
||||
)
|
||||
result=cursor.fetchone()
|
||||
#print "result of fetching TT by details:",result
|
||||
|
||||
try:
|
||||
len(result)
|
||||
typeId = result[0]
|
||||
log.debug("Existing Tourney Type Id found : %d" % typeId)
|
||||
tourneyTypeId = result[0]
|
||||
except TypeError: #this means we need to create a new entry
|
||||
log.debug("Tourney Type Id not found : create one")
|
||||
cursor.execute (self.sql.query['insertTourneyTypes'].replace('%s', self.sql.query['placeholder']),
|
||||
(tourney.siteId, tourney.buyin, tourney.fee, tourney.isKO, tourney.isRebuy,
|
||||
tourney.speed, tourney.isHU, tourney.isShootout, tourney.isMatrix)
|
||||
cursor.execute (self.sql.query['insertTourneyType'].replace('%s', self.sql.query['placeholder']),
|
||||
(hand.siteId, hand.buyinCurrency, hand.buyin, hand.fee, hand.gametype['category'], hand.gametype['limitType'],
|
||||
hand.buyInChips, hand.isKO, hand.koBounty, hand.isRebuy,
|
||||
hand.isAddOn, hand.speed, hand.isShootout, hand.isMatrix, hand.added, hand.addedCurrency)
|
||||
)
|
||||
typeId = self.get_last_insert_id(cursor)
|
||||
tourneyTypeId = self.get_last_insert_id(cursor)
|
||||
return tourneyTypeId
|
||||
#end def createTourneyType
|
||||
|
||||
return typeId
|
||||
#end def tRecogniseTourneyType
|
||||
def createOrUpdateTourney(self, hand, source):#note: this method is used on Hand and TourneySummary objects
|
||||
cursor = self.get_cursor()
|
||||
cursor.execute (self.sql.query['getTourneyByTourneyNo'].replace('%s', self.sql.query['placeholder']),
|
||||
(hand.siteId, hand.tourNo))
|
||||
columnNames=[desc[0] for desc in cursor.description]
|
||||
result=cursor.fetchone()
|
||||
|
||||
if result != None:
|
||||
expectedValues = ('comment', 'tourneyName', 'matrixIdProcessed', 'totalRebuyCount', 'totalAddOnCount',
|
||||
'prizepool', 'startTime', 'entries', 'commentTs', 'endTime')
|
||||
updateDb=False
|
||||
resultDict = dict(zip(columnNames, result))
|
||||
|
||||
tourneyId = resultDict["id"]
|
||||
if source=="TS":
|
||||
for ev in expectedValues :
|
||||
if getattr(hand, ev)==None and resultDict[ev]!=None:#DB has this value but object doesnt, so update object
|
||||
setattr(hand, ev, resultDict[ev])
|
||||
elif getattr(hand, ev)!=None and resultDict[ev]==None:#object has this value but DB doesnt, so update DB
|
||||
updateDb=True
|
||||
#elif ev=="startTime":
|
||||
# if (resultDict[ev] < hand.startTime):
|
||||
# hand.startTime=resultDict[ev]
|
||||
if updateDb:
|
||||
cursor.execute (self.sql.query['updateTourney'].replace('%s', self.sql.query['placeholder']),
|
||||
(hand.entries, hand.prizepool, hand.startTime, hand.endTime, hand.tourneyName,
|
||||
hand.matrixIdProcessed, hand.totalRebuyCount, hand.totalAddOnCount, hand.comment, hand.commentTs, tourneyId))
|
||||
else:
|
||||
if source=="HHC":
|
||||
cursor.execute (self.sql.query['insertTourney'].replace('%s', self.sql.query['placeholder']),
|
||||
(hand.tourneyTypeId, hand.tourNo, None, None,
|
||||
hand.startTime, None, None, None, None, None))
|
||||
elif source=="TS":
|
||||
cursor.execute (self.sql.query['insertTourney'].replace('%s', self.sql.query['placeholder']),
|
||||
(hand.tourneyTypeId, hand.tourNo, hand.entries, hand.prizepool, hand.startTime,
|
||||
hand.endTime, hand.tourneyName, hand.matrixIdProcessed, hand.totalRebuyCount, hand.totalAddOnCount))
|
||||
else:
|
||||
raise FpdbParseError("invalid source in Database.createOrUpdateTourney")
|
||||
tourneyId = self.get_last_insert_id(cursor)
|
||||
return tourneyId
|
||||
#end def createOrUpdateTourney
|
||||
|
||||
def createOrUpdateTourneysPlayers(self, hand, source):#note: this method is used on Hand and TourneySummary objects
|
||||
tourneysPlayersIds={}
|
||||
for player in hand.players:
|
||||
if source=="TS": #TODO remove this horrible hack
|
||||
playerId = hand.dbid_pids[player]
|
||||
elif source=="HHC":
|
||||
playerId = hand.dbid_pids[player[1]]
|
||||
else:
|
||||
raise FpdbParseError("invalid source in Database.createOrUpdateTourneysPlayers")
|
||||
|
||||
cursor = self.get_cursor()
|
||||
cursor.execute (self.sql.query['getTourneysPlayersByIds'].replace('%s', self.sql.query['placeholder']),
|
||||
(hand.tourneyId, playerId))
|
||||
columnNames=[desc[0] for desc in cursor.description]
|
||||
result=cursor.fetchone()
|
||||
|
||||
if result != None:
|
||||
expectedValues = ('rank', 'winnings', 'winningsCurrency', 'rebuyCount', 'addOnCount', 'koCount')
|
||||
updateDb=False
|
||||
resultDict = dict(zip(columnNames, result))
|
||||
|
||||
tourneysPlayersIds[player[1]]=result[0]
|
||||
if source=="TS":
|
||||
for ev in expectedValues :
|
||||
handAttribute=ev
|
||||
if ev!="winnings" and ev!="winningsCurrency":
|
||||
handAttribute+="s"
|
||||
|
||||
if getattr(hand, handAttribute)[player]==None and resultDict[ev]!=None:#DB has this value but object doesnt, so update object
|
||||
setattr(hand, handAttribute, resultDict[ev][player])
|
||||
elif getattr(hand, handAttribute)[player]!=None and resultDict[ev]==None:#object has this value but DB doesnt, so update DB
|
||||
updateDb=True
|
||||
if updateDb:
|
||||
cursor.execute (self.sql.query['updateTourneysPlayer'].replace('%s', self.sql.query['placeholder']),
|
||||
(hand.ranks[player], hand.winnings[player], hand.winningsCurrency[player],
|
||||
hand.rebuyCounts[player], hand.addOnCounts[player], hand.koCounts[player], tourneysPlayersIds[player[1]]))
|
||||
else:
|
||||
if source=="HHC":
|
||||
cursor.execute (self.sql.query['insertTourneysPlayer'].replace('%s', self.sql.query['placeholder']),
|
||||
(hand.tourneyId, playerId, None, None, None, None, None, None))
|
||||
elif source=="TS":
|
||||
#print "all values: tourneyId",hand.tourneyId, "playerId",playerId, "rank",hand.ranks[player], "winnings",hand.winnings[player], "winCurr",hand.winningsCurrency[player], hand.rebuyCounts[player], hand.addOnCounts[player], hand.koCounts[player]
|
||||
if hand.ranks[player]:
|
||||
cursor.execute (self.sql.query['insertTourneysPlayer'].replace('%s', self.sql.query['placeholder']),
|
||||
(hand.tourneyId, playerId, int(hand.ranks[player]), int(hand.winnings[player]), hand.winningsCurrency[player],
|
||||
hand.rebuyCounts[player], hand.addOnCounts[player], hand.koCounts[player]))
|
||||
else:
|
||||
cursor.execute (self.sql.query['insertTourneysPlayer'].replace('%s', self.sql.query['placeholder']),
|
||||
(hand.tourneyId, playerId, None, None, None,
|
||||
hand.rebuyCounts[player], hand.addOnCounts[player], hand.koCounts[player]))
|
||||
tourneysPlayersIds[player[1]]=self.get_last_insert_id(cursor)
|
||||
return tourneysPlayersIds
|
||||
#end def createOrUpdateTourneysPlayers
|
||||
|
||||
def getTourneyTypesIds(self):
|
||||
c = self.connection.cursor()
|
||||
c.execute(self.sql.query['getTourneyTypesIds'])
|
||||
result = c.fetchall()
|
||||
return result
|
||||
#end def getTourneyTypesIds
|
||||
#end class Database
|
||||
|
||||
# Class used to hold all the data needed to write a hand to the db
|
||||
# mainParser() in fpdb_parse_logic.py creates one of these and then passes it to
|
||||
|
@ -2036,7 +2162,6 @@ class HandToWrite:
|
|||
self.maxSeats = None
|
||||
self.tableName = None
|
||||
self.seatNos = None
|
||||
self.payin_amounts = None # tourney import was complaining mightily about this missing
|
||||
except:
|
||||
print "htw.init error: " + str(sys.exc_info())
|
||||
raise
|
||||
|
|
|
@ -1,810 +0,0 @@
|
|||
"""Database manager
|
||||
|
||||
@todo: (gtk) how to validate user input in gtk.Dialog? as soon as the user clicks ok the dialog is dead. we use a while loop as workaround. not nice
|
||||
@todo: (fpdb) we need the application name 'fpdb' from somewhere to put it in dialog titles
|
||||
@todo: (fpdb) config object should be initialized globally and accessible from all modules via Configuration.py
|
||||
|
||||
@todo: (all dialogs) save/restore size and pos
|
||||
|
||||
@todo: (WidgetDatabaseManager) give database status meaningful colors
|
||||
@todo: (WidgetDatabaseManager) implement database purging
|
||||
@todo: (WidgetDatabaseManager) implement database export
|
||||
@todo: (WidgetDatabaseManager) what to do on database doubleclick?
|
||||
@todo: (WidgetDatabaseManager) context menu for database tree
|
||||
@todo: (WidgetDatabaseManager) initializing/validating databases may take a while. how to give feedback?
|
||||
|
||||
"""
|
||||
|
||||
import os
|
||||
import pygtk
|
||||
pygtk.require('2.0')
|
||||
import gtk
|
||||
import gobject
|
||||
|
||||
#*******************************************************************************************************
|
||||
class DatabaseManager(gobject.GObject):
|
||||
DatabaseTypes = {}
|
||||
|
||||
@classmethod
|
||||
def from_fpdb(klass, data, defaultDatabaseType=None):
|
||||
|
||||
#NOTE: if no databases are present in config fpdb fails with
|
||||
# Traceback (most recent call last):
|
||||
# File "/home/me2/Scr/Repos/fpdb-mme/pyfpdb/DatabaseManager.py", line 783, in <module>
|
||||
# databaseManager = DatabaseManager.from_fpdb('', defaultDatabaseType=DatabaseTypeSqLite)
|
||||
# File "/home/me2/Scr/Repos/fpdb-mme/pyfpdb/DatabaseManager.py", line 36, in from_fpdb
|
||||
# config = Configuration.Config(file=options.config, dbname=options.dbname)
|
||||
# File "/home/me2/Scr/Repos/fpdb-mme/pyfpdb/Configuration.py", line 436, in __init__
|
||||
# db = self.get_db_parameters()
|
||||
# File "/home/me2/Scr/Repos/fpdb-mme/pyfpdb/Configuration.py", line 583, in get_db_parameters
|
||||
# name = self.db_selected
|
||||
# AttributeError: Config instance has no attribute 'db_selected'
|
||||
import sys
|
||||
import Options
|
||||
import Configuration
|
||||
#NOTE: fpdb should perform this globally
|
||||
(options, argv) = Options.fpdb_options()
|
||||
config = Configuration.Config(file=options.config, dbname=options.dbname)
|
||||
#TODO: handle no database present
|
||||
defaultDatabaseName = config.get_db_parameters().get('db-databaseName', None)
|
||||
#TODO: fpdb stores databases in no particular order. this has to be fixed somehow
|
||||
databases = []
|
||||
for name, fpdbDatabase in config.supported_databases.items():
|
||||
databaseKlass = klass.DatabaseTypes.get(fpdbDatabase.db_server, None)
|
||||
#NOTE: Config does not seem to validate user input, so anything may end up here
|
||||
if databaseKlass is None:
|
||||
raise ValueError('Unknown databasetype: %s' % fpdbDatabase.db_server)
|
||||
|
||||
database = databaseKlass()
|
||||
if database.Type == 'sqlite':
|
||||
database.name = fpdbDatabase.db_name
|
||||
database.file = fpdbDatabase.db_server
|
||||
else:
|
||||
database.name = fpdbDatabase.db_name
|
||||
database.host = fpdbDatabase.db_server
|
||||
#NOTE: fpdbDatabase.db_ip is no is a string
|
||||
database.port = int(fpdbDatabase.db_ip)
|
||||
database.user = fpdbDatabase.db_user
|
||||
database.password = fpdbDatabase.db_pass
|
||||
databases.append(database)
|
||||
|
||||
return klass(databases=databases, defaultDatabaseType=defaultDatabaseType)
|
||||
|
||||
def to_fpdb(self):
|
||||
pass
|
||||
|
||||
|
||||
def __init__(self, databases=None, defaultDatabaseType=None):
|
||||
gobject.GObject.__init__(self)
|
||||
|
||||
self._defaultDatabaseType = defaultDatabaseType
|
||||
self._databases = [] if databases is None else list(databases)
|
||||
self._activeDatabase = None
|
||||
def __iter__(self):
|
||||
return iter(self._databases)
|
||||
def set_default_database_type(self, databaseType):
|
||||
self._defaultDatabaseType = defaultDatabaseType
|
||||
def get_default_database_type(self):
|
||||
return self._defaultDatabaseType
|
||||
def database_from_id(self, idDatabase):
|
||||
for database in self._databases:
|
||||
if idDatabase == self.database_id(database):
|
||||
return database
|
||||
def database_id(self, database):
|
||||
return id(database)
|
||||
def add_database(self, database):
|
||||
if database in self._databases:
|
||||
raise ValueError('database already registered')
|
||||
self._databases.append(database)
|
||||
def remove_database(self, database):
|
||||
self._databases.remove(database)
|
||||
|
||||
def activate_database(self, database):
|
||||
if self._activeDatabase is not None:
|
||||
self._activeDatabase.status = self._activeDatabase.StatusInactive
|
||||
#TODO: finalize database
|
||||
self.emit('database-deactivated', self.database_id(self._activeDatabase) )
|
||||
|
||||
database.status = database.StatusActive
|
||||
#TODO: activate database
|
||||
self._activeDatabase = database
|
||||
self.emit('database-activated', self.database_id(database) )
|
||||
|
||||
def active_database(self):
|
||||
return self._activeDatabase
|
||||
|
||||
# register DatabaseManager signals
|
||||
gobject.type_register(DatabaseManager)
|
||||
gobject.signal_new('database-activated', DatabaseManager, gobject.SIGNAL_RUN_FIRST, gobject.TYPE_NONE, (int, ))
|
||||
gobject.signal_new('database-deactivated', DatabaseManager, gobject.SIGNAL_RUN_FIRST, gobject.TYPE_NONE, (int, ))
|
||||
gobject.signal_new('database-error', DatabaseManager, gobject.SIGNAL_RUN_FIRST, gobject.TYPE_NONE, (int, ))
|
||||
|
||||
class DatabaseTypeMeta(type):
|
||||
def __new__(klass, name, bases, kws):
|
||||
newKlass = type.__new__(klass, name, bases, kws)
|
||||
if newKlass.Type is not None:
|
||||
if newKlass.Type in DatabaseManager.DatabaseTypes:
|
||||
raise ValueError('data base type already registered for: %s' % newKlass.Type)
|
||||
DatabaseManager.DatabaseTypes[newKlass.Type] = newKlass
|
||||
return newKlass
|
||||
|
||||
class DatabaseTypeBase(object):
|
||||
__metaclass__ = DatabaseTypeMeta
|
||||
Type = None
|
||||
StatusActive = 'active'
|
||||
StatusInactive = 'inactive'
|
||||
StatusError = 'error' #TODO: not implemented
|
||||
|
||||
#TODO: not happy with returning error string. just being too lazy to impl dozens of error codes for later translation
|
||||
def init_new_database(self):
|
||||
"""initializes a new empty database
|
||||
@return: (str) error if something goes wrong, None otherwise
|
||||
"""
|
||||
raise NotImplementedError()
|
||||
|
||||
def validate_database(self):
|
||||
"""checks if the database is valid
|
||||
@return: (str) error if something goes wrong, None otherwise
|
||||
"""
|
||||
raise NotImplementedError()
|
||||
|
||||
class DatabaseTypePostgres(DatabaseTypeBase):
|
||||
Type = 'postgresql'
|
||||
@classmethod
|
||||
def display_name(klass):
|
||||
return 'Postgres'
|
||||
def __init__(self, name='', host='localhost', port=5432, user='postgres', password='', database='fpdb'):
|
||||
self.name = name
|
||||
self.host = host
|
||||
self.port = port
|
||||
self.user = user
|
||||
self.password = password
|
||||
self.database = database
|
||||
self.status = self.StatusInactive
|
||||
|
||||
#TODO: implement
|
||||
def init_new_database(self):
|
||||
pass
|
||||
|
||||
#TODO: implement
|
||||
def validate_database(self):
|
||||
pass
|
||||
|
||||
class DatabaseTypeMysql(DatabaseTypeBase):
|
||||
Type = 'mysql'
|
||||
@classmethod
|
||||
def display_name(klass):
|
||||
return 'MySql'
|
||||
def __init__(self, name='', host='localhost', port=3306, user='root', password='', database='fpdb'):
|
||||
self.name = name
|
||||
self.host = host
|
||||
self.port = port
|
||||
self.user = user
|
||||
self.password = password
|
||||
self.database = database
|
||||
self.status = self.StatusInactive
|
||||
|
||||
#TODO: implement
|
||||
def init_new_database(self):
|
||||
pass
|
||||
|
||||
#TODO: implement
|
||||
def validate_database(self):
|
||||
pass
|
||||
|
||||
|
||||
class DatabaseTypeSqLite(DatabaseTypeBase):
|
||||
Type = 'sqlite'
|
||||
@classmethod
|
||||
def display_name(klass):
|
||||
return 'SqLite'
|
||||
def __init__(self, name='', host='', file='', database='fpdb'):
|
||||
self.name = name
|
||||
self.file = file
|
||||
self.status = self.StatusInactive
|
||||
|
||||
def init_new_database(self):
|
||||
# make shure all attrs are specified
|
||||
if not self.file:
|
||||
return 'no database file specified'
|
||||
# create file if necessary (this will truncate file if it exists)
|
||||
try:
|
||||
open(self.file, 'w').close()
|
||||
except IOError:
|
||||
return 'can not write file'
|
||||
|
||||
#TODO: init tables (...)
|
||||
|
||||
|
||||
def validate_database(self):
|
||||
pass
|
||||
#TODO: check if tables (...) exist
|
||||
|
||||
|
||||
|
||||
#TODO: how do we want to handle unsupported database types?
|
||||
# ..uncomment to remove unsupported database types
|
||||
#try: import psycopg2
|
||||
#except ImportError: del DatabaseManager.DatabaseTypes['postgres']
|
||||
#try: import MySQLdb
|
||||
#except ImportError: del DatabaseManager.DatabaseTypes['mysql']
|
||||
#try: import sqlite3
|
||||
#except ImportError: del DatabaseManager.DatabaseTypes['sqlite']
|
||||
|
||||
#***************************************************************************************************************************
|
||||
#TODO: there is no title (on linux), wtf?
|
||||
def DialogError(parent=None, msg=''):
|
||||
dlg = gtk.MessageDialog(
|
||||
parent=parent,
|
||||
flags=gtk.DIALOG_MODAL|gtk.DIALOG_DESTROY_WITH_PARENT,
|
||||
type=gtk.MESSAGE_ERROR,
|
||||
buttons=gtk.BUTTONS_OK,
|
||||
message_format=msg,
|
||||
)
|
||||
dlg.run()
|
||||
dlg.destroy()
|
||||
return None
|
||||
|
||||
|
||||
#TODO: derrive from gtk.VBox?
|
||||
class WidgetDatabaseProperties(gtk.VBox):
|
||||
|
||||
ModeNew = 0
|
||||
ModeEdit = 1
|
||||
ModeAdd = 2
|
||||
|
||||
class SqLiteFileChooserButton(gtk.HBox):
|
||||
#NOTE: for some weird reason it is impossible to let the user choose a non exiting filename with gtk.FileChooserButton, so impl our own on the fly
|
||||
def __init__(self, widgetDatabaseProperties, parentWidget):
|
||||
gtk.HBox.__init__(self)
|
||||
self.set_homogeneous(False)
|
||||
|
||||
self.parentWidget = parentWidget
|
||||
self.widgetDatabaseProperties = widgetDatabaseProperties
|
||||
self.entry = gtk.Entry()
|
||||
self.button = gtk.Button('...')
|
||||
self.button.connect('clicked', self.on_button_clicked)
|
||||
|
||||
# layout widgets
|
||||
self.pack_start(self.entry, True, True)
|
||||
self.pack_start(self.button, False, False)
|
||||
|
||||
def get_filename(self):
|
||||
return self.entry.get_text()
|
||||
|
||||
def set_filename(self, name):
|
||||
self.entry.set_text(name)
|
||||
|
||||
def on_button_clicked(self, button):
|
||||
if self.widgetDatabaseProperties.mode == WidgetDatabaseProperties.ModeAdd:
|
||||
action = gtk.FILE_CHOOSER_ACTION_OPEN
|
||||
elif self.widgetDatabaseProperties.mode == WidgetDatabaseProperties.ModeNew:
|
||||
action = gtk.FILE_CHOOSER_ACTION_SAVE
|
||||
else:
|
||||
raise ValueError('unsupported dialog mode')
|
||||
dlg = gtk.FileChooserDialog(
|
||||
title='Choose an exiting database file or type in name of a new one',
|
||||
parent=self.parentWidget,
|
||||
action=action,
|
||||
buttons=(
|
||||
gtk.STOCK_CANCEL, gtk.RESPONSE_REJECT,
|
||||
gtk.STOCK_OK, gtk.RESPONSE_OK,
|
||||
),
|
||||
backend=None
|
||||
)
|
||||
dlg.set_default_response(gtk.RESPONSE_OK)
|
||||
dlg.set_do_overwrite_confirmation(True)
|
||||
if dlg.run() == gtk.RESPONSE_OK:
|
||||
fileName = dlg.get_filename()
|
||||
self.set_filename(fileName)
|
||||
dlg.destroy()
|
||||
|
||||
|
||||
#TODO: bit ugly this thingy. try to find a better way to map database attrs to gtk widgets
|
||||
class FieldWidget(object):
|
||||
def __init__(self, text='', attrDatabase='', widget=None, attrGet=None, attrSet=None, defaultValue=None, canEdit=False, tooltip=''):
|
||||
"""
|
||||
@param canEdit: True if the user can edit the attr in edit mode, False otherwise
|
||||
"""
|
||||
self._label = gtk.Label(text)
|
||||
self._attrDatabase = attrDatabase
|
||||
self._widget = widget
|
||||
self._defaultValue = defaultValue
|
||||
self._attrGetter=None,
|
||||
self._attrGet = attrGet
|
||||
self._attrSet = attrSet
|
||||
self._canEdit = canEdit
|
||||
|
||||
self._label.set_tooltip_text(tooltip)
|
||||
self._widget.set_tooltip_text(tooltip)
|
||||
|
||||
def widget(self):
|
||||
return self._widget
|
||||
def label(self):
|
||||
return self._label
|
||||
def is_sensitive(self, database):
|
||||
return hasattr(database, self._attrDatabase)
|
||||
def can_edit(self):
|
||||
return self._canEdit
|
||||
def set_sensitive(self, flag):
|
||||
self._label.set_sensitive(flag)
|
||||
self._widget.set_sensitive(flag)
|
||||
def value_from_database(self, database):
|
||||
getattr(self._widget, self._attrSet)( getattr(database, self._attrDatabase) )
|
||||
def value_to_database(self, database):
|
||||
setattr(database, self._attrDatabase, getattr(self._widget, self._attrGet)() )
|
||||
def reset_value(self):
|
||||
getattr(self._widget, self._attrSet)(self._defaultValue)
|
||||
|
||||
def __init__(self, databaseManager, database, mode=ModeEdit, parentWidget=None):
|
||||
gtk.VBox.__init__(self)
|
||||
|
||||
self.databaseManager = databaseManager
|
||||
self.database = database
|
||||
self.mode = mode
|
||||
self.parentWidget = parentWidget
|
||||
self.fieldWidgets = (
|
||||
self.FieldWidget(
|
||||
text='Name:',
|
||||
attrDatabase='name',
|
||||
widget=gtk.Entry(),
|
||||
defaultValue='',
|
||||
attrGet='get_text',
|
||||
attrSet='set_text',
|
||||
canEdit=True,
|
||||
tooltip='Any name you like to name the database '
|
||||
),
|
||||
self.FieldWidget(
|
||||
text='File:',
|
||||
attrDatabase='file',
|
||||
widget=self.SqLiteFileChooserButton(self, self.parentWidget),
|
||||
defaultValue='',
|
||||
attrGet='get_filename',
|
||||
attrSet='set_filename',
|
||||
canEdit=False,
|
||||
tooltip='Fully qualified path of the file to hold the database '
|
||||
),
|
||||
self.FieldWidget(
|
||||
text='Host:',
|
||||
attrDatabase='host',
|
||||
widget=gtk.Entry(),
|
||||
defaultValue='',
|
||||
attrGet='get_text',
|
||||
attrSet='set_text',
|
||||
canEdit=False,
|
||||
tooltip='Host the database is located at'
|
||||
),
|
||||
self.FieldWidget(
|
||||
text='Port:',
|
||||
attrDatabase='port',
|
||||
widget=gtk.SpinButton(adjustment=gtk.Adjustment(value=0, lower=0, upper=999999, step_incr=1, page_incr=10) ),
|
||||
defaultValue=0,
|
||||
attrGet='get_value',
|
||||
attrSet='set_value',
|
||||
canEdit=False,
|
||||
tooltip='Port to use to connect to the host'
|
||||
),
|
||||
self.FieldWidget(
|
||||
text='User:',
|
||||
attrDatabase='user',
|
||||
widget=gtk.Entry(),
|
||||
defaultValue='',
|
||||
attrGet='get_text',
|
||||
attrSet='set_text',
|
||||
canEdit=False,
|
||||
tooltip='User name used to login to the host'
|
||||
),
|
||||
self.FieldWidget(
|
||||
text='Pwd:',
|
||||
attrDatabase='password',
|
||||
widget=gtk.Entry(),
|
||||
defaultValue='',
|
||||
attrGet='get_text',
|
||||
attrSet='set_text',
|
||||
canEdit=False,
|
||||
tooltip='Password used to login to the host'
|
||||
),
|
||||
self.FieldWidget(
|
||||
text='Db:',
|
||||
attrDatabase='database',
|
||||
widget=gtk.Entry(),
|
||||
defaultValue='',
|
||||
attrGet='get_text',
|
||||
attrSet='set_text',
|
||||
canEdit=False,
|
||||
tooltip='Name of the database'
|
||||
),
|
||||
)
|
||||
|
||||
# setup database type combo
|
||||
self.comboType = gtk.ComboBox()
|
||||
listStore= gtk.ListStore(str, str)
|
||||
self.comboType.set_model(listStore)
|
||||
cell = gtk.CellRendererText()
|
||||
self.comboType.pack_start(cell, True)
|
||||
self.comboType.add_attribute(cell, 'text', 0)
|
||||
self.comboType.connect('changed', self.on_combo_type_changed)
|
||||
|
||||
# fill database type combo with available database klasses. we store (databaseDisplayName, databaseType) in our model for later lookup
|
||||
iCurrentDatabase = 0
|
||||
databaseTypes = [(klass.display_name(), klass.Type) for klass in databaseManager.DatabaseTypes.values()]
|
||||
databaseTypes.sort()
|
||||
for i, (databaseDisplayName, databaseType) in enumerate(databaseTypes):
|
||||
listStore.append( (databaseDisplayName, databaseType) )
|
||||
if databaseType == self.database.Type:
|
||||
iCurrentDatabase = i
|
||||
if self.mode == self.ModeEdit or len(databaseTypes) < 2:
|
||||
self.comboType.set_button_sensitivity(gtk.SENSITIVITY_OFF)
|
||||
|
||||
# init and layout field widgets
|
||||
self.pack_start(self.comboType, False, False, 2)
|
||||
table = gtk.Table(rows=len(self.fieldWidgets) +1, columns=2, homogeneous=False)
|
||||
self.pack_start(table, False, False, 2)
|
||||
for i,fieldWidget in enumerate(self.fieldWidgets):
|
||||
table.attach(fieldWidget.label(), 0, 1, i, i+1, xoptions=gtk.FILL)
|
||||
table.attach(fieldWidget.widget(), 1, 2, i, i+1)
|
||||
|
||||
# init widget
|
||||
self.comboType.set_active(iCurrentDatabase)
|
||||
self._adjust_widgets(self.database)
|
||||
|
||||
def _adjust_widgets(self, database):
|
||||
for fieldWidget in self.fieldWidgets:
|
||||
isSensitive = fieldWidget.is_sensitive(database)
|
||||
if isSensitive:
|
||||
fieldWidget.value_from_database(database)
|
||||
else:
|
||||
fieldWidget.reset_value()
|
||||
if self.mode == self.ModeEdit:
|
||||
isSensitive = isSensitive and fieldWidget.can_edit()
|
||||
fieldWidget.set_sensitive(isSensitive)
|
||||
|
||||
|
||||
def on_combo_type_changed(self, combo):
|
||||
i = self.comboType.get_active()
|
||||
if i < 0:
|
||||
return
|
||||
|
||||
# check if we need to init a new database
|
||||
currentDatabaseType = self.comboType.get_model()[i][1]
|
||||
if currentDatabaseType == self.database.Type:
|
||||
return
|
||||
|
||||
# create new empty database
|
||||
#NOTE: we dont register it in DatabaseManager
|
||||
self.database = self.databaseManager.DatabaseTypes[currentDatabaseType]()
|
||||
self._adjust_widgets(self.database)
|
||||
|
||||
|
||||
def get_database(self):
|
||||
for fieldWidget in self.fieldWidgets:
|
||||
if fieldWidget.is_sensitive(self.database):
|
||||
fieldWidget.value_to_database(self.database)
|
||||
return self.database
|
||||
|
||||
|
||||
class DialogDatabaseProperties(gtk.Dialog):
|
||||
def __init__(self, databaseManager, database, parent=None, mode=WidgetDatabaseProperties.ModeEdit, title=''):
|
||||
gtk.Dialog.__init__(self,
|
||||
title=title,
|
||||
parent=parent,
|
||||
flags=gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT,
|
||||
buttons=(
|
||||
gtk.STOCK_CANCEL, gtk.RESPONSE_REJECT,
|
||||
gtk.STOCK_OK, gtk.RESPONSE_ACCEPT,
|
||||
)
|
||||
)
|
||||
self.connect('response', self.on_dialog_response)
|
||||
|
||||
# setup widget
|
||||
self.widgetDatabaseProperties = WidgetDatabaseProperties(databaseManager,database, mode=mode, parentWidget=self)
|
||||
self.vbox.pack_start(self.widgetDatabaseProperties, True, True)
|
||||
self.show_all()
|
||||
|
||||
def get_widget_database_properties(self):
|
||||
return self.widgetDatabaseProperties
|
||||
|
||||
def on_dialog_response(self, dlg, responseId):
|
||||
if responseId == gtk.RESPONSE_REJECT:
|
||||
pass
|
||||
elif responseId == gtk.RESPONSE_ACCEPT:
|
||||
pass
|
||||
|
||||
|
||||
#TODO: derrive from gtk.VBox?
|
||||
# ..is there a way to derrive from gtk.Widget or similar? this would make parentWidget kw obsolete
|
||||
class WidgetDatabaseManager(gtk.VBox):
|
||||
"""
|
||||
"""
|
||||
|
||||
def __init__(self, databaseManager, parentWidget=None):
|
||||
gtk.VBox.__init__(self)
|
||||
|
||||
self.parentWidget = parentWidget
|
||||
self.databaseManager = databaseManager
|
||||
self.databaseManager.connect('database-activated', self.on_database_manager_database_activated)
|
||||
self.databaseManager.connect('database-deactivated', self.on_database_manager_database_deactivated)
|
||||
self.databaseStatusNames = {
|
||||
DatabaseTypeBase.StatusActive: 'Active',
|
||||
DatabaseTypeBase.StatusInactive: 'Inactive',
|
||||
DatabaseTypeBase.StatusError: 'Error',
|
||||
}
|
||||
|
||||
|
||||
#TODO: dono how to make word wrap work as expected
|
||||
self.labelInfo = gtk.Label('database management')
|
||||
self.labelInfo.set_line_wrap(True)
|
||||
self.labelInfo.set_selectable(True)
|
||||
self.labelInfo.set_single_line_mode(False)
|
||||
self.labelInfo.set_alignment(0, 0)
|
||||
|
||||
# database management buttons
|
||||
|
||||
#TODO: bit messy the distinction New/Add/Edit. we'd have to pass three flags to DialogDatabaseProperties
|
||||
# to handle this. maybe drop Edit (is just a Remove + Add), to keep things simple
|
||||
self.buttonDatabaseActivate = gtk.Button("Activate")
|
||||
self.buttonDatabaseActivate.set_tooltip_text('activates the database')
|
||||
self.buttonDatabaseActivate.connect('clicked', self.on_button_database_activate_clicked)
|
||||
self.buttonDatabaseActivate.set_sensitive(False)
|
||||
self.buttonDatabaseNew = gtk.Button("New..")
|
||||
self.buttonDatabaseNew.set_tooltip_text('creates a new database')
|
||||
self.buttonDatabaseNew.connect('clicked', self.on_button_database_new_clicked)
|
||||
self.buttonDatabaseAdd = gtk.Button("Add..")
|
||||
self.buttonDatabaseAdd.set_tooltip_text('adds an existing database')
|
||||
self.buttonDatabaseAdd.connect('clicked', self.on_button_database_add_clicked)
|
||||
self.buttonDatabaseEdit = gtk.Button("Edit..")
|
||||
self.buttonDatabaseEdit.set_tooltip_text('edit database settings')
|
||||
self.buttonDatabaseEdit.connect('clicked', self.on_button_database_edit_clicked)
|
||||
self.buttonDatabaseEdit.set_sensitive(False)
|
||||
self.buttonDatabaseRemove = gtk.Button("Remove")
|
||||
self.buttonDatabaseRemove.set_tooltip_text('removes the database from the list')
|
||||
self.buttonDatabaseRemove.set_sensitive(False)
|
||||
self.buttonDatabaseRemove.connect('clicked', self.on_button_database_remove_clicked)
|
||||
|
||||
#TODO: i dont think we should do any real database management here. maybe drop it
|
||||
#self.buttonDatabaseDelete = gtk.Button("Delete")
|
||||
#self.buttonDatabaseDelete.set_tooltip_text('removes the database from the list and deletes it')
|
||||
#self.buttonDatabaseDelete.set_sensitive(False)
|
||||
|
||||
# init database tree
|
||||
self.treeDatabases = gtk.TreeView()
|
||||
treeDatabaseColumns = ( # name, displayName, dataType
|
||||
('name', 'Name', str),
|
||||
('status', 'Status', str),
|
||||
('type', 'Type', str),
|
||||
('_id', '', int),
|
||||
)
|
||||
self.treeDatabaseColumns = {} # name --> index
|
||||
store = gtk.ListStore( *[i[2] for i in treeDatabaseColumns] )
|
||||
self.treeDatabases.set_model(store)
|
||||
for i, (name, displayName, dataType) in enumerate(treeDatabaseColumns):
|
||||
col = gtk.TreeViewColumn(displayName, gtk.CellRendererText(), text=i)
|
||||
self.treeDatabases.append_column(col)
|
||||
if name.startswith('_'):
|
||||
col.set_visible(False)
|
||||
self.treeDatabaseColumns[name] = i
|
||||
self.treeDatabases.get_selection().connect('changed', self.on_tree_databases_selection_changed)
|
||||
|
||||
# layout widgets
|
||||
vbox = gtk.VBox(self)
|
||||
vbox.pack_start(self.labelInfo, False, False, 2)
|
||||
vbox.pack_start(gtk.HSeparator(), False, False, 2)
|
||||
hbox = gtk.HBox()
|
||||
self.add(hbox)
|
||||
hbox.set_homogeneous(False)
|
||||
vbox = gtk.VBox()
|
||||
hbox.pack_start(vbox, False, False, 2)
|
||||
vbox.pack_start(self.buttonDatabaseActivate, False, False, 2)
|
||||
vbox.pack_start(self.buttonDatabaseNew, False, False, 2)
|
||||
vbox.pack_start(self.buttonDatabaseAdd, False, False, 2)
|
||||
vbox.pack_start(self.buttonDatabaseEdit, False, False, 2)
|
||||
vbox.pack_start(self.buttonDatabaseRemove, False, False, 2)
|
||||
#vbox.pack_start(self.buttonDatabaseDelete, False, False, 2)
|
||||
box = gtk.VBox()
|
||||
vbox.pack_start(box, True, True, 0)
|
||||
|
||||
hbox.pack_start(gtk.VSeparator(), False, False, 2)
|
||||
hbox.pack_end(self.treeDatabases, True, True, 2)
|
||||
|
||||
self.show_all()
|
||||
|
||||
# init widget
|
||||
model = self.treeDatabases.get_model()
|
||||
for database in self.databaseManager:
|
||||
it = model.append()
|
||||
model.set_value(it, self.treeDatabaseColumns['name'], database.name)
|
||||
model.set_value(it, self.treeDatabaseColumns['status'], self.databaseStatusNames[database.status] )
|
||||
model.set_value(it, self.treeDatabaseColumns['type'], database.display_name() )
|
||||
model.set_value(it, self.treeDatabaseColumns['_id'], self.databaseManager.database_id(database))
|
||||
|
||||
|
||||
def on_database_manager_database_activated(self, databaseManager, idDatabase):
|
||||
database = self.databaseManager.database_from_id(idDatabase)
|
||||
model = self.treeDatabases.get_model()
|
||||
for row in iter(model):
|
||||
if row[self.treeDatabaseColumns['_id']] == idDatabase:
|
||||
row[self.treeDatabaseColumns['status']] = self.databaseStatusNames[database.StatusActive]
|
||||
break
|
||||
else:
|
||||
raise ValueError('database not found')
|
||||
|
||||
|
||||
def on_database_manager_database_deactivated(self, databaseManager, idDatabase):
|
||||
database = self.databaseManager.database_from_id(idDatabase)
|
||||
model = self.treeDatabases.get_model()
|
||||
for row in iter(model):
|
||||
if row[self.treeDatabaseColumns['_id']] == idDatabase:
|
||||
row[self.treeDatabaseColumns['status']] = self.databaseStatusNames[database.StatusInactive]
|
||||
break
|
||||
else:
|
||||
raise ValueError('database not found')
|
||||
|
||||
|
||||
def on_button_database_activate_clicked(self, button):
|
||||
selection = self.treeDatabases.get_selection()
|
||||
if selection is None:
|
||||
return
|
||||
|
||||
model, it = selection.get_selected()
|
||||
idDatabase = model.get_value(it, self.treeDatabaseColumns['_id'])
|
||||
database = self.databaseManager.database_from_id(idDatabase)
|
||||
self.databaseManager.activate_database(database)
|
||||
|
||||
|
||||
#TODO: for some reason i have to click OK/Cancel twice to close the dialog
|
||||
def on_button_database_new_clicked(self, button):
|
||||
databaseKlass = self.databaseManager.get_default_database_type()
|
||||
if databaseKlass is None:
|
||||
raise ValueError('no default database type set')
|
||||
database = databaseKlass()
|
||||
|
||||
while True:
|
||||
dlg = DialogDatabaseProperties(
|
||||
self.databaseManager,
|
||||
database,
|
||||
parent=self.parentWidget,
|
||||
mode=WidgetDatabaseProperties.ModeNew,
|
||||
title='New database'
|
||||
)
|
||||
response = dlg.run()
|
||||
if response == gtk.RESPONSE_ACCEPT:
|
||||
database = dlg.get_widget_database_properties().get_database()
|
||||
#TODO: initing may or may not take a while. how to handle?
|
||||
error = database.init_new_database()
|
||||
if error:
|
||||
DialogError(parent=dlg, msg=error)
|
||||
dlg.destroy()
|
||||
continue
|
||||
else:
|
||||
database = None
|
||||
dlg.destroy()
|
||||
break
|
||||
|
||||
|
||||
if database is None:
|
||||
return
|
||||
|
||||
self.databaseManager.add_database(database)
|
||||
model = self.treeDatabases.get_model()
|
||||
it = model.append()
|
||||
model.set_value(it, self.treeDatabaseColumns['name'], database.name)
|
||||
model.set_value(it, self.treeDatabaseColumns['status'], self.databaseStatusNames[database.status] )
|
||||
model.set_value(it, self.treeDatabaseColumns['type'], database.display_name() )
|
||||
model.set_value(it, self.treeDatabaseColumns['_id'], self.databaseManager.database_id(database))
|
||||
|
||||
|
||||
def on_button_database_add_clicked(self, button):
|
||||
databaseKlass = self.databaseManager.get_default_database_type()
|
||||
if databaseKlass is None:
|
||||
raise ValueError('no defult database type set')
|
||||
database = databaseKlass()
|
||||
|
||||
while True:
|
||||
dlg = DialogDatabaseProperties(
|
||||
self.databaseManager,
|
||||
database,
|
||||
parent=self.parentWidget,
|
||||
mode=WidgetDatabaseProperties.ModeAdd,
|
||||
title='Add database'
|
||||
)
|
||||
response = dlg.run()
|
||||
if response == gtk.RESPONSE_ACCEPT:
|
||||
database = dlg.get_widget_database_properties().get_database()
|
||||
#TODO: validating may or may not take a while. how to handle?
|
||||
error = database.validate_database()
|
||||
if error:
|
||||
DialogError(parent=self.parentWidget, msg=error)
|
||||
dlg.destroy()
|
||||
continue
|
||||
else:
|
||||
database = None
|
||||
dlg.destroy()
|
||||
break
|
||||
|
||||
if database is None:
|
||||
return
|
||||
|
||||
self.databaseManager.add_database(database)
|
||||
model = self.treeDatabases.get_model()
|
||||
it = model.append()
|
||||
model.set_value(it, self.treeDatabaseColumns['name'], database.name)
|
||||
model.set_value(it, self.treeDatabaseColumns['status'], self.databaseStatusNames[database.status] )
|
||||
model.set_value(it, self.treeDatabaseColumns['type'], database.display_name() )
|
||||
model.set_value(it, self.treeDatabaseColumns['_id'], self.databaseManager.database_id(database))
|
||||
dlg.destroy()
|
||||
|
||||
def on_button_database_edit_clicked(self, button):
|
||||
selection = self.treeDatabases.get_selection()
|
||||
if selection is None:
|
||||
return
|
||||
|
||||
model, it = selection.get_selected()
|
||||
idDatabase = model.get_value(it, self.treeDatabaseColumns['_id'])
|
||||
database = self.databaseManager.database_from_id(idDatabase)
|
||||
dlg = DialogDatabaseProperties(
|
||||
self.databaseManager,
|
||||
database,
|
||||
parent=self.parentWidget,
|
||||
mode=WidgetDatabaseProperties.ModeEdit,
|
||||
title='Edit database'
|
||||
)
|
||||
response = dlg.run()
|
||||
if response == gtk.RESPONSE_REJECT:
|
||||
pass
|
||||
elif response == gtk.RESPONSE_ACCEPT:
|
||||
database = dlg.get_database()
|
||||
selection = self.treeDatabases.get_selection()
|
||||
if selection is not None:
|
||||
model, it = selection.get_selected()
|
||||
model.set_value(it, self.treeDatabaseColumns['name'], database.name)
|
||||
dlg.destroy()
|
||||
|
||||
|
||||
def on_button_database_remove_clicked(self, button):
|
||||
selection = self.treeDatabases.get_selection()
|
||||
if selection is None:
|
||||
return
|
||||
|
||||
model, it = selection.get_selected()
|
||||
#TODO: finalize database
|
||||
model.remove(it)
|
||||
|
||||
|
||||
def on_tree_databases_selection_changed(self, treeSelection):
|
||||
hasSelection = bool(treeSelection.count_selected_rows())
|
||||
|
||||
# enable/disable selection dependend widgets
|
||||
self.buttonDatabaseActivate.set_sensitive(hasSelection)
|
||||
self.buttonDatabaseEdit.set_sensitive(hasSelection)
|
||||
self.buttonDatabaseRemove.set_sensitive(hasSelection)
|
||||
#self.buttonDatabaseDelete.set_sensitive(hasSelection)
|
||||
|
||||
|
||||
class DialogDatabaseManager(gtk.Dialog):
|
||||
def __init__(self, databaseManager, parent=None):
|
||||
gtk.Dialog.__init__(self,
|
||||
title="Databases",
|
||||
parent=parent,
|
||||
flags=gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT,
|
||||
buttons=(
|
||||
gtk.STOCK_CANCEL, gtk.RESPONSE_REJECT,
|
||||
gtk.STOCK_OK, gtk.RESPONSE_ACCEPT,
|
||||
))
|
||||
#self.set_size_request(260, 250)
|
||||
self.widgetDatabaseManager = WidgetDatabaseManager(databaseManager, parentWidget=self)
|
||||
self.vbox.pack_start(self.widgetDatabaseManager, True, True)
|
||||
self.show_all()
|
||||
|
||||
#**************************************************************************************************
|
||||
if __name__ == '__main__':
|
||||
databaseManager = DatabaseManager.from_fpdb('', defaultDatabaseType=DatabaseTypeSqLite)
|
||||
|
||||
#d = DialogDatabaseProperties(
|
||||
# DatabaseManager(defaultDatabaseType=DatabaseTypeSqLite),
|
||||
#database=DatabaseTypePostgres(),
|
||||
# database=None,
|
||||
# )
|
||||
d = DialogDatabaseManager(databaseManager)
|
||||
d.connect("destroy", gtk.main_quit)
|
||||
d.run()
|
||||
#gtk.main()
|
|
@ -1,6 +1,7 @@
|
|||
#!/usr/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
#Copyright 2008 Carl Gherardi
|
||||
#Copyright 2008-2010 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.
|
||||
|
@ -12,8 +13,7 @@
|
|||
#
|
||||
#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.
|
||||
#In the "official" distribution you can find the license in agpl-3.0.txt.
|
||||
|
||||
#fpdb modules
|
||||
import Card
|
||||
|
@ -53,26 +53,28 @@ class DerivedStats():
|
|||
self.handsplayers[player[1]]['street0_3BDone'] = False
|
||||
self.handsplayers[player[1]]['street0_4BChance'] = False
|
||||
self.handsplayers[player[1]]['street0_4BDone'] = False
|
||||
self.handsplayers[player[1]]['stealAttemptChance'] = False
|
||||
self.handsplayers[player[1]]['stealAttempted'] = False
|
||||
self.handsplayers[player[1]]['raiseFirstInChance'] = False
|
||||
self.handsplayers[player[1]]['raisedFirstIn'] = False
|
||||
self.handsplayers[player[1]]['foldBbToStealChance'] = False
|
||||
self.handsplayers[player[1]]['foldSbToStealChance'] = False
|
||||
self.handsplayers[player[1]]['foldedSbToSteal'] = False
|
||||
self.handsplayers[player[1]]['foldedBbToSteal'] = False
|
||||
self.handsplayers[player[1]]['tourneyTypeId'] = None
|
||||
|
||||
for i in range(5):
|
||||
self.handsplayers[player[1]]['street%dCalls' % i] = 0
|
||||
self.handsplayers[player[1]]['street%dBets' % i] = 0
|
||||
self.handsplayers[player[1]]['street%dRaises' % i] = 0
|
||||
for i in range(1,5):
|
||||
self.handsplayers[player[1]]['street%dCBChance' %i] = False
|
||||
self.handsplayers[player[1]]['street%dCBDone' %i] = False
|
||||
self.handsplayers[player[1]]['street%dCheckCallRaiseChance' %i] = False
|
||||
self.handsplayers[player[1]]['street%dCheckCallRaiseDone' %i] = False
|
||||
|
||||
#FIXME - Everything below this point is incomplete.
|
||||
self.handsplayers[player[1]]['tourneyTypeId'] = 1
|
||||
for i in range(1,5):
|
||||
self.handsplayers[player[1]]['otherRaisedStreet%d' %i] = False
|
||||
self.handsplayers[player[1]]['foldToOtherRaisedStreet%d' %i] = False
|
||||
|
||||
#FIXME - Everything below this point is incomplete.
|
||||
for i in range(1,5):
|
||||
self.handsplayers[player[1]]['foldToStreet%dCBChance' %i] = False
|
||||
self.handsplayers[player[1]]['foldToStreet%dCBDone' %i] = False
|
||||
|
||||
|
@ -96,11 +98,12 @@ class DerivedStats():
|
|||
self.hands['tableName'] = hand.tablename
|
||||
self.hands['siteHandNo'] = hand.handid
|
||||
self.hands['gametypeId'] = None # Leave None, handled later after checking db
|
||||
self.hands['handStart'] = hand.starttime # format this!
|
||||
self.hands['startTime'] = hand.startTime # format this!
|
||||
self.hands['importTime'] = None
|
||||
self.hands['seats'] = self.countPlayers(hand)
|
||||
self.hands['maxSeats'] = hand.maxseats
|
||||
self.hands['texture'] = None # No calculation done for this yet.
|
||||
self.hands['tourneyId'] = hand.tourneyId
|
||||
|
||||
# This (i think...) is correct for both stud and flop games, as hand.board['street'] disappears, and
|
||||
# those values remain default in stud.
|
||||
|
@ -138,7 +141,15 @@ class DerivedStats():
|
|||
for player in hand.players:
|
||||
self.handsplayers[player[1]]['seatNo'] = player[0]
|
||||
self.handsplayers[player[1]]['startCash'] = int(100 * Decimal(player[2]))
|
||||
self.handsplayers[player[1]]['sitout'] = False #TODO: implement actual sitout detection
|
||||
if hand.gametype["type"]=="tour":
|
||||
self.handsplayers[player[1]]['tourneyTypeId']=hand.tourneyTypeId
|
||||
self.handsplayers[player[1]]['tourneysPlayersIds'] = hand.tourneysPlayersIds[player[1]]
|
||||
else:
|
||||
self.handsplayers[player[1]]['tourneysPlayersIds'] = None
|
||||
|
||||
# XXX: enumerate(list, start=x) is python 2.6 syntax; 'start'
|
||||
#for i, street in enumerate(hand.actionStreets[2:], start=1):
|
||||
for i, street in enumerate(hand.actionStreets[2:]):
|
||||
self.seen(self.hand, i+1)
|
||||
|
||||
|
@ -146,6 +157,8 @@ class DerivedStats():
|
|||
self.aggr(self.hand, i)
|
||||
self.calls(self.hand, i)
|
||||
self.bets(self.hand, i)
|
||||
if i>0:
|
||||
self.folds(self.hand, i)
|
||||
|
||||
# Winnings is a non-negative value of money collected from the pot, which already includes the
|
||||
# rake taken out. hand.collectees is Decimal, database requires cents
|
||||
|
@ -277,7 +290,10 @@ class DerivedStats():
|
|||
# print "p_actions:", self.pfba(actions), "p_folds:", self.pfba(actions, l=('folds',)), "alliners:", alliners
|
||||
# pas = set.union(self.pfba(actions) - self.pfba(actions, l=('folds',)), alliners)
|
||||
|
||||
p_in = set(x[1] for x in hand.players)
|
||||
# hand.players includes people that are sitting out on some sites.
|
||||
# Those that posted an ante should have been deal cards.
|
||||
p_in = set([x[0] for x in hand.actions['BLINDSANTES']] + [x[0] for x in hand.actions['PREFLOP']])
|
||||
|
||||
for (i, street) in enumerate(hand.actionStreets):
|
||||
actions = hand.actions[street]
|
||||
p_in = p_in - self.pfba(actions, l=('folds',))
|
||||
|
@ -302,13 +318,14 @@ class DerivedStats():
|
|||
self.hands['street%dRaises' % i] = len(filter( lambda action: action[1] in ('raises','bets'), hand.actions[street]))
|
||||
|
||||
def calcSteals(self, hand):
|
||||
"""Fills stealAttempt(Chance|ed, fold(Bb|Sb)ToSteal(Chance|)
|
||||
"""Fills raiseFirstInChance|raisedFirstIn, fold(Bb|Sb)ToSteal(Chance|)
|
||||
|
||||
Steal attempt - open raise on positions 1 0 S - i.e. MP3, CO, BU, SB
|
||||
Steal attempt - open raise on positions 1 0 S - i.e. CO, BU, SB
|
||||
(note: I don't think PT2 counts SB steals in HU hands, maybe we shouldn't?)
|
||||
Fold to steal - folding blind after steal attemp wo any other callers or raisers
|
||||
"""
|
||||
steal_attempt = False
|
||||
raised = False
|
||||
steal_positions = (1, 0, 'S')
|
||||
if hand.gametype['base'] == 'stud':
|
||||
steal_positions = (2, 1, 0)
|
||||
|
@ -328,10 +345,12 @@ class DerivedStats():
|
|||
if steal_attempt and act != 'folds':
|
||||
break
|
||||
|
||||
if posn in steal_positions and not steal_attempt:
|
||||
self.handsplayers[pname]['stealAttemptChance'] = True
|
||||
if not steal_attempt and not raised: # if posn in steal_positions and not steal_attempt:
|
||||
self.handsplayers[pname]['raiseFirstInChance'] = True
|
||||
if act in ('bets', 'raises'):
|
||||
self.handsplayers[pname]['stealAttempted'] = True
|
||||
self.handsplayers[pname]['raisedFirstIn'] = True
|
||||
raised = True
|
||||
if posn in steal_positions:
|
||||
steal_attempt = True
|
||||
if act == 'calls':
|
||||
break
|
||||
|
@ -368,8 +387,8 @@ class DerivedStats():
|
|||
name = self.lastBetOrRaiser(hand.actionStreets[i+1])
|
||||
if name:
|
||||
chance = self.noBetsBefore(hand.actionStreets[i+2], name)
|
||||
self.handsplayers[name]['street%dCBChance' % (i+1)] = True
|
||||
if chance == True:
|
||||
self.handsplayers[name]['street%dCBChance' % (i+1)] = True
|
||||
self.handsplayers[name]['street%dCBDone' % (i+1)] = self.betStreet(hand.actionStreets[i+2], name)
|
||||
|
||||
def calcCheckCallRaise(self, hand):
|
||||
|
@ -380,6 +399,7 @@ class DerivedStats():
|
|||
|
||||
CG: CheckCall would be a much better name for this.
|
||||
"""
|
||||
# XXX: enumerate(list, start=x) is python 2.6 syntax; 'start'
|
||||
#for i, street in enumerate(hand.actionStreets[2:], start=1):
|
||||
for i, street in enumerate(hand.actionStreets[2:]):
|
||||
actions = hand.actions[hand.actionStreets[i+1]]
|
||||
|
@ -408,10 +428,16 @@ class DerivedStats():
|
|||
|
||||
def aggr(self, hand, i):
|
||||
aggrers = set()
|
||||
others = set()
|
||||
# Growl - actionStreets contains 'BLINDSANTES', which isn't actually an action street
|
||||
|
||||
firstAggrMade=False
|
||||
for act in hand.actions[hand.actionStreets[i+1]]:
|
||||
if firstAggrMade:
|
||||
others.add(act[0])
|
||||
if act[1] in ('completes', 'bets', 'raises'):
|
||||
aggrers.add(act[0])
|
||||
firstAggrMade=True
|
||||
|
||||
for player in hand.players:
|
||||
#print "DEBUG: actionStreet[%s]: %s" %(hand.actionStreets[i+1], i)
|
||||
|
@ -420,6 +446,17 @@ class DerivedStats():
|
|||
else:
|
||||
self.handsplayers[player[1]]['street%sAggr' % i] = False
|
||||
|
||||
if len(aggrers)>0 and i>0:
|
||||
for playername in others:
|
||||
self.handsplayers[playername]['otherRaisedStreet%s' % i] = True
|
||||
#print "otherRaised detected on handid "+str(hand.handid)+" for "+playername+" on street "+str(i)
|
||||
|
||||
if i > 0 and len(aggrers) > 0:
|
||||
for playername in others:
|
||||
self.handsplayers[playername]['otherRaisedStreet%s' % i] = True
|
||||
#print "DEBUG: otherRaised detected on handid %s for %s on actionStreet[%s]: %s"
|
||||
# %(hand.handid, playername, hand.actionStreets[i+1], i)
|
||||
|
||||
def calls(self, hand, i):
|
||||
callers = []
|
||||
for act in hand.actions[hand.actionStreets[i+1]]:
|
||||
|
@ -429,11 +466,18 @@ class DerivedStats():
|
|||
# CG - I'm sure this stat is wrong
|
||||
# Best guess is that raise = 2 bets
|
||||
def bets(self, hand, i):
|
||||
betters = []
|
||||
for act in hand.actions[hand.actionStreets[i+1]]:
|
||||
if act[1] in ('bets'):
|
||||
self.handsplayers[act[0]]['street%sBets' % i] = 1 + self.handsplayers[act[0]]['street%sBets' % i]
|
||||
|
||||
def folds(self, hand, i):
|
||||
for act in hand.actions[hand.actionStreets[i+1]]:
|
||||
if act[1] in ('folds'):
|
||||
if self.handsplayers[act[0]]['otherRaisedStreet%s' % i] == True:
|
||||
self.handsplayers[act[0]]['foldToOtherRaisedStreet%s' % i] = True
|
||||
#print "DEBUG: fold detected on handid %s for %s on actionStreet[%s]: %s"
|
||||
# %(hand.handid, act[0],hand.actionStreets[i+1], i)
|
||||
|
||||
def countPlayers(self, hand):
|
||||
pass
|
||||
|
||||
|
@ -505,9 +549,14 @@ class DerivedStats():
|
|||
"""Returns true if player bet/raised the street as their first action"""
|
||||
betOrRaise = False
|
||||
for act in self.hand.actions[street]:
|
||||
if act[0] == player and act[1] in ('bets', 'raises'):
|
||||
if act[0] == player:
|
||||
if act[1] in ('bets', 'raises'):
|
||||
betOrRaise = True
|
||||
else:
|
||||
# player found but did not bet or raise as their first action
|
||||
pass
|
||||
break
|
||||
#else:
|
||||
# haven't found player's first action yet
|
||||
return betOrRaise
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# Copyright 2008, Carl Gherardi
|
||||
# Copyright 2008-2010, 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
|
||||
|
@ -34,11 +34,11 @@ class Everleaf(HandHistoryConverter):
|
|||
# Static regexes
|
||||
re_SplitHands = re.compile(r"\n\n\n+")
|
||||
re_TailSplitHands = re.compile(r"(\n\n\n+)")
|
||||
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)
|
||||
#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)
|
||||
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)
|
||||
re_Button = re.compile(ur"^Seat (?P<BUTTON>\d+) is the button", re.MULTILINE)
|
||||
re_PlayerInfo = re.compile(ur"^Seat (?P<SEAT>[0-9]+): (?P<PNAME>.*) \(\s+((?:\$| €|) (?P<CASH>[.0-9]+) (USD|EURO|Chips)|new player|All-in) \)", re.MULTILINE)
|
||||
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)
|
||||
#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)
|
||||
re_HandInfo = re.compile(ur".*#(?P<HID>[0-9]+)\n.*\n(Blinds )?(?P<CURRENCY>[$€])?(?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)
|
||||
re_Button = re.compile(ur"^Seat (?P<BUTTON>\d+) is the button$", re.MULTILINE)
|
||||
re_PlayerInfo = re.compile(ur"^Seat (?P<SEAT>[0-9]+): (?P<PNAME>.*) \(\s+([$€]? (?P<CASH>[.0-9]+) (USD|EURO|Chips)|new player|All-in) \)$", re.MULTILINE)
|
||||
re_Board = re.compile(ur"\[ (?P<CARDS>.+) \]")
|
||||
re_TourneyInfoFromFilename = re.compile(ur".*TID_(?P<TOURNO>[0-9]+)-(?P<TABLE>[0-9]+)\.txt")
|
||||
|
||||
|
@ -50,16 +50,16 @@ class Everleaf(HandHistoryConverter):
|
|||
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|EURO|Chips)\])?" % 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_PostSB = re.compile(ur"^%s: posts small blind \[[$€]? (?P<SB>[.0-9]+)\s.*\]$" % player_re, re.MULTILINE)
|
||||
self.re_PostBB = re.compile(ur"^%s: posts big blind \[[$€]? (?P<BB>[.0-9]+)\s.*\]$" % player_re, re.MULTILINE)
|
||||
self.re_PostBoth = re.compile(ur"^%s: posts both blinds \[[$€]? (?P<SBBB>[.0-9]+)\s.*\]$" % player_re, re.MULTILINE)
|
||||
self.re_Antes = re.compile(ur"^%s: posts ante \[[$€]? (?P<ANTE>[.0-9]+)\s.*\]$" % 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)
|
||||
# ^%s(?P<ATYPE>: bets| checks| raises| calls| folds)(\s\[(?:\$| €|) (?P<BET>[.,\d]+) (USD|EURO|Chips)\])?
|
||||
self.re_Action = re.compile(ur"^%s(?P<ATYPE>: bets| checks| raises| calls| folds)(\s\[(?:[$€]?) (?P<BET>[.,\d]+)\s?(USD|EURO|Chips|)\])?" % 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|EURO|chips)(.*?\[ (?P<CARDS>.*?) \])?" % player_re, re.MULTILINE)
|
||||
self.re_CollectPot = re.compile(ur"^%s wins (?:[$€]?)\s?(?P<POT>[.\d]+) (USD|EURO|chips)(.*?\[ (?P<CARDS>.*?) \])?" % player_re, re.MULTILINE)
|
||||
self.re_SitsOut = re.compile(ur"^%s sits out" % player_re, re.MULTILINE)
|
||||
|
||||
def readSupportedGames(self):
|
||||
|
@ -141,20 +141,26 @@ or None if we fail to get the info """
|
|||
hand.tablename = m.group('TABLE')
|
||||
hand.maxseats = 6 # assume 6-max unless we have proof it's a larger/smaller game, since everleaf doesn't give seat max info
|
||||
|
||||
currencies = { u'€':'EUR', '$':'USD', '':'T$', None:'T$' }
|
||||
mg = m.groupdict()
|
||||
hand.gametype['currency'] = currencies[mg['CURRENCY']]
|
||||
|
||||
|
||||
t = self.re_TourneyInfoFromFilename.search(self.in_path)
|
||||
if t:
|
||||
tourno = t.group('TOURNO')
|
||||
hand.tourNo = tourno
|
||||
hand.tablename = t.group('TABLE')
|
||||
#TODO we should fetch info including buyincurrency, buyin and fee from URL:
|
||||
# https://www.poker4ever.com/tourney/%TOURNEY_NUMBER%
|
||||
|
||||
# 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]
|
||||
# or : 2008/11/07 12:38:49 ET
|
||||
# Not getting it in my HH files yet, so using
|
||||
# 2008/11/10 3:58:52 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)
|
||||
hand.starttime = datetime.datetime.strptime(m.group('DATETIME'), "%Y/%m/%d - %H:%M:%S")
|
||||
hand.startTime = datetime.datetime.strptime(m.group('DATETIME'), "%Y/%m/%d - %H:%M:%S")
|
||||
return
|
||||
|
||||
def readPlayerStacks(self, hand):
|
||||
|
|
|
@ -1,3 +1,20 @@
|
|||
#!/usr/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
#Copyright 2009-2010 Matt Turnbull
|
||||
#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.
|
||||
|
||||
class FpdbError(Exception):
|
||||
def __init__(self, value):
|
||||
self.value = value
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#!/usr/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
#Copyright 2008 Steffen Jobbagy-Felso
|
||||
#Copyright 2008-2010 Steffen Schaumburg
|
||||
#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.
|
||||
|
@ -12,8 +13,7 @@
|
|||
#
|
||||
#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.
|
||||
#In the "official" distribution you can find the license in agpl-3.0.txt.
|
||||
|
||||
import threading
|
||||
import pygtk
|
||||
|
@ -22,7 +22,7 @@ import gtk
|
|||
import os
|
||||
import sys
|
||||
from optparse import OptionParser
|
||||
from time import *
|
||||
from time import gmtime, mktime, strftime, strptime
|
||||
import gobject
|
||||
#import pokereval
|
||||
|
||||
|
@ -35,7 +35,7 @@ import Configuration
|
|||
import Database
|
||||
import SQL
|
||||
import Charset
|
||||
|
||||
import Filters
|
||||
|
||||
class Filters(threading.Thread):
|
||||
def __init__(self, db, config, qdict, display = {}, debug=True):
|
||||
|
@ -58,9 +58,15 @@ class Filters(threading.Thread):
|
|||
,'limitsFL':'FL', 'limitsNL':'NL', 'limitsPL':'PL', 'ring':'Ring', 'tour':'Tourney'
|
||||
}
|
||||
|
||||
gen = self.conf.get_general_params()
|
||||
self.day_start = 0
|
||||
if 'day_start' in gen:
|
||||
self.day_start = float(gen['day_start'])
|
||||
|
||||
# Outer Packing box
|
||||
self.mainVBox = gtk.VBox(False, 0)
|
||||
|
||||
self.found = {'nl':False, 'fl':False, 'pl':False, 'ring':False, 'tour':False}
|
||||
self.label = {}
|
||||
self.callback = {}
|
||||
|
||||
|
@ -83,7 +89,7 @@ class Filters(threading.Thread):
|
|||
if len(result) == 1:
|
||||
self.siteid[site] = result[0][0]
|
||||
else:
|
||||
print "Either 0 or more than one site matched - EEK"
|
||||
print "Either 0 or more than one site matched (%s) - EEK" % site
|
||||
|
||||
# For use in date ranges.
|
||||
self.start_date = gtk.Entry(max=12)
|
||||
|
@ -221,18 +227,31 @@ class Filters(threading.Thread):
|
|||
|
||||
def getNumHands(self):
|
||||
return self.numHands
|
||||
#end def getNumHands
|
||||
|
||||
def getNumTourneys(self):
|
||||
return self.numTourneys
|
||||
#end def getNumTourneys
|
||||
|
||||
def getSites(self):
|
||||
return self.sites
|
||||
#end def getSites
|
||||
|
||||
def getTourneyTypes(self):
|
||||
return self.tourneyTypes
|
||||
#end def getTourneyTypes
|
||||
|
||||
def getGames(self):
|
||||
return self.games
|
||||
#end def getGames
|
||||
|
||||
def getSiteIds(self):
|
||||
return self.siteid
|
||||
#end def getSiteIds
|
||||
|
||||
def getHeroes(self):
|
||||
return self.heroes
|
||||
#end def getHeroes
|
||||
|
||||
def getLimits(self):
|
||||
ltuple = []
|
||||
|
@ -250,12 +269,14 @@ class Filters(threading.Thread):
|
|||
if 'to' in self.sbSeats:
|
||||
self.seats['to'] = self.sbSeats['to'].get_value_as_int()
|
||||
return self.seats
|
||||
#end def getSeats
|
||||
|
||||
def getGroups(self):
|
||||
return self.groups
|
||||
|
||||
def getDates(self):
|
||||
return self.__get_dates()
|
||||
#end def getDates
|
||||
|
||||
def registerButton1Name(self, title):
|
||||
self.Button1.set_label(title)
|
||||
|
@ -269,11 +290,13 @@ class Filters(threading.Thread):
|
|||
def registerButton2Name(self, title):
|
||||
self.Button2.set_label(title)
|
||||
self.label['button2'] = title
|
||||
#end def registerButton2Name
|
||||
|
||||
def registerButton2Callback(self, callback):
|
||||
self.Button2.connect("clicked", callback, "clicked")
|
||||
self.Button2.set_sensitive(True)
|
||||
self.callback['button2'] = callback
|
||||
#end def registerButton2Callback
|
||||
|
||||
def cardCallback(self, widget, data=None):
|
||||
log.debug( "%s was toggled %s" % (data, ("OFF", "ON")[widget.get_active()]) )
|
||||
|
@ -302,6 +325,7 @@ class Filters(threading.Thread):
|
|||
liststore.append(_nt)
|
||||
|
||||
self.__set_hero_name(pname, site)
|
||||
#end def createPlayerLine
|
||||
|
||||
def __set_hero_name(self, w, site):
|
||||
_name = w.get_text()
|
||||
|
@ -309,6 +333,7 @@ class Filters(threading.Thread):
|
|||
_guiname = unicode(_name)
|
||||
self.heroes[site] = _guiname
|
||||
#log.debug("setting heroes[%s]: %s"%(site, self.heroes[site]))
|
||||
#end def __set_hero_name
|
||||
|
||||
def __set_num_hands(self, w, val):
|
||||
try:
|
||||
|
@ -316,12 +341,27 @@ class Filters(threading.Thread):
|
|||
except:
|
||||
self.numHands = 0
|
||||
#log.debug("setting numHands:", self.numHands)
|
||||
#end def __set_num_hands
|
||||
|
||||
def createSiteLine(self, hbox, site):
|
||||
cb = gtk.CheckButton(site)
|
||||
cb.connect('clicked', self.__set_site_select, site)
|
||||
cb.set_active(True)
|
||||
hbox.pack_start(cb, False, False, 0)
|
||||
#end def createSiteLine
|
||||
|
||||
def __set_tourney_type_select(self, w, tourneyType):
|
||||
#print w.get_active()
|
||||
self.tourneyTypes[tourneyType] = w.get_active()
|
||||
log.debug("self.tourney_types[%s] set to %s" %(tourneyType, self.tourneyTypes[tourneyType]))
|
||||
#end def __set_tourney_type_select
|
||||
|
||||
def createTourneyTypeLine(self, hbox, tourneyType):
|
||||
cb = gtk.CheckButton(str(tourneyType))
|
||||
cb.connect('clicked', self.__set_tourney_type_select, tourneyType)
|
||||
hbox.pack_start(cb, False, False, 0)
|
||||
cb.set_active(True)
|
||||
#end def createTourneyTypeLine
|
||||
|
||||
def createGameLine(self, hbox, game):
|
||||
cb = gtk.CheckButton(game)
|
||||
|
@ -341,14 +381,16 @@ class Filters(threading.Thread):
|
|||
#print w.get_active()
|
||||
self.sites[site] = w.get_active()
|
||||
log.debug("self.sites[%s] set to %s" %(site, self.sites[site]))
|
||||
#end def __set_site_select
|
||||
|
||||
def __set_game_select(self, w, game):
|
||||
#print w.get_active()
|
||||
self.games[game] = w.get_active()
|
||||
log.debug("self.games[%s] set to %s" %(game, self.games[game]))
|
||||
#end def __set_game_select
|
||||
|
||||
def __set_limit_select(self, w, limit):
|
||||
#print w.get_active()
|
||||
#print "__set_limit_select: limit =", limit, w.get_active()
|
||||
self.limits[limit] = w.get_active()
|
||||
log.debug("self.limit[%s] set to %s" %(limit, self.limits[limit]))
|
||||
if limit.isdigit() or (len(limit) > 2 and (limit[-2:] == 'nl' or limit[-2:] == 'fl' or limit[-2:] == 'pl')):
|
||||
|
@ -488,6 +530,7 @@ class Filters(threading.Thread):
|
|||
#print "__set_seat_select: seat =", seat, "active =", w.get_active()
|
||||
self.seats[seat] = w.get_active()
|
||||
log.debug( "self.seats[%s] set to %s" %(seat, self.seats[seat]) )
|
||||
#end def __set_seat_select
|
||||
|
||||
def __set_group_select(self, w, group):
|
||||
#print "__set_seat_select: seat =", seat, "active =", w.get_active()
|
||||
|
@ -535,6 +578,7 @@ class Filters(threading.Thread):
|
|||
hbox.pack_start(phands, False, False, 0)
|
||||
phands.connect("changed", self.__set_num_hands, site)
|
||||
top_hbox.pack_start(showb, expand=False, padding=1)
|
||||
#end def fillPlayerFrame
|
||||
|
||||
def fillSitesFrame(self, vbox):
|
||||
top_hbox = gtk.HBox(False, 0)
|
||||
|
@ -566,6 +610,33 @@ class Filters(threading.Thread):
|
|||
# self.siteid[site] = result[0][0]
|
||||
#else:
|
||||
# print "Either 0 or more than one site matched - EEK"
|
||||
#end def fillSitesFrame
|
||||
|
||||
def fillTourneyTypesFrame(self, vbox):
|
||||
top_hbox = gtk.HBox(False, 0)
|
||||
vbox.pack_start(top_hbox, False, False, 0)
|
||||
lbl_title = gtk.Label(self.filterText['tourneyTypesTitle'])
|
||||
lbl_title.set_alignment(xalign=0.0, yalign=0.5)
|
||||
top_hbox.pack_start(lbl_title, expand=True, padding=3)
|
||||
showb = gtk.Button(label="hide", stock=None, use_underline=True)
|
||||
showb.set_alignment(xalign=1.0, yalign=0.5)
|
||||
showb.connect('clicked', self.__toggle_box, 'tourneyTypes')
|
||||
top_hbox.pack_start(showb, expand=False, padding=1)
|
||||
|
||||
vbox1 = gtk.VBox(False, 0)
|
||||
vbox.pack_start(vbox1, False, False, 0)
|
||||
self.boxes['tourneyTypes'] = vbox1
|
||||
|
||||
result = self.db.getTourneyTypesIds()
|
||||
if len(result) >= 1:
|
||||
for line in result:
|
||||
hbox = gtk.HBox(False, 0)
|
||||
vbox1.pack_start(hbox, False, True, 0)
|
||||
self.createTourneyTypeLine(hbox, line[0])
|
||||
else:
|
||||
print "INFO: No tourney types returned from database"
|
||||
log.info("No tourney types returned from database")
|
||||
#end def fillTourneyTypesFrame
|
||||
|
||||
def fillGamesFrame(self, vbox):
|
||||
top_hbox = gtk.HBox(False, 0)
|
||||
|
@ -592,6 +663,7 @@ class Filters(threading.Thread):
|
|||
else:
|
||||
print "INFO: No games returned from database"
|
||||
log.info("No games returned from database")
|
||||
#end def fillGamesFrame
|
||||
|
||||
def fillLimitsFrame(self, vbox, display):
|
||||
top_hbox = gtk.HBox(False, 0)
|
||||
|
@ -607,10 +679,10 @@ class Filters(threading.Thread):
|
|||
vbox.pack_start(vbox1, False, False, 0)
|
||||
self.boxes['limits'] = vbox1
|
||||
|
||||
self.cursor.execute(self.sql.query['getLimits3'])
|
||||
self.cursor.execute(self.sql.query['getCashLimits'])
|
||||
# selects limitType, bigBlind
|
||||
result = self.db.cursor.fetchall()
|
||||
found = {'nl':False, 'fl':False, 'pl':False, 'ring':False, 'tour':False}
|
||||
self.found = {'nl':False, 'fl':False, 'pl':False, 'ring':False, 'tour':False}
|
||||
|
||||
if len(result) >= 1:
|
||||
hbox = gtk.HBox(True, 0)
|
||||
|
@ -631,16 +703,16 @@ class Filters(threading.Thread):
|
|||
if True: #line[0] == 'ring':
|
||||
if line[1] == 'fl':
|
||||
name = str(line[2])
|
||||
found['fl'] = True
|
||||
self.found['fl'] = True
|
||||
elif line[1] == 'pl':
|
||||
name = str(line[2])+line[1]
|
||||
found['pl'] = True
|
||||
self.found['pl'] = True
|
||||
else:
|
||||
name = str(line[2])+line[1]
|
||||
found['nl'] = True
|
||||
self.found['nl'] = True
|
||||
self.cbLimits[name] = self.createLimitLine(hbox, name, name)
|
||||
self.types[name] = line[0]
|
||||
found[line[0]] = True # type is ring/tour
|
||||
self.found[line[0]] = True # type is ring/tour
|
||||
self.type = line[0] # if only one type, set it now
|
||||
if "LimitSep" in display and display["LimitSep"] == True and len(result) >= 2:
|
||||
hbox = gtk.HBox(True, 0)
|
||||
|
@ -658,15 +730,21 @@ class Filters(threading.Thread):
|
|||
self.cbNoLimits = self.createLimitLine(hbox, 'none', self.filterText['limitsnone'])
|
||||
|
||||
dest = vbox3 # for ring/tour buttons
|
||||
if "LimitType" in display and display["LimitType"] == True and found['nl'] and found['fl']:
|
||||
#if found['fl']:
|
||||
if "LimitType" in display and display["LimitType"] == True:
|
||||
num_limit_types = 0
|
||||
if self.found['fl']: num_limit_types = num_limit_types + 1
|
||||
if self.found['pl']: num_limit_types = num_limit_types + 1
|
||||
if self.found['nl']: num_limit_types = num_limit_types + 1
|
||||
if num_limit_types > 1:
|
||||
if self.found['fl']:
|
||||
hbox = gtk.HBox(False, 0)
|
||||
vbox3.pack_start(hbox, False, False, 0)
|
||||
self.cbFL = self.createLimitLine(hbox, 'fl', self.filterText['limitsFL'])
|
||||
#if found['nl']:
|
||||
if self.found['nl']:
|
||||
hbox = gtk.HBox(False, 0)
|
||||
vbox3.pack_start(hbox, False, False, 0)
|
||||
self.cbNL = self.createLimitLine(hbox, 'nl', self.filterText['limitsNL'])
|
||||
if self.found['pl']:
|
||||
hbox = gtk.HBox(False, 0)
|
||||
vbox3.pack_start(hbox, False, False, 0)
|
||||
self.cbPL = self.createLimitLine(hbox, 'pl', self.filterText['limitsPL'])
|
||||
|
@ -675,7 +753,7 @@ class Filters(threading.Thread):
|
|||
print "INFO: No games returned from database"
|
||||
log.info("No games returned from database")
|
||||
|
||||
if "Type" in display and display["Type"] == True and found['ring'] and found['tour']:
|
||||
if "Type" in display and display["Type"] == True and self.found['ring'] and self.found['tour']:
|
||||
rb1 = gtk.RadioButton(None, self.filterText['ring'])
|
||||
rb1.connect('clicked', self.__set_limit_select, 'ring')
|
||||
rb2 = gtk.RadioButton(rb1, self.filterText['tour'])
|
||||
|
@ -724,6 +802,7 @@ class Filters(threading.Thread):
|
|||
|
||||
self.sbSeats['from'] = sb1
|
||||
self.sbSeats['to'] = sb2
|
||||
#end def fillSeatsFrame
|
||||
|
||||
def fillGroupsFrame(self, vbox, display):
|
||||
hbox = gtk.HBox(False, 0)
|
||||
|
@ -828,11 +907,13 @@ class Filters(threading.Thread):
|
|||
hbox.pack_start(self.end_date, expand=False, padding=2)
|
||||
|
||||
hbox.pack_start(btn_clear, expand=False, padding=15)
|
||||
#end def fillDateFrame
|
||||
|
||||
def __refresh(self, widget, entry):
|
||||
for w in self.mainVBox.get_children():
|
||||
w.destroy()
|
||||
self.make_filter()
|
||||
#end def __refresh
|
||||
|
||||
def __toggle_box(self, widget, entry):
|
||||
if self.boxes[entry].props.visible:
|
||||
|
@ -841,6 +922,7 @@ class Filters(threading.Thread):
|
|||
else:
|
||||
self.boxes[entry].show()
|
||||
widget.set_label("hide")
|
||||
#end def __toggle_box
|
||||
|
||||
def __calendar_dialog(self, widget, entry):
|
||||
d = gtk.Window(gtk.WINDOW_TOPLEVEL)
|
||||
|
@ -858,21 +940,37 @@ class Filters(threading.Thread):
|
|||
d.add(vb)
|
||||
d.set_position(gtk.WIN_POS_MOUSE)
|
||||
d.show_all()
|
||||
#end def __calendar_dialog
|
||||
|
||||
def __clear_dates(self, w):
|
||||
self.start_date.set_text('')
|
||||
self.end_date.set_text('')
|
||||
#end def __clear_dates
|
||||
|
||||
def __get_dates(self):
|
||||
# self.day_start gives user's start of day in hours
|
||||
offset = int(self.day_start * 3600) # calc day_start in seconds
|
||||
|
||||
t1 = self.start_date.get_text()
|
||||
t2 = self.end_date.get_text()
|
||||
|
||||
if t1 == '':
|
||||
t1 = '1970-01-01'
|
||||
t1 = '1970-01-02'
|
||||
if t2 == '':
|
||||
t2 = '2020-12-12'
|
||||
|
||||
return (t1, t2)
|
||||
s1 = strptime(t1, "%Y-%m-%d") # make time_struct
|
||||
s2 = strptime(t2, "%Y-%m-%d")
|
||||
e1 = mktime(s1) + offset # s1 is localtime, but returned time since epoch is UTC, then add the
|
||||
e2 = mktime(s2) + offset # s2 is localtime, but returned time since epoch is UTC
|
||||
e2 = e2 + 24 * 3600 - 1 # date test is inclusive, so add 23h 59m 59s to e2
|
||||
|
||||
adj_t1 = strftime("%Y-%m-%d %H:%M:%S", gmtime(e1)) # make adjusted string including time
|
||||
adj_t2 = strftime("%Y-%m-%d %H:%M:%S", gmtime(e2))
|
||||
log.info("t1="+t1+" adj_t1="+adj_t1+'.')
|
||||
|
||||
return (adj_t1, adj_t2)
|
||||
#end def __get_dates
|
||||
|
||||
def __get_date(self, widget, calendar, entry, win):
|
||||
# year and day are correct, month is 0..11
|
||||
|
|
|
@ -1,78 +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 DB queries used in fpdb
|
||||
#
|
||||
|
||||
import sys
|
||||
import os
|
||||
|
||||
class FpdbSQLQueries:
|
||||
|
||||
def __init__(self, db):
|
||||
self.query = {}
|
||||
self.dbname = db
|
||||
|
||||
|
||||
if(self.dbname == 'MySQL InnoDB' or self.dbname == 'PostgreSQL'):
|
||||
self.query['set tx level'] = """SET SESSION TRANSACTION
|
||||
ISOLATION LEVEL READ COMMITTED"""
|
||||
elif(self.dbname == 'SQLite'):
|
||||
self.query['set tx level'] = """ """
|
||||
|
||||
|
||||
if(self.dbname == 'MySQL InnoDB') or (self.dbname == 'PostgreSQL'):
|
||||
self.query['getSiteId'] = """SELECT id from Sites where name = %s"""
|
||||
elif(self.dbname == 'SQLite'):
|
||||
self.query['getSiteId'] = """SELECT id from Sites where name = %s"""
|
||||
|
||||
if(self.dbname == 'MySQL InnoDB') or (self.dbname == 'PostgreSQL') or (self.dbname == 'SQLite'):
|
||||
self.query['getGames'] = """SELECT DISTINCT category from Gametypes"""
|
||||
|
||||
if(self.dbname == 'MySQL InnoDB') or (self.dbname == 'PostgreSQL') or (self.dbname == 'SQLite'):
|
||||
self.query['getLimits'] = """SELECT DISTINCT bigBlind from Gametypes ORDER by bigBlind DESC"""
|
||||
|
||||
|
||||
if __name__== "__main__":
|
||||
from optparse import OptionParser
|
||||
|
||||
print "FpdbSQLQueries starting from CLI"
|
||||
|
||||
#process CLI parameters
|
||||
usage = "usage: %prog [options]"
|
||||
parser = OptionParser()
|
||||
parser.add_option("-t", "--type", dest="dbtype", help="Available 'MySQL InnoDB', 'PostgreSQL', 'SQLite'(default: MySQL InnoDB)", default="MySQL InnoDB")
|
||||
parser.add_option("-s", "--show", action="store_true", dest="showsql", help="Show full SQL output")
|
||||
parser.add_option("-v", "--verbose", action="store_true", dest="verbose")
|
||||
|
||||
|
||||
(options, args) = parser.parse_args()
|
||||
|
||||
if options.verbose:
|
||||
print """No additional output available in this file"""
|
||||
|
||||
obj = FpdbSQLQueries(options.dbtype)
|
||||
|
||||
print "Available Queries for '" + options.dbtype + "':"
|
||||
|
||||
for key in obj.query:
|
||||
print " " + key
|
||||
if options.showsql:
|
||||
print obj.query[key]
|
|
@ -1,7 +1,7 @@
|
|||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# Copyright 2008, Carl Gherardi
|
||||
# Copyright 2008-2010, 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
|
||||
|
@ -20,6 +20,7 @@
|
|||
|
||||
import logging
|
||||
from HandHistoryConverter import *
|
||||
#import TourneySummary
|
||||
|
||||
# Fulltilt HH Format converter
|
||||
|
||||
|
@ -27,7 +28,7 @@ class Fulltilt(HandHistoryConverter):
|
|||
|
||||
sitename = "Fulltilt"
|
||||
filetype = "text"
|
||||
codepage = ["utf-16", "cp1252"]
|
||||
codepage = ["utf-16", "cp1252", "utf-8"]
|
||||
siteId = 1 # Needs to match id entry in Sites database
|
||||
|
||||
# Static regexes
|
||||
|
@ -53,7 +54,7 @@ class Fulltilt(HandHistoryConverter):
|
|||
\$?(?P<SB>[.0-9]+)/\$?(?P<BB>[.0-9]+)\s(Ante\s\$?(?P<ANTE>[.0-9]+)\s)?-\s
|
||||
\$?(?P<CAP>[.0-9]+\sCap\s)?
|
||||
(?P<GAMETYPE>[a-zA-Z\/\'\s]+)\s-\s
|
||||
(?P<DATETIME>\d+:\d+:\d+\s\w+\s-\s\d+/\d+/\d+)\s?
|
||||
(?P<DATETIME>\d+:\d+:\d+\s(?P<TZ1>\w+)\s-\s\d+/\d+/\d+|\d+:\d+\s(?P<TZ2>\w+)\s-\s\w+\,\s\w+\s\d+\,\s\d+)
|
||||
(?P<PARTIAL>\(partial\))?\n
|
||||
(?:.*?\n(?P<CANCELLED>Hand\s\#(?P=HID)\shas\sbeen\scanceled))?
|
||||
''', re.VERBOSE|re.DOTALL)
|
||||
|
@ -66,7 +67,7 @@ class Fulltilt(HandHistoryConverter):
|
|||
''', re.VERBOSE)
|
||||
re_Button = re.compile('^The button is in seat #(?P<BUTTON>\d+)', re.MULTILINE)
|
||||
re_PlayerInfo = re.compile('Seat (?P<SEAT>[0-9]+): (?P<PNAME>.{2,15}) \(\$(?P<CASH>[,.0-9]+)\)$', re.MULTILINE)
|
||||
re_TourneyPlayerInfo = re.compile('Seat (?P<SEAT>[0-9]+): (?P<PNAME>.{2,15}) \(\$?(?P<CASH>[,.0-9]+)\)(, is sitting out)?$', re.MULTILINE)
|
||||
re_TourneysPlayerInfo = re.compile('Seat (?P<SEAT>[0-9]+): (?P<PNAME>.{2,15}) \(\$?(?P<CASH>[,.0-9]+)\)(, is sitting out)?$', re.MULTILINE)
|
||||
re_Board = re.compile(r"\[(?P<CARDS>.+)\]")
|
||||
|
||||
#static regex for tourney purpose
|
||||
|
@ -87,8 +88,8 @@ class Fulltilt(HandHistoryConverter):
|
|||
re_TourneyBuyInChips = re.compile("Buy-In Chips: (?P<BUYINCHIPS>\d+)")
|
||||
re_TourneyEntries = re.compile("(?P<ENTRIES>\d+) Entries")
|
||||
re_TourneyPrizePool = re.compile("Total Prize Pool: (?P<PRIZEPOOL_CURRENCY>\$|)?(?P<PRIZEPOOL>[.,0-9]+)")
|
||||
re_TourneyRebuyAmount = re.compile("Rebuy: (?P<REBUY_CURRENCY>\$|)?(?P<REBUY_AMOUNT>[.,0-9]+)")
|
||||
re_TourneyAddOnAmount = re.compile("Add-On: (?P<ADDON_CURRENCY>\$|)?(?P<ADDON_AMOUNT>[.,0-9]+)")
|
||||
re_TourneyRebuyCost = re.compile("Rebuy: (?P<REBUY_CURRENCY>\$|)?(?P<REBUY_COST>[.,0-9]+)")
|
||||
re_TourneyAddOnCost = re.compile("Add-On: (?P<ADDON_CURRENCY>\$|)?(?P<ADDON_COST>[.,0-9]+)")
|
||||
re_TourneyRebuyCount = re.compile("performed (?P<REBUY_COUNT>\d+) Rebuy")
|
||||
re_TourneyAddOnCount = re.compile("performed (?P<ADDON_COUNT>\d+) Add-On")
|
||||
re_TourneyRebuysTotal = re.compile("Total Rebuys: (?P<REBUY_TOTAL>\d+)")
|
||||
|
@ -96,10 +97,10 @@ class Fulltilt(HandHistoryConverter):
|
|||
re_TourneyRebuyChips = re.compile("Rebuy Chips: (?P<REBUY_CHIPS>\d+)")
|
||||
re_TourneyAddOnChips = re.compile("Add-On Chips: (?P<ADDON_CHIPS>\d+)")
|
||||
re_TourneyKOBounty = re.compile("Knockout Bounty: (?P<KO_BOUNTY_CURRENCY>\$|)?(?P<KO_BOUNTY_AMOUNT>[.,0-9]+)")
|
||||
re_TourneyCountKO = re.compile("received (?P<COUNT_KO>\d+) Knockout Bounty Award(s)?")
|
||||
re_TourneyKoCount = re.compile("received (?P<COUNT_KO>\d+) Knockout Bounty Award(s)?")
|
||||
re_TourneyTimeInfo = re.compile("Tournament started: (?P<STARTTIME>.*)\nTournament ((?P<IN_PROGRESS>is still in progress)?|(finished:(?P<ENDTIME>.*))?)$")
|
||||
|
||||
re_TourneyPlayersSummary = re.compile("^(?P<RANK>(Still Playing|\d+))( - |: )(?P<PNAME>[^\n,]+)(, )?(?P<WINNING_CURRENCY>\$|)?(?P<WINNING>[.\d]+)?", re.MULTILINE)
|
||||
re_TourneysPlayersSummary = re.compile("^(?P<RANK>(Still Playing|\d+))( - |: )(?P<PNAME>[^\n,]+)(, )?(?P<WINNING_CURRENCY>\$|)?(?P<WINNING>[.\d]+)?", re.MULTILINE)
|
||||
re_TourneyHeroFinishingP = re.compile("(?P<HERO_NAME>.*) finished in (?P<HERO_FINISHING_POS>\d+)(st|nd|rd|th) place")
|
||||
|
||||
#TODO: See if we need to deal with play money tourney summaries -- Not right now (they shouldn't pass the re_TourneyInfo)
|
||||
|
@ -200,7 +201,18 @@ class Fulltilt(HandHistoryConverter):
|
|||
return None
|
||||
hand.handid = m.group('HID')
|
||||
hand.tablename = m.group('TABLE')
|
||||
hand.starttime = datetime.datetime.strptime(m.group('DATETIME'), "%H:%M:%S ET - %Y/%m/%d")
|
||||
|
||||
timezone = "ET"
|
||||
if m.group('TZ1') == "CET" or m.group('TZ2') == "CET":
|
||||
timezone = "CET"
|
||||
try:
|
||||
stringformat = "%H:%M:%S " + m.group('TZ1') + " - %Y/%m/%d"
|
||||
hand.startTime = datetime.datetime.strptime(m.group('DATETIME'), stringformat)
|
||||
except:
|
||||
stringformat = "%H:%M " + m.group('TZ2') + " - %a, %B %d, %Y"
|
||||
hand.startTime = datetime.datetime.strptime(m.group('DATETIME'), stringformat)
|
||||
|
||||
hand.startTime = HandHistoryConverter.changeTimezone(hand.startTime, timezone, "UTC")
|
||||
|
||||
if m.group("CANCELLED") or m.group("PARTIAL"):
|
||||
raise FpdbParseError(hid=m.group('HID'))
|
||||
|
@ -221,7 +233,14 @@ class Fulltilt(HandHistoryConverter):
|
|||
else:
|
||||
hand.tourneyComment = n.group('TOURNEY_NAME') # can be None
|
||||
if (n.group('CURRENCY') is not None and n.group('BUYIN') is not None and n.group('FEE') is not None):
|
||||
hand.buyin = "%s%s+%s%s" %(n.group('CURRENCY'), n.group('BUYIN'), n.group('CURRENCY'), n.group('FEE'))
|
||||
if n.group('CURRENCY')=="$":
|
||||
hand.buyinCurrency="USD"
|
||||
elif n.group('CURRENCY')==u"€":
|
||||
hand.buyinCurrency="EUR"
|
||||
else:
|
||||
hand.buyinCurrency="NA"
|
||||
hand.buyin = int(100*Decimal(n.group('BUYIN')))
|
||||
hand.fee = int(100*Decimal(n.group('FEE')))
|
||||
if n.group('TURBO') is not None :
|
||||
hand.speed = "Turbo"
|
||||
if n.group('SPECIAL') is not None :
|
||||
|
@ -231,7 +250,7 @@ class Fulltilt(HandHistoryConverter):
|
|||
if special == "KO":
|
||||
hand.isKO = True
|
||||
if special == "Head's Up":
|
||||
hand.isHU = True
|
||||
hand.maxSeats = 2
|
||||
if re.search("Matrix", special):
|
||||
hand.isMatrix = True
|
||||
if special == "Shootout":
|
||||
|
@ -264,7 +283,7 @@ class Fulltilt(HandHistoryConverter):
|
|||
if hand.gametype['type'] == "ring" :
|
||||
m = self.re_PlayerInfo.finditer(pre)
|
||||
else: #if hand.gametype['type'] == "tour"
|
||||
m = self.re_TourneyPlayerInfo.finditer(pre)
|
||||
m = self.re_TourneysPlayerInfo.finditer(pre)
|
||||
|
||||
for a in m:
|
||||
hand.addPlayer(int(a.group('SEAT')), a.group('PNAME'), a.group('CASH'))
|
||||
|
@ -426,23 +445,23 @@ class Fulltilt(HandHistoryConverter):
|
|||
def readSummaryInfo(self, summaryInfoList):
|
||||
self.status = True
|
||||
|
||||
m = re.search("Tournament Summary", summaryInfoList[0])
|
||||
if m:
|
||||
# info list should be 2 lines : Tourney infos & Finsihing postions with winnings
|
||||
if (len(summaryInfoList) != 2 ):
|
||||
log.info("Too many lines (%d) in file '%s' : '%s'" % (len(summaryInfoList), self.in_path, summaryInfoList) )
|
||||
self.status = False
|
||||
else:
|
||||
self.tourney = Tourney.Tourney(sitename = self.sitename, gametype = None, summaryText = summaryInfoList, builtFrom = "HHC")
|
||||
self.status = self.getPlayersPositionsAndWinnings(self.tourney)
|
||||
if self.status == True :
|
||||
self.status = self.determineTourneyType(self.tourney)
|
||||
#print self.tourney
|
||||
else:
|
||||
log.info("Parsing NOK : rejected")
|
||||
else:
|
||||
log.info( "This is not a summary file : '%s'" % (self.in_path) )
|
||||
self.status = False
|
||||
#m = re.search("Tournament Summary", summaryInfoList[0])
|
||||
#if m:
|
||||
# # info list should be 2 lines : Tourney infos & Finsihing postions with winnings
|
||||
# if (len(summaryInfoList) != 2 ):
|
||||
# log.info("Too many or too few lines (%d) in file '%s' : '%s'" % (len(summaryInfoList), self.in_path, summaryInfoList) )
|
||||
# self.status = False
|
||||
# else:
|
||||
# self.tourney = TourneySummary.TourneySummary(sitename = self.sitename, gametype = None, summaryText = summaryInfoList, builtFrom = "HHC")
|
||||
# self.status = self.getPlayersPositionsAndWinnings(self.tourney)
|
||||
# if self.status == True :
|
||||
# self.status = self.determineTourneyType(self.tourney)
|
||||
# #print self.tourney
|
||||
# else:
|
||||
# log.info("Parsing NOK : rejected")
|
||||
#else:
|
||||
# log.info( "This is not a summary file : '%s'" % (self.in_path) )
|
||||
# self.status = False
|
||||
|
||||
return self.status
|
||||
|
||||
|
@ -497,7 +516,6 @@ class Fulltilt(HandHistoryConverter):
|
|||
if special == "KO":
|
||||
tourney.isKO = True
|
||||
if special == "Heads Up":
|
||||
tourney.isHU = True
|
||||
tourney.maxseats = 2
|
||||
if re.search("Matrix", special):
|
||||
tourney.isMatrix = True
|
||||
|
@ -566,8 +584,8 @@ class Fulltilt(HandHistoryConverter):
|
|||
dictRegex = { "BUYINCHIPS" : self.re_TourneyBuyInChips,
|
||||
"ENTRIES" : self.re_TourneyEntries,
|
||||
"PRIZEPOOL" : self.re_TourneyPrizePool,
|
||||
"REBUY_AMOUNT" : self.re_TourneyRebuyAmount,
|
||||
"ADDON_AMOUNT" : self.re_TourneyAddOnAmount,
|
||||
"REBUY_COST" : self.re_TourneyRebuyCost,
|
||||
"ADDON_COST" : self.re_TourneyAddOnCost,
|
||||
"REBUY_TOTAL" : self.re_TourneyRebuysTotal,
|
||||
"ADDONS_TOTAL" : self.re_TourneyAddOnsTotal,
|
||||
"REBUY_CHIPS" : self.re_TourneyRebuyChips,
|
||||
|
@ -580,10 +598,10 @@ class Fulltilt(HandHistoryConverter):
|
|||
dictHolders = { "BUYINCHIPS" : "buyInChips",
|
||||
"ENTRIES" : "entries",
|
||||
"PRIZEPOOL" : "prizepool",
|
||||
"REBUY_AMOUNT" : "rebuyAmount",
|
||||
"ADDON_AMOUNT" : "addOnAmount",
|
||||
"REBUY_TOTAL" : "totalRebuys",
|
||||
"ADDONS_TOTAL" : "totalAddOns",
|
||||
"REBUY_COST" : "rebuyCost",
|
||||
"ADDON_COST" : "addOnCost",
|
||||
"REBUY_TOTAL" : "totalRebuyCount",
|
||||
"ADDONS_TOTAL" : "totalAddOnCount",
|
||||
"REBUY_CHIPS" : "rebuyChips",
|
||||
"ADDON_CHIPS" : "addOnChips",
|
||||
"STARTTIME" : "starttime",
|
||||
|
@ -607,42 +625,39 @@ class Fulltilt(HandHistoryConverter):
|
|||
if m is not None:
|
||||
mg = m.groupdict()
|
||||
if mg['REBUY_COUNT'] is not None :
|
||||
tourney.countRebuys.update( { tourney.hero : Decimal(mg['REBUY_COUNT']) } )
|
||||
tourney.rebuyCounts.update( { tourney.hero : Decimal(mg['REBUY_COUNT']) } )
|
||||
m = self.re_TourneyAddOnCount.search(tourneyText)
|
||||
if m is not None:
|
||||
mg = m.groupdict()
|
||||
if mg['ADDON_COUNT'] is not None :
|
||||
tourney.countAddOns.update( { tourney.hero : Decimal(mg['ADDON_COUNT']) } )
|
||||
m = self.re_TourneyCountKO.search(tourneyText)
|
||||
tourney.addOnCounts.update( { tourney.hero : Decimal(mg['ADDON_COUNT']) } )
|
||||
m = self.re_TourneyKoCount.search(tourneyText)
|
||||
if m is not None:
|
||||
mg = m.groupdict()
|
||||
if mg['COUNT_KO'] is not None :
|
||||
tourney.countKO.update( { tourney.hero : Decimal(mg['COUNT_KO']) } )
|
||||
tourney.koCounts.update( { tourney.hero : Decimal(mg['COUNT_KO']) } )
|
||||
|
||||
# Deal with money amounts
|
||||
tourney.koBounty = 100*Decimal(re.sub(u',', u'', "%s" % tourney.koBounty))
|
||||
tourney.prizepool = 100*Decimal(re.sub(u',', u'', "%s" % tourney.prizepool))
|
||||
tourney.rebuyAmount = 100*Decimal(re.sub(u',', u'', "%s" % tourney.rebuyAmount))
|
||||
tourney.addOnAmount = 100*Decimal(re.sub(u',', u'', "%s" % tourney.addOnAmount))
|
||||
tourney.rebuyCost = 100*Decimal(re.sub(u',', u'', "%s" % tourney.rebuyCost))
|
||||
tourney.addOnCost = 100*Decimal(re.sub(u',', u'', "%s" % tourney.addOnCost))
|
||||
|
||||
# Calculate payin amounts and update winnings -- not possible to take into account nb of rebuys, addons or Knockouts for other players than hero on FTP
|
||||
for p in tourney.players :
|
||||
tourney.payinAmounts[p] = tourney.buyin + tourney.fee + (tourney.rebuyAmount * tourney.countRebuys[p]) + (tourney.addOnAmount * tourney.countAddOns[p])
|
||||
#print " player %s : payinAmount = %d" %( p, tourney.payinAmounts[p])
|
||||
if tourney.isKO :
|
||||
#tourney.incrementPlayerWinnings(tourney.players[p], Decimal(tourney.koBounty)*Decimal(tourney.countKO[p]))
|
||||
tourney.winnings[p] += Decimal(tourney.koBounty)*Decimal(tourney.countKO[p])
|
||||
#tourney.incrementPlayerWinnings(tourney.players[p], Decimal(tourney.koBounty)*Decimal(tourney.koCounts[p]))
|
||||
tourney.winnings[p] += Decimal(tourney.koBounty)*Decimal(tourney.koCounts[p])
|
||||
#print "player %s : winnings %d" % (p, tourney.winnings[p])
|
||||
|
||||
|
||||
|
||||
#print mg
|
||||
return True
|
||||
#end def determineTourneyType
|
||||
|
||||
def getPlayersPositionsAndWinnings(self, tourney):
|
||||
playersText = tourney.summaryText[1]
|
||||
#print "Examine : '%s'" %(playersText)
|
||||
m = self.re_TourneyPlayersSummary.finditer(playersText)
|
||||
m = self.re_TourneysPlayersSummary.finditer(playersText)
|
||||
|
||||
for a in m:
|
||||
if a.group('PNAME') is not None and a.group('RANK') is not None:
|
||||
|
@ -656,7 +671,7 @@ class Fulltilt(HandHistoryConverter):
|
|||
else:
|
||||
winnings = "0"
|
||||
|
||||
tourney.addPlayer(rank, a.group('PNAME'), winnings, 0, 0, 0, 0)
|
||||
tourney.addPlayer(rank, a.group('PNAME'), winnings, "USD", 0, 0, 0) #TODO: make it store actual winnings currency
|
||||
else:
|
||||
print "FullTilt: Player finishing stats unreadable : %s" % a
|
||||
|
||||
|
@ -666,10 +681,10 @@ class Fulltilt(HandHistoryConverter):
|
|||
heroName = n.group('HERO_NAME')
|
||||
tourney.hero = heroName
|
||||
# Is this really useful ?
|
||||
if heroName not in tourney.finishPositions:
|
||||
print "FullTilt:", heroName, "not found in tourney.finishPositions ..."
|
||||
elif (tourney.finishPositions[heroName] != Decimal(n.group('HERO_FINISHING_POS'))):
|
||||
print "FullTilt: Bad parsing : finish position incoherent : %s / %s" % (tourney.finishPositions[heroName], n.group('HERO_FINISHING_POS'))
|
||||
if heroName not in tourney.ranks:
|
||||
print "FullTilt:", heroName, "not found in tourney.ranks ..."
|
||||
elif (tourney.ranks[heroName] != Decimal(n.group('HERO_FINISHING_POS'))):
|
||||
print "FullTilt: Bad parsing : finish position incoherent : %s / %s" % (tourney.ranks[heroName], n.group('HERO_FINISHING_POS'))
|
||||
|
||||
return True
|
||||
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#!/usr/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
#Copyright 2008 Steffen Jobbagy-Felso
|
||||
#Copyright 2008-2010 Steffen Schaumburg
|
||||
#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.
|
||||
|
@ -12,8 +13,7 @@
|
|||
#
|
||||
#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.
|
||||
#In the "official" distribution you can find the license in agpl-3.0.txt.
|
||||
|
||||
import threading
|
||||
import subprocess
|
||||
|
@ -32,11 +32,12 @@ import Configuration
|
|||
import string
|
||||
|
||||
class GuiAutoImport (threading.Thread):
|
||||
def __init__(self, settings, config, sql):
|
||||
def __init__(self, settings, config, sql, parent):
|
||||
self.importtimer = 0
|
||||
self.settings = settings
|
||||
self.config = config
|
||||
self.sql = sql
|
||||
self.parent = parent
|
||||
|
||||
imp = self.config.get_import_parameters()
|
||||
|
||||
|
@ -100,7 +101,7 @@ class GuiAutoImport (threading.Thread):
|
|||
hbox.pack_start(lbl1, expand=True, fill=False)
|
||||
|
||||
self.doAutoImportBool = False
|
||||
self.startButton = gtk.ToggleButton(" _Start Autoimport ")
|
||||
self.startButton = gtk.ToggleButton(" Start _Autoimport ")
|
||||
self.startButton.connect("clicked", self.startClicked, "start clicked")
|
||||
hbox.pack_start(self.startButton, expand=False, fill=False)
|
||||
|
||||
|
@ -138,6 +139,8 @@ class GuiAutoImport (threading.Thread):
|
|||
#dia_chooser.set_current_folder(pathname)
|
||||
dia_chooser.set_filename(current_path)
|
||||
#dia_chooser.set_select_multiple(select_multiple) #not in tv, but want this in bulk import
|
||||
dia_chooser.set_destroy_with_parent(True)
|
||||
dia_chooser.set_transient_for(self.parent)
|
||||
|
||||
response = dia_chooser.run()
|
||||
if response == gtk.RESPONSE_OK:
|
||||
|
@ -153,7 +156,7 @@ class GuiAutoImport (threading.Thread):
|
|||
def do_import(self):
|
||||
"""Callback for timer to do an import iteration."""
|
||||
if self.doAutoImportBool:
|
||||
self.startButton.set_label(u' I M P O R T I N G ')
|
||||
self.startButton.set_label(u' _Auto Import Running ')
|
||||
self.importer.runUpdated()
|
||||
self.addText(".")
|
||||
#sys.stdout.write(".")
|
||||
|
@ -164,9 +167,9 @@ class GuiAutoImport (threading.Thread):
|
|||
|
||||
def reset_startbutton(self):
|
||||
if self.pipe_to_hud is not None:
|
||||
self.startButton.set_label(u' _Stop Autoimport ')
|
||||
self.startButton.set_label(u' Stop _Autoimport ')
|
||||
else:
|
||||
self.startButton.set_label(u' _Start Autoimport ')
|
||||
self.startButton.set_label(u' Start _Autoimport ')
|
||||
|
||||
return False
|
||||
|
||||
|
@ -199,10 +202,10 @@ class GuiAutoImport (threading.Thread):
|
|||
bs = 0
|
||||
elif os.name == 'nt':
|
||||
path = sys.path[0].replace('\\','\\\\')
|
||||
command = 'python "'+path+'\\HUD_main.py" ' + self.settings['cl_options']
|
||||
command = 'pythonw "'+path+'\\HUD_main.pyw" ' + self.settings['cl_options']
|
||||
bs = 0
|
||||
else:
|
||||
command = os.path.join(sys.path[0], 'HUD_main.py')
|
||||
command = os.path.join(sys.path[0], 'HUD_main.pyw')
|
||||
command = [command, ] + string.split(self.settings['cl_options'])
|
||||
bs = 1
|
||||
|
||||
|
@ -210,7 +213,12 @@ class GuiAutoImport (threading.Thread):
|
|||
print "opening pipe to HUD"
|
||||
self.pipe_to_hud = subprocess.Popen(command, bufsize=bs,
|
||||
stdin=subprocess.PIPE,
|
||||
universal_newlines=True)
|
||||
stdout=subprocess.PIPE, # only needed for py2exe
|
||||
stderr=subprocess.PIPE, # only needed for py2exe
|
||||
universal_newlines=True
|
||||
)
|
||||
#self.pipe_to_hud.stdout.close()
|
||||
#self.pipe_to_hud.stderr.close()
|
||||
except:
|
||||
err = traceback.extract_tb(sys.exc_info()[2])[-1]
|
||||
#self.addText( "\n*** GuiAutoImport Error opening pipe: " + err[2] + "(" + str(err[1]) + "): " + str(sys.exc_info()[1]))
|
||||
|
@ -238,7 +246,7 @@ class GuiAutoImport (threading.Thread):
|
|||
#print >>self.pipe_to_hud.stdin, "\n"
|
||||
self.pipe_to_hud.communicate('\n') # waits for process to terminate
|
||||
self.pipe_to_hud = None
|
||||
self.startButton.set_label(u' _Start Autoimport ')
|
||||
self.startButton.set_label(u' Start _Autoimport ')
|
||||
|
||||
#end def GuiAutoImport.startClicked
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#!/usr/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# Copyright 2008 Steffen Jobbagy-Felso
|
||||
#Copyright 2008-2010 Steffen Schaumburg
|
||||
#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.
|
||||
|
@ -13,8 +13,7 @@
|
|||
#
|
||||
#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.
|
||||
#In the "official" distribution you can find the license in agpl-3.0.txt.
|
||||
|
||||
# Standard Library modules
|
||||
import os
|
||||
|
@ -51,7 +50,7 @@ class GuiBulkImport():
|
|||
ttime = None
|
||||
# Does the lock acquisition need to be more sophisticated for multiple dirs?
|
||||
# (see comment above about what to do if pipe already open)
|
||||
if self.settings['global_lock'].acquire(False): # returns false immediately if lock not acquired
|
||||
if self.settings['global_lock'].acquire(wait=False, source="GuiBulkImport"): # returns false immediately if lock not acquired
|
||||
#try:
|
||||
print "\nGlobal lock taken ..."
|
||||
self.progressbar.set_text("Importing...")
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#!/usr/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
#Copyright 2008 Carl Gherardi
|
||||
#Copyright 2008-2010 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.
|
||||
|
@ -13,9 +13,7 @@
|
|||
#
|
||||
#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.
|
||||
|
||||
#In the "official" distribution you can find the license in agpl-3.0.txt.
|
||||
|
||||
import os
|
||||
import sys
|
||||
|
@ -35,17 +33,32 @@ log = logging.getLogger("maintdbs")
|
|||
|
||||
import Exceptions
|
||||
import Database
|
||||
import SQL
|
||||
|
||||
|
||||
class GuiDatabase:
|
||||
|
||||
# columns in liststore:
|
||||
MODEL_DBMS = 0
|
||||
MODEL_NAME = 1
|
||||
MODEL_DESC = 2
|
||||
MODEL_USER = 3
|
||||
MODEL_PASS = 4
|
||||
MODEL_HOST = 5
|
||||
MODEL_DFLT = 6
|
||||
MODEL_DFLTIC = 7
|
||||
MODEL_STATUS = 8
|
||||
MODEL_STATIC = 9
|
||||
|
||||
# columns in listview:
|
||||
COL_DBMS = 0
|
||||
COL_NAME = 1
|
||||
COL_DESC = 2
|
||||
COL_USER = 3
|
||||
COL_PASS = 4
|
||||
COL_HOST = 5
|
||||
COL_ICON = 6
|
||||
COL_DFLT = 6
|
||||
COL_ICON = 7
|
||||
|
||||
def __init__(self, config, mainwin, dia):
|
||||
self.config = config
|
||||
|
@ -58,9 +71,9 @@ class GuiDatabase:
|
|||
#gtk.Widget.set_size_request(self.vbox, 700, 400);
|
||||
|
||||
# list of databases in self.config.supported_databases:
|
||||
self.liststore = gtk.ListStore(str, str, str, str
|
||||
,str, str, str, str) #object, gtk.gdk.Pixbuf)
|
||||
# dbms, name, comment, user, pass, ip, status(, icon?)
|
||||
self.liststore = gtk.ListStore(str, str, str, str, str
|
||||
,str, str, str, str, str)
|
||||
# dbms, name, comment, user, passwd, host, "", default_icon, status, icon
|
||||
# this is how to add a filter:
|
||||
#
|
||||
# # Creation of the filter, from the model
|
||||
|
@ -72,11 +85,12 @@ class GuiDatabase:
|
|||
self.listview = gtk.TreeView(model=self.liststore)
|
||||
self.listview.set_grid_lines(gtk.TREE_VIEW_GRID_LINES_NONE)
|
||||
self.listcols = []
|
||||
self.changes = False
|
||||
|
||||
scrolledwindow = gtk.ScrolledWindow()
|
||||
scrolledwindow.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
|
||||
scrolledwindow.add(self.listview)
|
||||
self.vbox.pack_start(scrolledwindow, expand=True, fill=True, padding=0)
|
||||
self.scrolledwindow = gtk.ScrolledWindow()
|
||||
self.scrolledwindow.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
|
||||
self.scrolledwindow.add(self.listview)
|
||||
self.vbox.pack_start(self.scrolledwindow, expand=True, fill=True, padding=0)
|
||||
|
||||
refreshbutton = gtk.Button("Refresh")
|
||||
refreshbutton.connect("clicked", self.refresh, None)
|
||||
|
@ -89,18 +103,28 @@ class GuiDatabase:
|
|||
col = self.addTextColumn("Username", 3, True)
|
||||
col = self.addTextColumn("Password", 4, True)
|
||||
col = self.addTextColumn("Host", 5, True)
|
||||
col = self.addTextObjColumn("", 6)
|
||||
col = self.addTextObjColumn("Default", 6, 6)
|
||||
col = self.addTextObjColumn("Status", 7, 8)
|
||||
|
||||
#self.listview.get_selection().set_mode(gtk.SELECTION_SINGLE)
|
||||
#self.listview.get_selection().connect("changed", self.on_selection_changed)
|
||||
self.listview.add_events(gtk.gdk.BUTTON_PRESS_MASK)
|
||||
self.listview.connect('button_press_event', self.selectTest)
|
||||
|
||||
self.loadDbs()
|
||||
|
||||
self.dia.connect('response', self.dialog_response_cb)
|
||||
#self.dia.connect('response', self.dialog_response_cb)
|
||||
except:
|
||||
err = traceback.extract_tb(sys.exc_info()[2])[-1]
|
||||
print 'guidbmaint: '+ err[2] + "(" + str(err[1]) + "): " + str(sys.exc_info()[1])
|
||||
|
||||
def dialog_response_cb(self, dialog, response_id):
|
||||
# this is called whether close button is pressed or window is closed
|
||||
log.info('dialog_response_cb: response_id='+str(response_id))
|
||||
#if self.changes:
|
||||
# self.config.save()
|
||||
dialog.destroy()
|
||||
return(response_id)
|
||||
|
||||
|
||||
def get_dialog(self):
|
||||
|
@ -127,6 +151,7 @@ class GuiDatabase:
|
|||
|
||||
def edited_cb(self, cell, path, new_text, user_data):
|
||||
liststore, col = user_data
|
||||
log.info('edited_cb: col = '+str(col))
|
||||
valid = True
|
||||
name = self.liststore[path][self.COL_NAME]
|
||||
|
||||
|
@ -140,10 +165,11 @@ class GuiDatabase:
|
|||
|
||||
self.config.set_db_parameters( db_server = self.liststore[path][self.COL_DBMS]
|
||||
, db_name = name
|
||||
, db_desc = self.liststore[path][self.COL_DESC]
|
||||
, db_ip = self.liststore[path][self.COL_HOST]
|
||||
, db_user = self.liststore[path][self.COL_USER]
|
||||
, db_pass = self.liststore[path][self.COL_PASS] )
|
||||
|
||||
self.changes = True
|
||||
return
|
||||
|
||||
def check_new_name(self, path, new_text):
|
||||
|
@ -154,38 +180,73 @@ class GuiDatabase:
|
|||
#TODO: popup an error message telling user names must be unique
|
||||
return name_ok
|
||||
|
||||
def addTextObjColumn(self, title, n):
|
||||
def addTextObjColumn(self, title, viewcol, storecol, editable=False):
|
||||
col = gtk.TreeViewColumn(title)
|
||||
self.listview.append_column(col)
|
||||
|
||||
cRenderT = gtk.CellRendererText()
|
||||
cRenderT.set_property("wrap-mode", pango.WRAP_WORD_CHAR)
|
||||
col.pack_start(cRenderT, False)
|
||||
col.add_attribute(cRenderT, 'text', n)
|
||||
col.add_attribute(cRenderT, 'text', storecol)
|
||||
|
||||
cRenderP = gtk.CellRendererPixbuf()
|
||||
col.pack_start(cRenderP, False)
|
||||
col.add_attribute(cRenderP, 'stock-id', n+1)
|
||||
col.pack_start(cRenderP, True)
|
||||
col.add_attribute(cRenderP, 'stock-id', storecol+1)
|
||||
|
||||
col.set_max_width(1000)
|
||||
col.set_spacing(0) # no effect
|
||||
self.listcols.append(col)
|
||||
#col.set_clickable(True)
|
||||
#col.connect("clicked", self.sortCols, p)
|
||||
|
||||
col.set_clickable(True)
|
||||
col.connect("clicked", self.sortCols, viewcol)
|
||||
return(col)
|
||||
|
||||
def selectTest(self, widget, event):
|
||||
if event.button == 1: # and event.type == gtk.gdk._2BUTTON_PRESS:
|
||||
pthinfo = self.listview.get_path_at_pos( int(event.x), int(event.y) )
|
||||
if pthinfo is not None:
|
||||
path, col, cellx, celly = pthinfo
|
||||
row = path[0]
|
||||
if col == self.listcols[self.COL_DFLT]:
|
||||
if self.liststore[row][self.MODEL_STATUS] == 'ok' and self.liststore[row][self.MODEL_DFLTIC] is None:
|
||||
self.setDefaultDB(row)
|
||||
|
||||
def setDefaultDB(self, row):
|
||||
print "set new defaultdb:", row, self.liststore[row][self.MODEL_NAME]
|
||||
for r in xrange(len(self.liststore)):
|
||||
if r == row:
|
||||
self.liststore[r][self.MODEL_DFLTIC] = gtk.STOCK_APPLY
|
||||
default = "True"
|
||||
else:
|
||||
self.liststore[r][self.MODEL_DFLTIC] = None
|
||||
default = "False"
|
||||
|
||||
self.config.set_db_parameters( db_server = self.liststore[r][self.COL_DBMS]
|
||||
, db_name = self.liststore[r][self.COL_NAME]
|
||||
, db_desc = self.liststore[r][self.COL_DESC]
|
||||
, db_ip = self.liststore[r][self.COL_HOST]
|
||||
, db_user = self.liststore[r][self.COL_USER]
|
||||
, db_pass = self.liststore[r][self.COL_PASS]
|
||||
, default = default
|
||||
)
|
||||
self.changes = True
|
||||
return
|
||||
|
||||
|
||||
def loadDbs(self):
|
||||
|
||||
self.liststore.clear()
|
||||
self.listcols = []
|
||||
self.dbs = [] # list of tuples: (dbms, name, comment, user, passwd, host, status, icon)
|
||||
#self.listcols = []
|
||||
dia = self.info_box2(None, 'Testing database connections ... ', "", False, False)
|
||||
while gtk.events_pending():
|
||||
gtk.mainiteration()
|
||||
|
||||
try:
|
||||
# want to fill: dbms, name, comment, user, passwd, host, status(, icon?)
|
||||
# want to fill: dbms, name, comment, user, passwd, host, default, status, icon
|
||||
for name in self.config.supported_databases: #db_ip/db_user/db_pass/db_server
|
||||
dbms = self.config.supported_databases[name].db_server # mysql/postgresql/sqlite
|
||||
dbms_num = self.config.get_backend(dbms) # 2 / 3 / 4
|
||||
comment = ""
|
||||
comment = self.config.supported_databases[name].db_desc
|
||||
if dbms == 'sqlite':
|
||||
user = ""
|
||||
passwd = ""
|
||||
|
@ -193,22 +254,30 @@ class GuiDatabase:
|
|||
user = self.config.supported_databases[name].db_user
|
||||
passwd = self.config.supported_databases[name].db_pass
|
||||
host = self.config.supported_databases[name].db_ip
|
||||
default = (name == self.config.db_selected)
|
||||
default_icon = None
|
||||
if default: default_icon = gtk.STOCK_APPLY
|
||||
status = ""
|
||||
icon = None
|
||||
err_msg = ""
|
||||
|
||||
db = Database.Database(self.config, sql = None, autoconnect = False)
|
||||
sql = SQL.Sql(db_server=dbms)
|
||||
db = Database.Database(self.config, sql = sql, autoconnect = False)
|
||||
# try to connect to db, set status and err_msg if it fails
|
||||
try:
|
||||
# is creating empty db for sqlite ... mod db.py further?
|
||||
# add noDbTables flag to db.py?
|
||||
log.debug("loaddbs: trying to connect to: %s/%s, %s, %s/%s" % (str(dbms_num),dbms,name,user,passwd))
|
||||
db.connect(backend=dbms_num, host=host, database=name, user=user, password=passwd, create=False)
|
||||
if db.connected:
|
||||
log.debug(" connected ok")
|
||||
status = 'ok'
|
||||
icon = gtk.STOCK_APPLY
|
||||
if db.wrongDbVersion:
|
||||
status = 'old'
|
||||
icon = gtk.STOCK_INFO
|
||||
else:
|
||||
log.debug(" not connected but no exception")
|
||||
except Exceptions.FpdbMySQLAccessDenied:
|
||||
err_msg = "MySQL Server reports: Access denied. Are your permissions set correctly?"
|
||||
status = "failed"
|
||||
|
@ -232,13 +301,17 @@ class GuiDatabase:
|
|||
+ err[2] + "(" + str(err[1]) + "): " + str(sys.exc_info()[1]) )
|
||||
status = "failed"
|
||||
icon = gtk.STOCK_CANCEL
|
||||
if err_msg:
|
||||
log.info( 'db connection to '+str(dbms_num)+','+host+','+name+','+user+','+passwd+' failed: '
|
||||
+ err_msg )
|
||||
|
||||
b = gtk.Button(name)
|
||||
b.show()
|
||||
iter = self.liststore.append( (dbms, name, comment, user, passwd, host, status, icon) )
|
||||
iter = self.liststore.append( (dbms, name, comment, user, passwd, host, "", default_icon, status, icon) )
|
||||
|
||||
self.info_box2(dia[0], "finished.", "", False, True)
|
||||
self.listview.show()
|
||||
scrolledwindow.show()
|
||||
self.scrolledwindow.show()
|
||||
self.vbox.show()
|
||||
self.dia.set_focus(self.listview)
|
||||
|
||||
|
@ -251,13 +324,16 @@ class GuiDatabase:
|
|||
|
||||
def sortCols(self, col, n):
|
||||
try:
|
||||
log.info('sortcols n='+str(n))
|
||||
if not col.get_sort_indicator() or col.get_sort_order() == gtk.SORT_ASCENDING:
|
||||
col.set_sort_order(gtk.SORT_DESCENDING)
|
||||
else:
|
||||
col.set_sort_order(gtk.SORT_ASCENDING)
|
||||
self.liststore.set_sort_column_id(n, col.get_sort_order())
|
||||
#self.liststore.set_sort_func(n, self.sortnums, (n,grid))
|
||||
log.info('sortcols len(listcols)='+str(len(self.listcols)))
|
||||
for i in xrange(len(self.listcols)):
|
||||
log.info('sortcols i='+str(i))
|
||||
self.listcols[i].set_sort_indicator(False)
|
||||
self.listcols[n].set_sort_indicator(True)
|
||||
# use this listcols[col].set_sort_indicator(True)
|
||||
|
@ -266,10 +342,69 @@ class GuiDatabase:
|
|||
err = traceback.extract_tb(sys.exc_info()[2])
|
||||
print "***sortCols error: " + str(sys.exc_info()[1])
|
||||
print "\n".join( [e[0]+':'+str(e[1])+" "+e[2] for e in err] )
|
||||
log.info('sortCols error: ' + str(sys.exc_info()) )
|
||||
|
||||
def refresh(self, widget, data):
|
||||
self.loadDbs()
|
||||
|
||||
def info_box(self, dia, str1, str2, run, destroy):
|
||||
if dia is None:
|
||||
#if run:
|
||||
btns = gtk.BUTTONS_NONE
|
||||
btns = gtk.BUTTONS_OK
|
||||
dia = gtk.MessageDialog( parent=self.main_window, flags=gtk.DIALOG_DESTROY_WITH_PARENT
|
||||
, type=gtk.MESSAGE_INFO, buttons=(btns), message_format=str1 )
|
||||
# try to remove buttons!
|
||||
# (main message is in inverse video if no buttons, so try removing them after
|
||||
# creating dialog)
|
||||
# NO! message just goes back to inverse video :-( use info_box2 instead
|
||||
for c in dia.vbox.get_children():
|
||||
if isinstance(c, gtk.HButtonBox):
|
||||
for d in c.get_children():
|
||||
log.info('child: '+str(d)+' is a '+str(d.__class__))
|
||||
if isinstance(d, gtk.Button):
|
||||
log.info('removing button '+str(d))
|
||||
c.remove(d)
|
||||
if str2:
|
||||
dia.format_secondary_text(str2)
|
||||
else:
|
||||
dia.set_markup(str1)
|
||||
if str2:
|
||||
dia.format_secondary_text(str2)
|
||||
dia.show()
|
||||
response = None
|
||||
if run: response = dia.run()
|
||||
if destroy: dia.destroy()
|
||||
return (dia, response)
|
||||
|
||||
def info_box2(self, dia, str1, str2, run, destroy):
|
||||
if dia is None:
|
||||
# create dialog and add icon and label
|
||||
btns = (gtk.BUTTONS_OK)
|
||||
btns = None
|
||||
# messagedialog puts text in inverse colors if no buttons are displayed??
|
||||
#dia = gtk.MessageDialog( parent=self.main_window, flags=gtk.DIALOG_DESTROY_WITH_PARENT
|
||||
# , type=gtk.MESSAGE_INFO, buttons=(btns), message_format=str1 )
|
||||
dia = gtk.Dialog( parent=self.main_window, flags=gtk.DIALOG_DESTROY_WITH_PARENT
|
||||
, title="" ) # , buttons=btns
|
||||
vbox = dia.vbox
|
||||
|
||||
h = gtk.HBox(False, 2)
|
||||
i = gtk.Image()
|
||||
i.set_from_stock(gtk.STOCK_DIALOG_INFO, gtk.ICON_SIZE_DIALOG)
|
||||
l = gtk.Label(str1)
|
||||
h.pack_start(i, padding=5)
|
||||
h.pack_start(l, padding=5)
|
||||
vbox.pack_start(h)
|
||||
else:
|
||||
# add extra label
|
||||
vbox = dia.vbox
|
||||
vbox.pack_start( gtk.Label(str1) )
|
||||
dia.show_all()
|
||||
response = None
|
||||
if run: response = dia.run()
|
||||
if destroy: dia.destroy()
|
||||
return (dia, response)
|
||||
|
||||
|
||||
if __name__=="__main__":
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#!/usr/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
#Copyright 2008 Steffen Jobbagy-Felso
|
||||
#Copyright 2008-2010 Steffen Schaumburg
|
||||
#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.
|
||||
|
@ -12,8 +13,7 @@
|
|||
#
|
||||
#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.
|
||||
#In the "official" distribution you can find the license in agpl-3.0.txt.
|
||||
|
||||
import threading
|
||||
import pygtk
|
||||
|
@ -23,6 +23,7 @@ import os
|
|||
import sys
|
||||
import traceback
|
||||
from time import *
|
||||
from datetime import datetime
|
||||
#import pokereval
|
||||
|
||||
try:
|
||||
|
@ -48,11 +49,12 @@ import Charset
|
|||
|
||||
class GuiGraphViewer (threading.Thread):
|
||||
|
||||
def __init__(self, querylist, config, debug=True):
|
||||
def __init__(self, querylist, config, parent, debug=True):
|
||||
"""Constructor for GraphViewer"""
|
||||
self.sql = querylist
|
||||
self.conf = config
|
||||
self.debug = debug
|
||||
self.parent = parent
|
||||
#print "start of GraphViewer constructor"
|
||||
self.db = Database.Database(self.conf, sql=self.sql)
|
||||
|
||||
|
@ -228,9 +230,9 @@ class GuiGraphViewer (threading.Thread):
|
|||
self.ax.plot(blue, color='blue', label='Showdown: $%.2f' %(blue[-1]))
|
||||
self.ax.plot(red, color='red', label='Non-showdown: $%.2f' %(red[-1]))
|
||||
if sys.version[0:3] == '2.5':
|
||||
self.ax.legend(loc='best', shadow=True, prop=FontProperties(size='smaller'))
|
||||
self.ax.legend(loc='upper left', shadow=True, prop=FontProperties(size='smaller'))
|
||||
else:
|
||||
self.ax.legend(loc='best', fancybox=True, shadow=True, prop=FontProperties(size='smaller'))
|
||||
self.ax.legend(loc='upper left', fancybox=True, shadow=True, prop=FontProperties(size='smaller'))
|
||||
|
||||
self.graphBox.add(self.canvas)
|
||||
self.canvas.show()
|
||||
|
@ -334,21 +336,41 @@ class GuiGraphViewer (threading.Thread):
|
|||
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:",
|
||||
action=gtk.FILE_CHOOSER_ACTION_OPEN,
|
||||
buttons=(gtk.STOCK_CANCEL,gtk.RESPONSE_CANCEL,gtk.STOCK_OPEN,gtk.RESPONSE_OK))
|
||||
#TODO: Suggest path and filename to start with
|
||||
action=gtk.FILE_CHOOSER_ACTION_SELECT_FOLDER,
|
||||
buttons=(gtk.STOCK_CANCEL,gtk.RESPONSE_CANCEL,gtk.STOCK_OK,gtk.RESPONSE_OK))
|
||||
dia_chooser.set_destroy_with_parent(True)
|
||||
dia_chooser.set_transient_for(self.parent)
|
||||
try:
|
||||
dia_chooser.set_filename(self.exportFile) # use previously chosen export path as default
|
||||
except:
|
||||
pass
|
||||
|
||||
response = dia_chooser.run()
|
||||
if response == gtk.RESPONSE_OK:
|
||||
self.exportDir = dia_chooser.get_filename()
|
||||
print "DEBUG: self.exportDir = %s" %(self.exportDir)
|
||||
elif response == gtk.RESPONSE_CANCEL:
|
||||
|
||||
if response <> gtk.RESPONSE_OK:
|
||||
print 'Closed, no graph exported'
|
||||
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")
|
||||
return
|
||||
|
||||
# generate a unique filename for export
|
||||
now = datetime.now()
|
||||
now_formatted = now.strftime("%Y%m%d%H%M%S")
|
||||
self.exportFile = dia_chooser.get_filename() + "/fpdb" + now_formatted + ".png"
|
||||
dia_chooser.destroy()
|
||||
|
||||
#print "DEBUG: self.exportFile = %s" %(self.exportFile)
|
||||
self.fig.savefig(self.exportFile, format="png")
|
||||
|
||||
#display info box to confirm graph created
|
||||
diainfo = gtk.MessageDialog(parent=self.parent,
|
||||
flags=gtk.DIALOG_DESTROY_WITH_PARENT,
|
||||
type=gtk.MESSAGE_INFO,
|
||||
buttons=gtk.BUTTONS_OK,
|
||||
message_format="Graph created")
|
||||
diainfo.format_secondary_text(self.exportFile)
|
||||
diainfo.run()
|
||||
diainfo.destroy()
|
||||
|
||||
#end of def exportGraph
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#!/usr/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
#Copyright 2008 Carl Gherardi
|
||||
#Copyright 2008-2010 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.
|
||||
|
@ -13,9 +13,7 @@
|
|||
#
|
||||
#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.
|
||||
|
||||
#In the "official" distribution you can find the license in agpl-3.0.txt.
|
||||
|
||||
import os
|
||||
import Queue
|
||||
|
@ -26,6 +24,8 @@ import gtk
|
|||
import gobject
|
||||
import pango
|
||||
|
||||
import os
|
||||
import traceback
|
||||
import logging
|
||||
# logging has been set up in fpdb.py or HUD_main.py, use their settings:
|
||||
log = logging.getLogger("logview")
|
||||
|
@ -33,6 +33,11 @@ log = logging.getLogger("logview")
|
|||
|
||||
MAX_LINES = 100000 # max lines to display in window
|
||||
EST_CHARS_PER_LINE = 150 # used to guesstimate number of lines in log file
|
||||
LOGFILES = [ [ 'Fpdb Errors', 'fpdb-errors.txt', False ] # label, filename, start value
|
||||
, [ 'Fpdb Log', 'fpdb-log.txt', True ]
|
||||
, [ 'HUD Errors', 'HUD-errors.txt', False ]
|
||||
, [ 'HUD Log', 'HUD-log.txt', False ]
|
||||
]
|
||||
|
||||
class GuiLogView:
|
||||
|
||||
|
@ -41,7 +46,7 @@ class GuiLogView:
|
|||
self.main_window = mainwin
|
||||
self.closeq = closeq
|
||||
|
||||
self.logfile = self.config.log_file # name of logfile
|
||||
self.logfile = os.path.join(self.config.dir_log, LOGFILES[1][1])
|
||||
self.dia = gtk.Dialog(title="Log Messages"
|
||||
,parent=None
|
||||
,flags=gtk.DIALOG_DESTROY_WITH_PARENT
|
||||
|
@ -69,10 +74,19 @@ class GuiLogView:
|
|||
scrolledwindow.add(self.listview)
|
||||
self.vbox.pack_start(scrolledwindow, expand=True, fill=True, padding=0)
|
||||
|
||||
hb = gtk.HBox(False, 0)
|
||||
grp = None
|
||||
for logf in LOGFILES:
|
||||
rb = gtk.RadioButton(group=grp, label=logf[0], use_underline=True)
|
||||
if grp is None: grp = rb
|
||||
rb.set_active(logf[2])
|
||||
rb.connect('clicked', self.__set_logfile, logf[0])
|
||||
hb.pack_start(rb, False, False, 3)
|
||||
refreshbutton = gtk.Button("Refresh")
|
||||
refreshbutton.connect("clicked", self.refresh, None)
|
||||
self.vbox.pack_start(refreshbutton, False, False, 3)
|
||||
hb.pack_start(refreshbutton, False, False, 3)
|
||||
refreshbutton.show()
|
||||
self.vbox.pack_start(hb, False, False, 0)
|
||||
|
||||
self.listview.show()
|
||||
scrolledwindow.show()
|
||||
|
@ -90,6 +104,14 @@ class GuiLogView:
|
|||
|
||||
self.dia.connect('response', self.dialog_response_cb)
|
||||
|
||||
def __set_logfile(self, w, file):
|
||||
#print "w is", w, "file is", file, "active is", w.get_active()
|
||||
if w.get_active():
|
||||
for logf in LOGFILES:
|
||||
if logf[0] == file:
|
||||
self.logfile = os.path.join(self.config.dir_log, logf[1])
|
||||
self.refresh(w, file) # params are not used
|
||||
|
||||
def dialog_response_cb(self, dialog, response_id):
|
||||
# this is called whether close button is pressed or window is closed
|
||||
self.closeq.put(self.__class__)
|
||||
|
@ -115,7 +137,7 @@ class GuiLogView:
|
|||
def loadLog(self):
|
||||
|
||||
self.liststore.clear()
|
||||
self.listcols = []
|
||||
# self.listcols = [] blanking listcols causes sortcols() to fail with index out of range
|
||||
|
||||
# guesstimate number of lines in file
|
||||
if os.path.exists(self.logfile):
|
||||
|
@ -131,11 +153,23 @@ class GuiLogView:
|
|||
|
||||
l = 0
|
||||
for line in open(self.logfile):
|
||||
# eg line:
|
||||
# example line in logfile format:
|
||||
# 2009-12-02 15:23:21,716 - config DEBUG config logger initialised
|
||||
l = l + 1
|
||||
if l > startline and len(line) > 49:
|
||||
if l > startline:
|
||||
# NOTE selecting a sort column and then switching to a log file
|
||||
# with several thousand rows will send cpu 100% for a prolonged period.
|
||||
# reason is that the append() method seems to sort every record as it goes, rather than
|
||||
# pulling in the whole file and sorting at the end.
|
||||
# one fix is to check if a column sort has been selected, reset to date/time asc
|
||||
# append all the rows and then reselect the required sort order.
|
||||
# Note: there is no easy method available to revert the list to an "unsorted" state.
|
||||
# always defaulting to date/time asc doesn't work, because some rows do not have date/time info
|
||||
# and would end up sorted out of context.
|
||||
if len(line) > 49 and line[23:26] == ' - ' and line[34:39] == ' ':
|
||||
iter = self.liststore.append( (line[0:23], line[26:32], line[39:46], line[48:].strip(), True) )
|
||||
else:
|
||||
iter = self.liststore.append( ('', '', '', line.strip(), True) )
|
||||
|
||||
def sortCols(self, col, n):
|
||||
try:
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#!/usr/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
#Copyright 2008 Steffen Jobbagy-Felso
|
||||
#Copyright 2010 Steffen Schaumburg
|
||||
#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.
|
||||
|
@ -12,650 +13,10 @@
|
|||
#
|
||||
#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.
|
||||
#In the "official" distribution you can find the license in agpl-3.0.txt.
|
||||
|
||||
import traceback
|
||||
import threading
|
||||
import pygtk
|
||||
pygtk.require('2.0')
|
||||
import gtk
|
||||
import os
|
||||
import sys
|
||||
from time import time, strftime
|
||||
|
||||
import Card
|
||||
import fpdb_import
|
||||
import Database
|
||||
import Filters
|
||||
import Charset
|
||||
|
||||
colalias,colshow,colheading,colxalign,colformat,coltype = 0,1,2,3,4,5
|
||||
ranks = {'x':0, '2':2, '3':3, '4':4, '5':5, '6':6, '7':7, '8':8, '9':9, 'T':10, 'J':11, 'Q':12, 'K':13, 'A':14}
|
||||
|
||||
class GuiPlayerStats(threading.Thread):
|
||||
|
||||
def __init__(self, config, querylist, mainwin, debug=True):
|
||||
self.debug = debug
|
||||
self.conf = config
|
||||
self.main_window = mainwin
|
||||
self.sql = querylist
|
||||
|
||||
self.liststore = [] # gtk.ListStore[] stores the contents of the grids
|
||||
self.listcols = [] # gtk.TreeViewColumn[][] stores the columns in the grids
|
||||
|
||||
self.MYSQL_INNODB = 2
|
||||
self.PGSQL = 3
|
||||
self.SQLITE = 4
|
||||
|
||||
# create new db connection to avoid conflicts with other threads
|
||||
self.db = Database.Database(self.conf, sql=self.sql)
|
||||
self.cursor = self.db.cursor
|
||||
|
||||
settings = {}
|
||||
settings.update(self.conf.get_db_parameters())
|
||||
settings.update(self.conf.get_tv_parameters())
|
||||
settings.update(self.conf.get_import_parameters())
|
||||
settings.update(self.conf.get_default_paths())
|
||||
|
||||
# text used on screen stored here so that it can be configured
|
||||
self.filterText = {'handhead':'Hand Breakdown for all levels listed above'
|
||||
}
|
||||
|
||||
filters_display = { "Heroes" : True,
|
||||
"Sites" : True,
|
||||
"Games" : True,
|
||||
"Limits" : True,
|
||||
"LimitSep" : True,
|
||||
"LimitType" : True,
|
||||
"Type" : True,
|
||||
"Seats" : True,
|
||||
"SeatSep" : True,
|
||||
"Dates" : True,
|
||||
"Groups" : True,
|
||||
"GroupsAll" : True,
|
||||
"Button1" : True,
|
||||
"Button2" : True
|
||||
}
|
||||
|
||||
self.filters = Filters.Filters(self.db, self.conf, self.sql, display = filters_display)
|
||||
self.filters.registerButton1Name("_Filters")
|
||||
self.filters.registerButton1Callback(self.showDetailFilter)
|
||||
self.filters.registerButton2Name("_Refresh")
|
||||
self.filters.registerButton2Callback(self.refreshStats)
|
||||
|
||||
# ToDo: store in config
|
||||
# ToDo: create popup to adjust column config
|
||||
# columns to display, keys match column name returned by sql, values in tuple are:
|
||||
# is column displayed, column heading, xalignment, formatting, celltype
|
||||
self.columns = [ ["game", True, "Game", 0.0, "%s", "str"]
|
||||
, ["hand", False, "Hand", 0.0, "%s", "str"] # true not allowed for this line
|
||||
, ["plposition", False, "Posn", 1.0, "%s", "str"] # true not allowed for this line (set in code)
|
||||
, ["pname", False, "Name", 0.0, "%s", "str"] # true not allowed for this line (set in code)
|
||||
, ["n", True, "Hds", 1.0, "%1.0f", "str"]
|
||||
, ["avgseats", False, "Seats", 1.0, "%3.1f", "str"]
|
||||
, ["vpip", True, "VPIP", 1.0, "%3.1f", "str"]
|
||||
, ["pfr", True, "PFR", 1.0, "%3.1f", "str"]
|
||||
, ["pf3", True, "PF3", 1.0, "%3.1f", "str"]
|
||||
, ["steals", True, "Steals", 1.0, "%3.1f", "str"]
|
||||
, ["saw_f", True, "Saw_F", 1.0, "%3.1f", "str"]
|
||||
, ["sawsd", True, "SawSD", 1.0, "%3.1f", "str"]
|
||||
, ["wtsdwsf", True, "WtSDwsF", 1.0, "%3.1f", "str"]
|
||||
, ["wmsd", True, "W$SD", 1.0, "%3.1f", "str"]
|
||||
, ["flafq", True, "FlAFq", 1.0, "%3.1f", "str"]
|
||||
, ["tuafq", True, "TuAFq", 1.0, "%3.1f", "str"]
|
||||
, ["rvafq", True, "RvAFq", 1.0, "%3.1f", "str"]
|
||||
, ["pofafq", False, "PoFAFq", 1.0, "%3.1f", "str"]
|
||||
, ["net", True, "Net($)", 1.0, "%6.2f", "cash"]
|
||||
, ["bbper100", True, "bb/100", 1.0, "%4.2f", "str"]
|
||||
, ["rake", True, "Rake($)", 1.0, "%6.2f", "cash"]
|
||||
, ["bb100xr", True, "bbxr/100", 1.0, "%4.2f", "str"]
|
||||
, ["variance", True, "Variance", 1.0, "%5.2f", "str"]
|
||||
]
|
||||
|
||||
# Detail filters: This holds the data used in the popup window, extra values are
|
||||
# added at the end of these lists during processing
|
||||
# sql test, screen description, min, max
|
||||
self.handtests = [ # already in filter class : ['h.seats', 'Number of Players', 2, 10]
|
||||
['h.maxSeats', 'Size of Table', 2, 10]
|
||||
,['h.playersVpi', 'Players who VPI', 0, 10]
|
||||
,['h.playersAtStreet1', 'Players at Flop', 0, 10]
|
||||
,['h.playersAtStreet2', 'Players at Turn', 0, 10]
|
||||
,['h.playersAtStreet3', 'Players at River', 0, 10]
|
||||
,['h.playersAtStreet4', 'Players at Street7', 0, 10]
|
||||
,['h.playersAtShowdown', 'Players at Showdown', 0, 10]
|
||||
,['h.street0Raises', 'Bets to See Flop', 0, 5]
|
||||
,['h.street1Raises', 'Bets to See Turn', 0, 5]
|
||||
,['h.street2Raises', 'Bets to See River', 0, 5]
|
||||
,['h.street3Raises', 'Bets to See Street7', 0, 5]
|
||||
,['h.street4Raises', 'Bets to See Showdown', 0, 5]
|
||||
]
|
||||
|
||||
self.stats_frame = None
|
||||
self.stats_vbox = None
|
||||
self.detailFilters = [] # the data used to enhance the sql select
|
||||
|
||||
#self.main_hbox = gtk.HBox(False, 0)
|
||||
#self.main_hbox.show()
|
||||
self.main_hbox = gtk.HPaned()
|
||||
|
||||
self.stats_frame = gtk.Frame()
|
||||
self.stats_frame.show()
|
||||
|
||||
self.stats_vbox = gtk.VBox(False, 0)
|
||||
self.stats_vbox.show()
|
||||
self.stats_frame.add(self.stats_vbox)
|
||||
# self.fillStatsFrame(self.stats_vbox)
|
||||
|
||||
#self.main_hbox.pack_start(self.filters.get_vbox())
|
||||
#self.main_hbox.pack_start(self.stats_frame, expand=True, fill=True)
|
||||
self.main_hbox.pack1(self.filters.get_vbox())
|
||||
self.main_hbox.pack2(self.stats_frame)
|
||||
self.main_hbox.show()
|
||||
|
||||
# make sure Hand column is not displayed
|
||||
[x for x in self.columns if x[0] == 'hand'][0][1] = False
|
||||
|
||||
def get_vbox(self):
|
||||
"""returns the vbox of this thread"""
|
||||
return self.main_hbox
|
||||
|
||||
def refreshStats(self, widget, data):
|
||||
try: self.stats_vbox.destroy()
|
||||
except AttributeError: pass
|
||||
self.liststore = []
|
||||
self.listcols = []
|
||||
#self.stats_vbox = gtk.VBox(False, 0)
|
||||
self.stats_vbox = gtk.VPaned()
|
||||
self.stats_vbox.show()
|
||||
self.stats_frame.add(self.stats_vbox)
|
||||
self.fillStatsFrame(self.stats_vbox)
|
||||
|
||||
def fillStatsFrame(self, vbox):
|
||||
sites = self.filters.getSites()
|
||||
heroes = self.filters.getHeroes()
|
||||
siteids = self.filters.getSiteIds()
|
||||
limits = self.filters.getLimits()
|
||||
type = self.filters.getType()
|
||||
seats = self.filters.getSeats()
|
||||
groups = self.filters.getGroups()
|
||||
dates = self.filters.getDates()
|
||||
games = self.filters.getGames()
|
||||
sitenos = []
|
||||
playerids = []
|
||||
|
||||
# Which sites are selected?
|
||||
for site in sites:
|
||||
if sites[site] == True:
|
||||
sitenos.append(siteids[site])
|
||||
_hname = Charset.to_utf8(heroes[site])
|
||||
result = self.db.get_player_id(self.conf, site, _hname)
|
||||
if result is not None:
|
||||
playerids.append(int(result))
|
||||
|
||||
if not sitenos:
|
||||
#Should probably pop up here.
|
||||
print "No sites selected - defaulting to PokerStars"
|
||||
sitenos = [2]
|
||||
if not playerids:
|
||||
print "No player ids found"
|
||||
return
|
||||
if not limits:
|
||||
print "No limits found"
|
||||
return
|
||||
|
||||
self.createStatsTable(vbox, playerids, sitenos, limits, type, seats, groups, dates, games)
|
||||
|
||||
def createStatsTable(self, vbox, playerids, sitenos, limits, type, seats, groups, dates, games):
|
||||
starttime = time()
|
||||
|
||||
# Scrolled window for summary table
|
||||
swin = gtk.ScrolledWindow(hadjustment=None, vadjustment=None)
|
||||
swin.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
|
||||
swin.show()
|
||||
vbox.pack1(swin)
|
||||
|
||||
# Display summary table at top of page
|
||||
# 3rd parameter passes extra flags, currently includes:
|
||||
# holecards - whether to display card breakdown (True/False)
|
||||
# numhands - min number hands required when displaying all players
|
||||
# gridnum - index for grid data structures
|
||||
flags = [False, self.filters.getNumHands(), 0]
|
||||
self.addGrid(swin, 'playerDetailedStats', flags, playerids
|
||||
,sitenos, limits, type, seats, groups, dates, games)
|
||||
|
||||
# Separator
|
||||
vbox2 = gtk.VBox(False, 0)
|
||||
heading = gtk.Label(self.filterText['handhead'])
|
||||
heading.show()
|
||||
vbox2.pack_start(heading, expand=False, padding=3)
|
||||
|
||||
# Scrolled window for detailed table (display by hand)
|
||||
swin = gtk.ScrolledWindow(hadjustment=None, vadjustment=None)
|
||||
swin.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
|
||||
swin.show()
|
||||
vbox2.pack_start(swin, expand=True, padding=3)
|
||||
vbox.pack2(vbox2)
|
||||
vbox2.show()
|
||||
|
||||
# Detailed table
|
||||
flags[0] = True
|
||||
flags[2] = 1
|
||||
self.addGrid(swin, 'playerDetailedStats', flags, playerids
|
||||
,sitenos, limits, type, seats, groups, dates, games)
|
||||
|
||||
self.db.rollback()
|
||||
print "Stats page displayed in %4.2f seconds" % (time() - starttime)
|
||||
#end def fillStatsFrame(self, vbox):
|
||||
|
||||
def reset_style_render_func(self, treeviewcolumn, cell, model, iter):
|
||||
cell.set_property('foreground', 'black')
|
||||
|
||||
def ledger_style_render_func(self, tvcol, cell, model, iter):
|
||||
str = cell.get_property('text')
|
||||
if '-' in str:
|
||||
str = str.replace("-", "")
|
||||
str = "(%s)" %(str)
|
||||
cell.set_property('text', str)
|
||||
cell.set_property('foreground', 'red')
|
||||
else:
|
||||
cell.set_property('foreground', 'darkgreen')
|
||||
|
||||
return
|
||||
|
||||
def sortnums(self, model, iter1, iter2, nums):
|
||||
try:
|
||||
ret = 0
|
||||
(n, grid) = nums
|
||||
a = self.liststore[grid].get_value(iter1, n)
|
||||
b = self.liststore[grid].get_value(iter2, n)
|
||||
if 'f' in self.cols_to_show[n][4]:
|
||||
try: a = float(a)
|
||||
except: a = 0.0
|
||||
try: b = float(b)
|
||||
except: b = 0.0
|
||||
if n == 0 and grid == 1: #make sure it only works on the starting hands
|
||||
a1,a2,a3 = ranks[a[0]], ranks[a[1]], (a+'o')[2]
|
||||
b1,b2,b3 = ranks[b[0]], ranks[b[1]], (b+'o')[2]
|
||||
if a1 > b1 or ( a1 == b1 and (a2 > b2 or (a2 == b2 and a3 > b3) ) ):
|
||||
ret = 1
|
||||
else:
|
||||
ret = -1
|
||||
else:
|
||||
if a < b:
|
||||
ret = -1
|
||||
elif a == b:
|
||||
ret = 0
|
||||
else:
|
||||
ret = 1
|
||||
#print "n =", n, "iter1[n] =", self.liststore[grid].get_value(iter1,n), "iter2[n] =", self.liststore[grid].get_value(iter2,n), "ret =", ret
|
||||
except:
|
||||
err = traceback.extract_tb(sys.exc_info()[2])
|
||||
print "***sortnums error: " + str(sys.exc_info()[1])
|
||||
print "\n".join( [e[0]+':'+str(e[1])+" "+e[2] for e in err] )
|
||||
|
||||
return(ret)
|
||||
|
||||
def sortcols(self, col, nums):
|
||||
try:
|
||||
#This doesn't actually work yet - clicking heading in top section sorts bottom section :-(
|
||||
(n, grid) = nums
|
||||
if not col.get_sort_indicator() or col.get_sort_order() == gtk.SORT_ASCENDING:
|
||||
col.set_sort_order(gtk.SORT_DESCENDING)
|
||||
else:
|
||||
col.set_sort_order(gtk.SORT_ASCENDING)
|
||||
self.liststore[grid].set_sort_column_id(n, col.get_sort_order())
|
||||
self.liststore[grid].set_sort_func(n, self.sortnums, (n,grid))
|
||||
for i in xrange(len(self.listcols[grid])):
|
||||
self.listcols[grid][i].set_sort_indicator(False)
|
||||
self.listcols[grid][n].set_sort_indicator(True)
|
||||
# use this listcols[col].set_sort_indicator(True)
|
||||
# to turn indicator off for other cols
|
||||
except:
|
||||
err = traceback.extract_tb(sys.exc_info()[2])
|
||||
print "***sortcols error: " + str(sys.exc_info()[1])
|
||||
print "\n".join( [e[0]+':'+str(e[1])+" "+e[2] for e in err] )
|
||||
|
||||
def addGrid(self, vbox, query, flags, playerids, sitenos, limits, type, seats, groups, dates, games):
|
||||
counter = 0
|
||||
row = 0
|
||||
sqlrow = 0
|
||||
if not flags: holecards,grid = False,0
|
||||
else: holecards,grid = flags[0],flags[2]
|
||||
|
||||
tmp = self.sql.query[query]
|
||||
tmp = self.refineQuery(tmp, flags, playerids, sitenos, limits, type, seats, groups, dates, games)
|
||||
self.cursor.execute(tmp)
|
||||
result = self.cursor.fetchall()
|
||||
colnames = [desc[0].lower() for desc in self.cursor.description]
|
||||
|
||||
# pre-fetch some constant values:
|
||||
self.cols_to_show = [x for x in self.columns if x[colshow]]
|
||||
hgametypeid_idx = colnames.index('hgametypeid')
|
||||
|
||||
assert len(self.liststore) == grid, "len(self.liststore)="+str(len(self.liststore))+" grid-1="+str(grid)
|
||||
self.liststore.append( gtk.ListStore(*([str] * len(self.cols_to_show))) )
|
||||
view = gtk.TreeView(model=self.liststore[grid])
|
||||
view.set_grid_lines(gtk.TREE_VIEW_GRID_LINES_BOTH)
|
||||
#vbox.pack_start(view, expand=False, padding=3)
|
||||
vbox.add(view)
|
||||
textcell = gtk.CellRendererText()
|
||||
textcell50 = gtk.CellRendererText()
|
||||
textcell50.set_property('xalign', 0.5)
|
||||
numcell = gtk.CellRendererText()
|
||||
numcell.set_property('xalign', 1.0)
|
||||
assert len(self.listcols) == grid
|
||||
self.listcols.append( [] )
|
||||
|
||||
# Create header row eg column: ("game", True, "Game", 0.0, "%s")
|
||||
for col, column in enumerate(self.cols_to_show):
|
||||
if column[colalias] == 'game' and holecards:
|
||||
s = [x for x in self.columns if x[colalias] == 'hand'][0][colheading]
|
||||
else:
|
||||
s = column[colheading]
|
||||
self.listcols[grid].append(gtk.TreeViewColumn(s))
|
||||
view.append_column(self.listcols[grid][col])
|
||||
if column[colformat] == '%s':
|
||||
if column[colxalign] == 0.0:
|
||||
self.listcols[grid][col].pack_start(textcell, expand=True)
|
||||
self.listcols[grid][col].add_attribute(textcell, 'text', col)
|
||||
cellrend = textcell
|
||||
else:
|
||||
self.listcols[grid][col].pack_start(textcell50, expand=True)
|
||||
self.listcols[grid][col].add_attribute(textcell50, 'text', col)
|
||||
cellrend = textcell50
|
||||
self.listcols[grid][col].set_expand(True)
|
||||
else:
|
||||
self.listcols[grid][col].pack_start(numcell, expand=True)
|
||||
self.listcols[grid][col].add_attribute(numcell, 'text', col)
|
||||
self.listcols[grid][col].set_expand(True)
|
||||
cellrend = numcell
|
||||
#self.listcols[grid][col].set_alignment(column[colxalign]) # no effect?
|
||||
self.listcols[grid][col].set_clickable(True)
|
||||
self.listcols[grid][col].connect("clicked", self.sortcols, (col,grid))
|
||||
if col == 0:
|
||||
self.listcols[grid][col].set_sort_order(gtk.SORT_DESCENDING)
|
||||
self.listcols[grid][col].set_sort_indicator(True)
|
||||
if column[coltype] == 'cash':
|
||||
self.listcols[grid][col].set_cell_data_func(numcell, self.ledger_style_render_func)
|
||||
else:
|
||||
self.listcols[grid][col].set_cell_data_func(cellrend, self.reset_style_render_func)
|
||||
|
||||
rows = len(result) # +1 for title row
|
||||
|
||||
while sqlrow < rows:
|
||||
treerow = []
|
||||
for col,column in enumerate(self.cols_to_show):
|
||||
if column[colalias] in colnames:
|
||||
value = result[sqlrow][colnames.index(column[colalias])]
|
||||
if column[colalias] == 'plposition':
|
||||
if value == 'B':
|
||||
value = 'BB'
|
||||
elif value == 'S':
|
||||
value = 'SB'
|
||||
elif value == '0':
|
||||
value = 'Btn'
|
||||
else:
|
||||
if column[colalias] == 'game':
|
||||
if holecards:
|
||||
value = Card.twoStartCardString( result[sqlrow][hgametypeid_idx] )
|
||||
else:
|
||||
minbb = result[sqlrow][colnames.index('minbigblind')]
|
||||
maxbb = result[sqlrow][colnames.index('maxbigblind')]
|
||||
value = result[sqlrow][colnames.index('limittype')] + ' ' \
|
||||
+ result[sqlrow][colnames.index('category')].title() + ' ' \
|
||||
+ result[sqlrow][colnames.index('name')] + ' $'
|
||||
if 100 * int(minbb/100.0) != minbb:
|
||||
value += '%.2f' % (minbb/100.0)
|
||||
else:
|
||||
value += '%.0f' % (minbb/100.0)
|
||||
if minbb != maxbb:
|
||||
if 100 * int(maxbb/100.0) != maxbb:
|
||||
value += ' - $' + '%.2f' % (maxbb/100.0)
|
||||
else:
|
||||
value += ' - $' + '%.0f' % (maxbb/100.0)
|
||||
else:
|
||||
continue
|
||||
if value and value != -999:
|
||||
treerow.append(column[colformat] % value)
|
||||
else:
|
||||
treerow.append(' ')
|
||||
iter = self.liststore[grid].append(treerow)
|
||||
sqlrow += 1
|
||||
row += 1
|
||||
vbox.show_all()
|
||||
|
||||
#end def addGrid(self, query, vars, playerids, sitenos, limits, type, seats, groups, dates):
|
||||
|
||||
def refineQuery(self, query, flags, playerids, sitenos, limits, type, seats, groups, dates, games):
|
||||
having = ''
|
||||
if not flags:
|
||||
holecards = False
|
||||
numhands = 0
|
||||
else:
|
||||
holecards = flags[0]
|
||||
numhands = flags[1]
|
||||
|
||||
if 'allplayers' in groups and groups['allplayers']:
|
||||
nametest = "(hp.playerId)"
|
||||
if holecards or groups['posn']:
|
||||
pname = "'all players'"
|
||||
# set flag in self.columns to not show player name column
|
||||
[x for x in self.columns if x[0] == 'pname'][0][1] = False
|
||||
# can't do this yet (re-write doing more maths in python instead of sql?)
|
||||
if numhands:
|
||||
nametest = "(-1)"
|
||||
else:
|
||||
pname = "p.name"
|
||||
# set flag in self.columns to show player name column
|
||||
[x for x in self.columns if x[0] == 'pname'][0][1] = True
|
||||
if numhands:
|
||||
having = ' and count(1) > %d ' % (numhands,)
|
||||
else:
|
||||
if playerids:
|
||||
nametest = str(tuple(playerids))
|
||||
nametest = nametest.replace("L", "")
|
||||
nametest = nametest.replace(",)",")")
|
||||
else:
|
||||
nametest = "1 = 2"
|
||||
pname = "p.name"
|
||||
# set flag in self.columns to not show player name column
|
||||
[x for x in self.columns if x[0] == 'pname'][0][1] = False
|
||||
query = query.replace("<player_test>", nametest)
|
||||
query = query.replace("<playerName>", pname)
|
||||
query = query.replace("<havingclause>", having)
|
||||
|
||||
gametest = ""
|
||||
q = []
|
||||
for m in self.filters.display.items():
|
||||
if m[0] == 'Games' and m[1]:
|
||||
for n in games:
|
||||
if games[n]:
|
||||
q.append(n)
|
||||
if len(q) > 0:
|
||||
gametest = str(tuple(q))
|
||||
gametest = gametest.replace("L", "")
|
||||
gametest = gametest.replace(",)",")")
|
||||
gametest = gametest.replace("u'","'")
|
||||
gametest = "and gt.category in %s" % gametest
|
||||
else:
|
||||
gametest = "and gt.category IS NULL"
|
||||
query = query.replace("<game_test>", gametest)
|
||||
|
||||
sitetest = ""
|
||||
q = []
|
||||
for m in self.filters.display.items():
|
||||
if m[0] == 'Sites' and m[1]:
|
||||
for n in sitenos:
|
||||
q.append(n)
|
||||
if len(q) > 0:
|
||||
sitetest = str(tuple(q))
|
||||
sitetest = sitetest.replace("L", "")
|
||||
sitetest = sitetest.replace(",)",")")
|
||||
sitetest = sitetest.replace("u'","'")
|
||||
sitetest = "and gt.siteId in %s" % sitetest
|
||||
else:
|
||||
sitetest = "and gt.siteId IS NULL"
|
||||
query = query.replace("<site_test>", sitetest)
|
||||
|
||||
if seats:
|
||||
query = query.replace('<seats_test>', 'between ' + str(seats['from']) + ' and ' + str(seats['to']))
|
||||
if 'show' in seats and seats['show']:
|
||||
query = query.replace('<groupbyseats>', ',h.seats')
|
||||
query = query.replace('<orderbyseats>', ',h.seats')
|
||||
else:
|
||||
query = query.replace('<groupbyseats>', '')
|
||||
query = query.replace('<orderbyseats>', '')
|
||||
else:
|
||||
query = query.replace('<seats_test>', 'between 0 and 100')
|
||||
query = query.replace('<groupbyseats>', '')
|
||||
query = query.replace('<orderbyseats>', '')
|
||||
|
||||
lims = [int(x) for x in limits if x.isdigit()]
|
||||
potlims = [int(x[0:-2]) for x in limits if len(x) > 2 and x[-2:] == 'pl']
|
||||
nolims = [int(x[0:-2]) for x in limits if len(x) > 2 and x[-2:] == 'nl']
|
||||
bbtest = "and ( (gt.limitType = 'fl' and gt.bigBlind in "
|
||||
# and ( (limit and bb in()) or (nolimit and bb in ()) )
|
||||
if lims:
|
||||
blindtest = str(tuple(lims))
|
||||
blindtest = blindtest.replace("L", "")
|
||||
blindtest = blindtest.replace(",)",")")
|
||||
bbtest = bbtest + blindtest + ' ) '
|
||||
else:
|
||||
bbtest = bbtest + '(-1) ) '
|
||||
bbtest = bbtest + " or (gt.limitType = 'pl' and gt.bigBlind in "
|
||||
if potlims:
|
||||
blindtest = str(tuple(potlims))
|
||||
blindtest = blindtest.replace("L", "")
|
||||
blindtest = blindtest.replace(",)",")")
|
||||
bbtest = bbtest + blindtest + ' ) '
|
||||
else:
|
||||
bbtest = bbtest + '(-1) ) '
|
||||
bbtest = bbtest + " or (gt.limitType = 'nl' and gt.bigBlind in "
|
||||
if nolims:
|
||||
blindtest = str(tuple(nolims))
|
||||
blindtest = blindtest.replace("L", "")
|
||||
blindtest = blindtest.replace(",)",")")
|
||||
bbtest = bbtest + blindtest + ' ) )'
|
||||
else:
|
||||
bbtest = bbtest + '(-1) ) )'
|
||||
if type == 'ring':
|
||||
bbtest = bbtest + " and gt.type = 'ring' "
|
||||
elif type == 'tour':
|
||||
bbtest = " and gt.type = 'tour' "
|
||||
query = query.replace("<gtbigBlind_test>", bbtest)
|
||||
|
||||
if holecards: # re-use level variables for hole card query
|
||||
query = query.replace("<hgameTypeId>", "hp.startcards")
|
||||
query = query.replace("<orderbyhgameTypeId>"
|
||||
, ",case when floor((hp.startcards-1)/13) >= mod((hp.startcards-1),13) then hp.startcards + 0.1 "
|
||||
+ " else 13*mod((hp.startcards-1),13) + floor((hp.startcards-1)/13) + 1 "
|
||||
+ " end desc ")
|
||||
else:
|
||||
query = query.replace("<orderbyhgameTypeId>", "")
|
||||
groupLevels = "show" not in str(limits)
|
||||
if groupLevels:
|
||||
query = query.replace("<hgameTypeId>", "-1")
|
||||
else:
|
||||
query = query.replace("<hgameTypeId>", "h.gameTypeId")
|
||||
|
||||
# process self.detailFilters (a list of tuples)
|
||||
flagtest = ''
|
||||
#self.detailFilters = [('h.seats', 5, 6)] # for debug
|
||||
if self.detailFilters:
|
||||
for f in self.detailFilters:
|
||||
if len(f) == 3:
|
||||
# X between Y and Z
|
||||
flagtest += ' and %s between %s and %s ' % (f[0], str(f[1]), str(f[2]))
|
||||
query = query.replace("<flagtest>", flagtest)
|
||||
|
||||
# allow for differences in sql cast() function:
|
||||
if self.db.backend == self.MYSQL_INNODB:
|
||||
query = query.replace("<signed>", 'signed ')
|
||||
else:
|
||||
query = query.replace("<signed>", '')
|
||||
|
||||
# Filter on dates
|
||||
query = query.replace("<datestest>", " between '" + dates[0] + "' and '" + dates[1] + "'")
|
||||
|
||||
# Group by position?
|
||||
if groups['posn']:
|
||||
#query = query.replace("<position>", "case hp.position when '0' then 'Btn' else hp.position end")
|
||||
query = query.replace("<position>", "hp.position")
|
||||
# set flag in self.columns to show posn column
|
||||
[x for x in self.columns if x[0] == 'plposition'][0][1] = True
|
||||
else:
|
||||
query = query.replace("<position>", "gt.base")
|
||||
# unset flag in self.columns to hide posn column
|
||||
[x for x in self.columns if x[0] == 'plposition'][0][1] = False
|
||||
|
||||
#print "query =\n", query
|
||||
return(query)
|
||||
#end def refineQuery(self, query, playerids, sitenos, limits):
|
||||
|
||||
def showDetailFilter(self, widget, data):
|
||||
detailDialog = gtk.Dialog(title="Detailed Filters", parent=self.main_window
|
||||
,flags=gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT
|
||||
,buttons=(gtk.STOCK_CANCEL, gtk.RESPONSE_REJECT,
|
||||
gtk.STOCK_OK, gtk.RESPONSE_ACCEPT))
|
||||
|
||||
handbox = gtk.VBox(True, 0)
|
||||
detailDialog.vbox.pack_start(handbox, False, False, 0)
|
||||
handbox.show()
|
||||
|
||||
label = gtk.Label("Hand Filters:")
|
||||
handbox.add(label)
|
||||
label.show()
|
||||
|
||||
betweenFilters = []
|
||||
for htest in self.handtests:
|
||||
hbox = gtk.HBox(False, 0)
|
||||
handbox.pack_start(hbox, False, False, 0)
|
||||
hbox.show()
|
||||
|
||||
cb = gtk.CheckButton()
|
||||
lbl_from = gtk.Label(htest[1])
|
||||
lbl_from.set_alignment(xalign=0.0, yalign=0.5)
|
||||
lbl_tween = gtk.Label('between')
|
||||
lbl_to = gtk.Label('and')
|
||||
adj1 = gtk.Adjustment(value=htest[2], lower=0, upper=10, step_incr=1, page_incr=1, page_size=0)
|
||||
sb1 = gtk.SpinButton(adjustment=adj1, climb_rate=0.0, digits=0)
|
||||
adj2 = gtk.Adjustment(value=htest[3], lower=2, upper=10, step_incr=1, page_incr=1, page_size=0)
|
||||
sb2 = gtk.SpinButton(adjustment=adj2, climb_rate=0.0, digits=0)
|
||||
|
||||
for df in [x for x in self.detailFilters if x[0] == htest[0]]:
|
||||
cb.set_active(True)
|
||||
|
||||
hbox.pack_start(cb, expand=False, padding=3)
|
||||
hbox.pack_start(lbl_from, expand=True, padding=3)
|
||||
hbox.pack_start(lbl_tween, expand=False, padding=3)
|
||||
hbox.pack_start(sb1, False, False, 0)
|
||||
hbox.pack_start(lbl_to, expand=False, padding=3)
|
||||
hbox.pack_start(sb2, False, False, 0)
|
||||
|
||||
cb.show()
|
||||
lbl_from.show()
|
||||
lbl_tween.show()
|
||||
sb1.show()
|
||||
lbl_to.show()
|
||||
sb2.show()
|
||||
|
||||
htest[4:7] = [cb,sb1,sb2]
|
||||
|
||||
response = detailDialog.run()
|
||||
|
||||
if response == gtk.RESPONSE_ACCEPT:
|
||||
self.detailFilters = []
|
||||
for ht in self.handtests:
|
||||
if ht[4].get_active():
|
||||
self.detailFilters.append( (ht[0], ht[5].get_value_as_int(), ht[6].get_value_as_int()) )
|
||||
ht[2],ht[3] = ht[5].get_value_as_int(), ht[6].get_value_as_int()
|
||||
print "detailFilters =", self.detailFilters
|
||||
self.refreshStats(None, None)
|
||||
|
||||
detailDialog.destroy()
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
pass
|
||||
#end class GuiPlayerStats
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#!/usr/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
#Copyright 2008 Steffen Jobbagy-Felso
|
||||
#Copyright 2008-2010 Steffen Schaumburg
|
||||
#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.
|
||||
|
@ -12,8 +13,7 @@
|
|||
#
|
||||
#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.
|
||||
#In the "official" distribution you can find the license in agpl-3.0.txt.
|
||||
|
||||
import threading
|
||||
import pygtk
|
||||
|
@ -25,7 +25,6 @@ from time import time, strftime
|
|||
import fpdb_import
|
||||
import Database
|
||||
import Filters
|
||||
import FpdbSQLQueries
|
||||
|
||||
class GuiPositionalStats (threading.Thread):
|
||||
def __init__(self, config, querylist, debug=True):
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#!/usr/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
#Copyright 2008 Carl Gherardi
|
||||
#Copyright 2008-2010 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.
|
||||
|
@ -13,9 +13,7 @@
|
|||
#
|
||||
#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.
|
||||
|
||||
#In the "official" distribution you can find the license in agpl-3.0.txt.
|
||||
|
||||
import xml.dom.minidom
|
||||
from xml.dom.minidom import Node
|
||||
|
@ -28,12 +26,27 @@ import gobject
|
|||
import Configuration
|
||||
|
||||
|
||||
rewrite = { 'general' : 'General', 'supported_databases' : 'Databases'
|
||||
, 'import' : 'Import', 'hud_ui' : 'HUD'
|
||||
, 'supported_sites' : 'Sites', 'supported_games' : 'Games'
|
||||
, 'popup_windows' : 'Popup Windows', 'pu' : 'Window'
|
||||
, 'pu_name' : 'Popup Name', 'pu_stat' : 'Stat'
|
||||
, 'pu_stat_name' : 'Stat Name'
|
||||
, 'aux_windows' : 'Auxiliary Windows', 'aw stud_mucked' : 'stud_mucked'
|
||||
, 'aw mucked' : 'mucked', 'hhcs' : 'Hand History Converters'
|
||||
, 'gui_cash_stats' : 'Ring Player Stats', 'field_type' : 'Field Type'
|
||||
, 'col_title' : 'Column Heading', 'xalignment' : 'Left/Right Align'
|
||||
, 'disp_all' : 'Show in Summaries', 'disp_posn' : 'Show in Position Stats'
|
||||
, 'col_name' : 'Stat Name', 'field_format' : 'Format'
|
||||
}
|
||||
|
||||
class GuiPrefs:
|
||||
|
||||
def __init__(self, config, mainwin, dia):
|
||||
def __init__(self, config, mainwin, dia, parentwin):
|
||||
self.config = config
|
||||
self.main_window = mainwin
|
||||
self.dialog = dia
|
||||
self.parent_window = parentwin #need to pass reference of parent, to set transient
|
||||
|
||||
self.tree_box = gtk.ScrolledWindow()
|
||||
self.tree_box.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
|
||||
|
@ -60,7 +73,7 @@ class GuiPrefs:
|
|||
configColumn.pack_start(cRender, True)
|
||||
configColumn.add_attribute(cRender, 'text', 1)
|
||||
|
||||
configColumn = gtk.TreeViewColumn("Value")
|
||||
configColumn = gtk.TreeViewColumn("Value (double-click to change)")
|
||||
self.configView.append_column(configColumn)
|
||||
cRender = gtk.CellRendererText()
|
||||
configColumn.pack_start(cRender, True)
|
||||
|
@ -79,6 +92,13 @@ class GuiPrefs:
|
|||
self.tree_box.show()
|
||||
self.dialog.show()
|
||||
|
||||
def rewriteText(self, s):
|
||||
upd = False
|
||||
if s in rewrite:
|
||||
s = rewrite[s]
|
||||
upd = True
|
||||
return( (s,upd) )
|
||||
|
||||
def addTreeRows(self, parent, node):
|
||||
if (node.nodeType == node.ELEMENT_NODE):
|
||||
(setting, value) = (node.nodeName, None)
|
||||
|
@ -95,11 +115,15 @@ class GuiPrefs:
|
|||
iter = self.configStore.append( parent, [node, setting, value] )
|
||||
if node.hasAttributes():
|
||||
for i in xrange(node.attributes.length):
|
||||
self.configStore.append( iter, [node, node.attributes.item(i).localName, node.attributes.item(i).value] )
|
||||
if node.attributes.item(i).localName in ('site_name', 'game_name', 'stat_name', 'name', 'db_server', 'site'):
|
||||
localName,updated = self.rewriteText( node.attributes.item(i).localName )
|
||||
self.configStore.append( iter, [node, localName, node.attributes.item(i).value] )
|
||||
if node.attributes.item(i).localName in ('site_name', 'game_name', 'stat_name', 'name', 'db_server', 'site', 'col_name'):
|
||||
name = " " + node.attributes.item(i).value
|
||||
if name != "":
|
||||
self.configStore.set_value(iter, 1, setting+name)
|
||||
|
||||
label,updated = self.rewriteText(setting+name)
|
||||
if name != "" or updated:
|
||||
self.configStore.set_value(iter, 1, label)
|
||||
|
||||
if node.hasChildNodes():
|
||||
for elem in node.childNodes:
|
||||
self.addTreeRows(iter, elem)
|
||||
|
@ -120,7 +144,7 @@ class GuiPrefs:
|
|||
name = tmodel.get_value( iter, 1 )
|
||||
val = tmodel.get_value( iter, 2 )
|
||||
dia_edit = gtk.Dialog(name,
|
||||
self.main_window,
|
||||
self.parent_window,
|
||||
gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT,
|
||||
(gtk.STOCK_CANCEL, gtk.RESPONSE_REJECT,
|
||||
gtk.STOCK_OK, gtk.RESPONSE_ACCEPT))
|
||||
|
@ -162,7 +186,8 @@ if __name__=="__main__":
|
|||
(gtk.STOCK_CANCEL, gtk.RESPONSE_REJECT,
|
||||
gtk.STOCK_SAVE, gtk.RESPONSE_ACCEPT))
|
||||
dia.set_default_size(700, 500)
|
||||
prefs = GuiPrefs(config, win, dia.vbox)
|
||||
pw=dia #pass parent window
|
||||
prefs = GuiPrefs(config, win, dia.vbox,pw)
|
||||
response = dia.run()
|
||||
if response == gtk.RESPONSE_ACCEPT:
|
||||
# save updated config
|
||||
|
|
735
pyfpdb/GuiRingPlayerStats.py
Normal file
735
pyfpdb/GuiRingPlayerStats.py
Normal file
|
@ -0,0 +1,735 @@
|
|||
#!/usr/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
#Copyright 2008-2010 Steffen Schaumburg
|
||||
#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.
|
||||
|
||||
import traceback
|
||||
import threading
|
||||
import pygtk
|
||||
pygtk.require('2.0')
|
||||
import gtk
|
||||
import os
|
||||
import sys
|
||||
from time import time, strftime
|
||||
|
||||
import Card
|
||||
import fpdb_import
|
||||
import Database
|
||||
import Filters
|
||||
import Charset
|
||||
import GuiPlayerStats
|
||||
|
||||
#colalias,colshowsumm,colshowposn,colheading,colxalign,colformat,coltype = 0,1,2,3,4,5,6
|
||||
#new order in config file:
|
||||
colalias,colheading,colshowsumm,colshowposn,colformat,coltype,colxalign = 0,1,2,3,4,5,6
|
||||
ranks = {'x':0, '2':2, '3':3, '4':4, '5':5, '6':6, '7':7, '8':8, '9':9, 'T':10, 'J':11, 'Q':12, 'K':13, 'A':14}
|
||||
|
||||
class GuiRingPlayerStats (GuiPlayerStats.GuiPlayerStats):
|
||||
|
||||
def __init__(self, config, querylist, mainwin, debug=True):
|
||||
self.debug = debug
|
||||
self.conf = config
|
||||
self.main_window = mainwin
|
||||
self.sql = querylist
|
||||
|
||||
self.liststore = [] # gtk.ListStore[] stores the contents of the grids
|
||||
self.listcols = [] # gtk.TreeViewColumn[][] stores the columns in the grids
|
||||
|
||||
self.MYSQL_INNODB = 2
|
||||
self.PGSQL = 3
|
||||
self.SQLITE = 4
|
||||
|
||||
# create new db connection to avoid conflicts with other threads
|
||||
self.db = Database.Database(self.conf, sql=self.sql)
|
||||
self.cursor = self.db.cursor
|
||||
|
||||
settings = {}
|
||||
settings.update(self.conf.get_db_parameters())
|
||||
settings.update(self.conf.get_tv_parameters())
|
||||
settings.update(self.conf.get_import_parameters())
|
||||
settings.update(self.conf.get_default_paths())
|
||||
|
||||
# text used on screen stored here so that it can be configured
|
||||
self.filterText = {'handhead':'Hand Breakdown for all levels listed above'
|
||||
}
|
||||
|
||||
filters_display = { "Heroes" : True,
|
||||
"Sites" : True,
|
||||
"Games" : True,
|
||||
"Limits" : True,
|
||||
"LimitSep" : True,
|
||||
"LimitType" : True,
|
||||
"Type" : True,
|
||||
"Seats" : True,
|
||||
"SeatSep" : True,
|
||||
"Dates" : True,
|
||||
"Groups" : True,
|
||||
"GroupsAll" : True,
|
||||
"Button1" : True,
|
||||
"Button2" : True
|
||||
}
|
||||
|
||||
self.filters = Filters.Filters(self.db, self.conf, self.sql, display = filters_display)
|
||||
self.filters.registerButton1Name("_Filters")
|
||||
self.filters.registerButton1Callback(self.showDetailFilter)
|
||||
self.filters.registerButton2Name("_Refresh Stats")
|
||||
self.filters.registerButton2Callback(self.refreshStats)
|
||||
|
||||
# ToDo: store in config
|
||||
# ToDo: create popup to adjust column config
|
||||
# columns to display, keys match column name returned by sql, values in tuple are:
|
||||
# is column displayed(summary then position), column heading, xalignment, formatting, celltype
|
||||
self.columns = self.conf.get_gui_cash_stat_params()
|
||||
# self.columns = [ ["game", True, True, "Game", 0.0, "%s", "str"]
|
||||
# , ["hand", False, False, "Hand", 0.0, "%s", "str"] # initial setting ignored for this line (set in code)
|
||||
# , ["plposition", False, False, "Posn", 1.0, "%s", "str"] # initial setting ignored for this line (set in code)
|
||||
# , ["pname", False, False, "Name", 0.0, "%s", "str"] # initial setting ignored for this line (set in code)
|
||||
# , ["n", True, True, "Hds", 1.0, "%1.0f", "str"]
|
||||
# , ["avgseats", False, False, "Seats", 1.0, "%3.1f", "str"]
|
||||
# , ["vpip", True, True, "VPIP", 1.0, "%3.1f", "str"]
|
||||
# , ["pfr", True, True, "PFR", 1.0, "%3.1f", "str"]
|
||||
# , ["pf3", True, True, "PF3", 1.0, "%3.1f", "str"]
|
||||
# , ["aggfac", True, True, "AggFac", 1.0, "%2.2f", "str"]
|
||||
# , ["aggfrq", True, True, "AggFreq", 1.0, "%3.1f", "str"]
|
||||
# , ["conbet", True, True, "ContBet", 1.0, "%3.1f", "str"]
|
||||
# , ["rfi", True, True, "RFI", 1.0, "%3.1f", "str"]
|
||||
# , ["steals", True, True, "Steals", 1.0, "%3.1f", "str"]
|
||||
# , ["saw_f", True, True, "Saw_F", 1.0, "%3.1f", "str"]
|
||||
# , ["sawsd", True, True, "SawSD", 1.0, "%3.1f", "str"]
|
||||
# , ["wtsdwsf", True, True, "WtSDwsF", 1.0, "%3.1f", "str"]
|
||||
# , ["wmsd", True, True, "W$SD", 1.0, "%3.1f", "str"]
|
||||
# , ["flafq", True, True, "FlAFq", 1.0, "%3.1f", "str"]
|
||||
# , ["tuafq", True, True, "TuAFq", 1.0, "%3.1f", "str"]
|
||||
# , ["rvafq", True, True, "RvAFq", 1.0, "%3.1f", "str"]
|
||||
# , ["pofafq", False, False, "PoFAFq", 1.0, "%3.1f", "str"]
|
||||
# , ["net", True, True, "Net($)", 1.0, "%6.2f", "cash"]
|
||||
# , ["bbper100", True, True, "bb/100", 1.0, "%4.2f", "str"]
|
||||
# , ["rake", True, True, "Rake($)", 1.0, "%6.2f", "cash"]
|
||||
# , ["bb100xr", True, True, "bbxr/100", 1.0, "%4.2f", "str"]
|
||||
# , ["variance", True, True, "Variance", 1.0, "%5.2f", "str"]
|
||||
# ]
|
||||
|
||||
# Detail filters: This holds the data used in the popup window, extra values are
|
||||
# added at the end of these lists during processing
|
||||
# sql test, screen description, min, max
|
||||
self.handtests = [ # already in filter class : ['h.seats', 'Number of Players', 2, 10]
|
||||
['h.maxSeats', 'Size of Table', 2, 10]
|
||||
,['h.playersVpi', 'Players who VPI', 0, 10]
|
||||
,['h.playersAtStreet1', 'Players at Flop', 0, 10]
|
||||
,['h.playersAtStreet2', 'Players at Turn', 0, 10]
|
||||
,['h.playersAtStreet3', 'Players at River', 0, 10]
|
||||
,['h.playersAtStreet4', 'Players at Street7', 0, 10]
|
||||
,['h.playersAtShowdown', 'Players at Showdown', 0, 10]
|
||||
,['h.street0Raises', 'Bets to See Flop', 0, 5]
|
||||
,['h.street1Raises', 'Bets to See Turn', 0, 5]
|
||||
,['h.street2Raises', 'Bets to See River', 0, 5]
|
||||
,['h.street3Raises', 'Bets to See Street7', 0, 5]
|
||||
,['h.street4Raises', 'Bets to See Showdown', 0, 5]
|
||||
]
|
||||
|
||||
self.stats_frame = None
|
||||
self.stats_vbox = None
|
||||
self.detailFilters = [] # the data used to enhance the sql select
|
||||
|
||||
#self.main_hbox = gtk.HBox(False, 0)
|
||||
#self.main_hbox.show()
|
||||
self.main_hbox = gtk.HPaned()
|
||||
|
||||
self.stats_frame = gtk.Frame()
|
||||
self.stats_frame.show()
|
||||
|
||||
self.stats_vbox = gtk.VPaned()
|
||||
self.stats_vbox.show()
|
||||
self.stats_frame.add(self.stats_vbox)
|
||||
self.top_pane_height = 0
|
||||
self.height_inc = None
|
||||
# self.fillStatsFrame(self.stats_vbox)
|
||||
|
||||
#self.main_hbox.pack_start(self.filters.get_vbox())
|
||||
#self.main_hbox.pack_start(self.stats_frame, expand=True, fill=True)
|
||||
self.main_hbox.pack1(self.filters.get_vbox())
|
||||
self.main_hbox.pack2(self.stats_frame)
|
||||
self.main_hbox.show()
|
||||
|
||||
# make sure Hand column is not displayed
|
||||
[x for x in self.columns if x[0] == 'hand'][0][colshowsumm] = False
|
||||
[x for x in self.columns if x[0] == 'hand'][0][colshowposn] = False
|
||||
# if rfi and steal both on for summaries, turn rfi off
|
||||
if ( [x for x in self.columns if x[0] == 'rfi'][0][colshowsumm]
|
||||
and [x for x in self.columns if x[0] == 'steals'][0][colshowsumm]):
|
||||
[x for x in self.columns if x[0] == 'rfi'][0][colshowsumm] = False
|
||||
# if rfi and steal both on for position breakdowns, turn steals off:
|
||||
if ( [x for x in self.columns if x[0] == 'rfi'][0][colshowposn]
|
||||
and [x for x in self.columns if x[0] == 'steals'][0][colshowposn]):
|
||||
[x for x in self.columns if x[0] == 'steals'][0][colshowposn] = False
|
||||
|
||||
self.last_pos = -1
|
||||
|
||||
|
||||
def get_vbox(self):
|
||||
"""returns the vbox of this thread"""
|
||||
return self.main_hbox
|
||||
#end def get_vbox
|
||||
|
||||
def refreshStats(self, widget, data):
|
||||
#self.last_pos = self.stats_vbox.get_position()
|
||||
self.height_inc = None
|
||||
#old_len = 0
|
||||
#if self.liststore:
|
||||
# old_len = len(self.liststore[0])
|
||||
try: self.stats_vbox.destroy()
|
||||
except AttributeError: pass
|
||||
self.liststore = []
|
||||
self.listcols = []
|
||||
self.stats_vbox = gtk.VPaned()
|
||||
self.stats_vbox.show()
|
||||
self.stats_frame.add(self.stats_vbox)
|
||||
self.fillStatsFrame(self.stats_vbox)
|
||||
|
||||
# set height of top pane
|
||||
# (tried 2 ways, guesstimate using ratio of old to new number of rows and sum of
|
||||
# heights of parts)
|
||||
new_len = 0
|
||||
if self.liststore:
|
||||
#new_len = len(self.liststore[0])
|
||||
#print "setting to", self.top_pane_height + self.height_inc
|
||||
self.stats_vbox.set_position(self.top_pane_height + self.height_inc)
|
||||
#if self.last_pos > 0:
|
||||
# if old_len > 0 and new_len > 0 and new_len <= 10:
|
||||
# self.stats_vbox.set_position(self.last_pos * (new_len+1.9)/(old_len+1.9))
|
||||
# else:
|
||||
# self.stats_vbox.set_position(self.last_pos)
|
||||
#end def refreshStats
|
||||
|
||||
def fillStatsFrame(self, vbox):
|
||||
sites = self.filters.getSites()
|
||||
heroes = self.filters.getHeroes()
|
||||
siteids = self.filters.getSiteIds()
|
||||
limits = self.filters.getLimits()
|
||||
type = self.filters.getType()
|
||||
seats = self.filters.getSeats()
|
||||
groups = self.filters.getGroups()
|
||||
dates = self.filters.getDates()
|
||||
games = self.filters.getGames()
|
||||
sitenos = []
|
||||
playerids = []
|
||||
|
||||
# Which sites are selected?
|
||||
for site in sites:
|
||||
if sites[site] == True:
|
||||
sitenos.append(siteids[site])
|
||||
_hname = Charset.to_utf8(heroes[site])
|
||||
result = self.db.get_player_id(self.conf, site, _hname)
|
||||
if result is not None:
|
||||
playerids.append(int(result))
|
||||
|
||||
if not sitenos:
|
||||
#Should probably pop up here.
|
||||
print "No sites selected - defaulting to PokerStars"
|
||||
sitenos = [2]
|
||||
if not playerids:
|
||||
print "No player ids found"
|
||||
return
|
||||
if not limits:
|
||||
print "No limits found"
|
||||
return
|
||||
|
||||
self.createStatsTable(vbox, playerids, sitenos, limits, type, seats, groups, dates, games)
|
||||
#end def fillStatsFrame
|
||||
|
||||
def createStatsTable(self, vbox, playerids, sitenos, limits, type, seats, groups, dates, games):
|
||||
startTime = time()
|
||||
show_detail = True
|
||||
|
||||
# Scrolled window for summary table
|
||||
swin = gtk.ScrolledWindow(hadjustment=None, vadjustment=None)
|
||||
swin.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
|
||||
vbox.pack1(swin) #, resize=True) don't use resize, self.height_inc relies on initial
|
||||
# height of pane being correct for one row
|
||||
|
||||
# Display summary table at top of page
|
||||
# 3rd parameter passes extra flags, currently includes:
|
||||
# holecards - whether to display card breakdown (True/False)
|
||||
# numhands - min number hands required when displaying all players
|
||||
# gridnum - index for grid data structures
|
||||
flags = [False, self.filters.getNumHands(), 0]
|
||||
self.addGrid(swin, 'playerDetailedStats', flags, playerids
|
||||
,sitenos, limits, type, seats, groups, dates, games)
|
||||
swin.show()
|
||||
|
||||
if 'allplayers' in groups and groups['allplayers']:
|
||||
# can't currently do this combination so skip detailed table
|
||||
show_detail = False
|
||||
|
||||
if show_detail:
|
||||
# Separator
|
||||
vbox2 = gtk.VBox(False, 0)
|
||||
heading = gtk.Label(self.filterText['handhead'])
|
||||
heading.show()
|
||||
vbox2.pack_start(heading, expand=False, padding=3)
|
||||
|
||||
# Scrolled window for detailed table (display by hand)
|
||||
swin2 = gtk.ScrolledWindow(hadjustment=None, vadjustment=None)
|
||||
swin2.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
|
||||
swin2.show()
|
||||
vbox2.pack_start(swin2, expand=True, padding=3)
|
||||
vbox.pack2(vbox2)
|
||||
vbox2.show()
|
||||
|
||||
# Detailed table
|
||||
flags[0] = True
|
||||
flags[2] = 1
|
||||
self.addGrid(swin2, 'playerDetailedStats', flags, playerids
|
||||
,sitenos, limits, type, seats, groups, dates, games)
|
||||
|
||||
if self.height_inc is None:
|
||||
self.height_inc = 0
|
||||
# need this to check whether scrollbar is visible:
|
||||
while gtk.events_pending(): # see http://faq.pygtk.org/index.py?req=index for more hints (3.7)
|
||||
gtk.main_iteration(False)
|
||||
hs = swin.get_hscrollbar()
|
||||
if hs is not None:
|
||||
#print "hs vis", hs.get_property('visible'), hs.get_property('visible').__class__
|
||||
if hs.get_property('visible'):
|
||||
self.height_inc = hs.size_request()[1] + swin.style_get_property('scrollbar-spacing')
|
||||
#print "hh set to", self.height_inc
|
||||
self.stats_vbox.set_position(self.top_pane_height + self.height_inc)
|
||||
|
||||
self.db.rollback()
|
||||
print "Stats page displayed in %4.2f seconds" % (time() - startTime)
|
||||
#end def createStatsTable
|
||||
|
||||
def reset_style_render_func(self, treeviewcolumn, cell, model, iter):
|
||||
cell.set_property('foreground', 'black')
|
||||
#end def reset_style_render_func
|
||||
|
||||
def ledger_style_render_func(self, tvcol, cell, model, iter):
|
||||
str = cell.get_property('text')
|
||||
if '-' in str:
|
||||
str = str.replace("-", "")
|
||||
str = "(%s)" %(str)
|
||||
cell.set_property('text', str)
|
||||
cell.set_property('foreground', 'red')
|
||||
else:
|
||||
cell.set_property('foreground', 'darkgreen')
|
||||
|
||||
return
|
||||
|
||||
def sortnums(self, model, iter1, iter2, nums):
|
||||
try:
|
||||
ret = 0
|
||||
(n, grid) = nums
|
||||
a = self.liststore[grid].get_value(iter1, n)
|
||||
b = self.liststore[grid].get_value(iter2, n)
|
||||
if 'f' in self.cols_to_show[n][4]:
|
||||
try: a = float(a)
|
||||
except: a = 0.0
|
||||
try: b = float(b)
|
||||
except: b = 0.0
|
||||
if n == 0 and grid == 1: #make sure it only works on the starting hands
|
||||
a1,a2,a3 = ranks[a[0]], ranks[a[1]], (a+'o')[2]
|
||||
b1,b2,b3 = ranks[b[0]], ranks[b[1]], (b+'o')[2]
|
||||
if a1 > b1 or ( a1 == b1 and (a2 > b2 or (a2 == b2 and a3 > b3) ) ):
|
||||
ret = 1
|
||||
else:
|
||||
ret = -1
|
||||
else:
|
||||
if a < b:
|
||||
ret = -1
|
||||
elif a == b:
|
||||
ret = 0
|
||||
else:
|
||||
ret = 1
|
||||
#print "n =", n, "iter1[n] =", self.liststore[grid].get_value(iter1,n), "iter2[n] =", self.liststore[grid].get_value(iter2,n), "ret =", ret
|
||||
except:
|
||||
err = traceback.extract_tb(sys.exc_info()[2])
|
||||
print "***sortnums error: " + str(sys.exc_info()[1])
|
||||
print "\n".join( [e[0]+':'+str(e[1])+" "+e[2] for e in err] )
|
||||
|
||||
return(ret)
|
||||
|
||||
def sortcols(self, col, nums):
|
||||
try:
|
||||
#This doesn't actually work yet - clicking heading in top section sorts bottom section :-(
|
||||
(n, grid) = nums
|
||||
if not col.get_sort_indicator() or col.get_sort_order() == gtk.SORT_ASCENDING:
|
||||
col.set_sort_order(gtk.SORT_DESCENDING)
|
||||
else:
|
||||
col.set_sort_order(gtk.SORT_ASCENDING)
|
||||
self.liststore[grid].set_sort_column_id(n, col.get_sort_order())
|
||||
self.liststore[grid].set_sort_func(n, self.sortnums, (n,grid))
|
||||
for i in xrange(len(self.listcols[grid])):
|
||||
self.listcols[grid][i].set_sort_indicator(False)
|
||||
self.listcols[grid][n].set_sort_indicator(True)
|
||||
# use this listcols[col].set_sort_indicator(True)
|
||||
# to turn indicator off for other cols
|
||||
except:
|
||||
err = traceback.extract_tb(sys.exc_info()[2])
|
||||
print "***sortcols error: " + str(sys.exc_info()[1])
|
||||
print "\n".join( [e[0]+':'+str(e[1])+" "+e[2] for e in err] )
|
||||
#end def sortcols
|
||||
|
||||
def addGrid(self, vbox, query, flags, playerids, sitenos, limits, type, seats, groups, dates, games):
|
||||
counter = 0
|
||||
row = 0
|
||||
sqlrow = 0
|
||||
if not flags: holecards,grid = False,0
|
||||
else: holecards,grid = flags[0],flags[2]
|
||||
|
||||
tmp = self.sql.query[query]
|
||||
tmp = self.refineQuery(tmp, flags, playerids, sitenos, limits, type, seats, groups, dates, games)
|
||||
self.cursor.execute(tmp)
|
||||
result = self.cursor.fetchall()
|
||||
colnames = [desc[0].lower() for desc in self.cursor.description]
|
||||
|
||||
# pre-fetch some constant values:
|
||||
colshow = colshowsumm
|
||||
if groups['posn']: colshow = colshowposn
|
||||
self.cols_to_show = [x for x in self.columns if x[colshow]]
|
||||
hgametypeid_idx = colnames.index('hgametypeid')
|
||||
|
||||
assert len(self.liststore) == grid, "len(self.liststore)="+str(len(self.liststore))+" grid-1="+str(grid)
|
||||
self.liststore.append( gtk.ListStore(*([str] * len(self.cols_to_show))) )
|
||||
view = gtk.TreeView(model=self.liststore[grid])
|
||||
view.set_grid_lines(gtk.TREE_VIEW_GRID_LINES_BOTH)
|
||||
#vbox.pack_start(view, expand=False, padding=3)
|
||||
vbox.add(view)
|
||||
textcell = gtk.CellRendererText()
|
||||
textcell50 = gtk.CellRendererText()
|
||||
textcell50.set_property('xalign', 0.5)
|
||||
numcell = gtk.CellRendererText()
|
||||
numcell.set_property('xalign', 1.0)
|
||||
assert len(self.listcols) == grid
|
||||
self.listcols.append( [] )
|
||||
|
||||
# Create header row eg column: ("game", True, "Game", 0.0, "%s")
|
||||
for col, column in enumerate(self.cols_to_show):
|
||||
if column[colalias] == 'game' and holecards:
|
||||
s = [x for x in self.columns if x[colalias] == 'hand'][0][colheading]
|
||||
else:
|
||||
s = column[colheading]
|
||||
self.listcols[grid].append(gtk.TreeViewColumn(s))
|
||||
view.append_column(self.listcols[grid][col])
|
||||
if column[colformat] == '%s':
|
||||
if column[colxalign] == 0.0:
|
||||
self.listcols[grid][col].pack_start(textcell, expand=True)
|
||||
self.listcols[grid][col].add_attribute(textcell, 'text', col)
|
||||
cellrend = textcell
|
||||
else:
|
||||
self.listcols[grid][col].pack_start(textcell50, expand=True)
|
||||
self.listcols[grid][col].add_attribute(textcell50, 'text', col)
|
||||
cellrend = textcell50
|
||||
self.listcols[grid][col].set_expand(True)
|
||||
else:
|
||||
self.listcols[grid][col].pack_start(numcell, expand=True)
|
||||
self.listcols[grid][col].add_attribute(numcell, 'text', col)
|
||||
self.listcols[grid][col].set_expand(True)
|
||||
cellrend = numcell
|
||||
#self.listcols[grid][col].set_alignment(column[colxalign]) # no effect?
|
||||
self.listcols[grid][col].set_clickable(True)
|
||||
self.listcols[grid][col].connect("clicked", self.sortcols, (col,grid))
|
||||
if col == 0:
|
||||
self.listcols[grid][col].set_sort_order(gtk.SORT_DESCENDING)
|
||||
self.listcols[grid][col].set_sort_indicator(True)
|
||||
if column[coltype] == 'cash':
|
||||
self.listcols[grid][col].set_cell_data_func(numcell, self.ledger_style_render_func)
|
||||
else:
|
||||
self.listcols[grid][col].set_cell_data_func(cellrend, self.reset_style_render_func)
|
||||
|
||||
rows = len(result) # +1 for title row
|
||||
|
||||
while sqlrow < rows:
|
||||
treerow = []
|
||||
for col,column in enumerate(self.cols_to_show):
|
||||
if column[colalias] in colnames:
|
||||
value = result[sqlrow][colnames.index(column[colalias])]
|
||||
if column[colalias] == 'plposition':
|
||||
if value == 'B':
|
||||
value = 'BB'
|
||||
elif value == 'S':
|
||||
value = 'SB'
|
||||
elif value == '0':
|
||||
value = 'Btn'
|
||||
else:
|
||||
if column[colalias] == 'game':
|
||||
if holecards:
|
||||
value = Card.twoStartCardString( result[sqlrow][hgametypeid_idx] )
|
||||
else:
|
||||
minbb = result[sqlrow][colnames.index('minbigblind')]
|
||||
maxbb = result[sqlrow][colnames.index('maxbigblind')]
|
||||
value = result[sqlrow][colnames.index('limittype')] + ' ' \
|
||||
+ result[sqlrow][colnames.index('category')].title() + ' ' \
|
||||
+ result[sqlrow][colnames.index('name')] + ' $'
|
||||
if 100 * int(minbb/100.0) != minbb:
|
||||
value += '%.2f' % (minbb/100.0)
|
||||
else:
|
||||
value += '%.0f' % (minbb/100.0)
|
||||
if minbb != maxbb:
|
||||
if 100 * int(maxbb/100.0) != maxbb:
|
||||
value += ' - $' + '%.2f' % (maxbb/100.0)
|
||||
else:
|
||||
value += ' - $' + '%.0f' % (maxbb/100.0)
|
||||
else:
|
||||
continue
|
||||
if value and value != -999:
|
||||
treerow.append(column[colformat] % value)
|
||||
else:
|
||||
treerow.append(' ')
|
||||
iter = self.liststore[grid].append(treerow)
|
||||
#print treerow
|
||||
sqlrow += 1
|
||||
row += 1
|
||||
vbox.show_all()
|
||||
view.show()
|
||||
if len(self.liststore) == 1:
|
||||
#print "view hieght is ", view.get_allocation().height, view.size_request(), view.get_visible_rect().height, view.get_vadjustment().get_value()
|
||||
self.top_pane_height = view.size_request()[1]
|
||||
#print "saved ", self.top_pane_height
|
||||
#end def addGrid
|
||||
|
||||
def refineQuery(self, query, flags, playerids, sitenos, limits, type, seats, groups, dates, games):
|
||||
having = ''
|
||||
if not flags:
|
||||
holecards = False
|
||||
numhands = 0
|
||||
else:
|
||||
holecards = flags[0]
|
||||
numhands = flags[1]
|
||||
colshow = colshowsumm
|
||||
if groups['posn']: colshow = colshowposn
|
||||
|
||||
if 'allplayers' in groups and groups['allplayers']:
|
||||
nametest = "(hp.playerId)"
|
||||
if holecards or groups['posn']:
|
||||
pname = "'all players'"
|
||||
# set flag in self.columns to not show player name column
|
||||
[x for x in self.columns if x[0] == 'pname'][0][colshow] = False
|
||||
# can't do this yet (re-write doing more maths in python instead of sql?)
|
||||
if numhands:
|
||||
nametest = "(-1)"
|
||||
else:
|
||||
pname = "p.name"
|
||||
# set flag in self.columns to show player name column
|
||||
[x for x in self.columns if x[0] == 'pname'][0][colshow] = True
|
||||
if numhands:
|
||||
having = ' and count(1) > %d ' % (numhands,)
|
||||
else:
|
||||
if playerids:
|
||||
nametest = str(tuple(playerids))
|
||||
nametest = nametest.replace("L", "")
|
||||
nametest = nametest.replace(",)",")")
|
||||
else:
|
||||
nametest = "1 = 2"
|
||||
pname = "p.name"
|
||||
# set flag in self.columns to not show player name column
|
||||
[x for x in self.columns if x[0] == 'pname'][0][colshow] = False
|
||||
query = query.replace("<player_test>", nametest)
|
||||
query = query.replace("<playerName>", pname)
|
||||
query = query.replace("<havingclause>", having)
|
||||
|
||||
gametest = ""
|
||||
q = []
|
||||
for m in self.filters.display.items():
|
||||
if m[0] == 'Games' and m[1]:
|
||||
for n in games:
|
||||
if games[n]:
|
||||
q.append(n)
|
||||
if len(q) > 0:
|
||||
gametest = str(tuple(q))
|
||||
gametest = gametest.replace("L", "")
|
||||
gametest = gametest.replace(",)",")")
|
||||
gametest = gametest.replace("u'","'")
|
||||
gametest = "and gt.category in %s" % gametest
|
||||
else:
|
||||
gametest = "and gt.category IS NULL"
|
||||
query = query.replace("<game_test>", gametest)
|
||||
|
||||
sitetest = ""
|
||||
q = []
|
||||
for m in self.filters.display.items():
|
||||
if m[0] == 'Sites' and m[1]:
|
||||
for n in sitenos:
|
||||
q.append(n)
|
||||
if len(q) > 0:
|
||||
sitetest = str(tuple(q))
|
||||
sitetest = sitetest.replace("L", "")
|
||||
sitetest = sitetest.replace(",)",")")
|
||||
sitetest = sitetest.replace("u'","'")
|
||||
sitetest = "and gt.siteId in %s" % sitetest
|
||||
else:
|
||||
sitetest = "and gt.siteId IS NULL"
|
||||
query = query.replace("<site_test>", sitetest)
|
||||
|
||||
if seats:
|
||||
query = query.replace('<seats_test>', 'between ' + str(seats['from']) + ' and ' + str(seats['to']))
|
||||
if 'show' in seats and seats['show']:
|
||||
query = query.replace('<groupbyseats>', ',h.seats')
|
||||
query = query.replace('<orderbyseats>', ',h.seats')
|
||||
else:
|
||||
query = query.replace('<groupbyseats>', '')
|
||||
query = query.replace('<orderbyseats>', '')
|
||||
else:
|
||||
query = query.replace('<seats_test>', 'between 0 and 100')
|
||||
query = query.replace('<groupbyseats>', '')
|
||||
query = query.replace('<orderbyseats>', '')
|
||||
|
||||
lims = [int(x) for x in limits if x.isdigit()]
|
||||
potlims = [int(x[0:-2]) for x in limits if len(x) > 2 and x[-2:] == 'pl']
|
||||
nolims = [int(x[0:-2]) for x in limits if len(x) > 2 and x[-2:] == 'nl']
|
||||
bbtest = "and ( (gt.limitType = 'fl' and gt.bigBlind in "
|
||||
# and ( (limit and bb in()) or (nolimit and bb in ()) )
|
||||
if lims:
|
||||
blindtest = str(tuple(lims))
|
||||
blindtest = blindtest.replace("L", "")
|
||||
blindtest = blindtest.replace(",)",")")
|
||||
bbtest = bbtest + blindtest + ' ) '
|
||||
else:
|
||||
bbtest = bbtest + '(-1) ) '
|
||||
bbtest = bbtest + " or (gt.limitType = 'pl' and gt.bigBlind in "
|
||||
if potlims:
|
||||
blindtest = str(tuple(potlims))
|
||||
blindtest = blindtest.replace("L", "")
|
||||
blindtest = blindtest.replace(",)",")")
|
||||
bbtest = bbtest + blindtest + ' ) '
|
||||
else:
|
||||
bbtest = bbtest + '(-1) ) '
|
||||
bbtest = bbtest + " or (gt.limitType = 'nl' and gt.bigBlind in "
|
||||
if nolims:
|
||||
blindtest = str(tuple(nolims))
|
||||
blindtest = blindtest.replace("L", "")
|
||||
blindtest = blindtest.replace(",)",")")
|
||||
bbtest = bbtest + blindtest + ' ) )'
|
||||
else:
|
||||
bbtest = bbtest + '(-1) ) )'
|
||||
if type == 'ring':
|
||||
bbtest = bbtest + " and gt.type = 'ring' "
|
||||
elif type == 'tour':
|
||||
bbtest = " and gt.type = 'tour' "
|
||||
query = query.replace("<gtbigBlind_test>", bbtest)
|
||||
|
||||
if holecards: # re-use level variables for hole card query
|
||||
query = query.replace("<hgameTypeId>", "hp.startcards")
|
||||
query = query.replace("<orderbyhgameTypeId>"
|
||||
, ",case when floor((hp.startcards-1)/13) >= mod((hp.startcards-1),13) then hp.startcards + 0.1 "
|
||||
+ " else 13*mod((hp.startcards-1),13) + floor((hp.startcards-1)/13) + 1 "
|
||||
+ " end desc ")
|
||||
else:
|
||||
query = query.replace("<orderbyhgameTypeId>", "")
|
||||
groupLevels = "show" not in str(limits)
|
||||
if groupLevels:
|
||||
query = query.replace("<hgameTypeId>", "p.name") # need to use p.name for sqlite posn stats to work
|
||||
else:
|
||||
query = query.replace("<hgameTypeId>", "h.gameTypeId")
|
||||
|
||||
# process self.detailFilters (a list of tuples)
|
||||
flagtest = ''
|
||||
#self.detailFilters = [('h.seats', 5, 6)] # for debug
|
||||
if self.detailFilters:
|
||||
for f in self.detailFilters:
|
||||
if len(f) == 3:
|
||||
# X between Y and Z
|
||||
flagtest += ' and %s between %s and %s ' % (f[0], str(f[1]), str(f[2]))
|
||||
query = query.replace("<flagtest>", flagtest)
|
||||
|
||||
# allow for differences in sql cast() function:
|
||||
if self.db.backend == self.MYSQL_INNODB:
|
||||
query = query.replace("<signed>", 'signed ')
|
||||
else:
|
||||
query = query.replace("<signed>", '')
|
||||
|
||||
# Filter on dates
|
||||
query = query.replace("<datestest>", " between '" + dates[0] + "' and '" + dates[1] + "'")
|
||||
|
||||
# Group by position?
|
||||
if groups['posn']:
|
||||
#query = query.replace("<position>", "case hp.position when '0' then 'Btn' else hp.position end")
|
||||
query = query.replace("<position>", "hp.position")
|
||||
# set flag in self.columns to show posn column
|
||||
[x for x in self.columns if x[0] == 'plposition'][0][colshow] = True
|
||||
else:
|
||||
query = query.replace("<position>", "gt.base")
|
||||
# unset flag in self.columns to hide posn column
|
||||
[x for x in self.columns if x[0] == 'plposition'][0][colshow] = False
|
||||
|
||||
#print "query =\n", query
|
||||
return(query)
|
||||
#end def refineQuery
|
||||
|
||||
def showDetailFilter(self, widget, data):
|
||||
detailDialog = gtk.Dialog(title="Detailed Filters", parent=self.main_window
|
||||
,flags=gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT
|
||||
,buttons=(gtk.STOCK_CANCEL, gtk.RESPONSE_REJECT,
|
||||
gtk.STOCK_OK, gtk.RESPONSE_ACCEPT))
|
||||
|
||||
handbox = gtk.VBox(True, 0)
|
||||
detailDialog.vbox.pack_start(handbox, False, False, 0)
|
||||
handbox.show()
|
||||
|
||||
label = gtk.Label("Hand Filters:")
|
||||
handbox.add(label)
|
||||
label.show()
|
||||
|
||||
betweenFilters = []
|
||||
for htest in self.handtests:
|
||||
hbox = gtk.HBox(False, 0)
|
||||
handbox.pack_start(hbox, False, False, 0)
|
||||
hbox.show()
|
||||
|
||||
cb = gtk.CheckButton()
|
||||
lbl_from = gtk.Label(htest[1])
|
||||
lbl_from.set_alignment(xalign=0.0, yalign=0.5)
|
||||
lbl_tween = gtk.Label('between')
|
||||
lbl_to = gtk.Label('and')
|
||||
adj1 = gtk.Adjustment(value=htest[2], lower=0, upper=10, step_incr=1, page_incr=1, page_size=0)
|
||||
sb1 = gtk.SpinButton(adjustment=adj1, climb_rate=0.0, digits=0)
|
||||
adj2 = gtk.Adjustment(value=htest[3], lower=2, upper=10, step_incr=1, page_incr=1, page_size=0)
|
||||
sb2 = gtk.SpinButton(adjustment=adj2, climb_rate=0.0, digits=0)
|
||||
|
||||
for df in [x for x in self.detailFilters if x[0] == htest[0]]:
|
||||
cb.set_active(True)
|
||||
|
||||
hbox.pack_start(cb, expand=False, padding=3)
|
||||
hbox.pack_start(lbl_from, expand=True, padding=3)
|
||||
hbox.pack_start(lbl_tween, expand=False, padding=3)
|
||||
hbox.pack_start(sb1, False, False, 0)
|
||||
hbox.pack_start(lbl_to, expand=False, padding=3)
|
||||
hbox.pack_start(sb2, False, False, 0)
|
||||
|
||||
cb.show()
|
||||
lbl_from.show()
|
||||
lbl_tween.show()
|
||||
sb1.show()
|
||||
lbl_to.show()
|
||||
sb2.show()
|
||||
|
||||
htest[4:7] = [cb,sb1,sb2]
|
||||
|
||||
response = detailDialog.run()
|
||||
|
||||
if response == gtk.RESPONSE_ACCEPT:
|
||||
self.detailFilters = []
|
||||
for ht in self.handtests:
|
||||
if ht[4].get_active():
|
||||
self.detailFilters.append( (ht[0], ht[5].get_value_as_int(), ht[6].get_value_as_int()) )
|
||||
ht[2],ht[3] = ht[5].get_value_as_int(), ht[6].get_value_as_int()
|
||||
print "detailFilters =", self.detailFilters
|
||||
self.refreshStats(None, None)
|
||||
|
||||
detailDialog.destroy()
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
@ -1,6 +1,7 @@
|
|||
#!/usr/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
#Copyright 2008 Steffen Jobbagy-Felso
|
||||
#Copyright 2008-2010 Steffen Schaumburg
|
||||
#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.
|
||||
|
@ -12,8 +13,7 @@
|
|||
#
|
||||
#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.
|
||||
#In the "official" distribution you can find the license in agpl-3.0.txt.
|
||||
|
||||
import sys
|
||||
import threading
|
||||
|
@ -33,7 +33,7 @@ try:
|
|||
from matplotlib.backends.backend_gtkagg import NavigationToolbar2GTKAgg as NavigationToolbar
|
||||
from matplotlib.finance import candlestick2
|
||||
|
||||
from numpy import diff, nonzero, sum, cumsum, max, min
|
||||
from numpy import diff, nonzero, sum, cumsum, max, min, append
|
||||
# from matplotlib.dates import DateFormatter, WeekdayLocator, HourLocator, \
|
||||
# DayLocator, MONDAY, timezone
|
||||
|
||||
|
@ -46,7 +46,6 @@ import Card
|
|||
import fpdb_import
|
||||
import Database
|
||||
import Filters
|
||||
import FpdbSQLQueries
|
||||
import Charset
|
||||
|
||||
class GuiSessionViewer (threading.Thread):
|
||||
|
@ -184,7 +183,7 @@ class GuiSessionViewer (threading.Thread):
|
|||
sitenos.append(siteids[site])
|
||||
_q = self.sql.query['getPlayerId']
|
||||
_name = Charset.to_utf8(heroes[site])
|
||||
print 'DEBUG(_name) :: %s' % _name
|
||||
#print 'DEBUG(_name) :: %s' % _name
|
||||
self.cursor.execute(_q, (_name,)) # arg = tuple
|
||||
result = self.db.cursor.fetchall()
|
||||
if len(result) == 1:
|
||||
|
@ -241,6 +240,9 @@ class GuiSessionViewer (threading.Thread):
|
|||
#end def fillStatsFrame(self, vbox):
|
||||
|
||||
def generateDatasets(self, playerids, sitenos, limits, seats):
|
||||
THRESHOLD = 1800 # Minimum number of seconds between consecutive hands before being considered a new session
|
||||
PADDING = 5 # Additional time in minutes to add to a session, session startup, shutdown etc (FiXME: user configurable)
|
||||
|
||||
# Get a list of all handids and their timestampts
|
||||
#FIXME: Query still need to filter on blind levels
|
||||
|
||||
|
@ -255,23 +257,31 @@ class GuiSessionViewer (threading.Thread):
|
|||
q = q.replace("<ampersand_s>", "%s")
|
||||
|
||||
self.db.cursor.execute(q)
|
||||
THRESHOLD = 1800
|
||||
hands = self.db.cursor.fetchall()
|
||||
|
||||
# Take that list and create an array of the time between hands
|
||||
times = map(lambda x:long(x[0]), hands)
|
||||
handids = map(lambda x:int(x[1]), hands)
|
||||
winnings = map(lambda x:float(x[4]), hands)
|
||||
print "DEBUG: len(times) %s" %(len(times))
|
||||
#print "DEBUG: len(times) %s" %(len(times))
|
||||
diffs = diff(times) # This array is the difference in starttime between consecutive hands
|
||||
index = nonzero(diff(times) > THRESHOLD) # This array represents the indexes into 'times' for start/end times of sessions
|
||||
# ie. times[index[0][0]] is the end of the first session
|
||||
diffs2 = append(diffs,THRESHOLD + 1) # Append an additional session to the end of the diffs, so the next line
|
||||
# includes an index into the last 'session'
|
||||
index = nonzero(diffs2 > THRESHOLD) # This array represents the indexes into 'times' for start/end times of sessions
|
||||
# times[index[0][0]] is the end of the first session,
|
||||
#print "DEBUG: len(index[0]) %s" %(len(index[0]))
|
||||
if len(index[0]) > 0:
|
||||
#print "DEBUG: index[0][0] %s" %(index[0][0])
|
||||
#print "DEBUG: index %s" %(index)
|
||||
pass
|
||||
else:
|
||||
index = [[0]]
|
||||
#print "DEBUG: index %s" %(index)
|
||||
#print "DEBUG: index[0][0] %s" %(index[0][0])
|
||||
pass
|
||||
|
||||
total = 0
|
||||
last_idx = 0
|
||||
first_idx = 0
|
||||
lowidx = 0
|
||||
uppidx = 0
|
||||
opens = []
|
||||
|
@ -281,27 +291,36 @@ class GuiSessionViewer (threading.Thread):
|
|||
results = []
|
||||
cum_sum = cumsum(winnings)
|
||||
cum_sum = cum_sum/100
|
||||
sid = 1
|
||||
# Take all results and format them into a list for feeding into gui model.
|
||||
for i in range(len(index[0])):
|
||||
sid = i # Session id
|
||||
hds = index[0][i] - last_idx # Number of hands in session
|
||||
hds = index[0][i] - first_idx + 1 # Number of hands in session
|
||||
if hds > 0:
|
||||
stime = strftime("%d/%m/%Y %H:%M", localtime(times[last_idx])) # Formatted start time
|
||||
stime = strftime("%d/%m/%Y %H:%M", localtime(times[first_idx])) # Formatted start time
|
||||
etime = strftime("%d/%m/%Y %H:%M", localtime(times[index[0][i]])) # Formatted end time
|
||||
hph = (times[index[0][i]] - times[last_idx])/60 # Hands per hour
|
||||
won = sum(winnings[last_idx:index[0][i]])/100.0
|
||||
hwm = max(cum_sum[last_idx:index[0][i]])
|
||||
lwm = min(cum_sum[last_idx:index[0][i]])
|
||||
#print "DEBUG: range: (%s, %s) - (min, max): (%s, %s)" %(last_idx, index[0][i], hwm, lwm)
|
||||
minutesplayed = (times[index[0][i]] - times[first_idx])/60
|
||||
if minutesplayed == 0:
|
||||
minutesplayed = 1
|
||||
minutesplayed = minutesplayed + PADDING
|
||||
hph = hds*60/minutesplayed # Hands per hour
|
||||
won = sum(winnings[first_idx:index[0][i]])/100.0
|
||||
hwm = max(cum_sum[first_idx:index[0][i]])
|
||||
lwm = min(cum_sum[first_idx:index[0][i]])
|
||||
open = (sum(winnings[:first_idx]))/100
|
||||
close = (sum(winnings[:index[0][i]]))/100
|
||||
#print "DEBUG: range: (%s, %s) - (min, max): (%s, %s) - (open,close): (%s, %s)" %(first_idx, index[0][i], lwm, hwm, open, close)
|
||||
|
||||
results.append([sid, hds, stime, etime, hph, won])
|
||||
opens.append((sum(winnings[:last_idx]))/100)
|
||||
closes.append((sum(winnings[:index[0][i]]))/100)
|
||||
opens.append(open)
|
||||
closes.append(close)
|
||||
highs.append(hwm)
|
||||
lows.append(lwm)
|
||||
#print "Hands in session %4s: %4s Start: %s End: %s HPH: %s Profit: %s" %(sid, hds, stime, etime, hph, won)
|
||||
total = total + (index[0][i] - last_idx)
|
||||
last_idx = index[0][i] + 1
|
||||
#print "DEBUG: Hands in session %4s: %4s Start: %s End: %s HPH: %s Profit: %s" %(sid, hds, stime, etime, hph, won)
|
||||
total = total + (index[0][i] - first_idx)
|
||||
first_idx = index[0][i] + 1
|
||||
sid = sid+1
|
||||
else:
|
||||
print "hds <= 0"
|
||||
|
||||
return (results, opens, closes, highs, lows)
|
||||
|
||||
|
@ -330,11 +349,6 @@ class GuiSessionViewer (threading.Thread):
|
|||
def generateGraph(self, opens, closes, highs, lows):
|
||||
self.clearGraphData()
|
||||
|
||||
#FIXME: Weird - first data entry is crashing this for me
|
||||
opens = opens[1:]
|
||||
closes = closes[1:]
|
||||
highs = highs[1:]
|
||||
lows = lows[1:]
|
||||
# print "DEBUG:"
|
||||
# print "highs = %s" % highs
|
||||
# print "lows = %s" % lows
|
||||
|
|
|
@ -1,291 +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.
|
||||
|
||||
import threading
|
||||
import pygtk
|
||||
pygtk.require('2.0')
|
||||
import gtk
|
||||
import os
|
||||
|
||||
import fpdb_import
|
||||
import fpdb_db
|
||||
from Exceptions import *
|
||||
|
||||
|
||||
class GuiTableViewer (threading.Thread):
|
||||
def hudDivide (self, a, b):
|
||||
if b==0:
|
||||
return "n/a"
|
||||
else:
|
||||
return str(int((a/float(b))*100))+"%"
|
||||
#end def hudDivide
|
||||
|
||||
def browse_clicked(self, widget, data):
|
||||
"""runs when user clicks browse on tv tab"""
|
||||
#print "start of table_viewer.browser_clicked"
|
||||
current_path=self.filename_tbuffer.get_text(self.filename_tbuffer.get_start_iter(), self.filename_tbuffer.get_end_iter())
|
||||
|
||||
dia_chooser = gtk.FileChooserDialog(title="Please choose the file for which you want to open the Table Viewer",
|
||||
action=gtk.FILE_CHOOSER_ACTION_OPEN,
|
||||
buttons=(gtk.STOCK_CANCEL,gtk.RESPONSE_CANCEL,gtk.STOCK_OPEN,gtk.RESPONSE_OK))
|
||||
#dia_chooser.set_current_folder(pathname)
|
||||
dia_chooser.set_filename(current_path)
|
||||
#dia_chooser.set_select_multiple(select_multiple) #not in tv, but want this in bulk import
|
||||
|
||||
response = dia_chooser.run()
|
||||
if response == gtk.RESPONSE_OK:
|
||||
#print dia_chooser.get_filename(), 'selected'
|
||||
self.filename_tbuffer.set_text(dia_chooser.get_filename())
|
||||
elif response == gtk.RESPONSE_CANCEL:
|
||||
print 'Closed, no files selected'
|
||||
dia_chooser.destroy()
|
||||
#end def table_viewer.browse_clicked
|
||||
|
||||
def prepare_data(self):
|
||||
"""prepares the data for display by refresh_clicked, returns a 2D array"""
|
||||
#print "start of prepare_data"
|
||||
arr=[]
|
||||
#first prepare the header row
|
||||
if (self.category=="holdem" or self.category=="omahahi" or self.category=="omahahilo"):
|
||||
tmp=("Name", "HDs", "VPIP", "PFR", "PF3B", "ST")
|
||||
|
||||
tmp+=("FS", "FB")
|
||||
|
||||
tmp+=("CB", )
|
||||
|
||||
tmp+=("2B", "3B")
|
||||
|
||||
tmp+=("AF", "FF", "AT", "FT", "AR", "FR")
|
||||
|
||||
tmp+=("WtSD", "W$wsF", "W$SD")
|
||||
else:
|
||||
raise FpdbError("reimplement stud")
|
||||
arr.append(tmp)
|
||||
|
||||
#then the data rows
|
||||
for player in range(len(self.player_names)):
|
||||
tmp=[]
|
||||
p_name = Charset.to_gui(self.player_names[player][0])
|
||||
tmp.append(p_name)
|
||||
|
||||
seatCount=len(self.player_names)
|
||||
if seatCount>=8:
|
||||
minSeats,maxSeats=7,10
|
||||
elif seatCount==7:
|
||||
minSeats,maxSeats=6,10
|
||||
elif seatCount==6 or seatCount==5:
|
||||
minSeats,maxSeats=seatCount-1,seatCount+1
|
||||
elif seatCount==4:
|
||||
minSeats,maxSeats=4,5
|
||||
elif seatCount==2 or seatCount==3:
|
||||
minSeats,maxSeats=seatCount,seatCount
|
||||
else:
|
||||
FpdbError("invalid seatCount")
|
||||
|
||||
self.cursor.execute("SELECT * FROM HudCache WHERE gametypeId=%s AND playerId=%s AND activeSeats>=%s AND activeSeats<=%s", (self.gametype_id, self.player_ids[player][0], minSeats, maxSeats))
|
||||
rows=self.cursor.fetchall()
|
||||
|
||||
row=[]
|
||||
for field_no in range(len(rows[0])):
|
||||
row.append(rows[0][field_no])
|
||||
|
||||
for row_no in range(len(rows)):
|
||||
if row_no==0:
|
||||
pass
|
||||
else:
|
||||
for field_no in range(len(rows[row_no])):
|
||||
if field_no<=3:
|
||||
pass
|
||||
else:
|
||||
#print "in prep data, row_no:",row_no,"field_no:",field_no
|
||||
row[field_no]+=rows[row_no][field_no]
|
||||
|
||||
tmp.append(str(row[6]))#Hands
|
||||
tmp.append(self.hudDivide(row[7],row[6])) #VPIP
|
||||
tmp.append(self.hudDivide(row[8],row[6])) #PFR
|
||||
tmp.append(self.hudDivide(row[10],row[9])+" ("+str(row[9])+")") #PF3B
|
||||
|
||||
tmp.append(self.hudDivide(row[31],row[30])+" ("+str(row[30])+")") #ST
|
||||
|
||||
tmp.append(self.hudDivide(row[35],row[34])+" ("+str(row[34])+")") #FS
|
||||
tmp.append(self.hudDivide(row[33],row[32])+" ("+str(row[32])+")") #FB
|
||||
|
||||
tmp.append(self.hudDivide(row[37],row[36])+" ("+str(row[36])+")") #CB
|
||||
|
||||
tmp.append(self.hudDivide(row[39],row[38])+" ("+str(row[38])+")") #2B
|
||||
tmp.append(self.hudDivide(row[41],row[40])+" ("+str(row[40])+")") #3B
|
||||
|
||||
tmp.append(self.hudDivide(row[16],row[11])+" ("+str(row[11])+")") #AF
|
||||
tmp.append(self.hudDivide(row[24],row[20])+" ("+str(row[20])+")") #FF
|
||||
tmp.append(self.hudDivide(row[17],row[12])+" ("+str(row[12])+")") #AT
|
||||
tmp.append(self.hudDivide(row[25],row[21])+" ("+str(row[21])+")") #FT
|
||||
tmp.append(self.hudDivide(row[18],row[13])+" ("+str(row[13])+")") #AR
|
||||
tmp.append(self.hudDivide(row[26],row[22])+" ("+str(row[22])+")") #FR
|
||||
|
||||
tmp.append(self.hudDivide(row[15],row[11])) #WtSD
|
||||
tmp.append(self.hudDivide(row[28],row[11])) #W$wSF
|
||||
tmp.append(self.hudDivide(row[29],row[15])+" ("+str(row[15])+")") #W$@SD
|
||||
|
||||
arr.append(tmp)
|
||||
return arr
|
||||
#end def table_viewer.prepare_data
|
||||
|
||||
def refresh_clicked(self, widget, data):
|
||||
"""runs when user clicks refresh"""
|
||||
#print "start of table_viewer.refresh_clicked"
|
||||
arr=self.prepare_data()
|
||||
|
||||
try: self.data_table.destroy()
|
||||
except AttributeError: pass
|
||||
self.data_table=gtk.Table(rows=len(arr), columns=len(arr[0]), homogeneous=False)
|
||||
self.main_vbox.pack_start(self.data_table)
|
||||
self.data_table.show()
|
||||
|
||||
for row in range(len(arr)):
|
||||
for column in range (len(arr[row])):
|
||||
eventBox=gtk.EventBox()
|
||||
new_label=gtk.Label(arr[row][column])
|
||||
if row%2==0: #
|
||||
bg_col="white"
|
||||
if column==0 or (column>=5 and column<=10):
|
||||
bg_col="lightgrey"
|
||||
else:
|
||||
bg_col="lightgrey"
|
||||
if column==0 or (column>=5 and column<=10):
|
||||
bg_col="grey"
|
||||
#style = eventBox.get_style()
|
||||
#style.font.height=8
|
||||
#eventBox.set_style(style)
|
||||
|
||||
eventBox.modify_bg(gtk.STATE_NORMAL, gtk.gdk.color_parse(bg_col))
|
||||
eventBox.add(new_label)
|
||||
self.data_table.attach(child=eventBox, left_attach=column, right_attach=column+1, top_attach=row, bottom_attach=row+1)
|
||||
eventBox.show()
|
||||
new_label.show()
|
||||
#end def table_viewer.refresh_clicked
|
||||
|
||||
def read_names_clicked(self, widget, data):
|
||||
"""runs when user clicks read names"""
|
||||
#print "start of table_viewer.read_names_clicked"
|
||||
self.db.reconnect()
|
||||
self.cursor=self.db.get_cursor()
|
||||
#self.hands_id=self.last_read_hand_id
|
||||
|
||||
self.cursor.execute("SELECT gametypeId FROM Hands WHERE id=%s", (self.hands_id, ))
|
||||
self.gametype_id=self.cursor.fetchone()[0]
|
||||
self.cursor.execute("SELECT category FROM Gametypes WHERE id=%s", (self.gametype_id, ))
|
||||
self.category=self.cursor.fetchone()[0]
|
||||
#print "self.gametype_id", self.gametype_id," category:", self.category, " self.hands_id:", self.hands_id
|
||||
|
||||
self.cursor.execute("""SELECT DISTINCT Players.id FROM HandsPlayers
|
||||
INNER JOIN Players ON HandsPlayers.playerId=Players.id
|
||||
WHERE handId=%s""", (self.hands_id, ))
|
||||
self.player_ids=self.cursor.fetchall()
|
||||
#print "self.player_ids:",self.player_ids
|
||||
|
||||
self.cursor.execute("""SELECT DISTINCT Players.name FROM HandsPlayers
|
||||
INNER JOIN Players ON HandsPlayers.playerId=Players.id
|
||||
WHERE handId=%s""", (self.hands_id, ))
|
||||
self.player_names=self.cursor.fetchall()
|
||||
#print "self.player_names:",self.player_names
|
||||
#end def table_viewer.read_names_clicked
|
||||
|
||||
def import_clicked(self, widget, data):
|
||||
"""runs when user clicks import"""
|
||||
#print "start of table_viewer.import_clicked"
|
||||
self.inputFile=self.filename_tbuffer.get_text(self.filename_tbuffer.get_start_iter(), self.filename_tbuffer.get_end_iter())
|
||||
|
||||
self.importer = fpdb_import.Importer(self, self.settings, self.config)
|
||||
self.importer.setMinPrint(0)
|
||||
self.importer.setQuiet(False)
|
||||
self.importer.setFailOnError(False)
|
||||
self.importer.setHandCount(0)
|
||||
|
||||
self.importer.addImportFile(self.inputFile)
|
||||
self.importer.runImport()
|
||||
self.hands_id=self.importer.handsId
|
||||
#end def table_viewer.import_clicked
|
||||
|
||||
def all_clicked(self, widget, data):
|
||||
"""runs when user clicks all"""
|
||||
#print "start of table_viewer.all_clicked"
|
||||
self.import_clicked(widget, data)
|
||||
self.read_names_clicked(widget, data)
|
||||
self.refresh_clicked(widget, data)
|
||||
#end def table_viewer.all_clicked
|
||||
|
||||
def get_vbox(self):
|
||||
"""returns the vbox of this thread"""
|
||||
return self.main_vbox
|
||||
#end def get_vbox
|
||||
|
||||
def __init__(self, db, settings, config=None, debug=True):
|
||||
"""Constructor for table_viewer"""
|
||||
self.debug=debug
|
||||
#print "start of table_viewer constructor"
|
||||
self.db = db
|
||||
self.cursor = db.get_cursor()
|
||||
self.settings = settings
|
||||
self.config = config
|
||||
|
||||
self.main_vbox = gtk.VBox(False, 0)
|
||||
self.main_vbox.show()
|
||||
|
||||
self.settings_hbox = gtk.HBox(False, 0)
|
||||
self.main_vbox.pack_end(self.settings_hbox, False, True, 0)
|
||||
self.settings_hbox.show()
|
||||
|
||||
self.filename_label = gtk.Label("Path of history file")
|
||||
self.settings_hbox.pack_start(self.filename_label, False, False)
|
||||
self.filename_label.show()
|
||||
|
||||
self.filename_tbuffer=gtk.TextBuffer()
|
||||
self.filename_tbuffer.set_text(self.settings['hud-defaultPath'])
|
||||
self.filename_tview=gtk.TextView(self.filename_tbuffer)
|
||||
self.settings_hbox.pack_start(self.filename_tview, True, True, padding=5)
|
||||
self.filename_tview.show()
|
||||
|
||||
self.browse_button=gtk.Button("Browse...")
|
||||
self.browse_button.connect("clicked", self.browse_clicked, "Browse clicked")
|
||||
self.settings_hbox.pack_start(self.browse_button, False, False)
|
||||
self.browse_button.show()
|
||||
|
||||
|
||||
self.button_hbox = gtk.HBox(False, 0)
|
||||
self.main_vbox.pack_end(self.button_hbox, False, True, 0)
|
||||
self.button_hbox.show()
|
||||
|
||||
#self.import_button = gtk.Button("Import")
|
||||
#self.import_button.connect("clicked", self.import_clicked, "Import clicked")
|
||||
#self.button_hbox.add(self.import_button)
|
||||
#self.import_button.show()
|
||||
|
||||
#self.read_names_button = gtk.Button("Read Names")
|
||||
#self.read_names_button.connect("clicked", self.read_names_clicked, "Read clicked")
|
||||
#self.button_hbox.add(self.read_names_button)
|
||||
#self.read_names_button.show()
|
||||
|
||||
#self.refresh_button = gtk.Button("Show/Refresh data")
|
||||
#self.refresh_button.connect("clicked", self.refresh_clicked, "Refresh clicked")
|
||||
#self.button_hbox.add(self.refresh_button)
|
||||
#self.refresh_button.show()
|
||||
|
||||
self.all_button = gtk.Button("Import&Read&Refresh")
|
||||
self.all_button.connect("clicked", self.all_clicked, "All clicked")
|
||||
self.button_hbox.add(self.all_button)
|
||||
self.all_button.show()
|
||||
#end of table_viewer.__init__
|
457
pyfpdb/GuiTourneyPlayerStats.py
Normal file
457
pyfpdb/GuiTourneyPlayerStats.py
Normal file
|
@ -0,0 +1,457 @@
|
|||
#!/usr/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
#Copyright 2010 Steffen Schaumburg
|
||||
#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.
|
||||
|
||||
#import traceback
|
||||
import threading
|
||||
import pygtk
|
||||
pygtk.require('2.0')
|
||||
import gtk
|
||||
#import os
|
||||
#import sys
|
||||
from time import time, strftime
|
||||
|
||||
#import Card
|
||||
#import fpdb_import
|
||||
#import Database
|
||||
import Charset
|
||||
import TourneyFilters
|
||||
import GuiPlayerStats
|
||||
|
||||
colalias,colshow,colheading,colxalign,colformat,coltype = 0,1,2,3,4,5
|
||||
|
||||
class GuiTourneyPlayerStats (GuiPlayerStats.GuiPlayerStats):
|
||||
def __init__(self, config, db, sql, mainwin, debug=True):
|
||||
self.conf = config
|
||||
self.db = db
|
||||
self.cursor = self.db.cursor
|
||||
self.sql = sql
|
||||
self.main_window = mainwin
|
||||
self.debug = debug
|
||||
|
||||
self.liststore = [] # gtk.ListStore[] stores the contents of the grids
|
||||
self.listcols = [] # gtk.TreeViewColumn[][] stores the columns in the grids
|
||||
|
||||
filters_display = { "Heroes" : True,
|
||||
"Sites" : True,
|
||||
#"Games" : True,
|
||||
#"Limits" : True,
|
||||
#"LimitSep" : True,
|
||||
#"LimitType" : True,
|
||||
#"Type" : True,
|
||||
"Seats" : True,
|
||||
#"SeatSep" : True,
|
||||
"Dates" : True,
|
||||
#"Groups" : True,
|
||||
#"GroupsAll" : True,
|
||||
#"Button1" : True,
|
||||
"Button2" : True}
|
||||
|
||||
self.stats_frame = None
|
||||
self.stats_vbox = None
|
||||
self.detailFilters = [] # the data used to enhance the sql select
|
||||
|
||||
self.main_hbox = gtk.HPaned()
|
||||
|
||||
self.filters = TourneyFilters.TourneyFilters(self.db, self.conf, self.sql, display = filters_display)
|
||||
#self.filters.registerButton1Name("_Filters")
|
||||
#self.filters.registerButton1Callback(self.showDetailFilter)
|
||||
self.filters.registerButton2Name("_Refresh Stats")
|
||||
self.filters.registerButton2Callback(self.refreshStats)
|
||||
|
||||
# ToDo: store in config
|
||||
# ToDo: create popup to adjust column config
|
||||
# columns to display, keys match column name returned by sql, values in tuple are:
|
||||
# is column displayed, column heading, xalignment, formatting, celltype
|
||||
self.columns = [ ["siteName", True, "Site", 0.0, "%s", "str"]
|
||||
#,["tourney", False, "Tourney", 0.0, "%s", "str"] # true not allowed for this line
|
||||
, ["category", True, "Cat.", 0.0, "%s", "str"]
|
||||
, ["limitType", True, "Limit", 0.0, "%s", "str"]
|
||||
, ["currency", True, "Curr.", 0.0, "%s", "str"]
|
||||
, ["buyIn", True, "BuyIn", 1.0, "%3.2f", "str"]
|
||||
, ["fee", True, "Fee", 1.0, "%3.2f", "str"]
|
||||
, ["playerName", False, "Name", 0.0, "%s", "str"] # true not allowed for this line (set in code)
|
||||
, ["tourneyCount", True, "#", 1.0, "%1.0f", "str"]
|
||||
, ["itm", True, "ITM%", 1.0, "%3.2f", "str"]
|
||||
, ["1st", False, "1st", 1.0, "%1.0f", "str"]
|
||||
, ["2nd", True, "2nd", 1.0, "%1.0f", "str"]
|
||||
, ["3rd", True, "3rd", 1.0, "%1.0f", "str"]
|
||||
, ["unknownRank", True, "Rank?", 1.0, "%1.0f", "str"]
|
||||
, ["spent", True, "Spent", 1.0, "%3.2f", "str"]
|
||||
, ["won", True, "Won", 1.0, "%3.2f", "str"]
|
||||
, ["roi", True, "ROI%", 1.0, "%3.0f", "str"]
|
||||
, ["profitPerTourney", True,"$/Tour", 1.0, "%3.2f", "str"]]
|
||||
|
||||
self.stats_frame = gtk.Frame()
|
||||
self.stats_frame.show()
|
||||
|
||||
self.stats_vbox = gtk.VPaned()
|
||||
self.stats_vbox.show()
|
||||
self.stats_frame.add(self.stats_vbox)
|
||||
# self.fillStatsFrame(self.stats_vbox)
|
||||
|
||||
#self.main_hbox.pack_start(self.filters.get_vbox())
|
||||
#self.main_hbox.pack_start(self.stats_frame, expand=True, fill=True)
|
||||
self.main_hbox.pack1(self.filters.get_vbox())
|
||||
self.main_hbox.pack2(self.stats_frame)
|
||||
self.main_hbox.show()
|
||||
#end def __init__
|
||||
|
||||
def addGrid(self, vbox, query, numTourneys, tourneyTypes, playerids, sitenos, seats, dates):
|
||||
#print "start of addGrid query", query
|
||||
#print "start of addGrid. numTourneys:",numTourneys,"tourneyTypes:", tourneyTypes, "playerids:",playerids
|
||||
counter = 0
|
||||
row = 0
|
||||
sqlrow = 0
|
||||
grid=numTourneys #TODO: should this be numTourneyTypes?
|
||||
|
||||
query = self.sql.query[query]
|
||||
query = self.refineQuery(query, numTourneys, tourneyTypes, playerids, sitenos, seats, dates)
|
||||
self.cursor.execute(query)
|
||||
result = self.cursor.fetchall()
|
||||
#print "result of the big query in addGrid:",result
|
||||
colnames = [desc[0] for desc in self.cursor.description]
|
||||
|
||||
# pre-fetch some constant values:
|
||||
#self.cols_to_show = [x for x in self.columns if x[colshow]]
|
||||
#htourneytypeid_idx = colnames.index('tourneyTypeId')
|
||||
self.cols_to_show = self.columns #TODO do i need above 2 lines?
|
||||
|
||||
assert len(self.liststore) == grid, "len(self.liststore)="+str(len(self.liststore))+" grid-1="+str(grid)
|
||||
self.liststore.append( gtk.ListStore(*([str] * len(self.cols_to_show))) )
|
||||
view = gtk.TreeView(model=self.liststore[grid])
|
||||
view.set_grid_lines(gtk.TREE_VIEW_GRID_LINES_BOTH)
|
||||
#vbox.pack_start(view, expand=False, padding=3)
|
||||
vbox.add(view)
|
||||
textcell = gtk.CellRendererText()
|
||||
textcell50 = gtk.CellRendererText()
|
||||
textcell50.set_property('xalign', 0.5)
|
||||
numcell = gtk.CellRendererText()
|
||||
numcell.set_property('xalign', 1.0)
|
||||
assert len(self.listcols) == grid
|
||||
self.listcols.append( [] )
|
||||
|
||||
# Create header row eg column: ("game", True, "Game", 0.0, "%s")
|
||||
for col, column in enumerate(self.cols_to_show):
|
||||
if column[colalias] == 'game' and holecards:
|
||||
s = [x for x in self.columns if x[colalias] == 'hand'][0][colheading]
|
||||
else:
|
||||
s = column[colheading]
|
||||
self.listcols[grid].append(gtk.TreeViewColumn(s))
|
||||
view.append_column(self.listcols[grid][col])
|
||||
if column[colformat] == '%s':
|
||||
if column[colxalign] == 0.0:
|
||||
self.listcols[grid][col].pack_start(textcell, expand=True)
|
||||
self.listcols[grid][col].add_attribute(textcell, 'text', col)
|
||||
cellrend = textcell
|
||||
else:
|
||||
self.listcols[grid][col].pack_start(textcell50, expand=True)
|
||||
self.listcols[grid][col].add_attribute(textcell50, 'text', col)
|
||||
cellrend = textcell50
|
||||
self.listcols[grid][col].set_expand(True)
|
||||
else:
|
||||
self.listcols[grid][col].pack_start(numcell, expand=True)
|
||||
self.listcols[grid][col].add_attribute(numcell, 'text', col)
|
||||
self.listcols[grid][col].set_expand(True)
|
||||
cellrend = numcell
|
||||
#self.listcols[grid][col].set_alignment(column[colxalign]) # no effect?
|
||||
self.listcols[grid][col].set_clickable(True)
|
||||
self.listcols[grid][col].connect("clicked", self.sortCols, (col,grid))
|
||||
if col == 0:
|
||||
self.listcols[grid][col].set_sort_order(gtk.SORT_DESCENDING)
|
||||
self.listcols[grid][col].set_sort_indicator(True)
|
||||
if column[coltype] == 'cash':
|
||||
self.listcols[grid][col].set_cell_data_func(numcell, self.ledger_style_render_func)
|
||||
else:
|
||||
self.listcols[grid][col].set_cell_data_func(cellrend, self.reset_style_render_func)
|
||||
|
||||
rows = len(result) # +1 for title row
|
||||
|
||||
while sqlrow < rows:
|
||||
treerow = []
|
||||
for col,column in enumerate(self.cols_to_show):
|
||||
if column[colalias] in colnames:
|
||||
value = result[sqlrow][colnames.index(column[colalias])]
|
||||
else:
|
||||
value = 111
|
||||
if value and value != -999:
|
||||
treerow.append(column[colformat] % value)
|
||||
else:
|
||||
treerow.append(' ')
|
||||
#print "addGrid, just before end of big for. grid:",grid,"treerow:",treerow
|
||||
iter = self.liststore[grid].append(treerow)
|
||||
sqlrow += 1
|
||||
row += 1
|
||||
vbox.show_all()
|
||||
#end def addGrid
|
||||
|
||||
def createStatsTable(self, vbox, tourneyTypes, playerids, sitenos, seats, dates):
|
||||
startTime = time()
|
||||
show_detail = True
|
||||
|
||||
# Scrolled window for summary table
|
||||
swin = gtk.ScrolledWindow(hadjustment=None, vadjustment=None)
|
||||
swin.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
|
||||
swin.show()
|
||||
vbox.pack1(swin)
|
||||
|
||||
numTourneys = self.filters.getNumTourneys()
|
||||
self.addGrid(swin, 'tourneyPlayerDetailedStats', numTourneys, tourneyTypes, playerids
|
||||
,sitenos, seats, dates)
|
||||
|
||||
#if 'allplayers' in groups and groups['allplayers']:
|
||||
# can't currently do this combination so skip detailed table
|
||||
show_detail = False
|
||||
|
||||
if show_detail:
|
||||
# Separator
|
||||
vbox2 = gtk.VBox(False, 0)
|
||||
heading = gtk.Label(self.filterText['handhead'])
|
||||
heading.show()
|
||||
vbox2.pack_start(heading, expand=False, padding=3)
|
||||
|
||||
# Scrolled window for detailed table (display by hand)
|
||||
swin = gtk.ScrolledWindow(hadjustment=None, vadjustment=None)
|
||||
swin.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
|
||||
swin.show()
|
||||
vbox2.pack_start(swin, expand=True, padding=3)
|
||||
vbox.pack2(vbox2)
|
||||
vbox2.show()
|
||||
|
||||
# Detailed table
|
||||
flags[0] = True
|
||||
flags[2] = 1
|
||||
self.addGrid(swin, 'playerDetailedStats', flags, playerids, sitenos, seats, dates)
|
||||
|
||||
self.db.rollback()
|
||||
print "Stats page displayed in %4.2f seconds" % (time() - startTime)
|
||||
#end def createStatsTable
|
||||
|
||||
def fillStatsFrame(self, vbox):
|
||||
tourneyTypes = self.filters.getTourneyTypes()
|
||||
#tourneys = self.tourneys.getTourneys()
|
||||
sites = self.filters.getSites()
|
||||
heroes = self.filters.getHeroes()
|
||||
siteids = self.filters.getSiteIds()
|
||||
seats = self.filters.getSeats()
|
||||
dates = self.filters.getDates()
|
||||
sitenos = []
|
||||
playerids = []
|
||||
|
||||
# Which sites are selected?
|
||||
for site in sites:
|
||||
if sites[site] == True:
|
||||
sitenos.append(siteids[site])
|
||||
_hname = Charset.to_utf8(heroes[site])
|
||||
result = self.db.get_player_id(self.conf, site, _hname)
|
||||
if result is not None:
|
||||
playerids.append(int(result))
|
||||
|
||||
if not sitenos:
|
||||
#Should probably pop up here.
|
||||
print "No sites selected - defaulting to PokerStars"
|
||||
sitenos = [2]
|
||||
if not playerids:
|
||||
print "No player ids found"
|
||||
return
|
||||
|
||||
self.createStatsTable(vbox, tourneyTypes, playerids, sitenos, seats, dates)
|
||||
#end def fillStatsFrame
|
||||
|
||||
def get_vbox(self):
|
||||
"""returns the vbox of this thread"""
|
||||
return self.main_hbox
|
||||
#end def get_vbox
|
||||
|
||||
def refineQuery(self, query, numTourneys, tourneyTypes, playerids, sitenos, seats, dates):
|
||||
having = ''
|
||||
|
||||
#print "start of refinequery, playerids:",playerids
|
||||
if playerids:
|
||||
nametest = str(tuple(playerids))
|
||||
nametest = nametest.replace("L", "")
|
||||
nametest = nametest.replace(",)",")")
|
||||
else:
|
||||
nametest = "1 = 2"
|
||||
#print "refinequery, nametest after initial creation:",nametest
|
||||
pname = "p.name"
|
||||
# set flag in self.columns to not show player name column
|
||||
#[x for x in self.columns if x[0] == 'pname'][0][1] = False #TODO: fix and reactivate
|
||||
|
||||
query = query.replace("<nametest>", nametest)
|
||||
query = query.replace("<playerName>", pname)
|
||||
query = query.replace("<havingclause>", having)
|
||||
|
||||
#TODO: remove, or replace with tourneytest
|
||||
#gametest = ""
|
||||
#q = []
|
||||
#for m in self.filters.display.items():
|
||||
# if m[0] == 'Games' and m[1]:
|
||||
# for n in games:
|
||||
# if games[n]:
|
||||
# q.append(n)
|
||||
# if len(q) > 0:
|
||||
# gametest = str(tuple(q))
|
||||
# gametest = gametest.replace("L", "")
|
||||
# gametest = gametest.replace(",)",")")
|
||||
# gametest = gametest.replace("u'","'")
|
||||
# gametest = "and gt.category in %s" % gametest
|
||||
# else:
|
||||
# gametest = "and gt.category IS NULL"
|
||||
#query = query.replace("<game_test>", gametest)
|
||||
|
||||
sitetest = ""
|
||||
q = []
|
||||
for m in self.filters.display.items():
|
||||
if m[0] == 'Sites' and m[1]:
|
||||
for n in sitenos:
|
||||
q.append(n)
|
||||
if len(q) > 0:
|
||||
sitetest = str(tuple(q))
|
||||
sitetest = sitetest.replace("L", "")
|
||||
sitetest = sitetest.replace(",)",")")
|
||||
sitetest = sitetest.replace("u'","'")
|
||||
sitetest = "and tt.siteId in %s" % sitetest#[1:-1]
|
||||
else:
|
||||
sitetest = "and tt.siteId IS NULL"
|
||||
#print "refinequery, sitetest before its use for replacement:",sitetest
|
||||
query = query.replace("<sitetest>", sitetest)
|
||||
|
||||
if seats:
|
||||
query = query.replace('<seats_test>', 'between ' + str(seats['from']) + ' and ' + str(seats['to']))
|
||||
if 'show' in seats and seats['show']:
|
||||
query = query.replace('<groupbyseats>', ',h.seats')
|
||||
query = query.replace('<orderbyseats>', ',h.seats')
|
||||
else:
|
||||
query = query.replace('<groupbyseats>', '')
|
||||
query = query.replace('<orderbyseats>', '')
|
||||
else:
|
||||
query = query.replace('<seats_test>', 'between 0 and 100')
|
||||
query = query.replace('<groupbyseats>', '')
|
||||
query = query.replace('<orderbyseats>', '')
|
||||
|
||||
#lims = [int(x) for x in limits if x.isdigit()]
|
||||
#potlims = [int(x[0:-2]) for x in limits if len(x) > 2 and x[-2:] == 'pl']
|
||||
#nolims = [int(x[0:-2]) for x in limits if len(x) > 2 and x[-2:] == 'nl']
|
||||
#bbtest = "and ( (gt.limitType = 'fl' and gt.bigBlind in "
|
||||
# and ( (limit and bb in()) or (nolimit and bb in ()) )
|
||||
#if lims:
|
||||
# blindtest = str(tuple(lims))
|
||||
# blindtest = blindtest.replace("L", "")
|
||||
# blindtest = blindtest.replace(",)",")")
|
||||
# bbtest = bbtest + blindtest + ' ) '
|
||||
#else:
|
||||
# bbtest = bbtest + '(-1) ) '
|
||||
#bbtest = bbtest + " or (gt.limitType = 'pl' and gt.bigBlind in "
|
||||
#if potlims:
|
||||
# blindtest = str(tuple(potlims))
|
||||
# blindtest = blindtest.replace("L", "")
|
||||
# blindtest = blindtest.replace(",)",")")
|
||||
# bbtest = bbtest + blindtest + ' ) '
|
||||
#else:
|
||||
# bbtest = bbtest + '(-1) ) '
|
||||
#bbtest = bbtest + " or (gt.limitType = 'nl' and gt.bigBlind in "
|
||||
#if nolims:
|
||||
# blindtest = str(tuple(nolims))
|
||||
# blindtest = blindtest.replace("L", "")
|
||||
# blindtest = blindtest.replace(",)",")")
|
||||
# bbtest = bbtest + blindtest + ' ) )'
|
||||
#else:
|
||||
# bbtest = bbtest + '(-1) ) )'
|
||||
|
||||
#if type == 'ring':
|
||||
# bbtest = bbtest + " and gt.type = 'ring' "
|
||||
#elif type == 'tour':
|
||||
#bbtest = " and gt.type = 'tour' "
|
||||
|
||||
#query = query.replace("<gtbigBlind_test>", bbtest)
|
||||
|
||||
#query = query.replace("<orderbyhgameTypeId>", "")
|
||||
|
||||
# process self.detailFilters (a list of tuples)
|
||||
flagtest = ''
|
||||
#self.detailFilters = [('h.seats', 5, 6)] # for debug
|
||||
if self.detailFilters:
|
||||
for f in self.detailFilters:
|
||||
if len(f) == 3:
|
||||
# X between Y and Z
|
||||
flagtest += ' and %s between %s and %s ' % (f[0], str(f[1]), str(f[2]))
|
||||
query = query.replace("<flagtest>", flagtest)
|
||||
|
||||
# allow for differences in sql cast() function:
|
||||
if self.db.backend == self.db.MYSQL_INNODB:
|
||||
query = query.replace("<signed>", 'signed ')
|
||||
else:
|
||||
query = query.replace("<signed>", '')
|
||||
|
||||
# Filter on dates
|
||||
query = query.replace("<datestest>", " between '" + dates[0] + "' and '" + dates[1] + "'")
|
||||
|
||||
# Group by position?
|
||||
#if groups['posn']:
|
||||
# #query = query.replace("<position>", "case hp.position when '0' then 'Btn' else hp.position end")
|
||||
# query = query.replace("<position>", "hp.position")
|
||||
# # set flag in self.columns to show posn column
|
||||
# [x for x in self.columns if x[0] == 'plposition'][0][1] = True
|
||||
#else:
|
||||
# query = query.replace("<position>", "gt.base")
|
||||
# # unset flag in self.columns to hide posn column
|
||||
# [x for x in self.columns if x[0] == 'plposition'][0][1] = False
|
||||
|
||||
#print "query at end of refine query:", query
|
||||
return(query)
|
||||
#end def refineQuery
|
||||
|
||||
def refreshStats(self, widget, data):
|
||||
self.last_pos = self.stats_vbox.get_position()
|
||||
try: self.stats_vbox.destroy()
|
||||
except AttributeError: pass
|
||||
self.liststore = []
|
||||
self.listcols = []
|
||||
#self.stats_vbox = gtk.VBox(False, 0)
|
||||
self.stats_vbox = gtk.VPaned()
|
||||
self.stats_vbox.show()
|
||||
self.stats_frame.add(self.stats_vbox)
|
||||
self.fillStatsFrame(self.stats_vbox)
|
||||
if self.last_pos > 0:
|
||||
self.stats_vbox.set_position(self.last_pos)
|
||||
#end def refreshStats
|
||||
|
||||
def reset_style_render_func(self, treeviewcolumn, cell, model, iter):
|
||||
cell.set_property('foreground', 'black')
|
||||
#end def reset_style_render_func
|
||||
|
||||
def sortCols(self, col, nums):
|
||||
try:
|
||||
#This doesn't actually work yet - clicking heading in top section sorts bottom section :-(
|
||||
(n, grid) = nums
|
||||
if not col.get_sort_indicator() or col.get_sort_order() == gtk.SORT_ASCENDING:
|
||||
col.set_sort_order(gtk.SORT_DESCENDING)
|
||||
else:
|
||||
col.set_sort_order(gtk.SORT_ASCENDING)
|
||||
self.liststore[grid].set_sort_column_id(n, col.get_sort_order())
|
||||
self.liststore[grid].set_sort_func(n, self.sortnums, (n,grid))
|
||||
for i in xrange(len(self.listcols[grid])):
|
||||
self.listcols[grid][i].set_sort_indicator(False)
|
||||
self.listcols[grid][n].set_sort_indicator(True)
|
||||
# use this listcols[col].set_sort_indicator(True)
|
||||
# to turn indicator off for other cols
|
||||
except:
|
||||
err = traceback.extract_tb(sys.exc_info()[2])
|
||||
print "***sortCols error: " + str(sys.exc_info()[1])
|
||||
print "\n".join( [e[0]+':'+str(e[1])+" "+e[2] for e in err] )
|
||||
#end def sortCols
|
||||
#end class GuiTourneyPlayerStats
|
|
@ -508,6 +508,9 @@ Left-Drag to Move"
|
|||
<pu_stat pu_stat_name="a_freq2"> </pu_stat>
|
||||
<pu_stat pu_stat_name="a_freq3"> </pu_stat>
|
||||
<pu_stat pu_stat_name="a_freq4"> </pu_stat>
|
||||
<pu_stat pu_stat_name="agg_freq"> </pu_stat>
|
||||
<pu_stat pu_stat_name="agg_fact"> </pu_stat>
|
||||
<pu_stat pu_stat_name="cbet"> </pu_stat>
|
||||
<pu_stat pu_stat_name="cb1"> </pu_stat>
|
||||
<pu_stat pu_stat_name="cb2"> </pu_stat>
|
||||
<pu_stat pu_stat_name="cb3"> </pu_stat>
|
||||
|
|
|
@ -2,6 +2,13 @@
|
|||
|
||||
<FreePokerToolsConfig xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="FreePokerToolsConfig.xsd">
|
||||
|
||||
<!-- config_wrap_len is preferred max line length in this file, -1 means no max
|
||||
day_start is time that logical day starts, e.g. 5 means that any play
|
||||
between 00:00 and 04:59:59 counts as being on the previous day -->
|
||||
<general config_wrap_len="-1"
|
||||
day_start="5"
|
||||
/>
|
||||
|
||||
<import callFpdbHud = "True" interval = "10" fastStoreHudCache="False" hhArchiveBase="~/.fpdb/HandHistories/" saveActions="True"></import>
|
||||
|
||||
<!-- These values determine what stats are displayed in the HUD
|
||||
|
@ -114,6 +121,10 @@ Left-Drag to Move"
|
|||
hudopacity="1.0"
|
||||
font="Sans"
|
||||
font_size="8"
|
||||
xpad="1"
|
||||
ypad="0"
|
||||
xshift="0"
|
||||
yshift="0"
|
||||
supported_games="holdem,razz,omahahi,omahahilo,studhi,studhilo">
|
||||
<layout max="8" width="792" height="546" fav_seat="0">
|
||||
<location seat="1" x="684" y="61"> </location>
|
||||
|
@ -545,20 +556,27 @@ Left-Drag to Move"
|
|||
|
||||
<popup_windows>
|
||||
<pu pu_name="default">
|
||||
<pu_stat pu_stat_name="playername"> </pu_stat>
|
||||
<pu_stat pu_stat_name="totalprofit"> </pu_stat>
|
||||
<pu_stat pu_stat_name="profit100"> </pu_stat>
|
||||
<pu_stat pu_stat_name="n"> </pu_stat>
|
||||
<pu_stat pu_stat_name="vpip"> </pu_stat>
|
||||
<pu_stat pu_stat_name="pfr"> </pu_stat>
|
||||
<pu_stat pu_stat_name="three_B_0"> </pu_stat>
|
||||
<pu_stat pu_stat_name="steal"> </pu_stat>
|
||||
<pu_stat pu_stat_name="f_steal"> </pu_stat>
|
||||
<pu_stat pu_stat_name="f_BB_steal"> </pu_stat>
|
||||
<pu_stat pu_stat_name="f_SB_steal"> </pu_stat>
|
||||
<pu_stat pu_stat_name="wmsd"> </pu_stat>
|
||||
<pu_stat pu_stat_name="wtsd"> </pu_stat>
|
||||
<pu_stat pu_stat_name="WMsF"> </pu_stat>
|
||||
<pu_stat pu_stat_name="agg_fact"> </pu_stat>
|
||||
<pu_stat pu_stat_name="a_freq1"> </pu_stat>
|
||||
<pu_stat pu_stat_name="a_freq2"> </pu_stat>
|
||||
<pu_stat pu_stat_name="a_freq3"> </pu_stat>
|
||||
<pu_stat pu_stat_name="a_freq4"> </pu_stat>
|
||||
<pu_stat pu_stat_name="agg_freq"> </pu_stat>
|
||||
<pu_stat pu_stat_name="cbet"> </pu_stat>
|
||||
<pu_stat pu_stat_name="cb1"> </pu_stat>
|
||||
<pu_stat pu_stat_name="cb2"> </pu_stat>
|
||||
<pu_stat pu_stat_name="cb3"> </pu_stat>
|
||||
|
@ -630,5 +648,9 @@ Left-Drag to Move"
|
|||
<database db_ip="localhost" db_server="sqlite" db_name="fpdb.db3" db_user="fpdb" db_pass="fpdb"/>
|
||||
</supported_databases>
|
||||
|
||||
<email>
|
||||
<email siteName="PokerStars" fetchType="request-summary" host="YOUR_EMAIL_SERVER" username="YOUR_EMAIL_USERNAME" password="YOUR_EMAIL_PASSWORD" useSsl="True" folder="INBOX"/>
|
||||
</email>
|
||||
</FreePokerToolsConfig>
|
||||
|
||||
<!-- IMPORTANT: Please note that fpdb stores your email password in clear text.
|
||||
So do not post a config containing a password on the Internet or anywhere else without removing the password! -->
|
||||
|
|
|
@ -1,10 +1,7 @@
|
|||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
"""Hud_main.py
|
||||
|
||||
Main for FreePokerTools HUD.
|
||||
"""
|
||||
# Copyright 2008, 2009, Ray E. Barker
|
||||
# Copyright 2008-2010, 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
|
||||
|
@ -22,10 +19,14 @@ Main for FreePokerTools HUD.
|
|||
|
||||
########################################################################
|
||||
|
||||
# to do allow window resizing
|
||||
# to do hud to echo, but ignore non numbers
|
||||
# to do no stat window for hero
|
||||
# to do things to add to config.xml
|
||||
"""Hud_main.py
|
||||
|
||||
Main for FreePokerTools HUD.
|
||||
"""
|
||||
# TODO allow window resizing
|
||||
# TODO hud to echo, but ignore non numbers
|
||||
# TODO no stat window for hero
|
||||
# TODO things to add to config.xml
|
||||
|
||||
# Standard Library modules
|
||||
import sys
|
|
@ -1,4 +1,20 @@
|
|||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
#Copyright 2009-2010 Eric Blade
|
||||
#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.
|
||||
|
||||
import sys
|
||||
import os
|
||||
import thread
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#!/usr/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
#Copyright 2008 Carl Gherardi
|
||||
#Copyright 2008-2010 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.
|
||||
|
@ -13,8 +13,7 @@
|
|||
#
|
||||
#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.
|
||||
#In the "official" distribution you can find the license in agpl-3.0.txt.
|
||||
|
||||
# TODO: get writehand() encoding correct
|
||||
|
||||
|
@ -39,7 +38,6 @@ from Exceptions import *
|
|||
import DerivedStats
|
||||
import Card
|
||||
|
||||
|
||||
class Hand(object):
|
||||
|
||||
###############################################################3
|
||||
|
@ -58,7 +56,7 @@ class Hand(object):
|
|||
self.siteId = self.SITEIDS[sitename]
|
||||
self.stats = DerivedStats.DerivedStats(self)
|
||||
self.gametype = gametype
|
||||
self.starttime = 0
|
||||
self.startTime = 0
|
||||
self.handText = handText
|
||||
self.handid = 0
|
||||
self.cancelled = False
|
||||
|
@ -70,23 +68,32 @@ class Hand(object):
|
|||
self.maxseats = None
|
||||
self.counted_seats = 0
|
||||
self.buttonpos = 0
|
||||
|
||||
#tourney stuff
|
||||
self.tourNo = None
|
||||
self.tourneyId = None
|
||||
self.tourneyTypeId = None
|
||||
self.buyin = None
|
||||
self.buyinCurrency = None
|
||||
self.buyInChips = None
|
||||
self.fee = None # the Database code is looking for this one .. ?
|
||||
self.level = None
|
||||
self.mixed = None
|
||||
# Some attributes for hand from a tourney
|
||||
self.speed = "Normal"
|
||||
self.isRebuy = False
|
||||
self.isKO = False
|
||||
self.isHU = False
|
||||
self.isMatrix = False
|
||||
self.isShootout = False
|
||||
self.speed = None
|
||||
self.isRebuy = None
|
||||
self.isAddOn = None
|
||||
self.isKO = None
|
||||
self.koBounty = None
|
||||
self.isMatrix = None
|
||||
self.isShootout = None
|
||||
self.added = None
|
||||
self.addedCurrency = None
|
||||
self.tourneyComment = None
|
||||
|
||||
self.seating = []
|
||||
self.players = []
|
||||
self.posted = []
|
||||
self.tourneysPlayersIds = []
|
||||
|
||||
# Collections indexed by street names
|
||||
self.bets = {}
|
||||
|
@ -136,8 +143,6 @@ class Hand(object):
|
|||
("TABLE NAME", self.tablename),
|
||||
("HERO", self.hero),
|
||||
("MAXSEATS", self.maxseats),
|
||||
("TOURNAMENT NO", self.tourNo),
|
||||
("BUYIN", self.buyin),
|
||||
("LEVEL", self.level),
|
||||
("MIXED", self.mixed),
|
||||
("LASTBET", self.lastBet),
|
||||
|
@ -153,7 +158,21 @@ class Hand(object):
|
|||
("TOTAL POT", self.totalpot),
|
||||
("TOTAL COLLECTED", self.totalcollected),
|
||||
("RAKE", self.rake),
|
||||
("START TIME", self.starttime),
|
||||
("START TIME", self.startTime),
|
||||
("TOURNAMENT NO", self.tourNo),
|
||||
("TOURNEY ID", self.tourneyId),
|
||||
("TOURNEY TYPE ID", self.tourneyTypeId),
|
||||
("BUYIN", self.buyin),
|
||||
("BUYIN CURRENCY", self.buyinCurrency),
|
||||
("BUYIN CHIPS", self.buyInChips),
|
||||
("FEE", self.fee),
|
||||
("IS REBUY", self.isRebuy),
|
||||
("IS ADDON", self.isAddOn),
|
||||
("IS KO", self.isKO),
|
||||
("KO BOUNTY", self.koBounty),
|
||||
("IS MATRIX", self.isMatrix),
|
||||
("IS SHOOTOUT", self.isShootout),
|
||||
("TOURNEY COMMENT", self.tourneyComment),
|
||||
)
|
||||
|
||||
structs = ( ("PLAYERS", self.players),
|
||||
|
@ -168,6 +187,7 @@ class Hand(object):
|
|||
("BOARD", self.board),
|
||||
("DISCARDS", self.discards),
|
||||
("HOLECARDS", self.holecards),
|
||||
("TOURNEYS PLAYER IDS", self.tourneysPlayersIds),
|
||||
)
|
||||
str = ''
|
||||
for (name, var) in vars:
|
||||
|
@ -210,6 +230,15 @@ dealt whether they were seen in a 'dealt to' line
|
|||
#Gametypes
|
||||
self.dbid_gt = db.getGameTypeId(self.siteId, self.gametype)
|
||||
|
||||
if self.tourNo!=None:
|
||||
self.tourneyTypeId = db.createTourneyType(self)
|
||||
db.commit()
|
||||
self.tourneyId = db.createOrUpdateTourney(self, "HHC")
|
||||
db.commit()
|
||||
self.tourneysPlayersIds = db.createOrUpdateTourneysPlayers(self, "HHC")
|
||||
db.commit()
|
||||
#end def prepInsert
|
||||
|
||||
def insert(self, db):
|
||||
""" Function to insert Hand into database
|
||||
Should not commit, and do minimal selects. Callers may want to cache commits
|
||||
|
@ -231,17 +260,15 @@ db: a connected Database object"""
|
|||
|
||||
self.dbid_hands = db.storeHand(hh)
|
||||
db.storeHandsPlayers(self.dbid_hands, self.dbid_pids, self.stats.getHandsPlayers())
|
||||
# HandsActions - all actions for all players for all streets - self.actions
|
||||
# TODO HandsActions - all actions for all players for all streets - self.actions
|
||||
# HudCache data can be generated from HandsActions (HandsPlayers?)
|
||||
# Tourneys ?
|
||||
# TourneysPlayers
|
||||
else:
|
||||
log.info("Hand.insert(): hid #: %s is a duplicate" % hh['siteHandNo'])
|
||||
self.is_duplicate = True # i.e. don't update hudcache
|
||||
raise FpdbHandDuplicate(hh['siteHandNo'])
|
||||
|
||||
def updateHudCache(self, db):
|
||||
db.storeHudCache(self.dbid_gt, self.dbid_pids, self.starttime, self.stats.getHandsPlayers())
|
||||
db.storeHudCache(self.dbid_gt, self.dbid_pids, self.startTime, self.stats.getHandsPlayers())
|
||||
|
||||
def select(self, handId):
|
||||
""" Function to create Hand object from database """
|
||||
|
@ -274,15 +301,16 @@ If a player has None chips he won't be added."""
|
|||
self.streets.update(match.groupdict())
|
||||
log.debug("markStreets:\n"+ str(self.streets))
|
||||
else:
|
||||
tmp = self.handText[0:100]
|
||||
log.error("markstreets didn't match")
|
||||
log.error(" - Assuming hand cancelled")
|
||||
self.cancelled = True
|
||||
raise FpdbParseError
|
||||
raise FpdbParseError("FpdbParseError: markStreets appeared to fail: First 100 chars: '%s'" % tmp)
|
||||
|
||||
def checkPlayerExists(self,player):
|
||||
if player not in [p[1] for p in self.players]:
|
||||
print "checkPlayerExists", player, "fail"
|
||||
raise FpdbParseError
|
||||
print "DEBUG: checkPlayerExists %s fail" % player
|
||||
raise FpdbParseError("checkPlayerExists: '%s' failed." % player)
|
||||
|
||||
|
||||
|
||||
|
@ -344,7 +372,7 @@ For sites (currently only Carbon Poker) which record "all in" as a special actio
|
|||
self.actions['BLINDSANTES'].append(act)
|
||||
|
||||
if blindtype == 'both':
|
||||
# work with the real ammount. limit games are listed as $1, $2, where
|
||||
# work with the real amount. limit games are listed as $1, $2, where
|
||||
# the SB 0.50 and the BB is $1, after the turn the minimum bet amount is $2....
|
||||
amount = self.bb
|
||||
self.bets['BLINDSANTES'][player].append(Decimal(self.sb))
|
||||
|
@ -603,10 +631,10 @@ Map the tuple self.gametype onto the pokerstars string describing it
|
|||
gs = gs + " %s (%s) - " % (self.getGameTypeAsString(), self.getStakesAsString())
|
||||
|
||||
try:
|
||||
timestr = datetime.datetime.strftime(self.starttime, '%Y/%m/%d %H:%M:%S ET')
|
||||
timestr = datetime.datetime.strftime(self.startTime, '%Y/%m/%d %H:%M:%S ET')
|
||||
except TypeError:
|
||||
print "*** ERROR - HAND: calling writeGameLine with unexpected STARTTIME value, expecting datetime.date object, received:", self.starttime
|
||||
print "*** Make sure your HandHistoryConverter is setting hand.starttime properly!"
|
||||
print "*** ERROR - HAND: calling writeGameLine with unexpected STARTTIME value, expecting datetime.date object, received:", self.startTime
|
||||
print "*** Make sure your HandHistoryConverter is setting hand.startTime properly!"
|
||||
print "*** Game String:", gs
|
||||
return gs
|
||||
else:
|
||||
|
@ -806,7 +834,7 @@ class HoldemOmahaHand(Hand):
|
|||
T.h1[
|
||||
T.span(class_='site')["%s Game #%s]" % ('PokerStars', self.handid)],
|
||||
T.span(class_='type_limit')[ "%s ($%s/$%s)" %(self.getGameTypeAsString(), self.sb, self.bb) ],
|
||||
T.span(class_='date')[ datetime.datetime.strftime(self.starttime,'%Y/%m/%d - %H:%M:%S ET') ]
|
||||
T.span(class_='date')[ datetime.datetime.strftime(self.startTime,'%Y/%m/%d - %H:%M:%S ET') ]
|
||||
],
|
||||
T.h2[ "Table '%s' %d-max Seat #%s is the button" %(self.tablename,
|
||||
self.maxseats, self.buttonpos)],
|
||||
|
@ -1487,9 +1515,9 @@ class Pot(object):
|
|||
if self.sym is None:
|
||||
self.sym = "C"
|
||||
if self.total is None:
|
||||
print "call Pot.end() before printing pot total"
|
||||
print "DEBUG: call Pot.end() before printing pot total"
|
||||
# NB if I'm sure end() is idempotent, call it here.
|
||||
raise FpdbParseError
|
||||
raise FpdbParseError("FpdbError in printing Hand object")
|
||||
|
||||
ret = "Total pot %s%.2f" % (self.sym, self.total)
|
||||
if len(self.pots) < 2:
|
||||
|
@ -1556,7 +1584,7 @@ limit 1""", {'handid':handid})
|
|||
SELECT
|
||||
h.sitehandno as hid,
|
||||
h.tablename as table,
|
||||
h.handstart as starttime
|
||||
h.startTime as startTime
|
||||
FROM
|
||||
hands as h
|
||||
WHERE h.id = %(handid)s
|
||||
|
@ -1564,7 +1592,7 @@ WHERE h.id = %(handid)s
|
|||
res = c.fetchone()
|
||||
h.handid = res[0]
|
||||
h.tablename = res[1]
|
||||
h.starttime = res[2] # automatically a datetime
|
||||
h.startTime = res[2] # automatically a datetime
|
||||
|
||||
# PlayerStacks
|
||||
c.execute("""
|
||||
|
|
|
@ -1,9 +1,10 @@
|
|||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
"""HandHistory.py
|
||||
|
||||
Parses HandHistory xml files and returns requested objects.
|
||||
"""
|
||||
# Copyright 2008, Ray E. Barker
|
||||
# Copyright 2008-2010, 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
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#!/usr/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
#Copyright 2008 Carl Gherardi
|
||||
#Copyright 2008-2010 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.
|
||||
|
@ -13,8 +13,7 @@
|
|||
#
|
||||
#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.
|
||||
#In the "official" distribution you can find the license in agpl-3.0.txt.
|
||||
|
||||
import re
|
||||
import sys
|
||||
|
@ -27,8 +26,11 @@ import codecs
|
|||
from decimal import Decimal
|
||||
import operator
|
||||
from xml.dom.minidom import Node
|
||||
|
||||
import time
|
||||
import datetime
|
||||
from pytz import timezone
|
||||
import pytz
|
||||
|
||||
import logging
|
||||
# logging has been set up in fpdb.py or HUD_main.py, use their settings:
|
||||
|
@ -36,7 +38,6 @@ log = logging.getLogger("parser")
|
|||
|
||||
|
||||
import Hand
|
||||
import Tourney
|
||||
from Exceptions import FpdbParseError
|
||||
import Configuration
|
||||
|
||||
|
@ -62,7 +63,7 @@ class HandHistoryConverter():
|
|||
codepage = "cp1252"
|
||||
|
||||
|
||||
def __init__(self, config, in_path = '-', out_path = '-', follow=False, index=0, autostart=True, starsArchive=False):
|
||||
def __init__(self, config, in_path = '-', out_path = '-', follow=False, index=0, autostart=True, starsArchive=False, ftpArchive=False):
|
||||
"""\
|
||||
in_path (default '-' = sys.stdin)
|
||||
out_path (default '-' = sys.stdout)
|
||||
|
@ -75,6 +76,7 @@ follow : whether to tail -f the input"""
|
|||
|
||||
self.index = index
|
||||
self.starsArchive = starsArchive
|
||||
self.ftpArchive = ftpArchive
|
||||
|
||||
self.in_path = in_path
|
||||
self.out_path = out_path
|
||||
|
@ -136,8 +138,7 @@ Otherwise, finish at EOF.
|
|||
self.numHands += 1
|
||||
except FpdbParseError, e:
|
||||
self.numErrors += 1
|
||||
log.warning("Failed to convert hand %s" % e.hid)
|
||||
log.warning("Exception msg: '%s'" % str(e))
|
||||
log.warning("HHC.start(follow): processHand failed: Exception msg: '%s'" % e)
|
||||
log.debug(handText)
|
||||
else:
|
||||
handsList = self.allHandsAsList()
|
||||
|
@ -151,8 +152,7 @@ Otherwise, finish at EOF.
|
|||
self.processedHands.append(self.processHand(handText))
|
||||
except FpdbParseError, e:
|
||||
self.numErrors += 1
|
||||
log.warning("Failed to convert hand %s" % e.hid)
|
||||
log.warning("Exception msg: '%s'" % str(e))
|
||||
log.warning("HHC.start(): processHand failed: Exception msg: '%s'" % e)
|
||||
log.debug(handText)
|
||||
self.numHands = len(handsList)
|
||||
endtime = time.time()
|
||||
|
@ -247,6 +247,11 @@ which it expects to find at self.re_TailSplitHands -- see for e.g. Everleaf.py.
|
|||
m = re.compile('^Hand #\d+', re.MULTILINE)
|
||||
self.obs = m.sub('', self.obs)
|
||||
|
||||
if self.ftpArchive == True:
|
||||
log.debug("Converting ftpArchive format to readable")
|
||||
m = re.compile('^\*\*\*\*\*\*+\s#\s\d+\s\*\*\*\*\*+$', re.MULTILINE)
|
||||
self.obs = m.sub('', self.obs)
|
||||
|
||||
if self.obs is None or self.obs == "":
|
||||
log.info("Read no hands.")
|
||||
return []
|
||||
|
@ -428,9 +433,9 @@ or None if we fail to get the info """
|
|||
try:
|
||||
in_fh = codecs.open(self.in_path, 'r', kodec)
|
||||
whole_file = in_fh.read()
|
||||
in_fh.close()
|
||||
self.obs = whole_file[self.index:]
|
||||
self.index = len(whole_file)
|
||||
in_fh.close()
|
||||
break
|
||||
except:
|
||||
pass
|
||||
|
@ -493,6 +498,72 @@ or None if we fail to get the info """
|
|||
def getTourney(self):
|
||||
return self.tourney
|
||||
|
||||
@staticmethod
|
||||
def changeTimezone(time, givenTimezone, wantedTimezone):
|
||||
#print "raw time:",time, "given TZ:", givenTimezone
|
||||
if wantedTimezone=="UTC":
|
||||
wantedTimezone = pytz.utc
|
||||
else:
|
||||
raise Error #TODO raise appropriate error
|
||||
|
||||
if givenTimezone=="ET":
|
||||
givenTimezone = timezone('US/Eastern')
|
||||
elif givenTimezone=="CET":
|
||||
givenTimezone = timezone('Europe/Berlin')
|
||||
#Note: Daylight Saving Time is standardised across the EU so this should be fine
|
||||
elif givenTimezone == 'HST': # Hawaiian Standard Time
|
||||
pass
|
||||
elif givenTimezone == 'AKT': # Alaska Time
|
||||
pass
|
||||
elif givenTimezone == 'PT': # Pacific Time
|
||||
pass
|
||||
elif givenTimezone == 'MT': # Mountain Time
|
||||
pass
|
||||
elif givenTimezone == 'CT': # Central Time
|
||||
pass
|
||||
elif givenTimezone == 'AT': # Atlantic Time
|
||||
pass
|
||||
elif givenTimezone == 'NT': # Newfoundland Time
|
||||
pass
|
||||
elif givenTimezone == 'ART': # Argentinian Time
|
||||
pass
|
||||
elif givenTimezone == 'BRT': # Brasilia Time
|
||||
pass
|
||||
elif givenTimezone == 'AKT': # Alaska Time
|
||||
pass
|
||||
elif givenTimezone == 'WET': # Western European Time
|
||||
pass
|
||||
elif givenTimezone == 'EET': # Eastern European Time
|
||||
pass
|
||||
elif givenTimezone == 'MSK': # Moscow Standard Time
|
||||
pass
|
||||
elif givenTimezone == 'IST': # India Standard Time
|
||||
pass
|
||||
elif givenTimezone == 'CCT': # China Coast Time
|
||||
pass
|
||||
elif givenTimezone == 'JST': # Japan Standard Time
|
||||
pass
|
||||
elif givenTimezone == 'AWST': # Australian Western Standard Time
|
||||
givenTimezone = timezone('Australia/West')
|
||||
elif givenTimezone == 'ACST': # Australian Central Standard Time
|
||||
givenTimezone = timezone('Australia/Darwin')
|
||||
elif givenTimezone == 'AEST': # Australian Eastern Standard Time
|
||||
# Each State on the East Coast has different DSTs.
|
||||
# Melbournce is out because I don't like AFL, Queensland doesn't have DST
|
||||
# ACT is full of politicians and Tasmania will never notice.
|
||||
# Using Sydney.
|
||||
givenTimezone = timezone('Australia/Sydney')
|
||||
elif givenTimezone == 'NZT': # New Zealand Time
|
||||
pass
|
||||
else:
|
||||
raise Error #TODO raise appropriate error
|
||||
|
||||
localisedTime = givenTimezone.localize(time)
|
||||
utcTime = localisedTime.astimezone(wantedTimezone)
|
||||
#print "utcTime:",utcTime
|
||||
return utcTime
|
||||
#end @staticmethod def changeTimezone
|
||||
|
||||
@staticmethod
|
||||
def getTableTitleRe(type, table_name=None, tournament = None, table_number=None):
|
||||
"Returns string to search in windows titles"
|
||||
|
|
|
@ -1,9 +1,10 @@
|
|||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
"""Hello.py
|
||||
|
||||
Hello World demostration for Aux_Window.
|
||||
"""
|
||||
# Copyright 2009, Ray E. Barker
|
||||
# Copyright 2009-2010, 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
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
Create and manage the hud overlays.
|
||||
"""
|
||||
# Copyright 2008, 2009 Ray E. Barker
|
||||
# Copyright 2008-2010 Ray E. Barker
|
||||
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
|
@ -87,6 +87,7 @@ class Hud:
|
|||
(font, font_size) = config.get_default_font(self.table.site)
|
||||
self.colors = config.get_default_colors(self.table.site)
|
||||
self.hud_ui = config.get_hud_ui_parameters()
|
||||
self.site_params = config.get_site_parameters(self.table.site)
|
||||
|
||||
self.backgroundcolor = gtk.gdk.color_parse(self.colors['hudbgcolor'])
|
||||
self.foregroundcolor = gtk.gdk.color_parse(self.colors['hudfgcolor'])
|
||||
|
@ -448,6 +449,8 @@ class Hud:
|
|||
if os.name == 'nt':
|
||||
if not win32gui.IsWindow(self.table.number):
|
||||
self.parent.kill_hud(self, self.table.name)
|
||||
self.parent.kill_hud(self, self.table.name.split(" ")[0])
|
||||
#table.name is only a valid handle for ring games ! we are not killing tourney tables here.
|
||||
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?
|
||||
if self.table.gdkhandle is not None:
|
||||
|
@ -455,7 +458,7 @@ class Hud:
|
|||
if self.table.x != x or self.table.y != y:
|
||||
self.table.x = x
|
||||
self.table.y = y
|
||||
self.main_window.move(x, y)
|
||||
self.main_window.move(x + self.site_params['xshift'], y + self.site_params['yshift'])
|
||||
adj = self.adj_seats(self.hand, self.config)
|
||||
loc = self.config.get_locations(self.table.site, self.max)
|
||||
# TODO: is stat_windows getting converted somewhere from a list to a dict, for no good reason?
|
||||
|
@ -467,6 +470,9 @@ class Hud:
|
|||
for aux in self.aux_windows:
|
||||
aux.update_card_positions()
|
||||
|
||||
self.reposition_windows()
|
||||
# call reposition_windows, which apparently moves even hidden windows, where this function does not, even though they do the same thing, afaict
|
||||
|
||||
return True
|
||||
|
||||
def on_button_press(self, widget, event):
|
||||
|
|
81
pyfpdb/ImapFetcher.py
Executable file
81
pyfpdb/ImapFetcher.py
Executable file
|
@ -0,0 +1,81 @@
|
|||
#!/usr/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
#Copyright 2010 Steffen Schaumburg
|
||||
#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.
|
||||
|
||||
"""This file is to fetch summaries through IMAP and pass them on to the appropriate parser"""
|
||||
#see http://docs.python.org/library/imaplib.html for the python interface
|
||||
#see http://tools.ietf.org/html/rfc2060#section-6.4.4 for IMAP4 search criteria
|
||||
|
||||
from imaplib import IMAP4, IMAP4_SSL
|
||||
import PokerStarsSummary
|
||||
|
||||
def splitPokerStarsSummaries(emailText):
|
||||
splitSummaries=emailText.split("\nPokerStars Tournament #")[1:]
|
||||
for i in range(len(splitSummaries)):
|
||||
splitSummaries[i]="PokerStars Tournament #"+splitSummaries[i]
|
||||
return splitSummaries
|
||||
#end def emailText
|
||||
|
||||
def run(config, db):
|
||||
#print "start of IS.run"
|
||||
server=None
|
||||
#try:
|
||||
#print "useSSL",config.email.useSsl,"host",config.email.host
|
||||
if config.email.useSsl:
|
||||
server = IMAP4_SSL(config.email.host)
|
||||
else:
|
||||
server = IMAP4(config.email.host)
|
||||
response = server.login(config.email.username, config.email.password) #TODO catch authentication error
|
||||
print "response to logging in:",response
|
||||
#print "server.list():",server.list() #prints list of folders
|
||||
|
||||
response = server.select(config.email.folder)
|
||||
#print "response to selecting INBOX:",response
|
||||
if response[0]!="OK":
|
||||
raise error #TODO: show error message
|
||||
|
||||
neededMessages=[]
|
||||
response, searchData = server.search(None, "SUBJECT", "PokerStars Tournament History Request")
|
||||
for messageNumber in searchData[0].split(" "):
|
||||
response, headerData = server.fetch(messageNumber, "(BODY[HEADER.FIELDS (SUBJECT)])")
|
||||
#print "response to fetch subject:",response
|
||||
if response!="OK":
|
||||
raise error #TODO: show error message
|
||||
if headerData[1].find("Subject: PokerStars Tournament History Request - Last x")!=1:
|
||||
neededMessages.append(("PS", messageNumber))
|
||||
|
||||
if (len(neededMessages)==0):
|
||||
raise error #TODO: show error message
|
||||
for messageData in neededMessages:
|
||||
response, bodyData = server.fetch(messageData[1], "(UID BODY[TEXT])")
|
||||
bodyData=bodyData[0][1]
|
||||
if response!="OK":
|
||||
raise error #TODO: show error message
|
||||
if messageData[0]=="PS":
|
||||
summaryTexts=(splitPokerStarsSummaries(bodyData))
|
||||
for summaryText in summaryTexts:
|
||||
result=PokerStarsSummary.PokerStarsSummary(db=db, config=config, siteName=u"PokerStars", summaryText=summaryText, builtFrom = "IMAP")
|
||||
#print "finished importing a PS summary with result:",result
|
||||
#TODO: count results and output to shell like hand importer does
|
||||
|
||||
print "completed running Imap import, closing server connection"
|
||||
#finally:
|
||||
# try:
|
||||
server.close()
|
||||
# finally:
|
||||
# pass
|
||||
server.logout()
|
||||
|
|
@ -1,9 +1,10 @@
|
|||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
"""Mucked.py
|
||||
|
||||
Mucked cards display for FreePokerTools HUD.
|
||||
"""
|
||||
# Copyright 2008, 2009, Ray E. Barker
|
||||
# Copyright 2008-2010, 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
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
#!/usr/bin/env python
|
||||
# Copyright 2008, Carl Gherardi
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# Copyright 2008-2010, 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
|
||||
|
@ -136,7 +138,7 @@ class OnGame(HandHistoryConverter):
|
|||
#TODO: Do conversion from GMT to ET
|
||||
#TODO: Need some date functions to convert to different timezones (Date::Manip for perl rocked for this)
|
||||
|
||||
hand.starttime = time.strptime(m.group('DATETIME'), "%d %b %Y %I:%M %p")
|
||||
hand.startTime = time.strptime(m.group('DATETIME'), "%d %b %Y %I:%M %p")
|
||||
#hand.starttime = "%d/%02d/%02d %d:%02d:%02d ET" %(int(m.group('YEAR')), int(m.group('MON')), int(m.group('DAY')),
|
||||
#int(m.group('HR')), int(m.group('MIN')), int(m.group('SEC')))
|
||||
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#!/usr/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
#Copyright 2008 Ray E. Barker
|
||||
#Copyright 2008-2010 Ray E. Barker
|
||||
#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.
|
||||
|
@ -12,8 +13,7 @@
|
|||
#
|
||||
#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.
|
||||
#In the "official" distribution you can find the license in agpl-3.0.txt.
|
||||
|
||||
import sys
|
||||
from optparse import OptionParser
|
||||
|
|
33
pyfpdb/P5sResultsParser.py
Normal file
33
pyfpdb/P5sResultsParser.py
Normal file
|
@ -0,0 +1,33 @@
|
|||
import urllib2, re
|
||||
import pprint
|
||||
from BeautifulSoup import BeautifulSoup
|
||||
|
||||
|
||||
playername = ''
|
||||
|
||||
if playername == '':
|
||||
print "You need to manually enter the playername"
|
||||
exit(0)
|
||||
|
||||
page = urllib2.urlopen("http://www.pocketfives.com/poker-scores/%s/" %playername)
|
||||
soup = BeautifulSoup(page)
|
||||
|
||||
results = []
|
||||
|
||||
for table in soup.findAll('table'):
|
||||
# print "Found %s" % table
|
||||
for row in table.findAll('tr'):
|
||||
tmp = []
|
||||
for col in row.findAll('td'):
|
||||
tmp = tmp + [col.string]
|
||||
#print col.string
|
||||
if len(tmp) > 3 and tmp[2] <> None:
|
||||
results = results + [tmp]
|
||||
|
||||
cols = ['TOURNAMENT', 'SITE', 'DATE', 'PRIZEPOOL', 'BUY-IN', 'PLACE', 'WON']
|
||||
|
||||
pp = pprint.PrettyPrinter(indent=4)
|
||||
|
||||
for result in results:
|
||||
print "Site: %s Date: %s\tPrizepool: %s\tBuyin: %s\tPosition: %s\tWon: %s" %(result[2], result[3], result[4], result[5], result[6], result[7])
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# Copyright 2009, Grigorij Indigirkin
|
||||
# Copyright 2009-2010, Grigorij Indigirkin
|
||||
#
|
||||
# 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
|
||||
|
@ -265,6 +265,7 @@ class PartyPoker(HandHistoryConverter):
|
|||
if v[0] in self.pot.returned:
|
||||
self.collected[i][1] = Decimal(v[1]) - self.pot.returned[v[0]]
|
||||
self.collectees[v[0]] -= self.pot.returned[v[0]]
|
||||
self.pot.returned[v[0]] = 0
|
||||
return origTotalPot()
|
||||
return totalPot
|
||||
instancemethod = type(hand.totalPot)
|
||||
|
@ -284,7 +285,7 @@ class PartyPoker(HandHistoryConverter):
|
|||
'July','August','September','October','November','December']
|
||||
month = months.index(m2.group('M')) + 1
|
||||
datetimestr = "%s/%s/%s %s:%s:%s" % (m2.group('Y'), month,m2.group('D'),m2.group('H'),m2.group('MIN'),m2.group('S'))
|
||||
hand.starttime = datetime.datetime.strptime(datetimestr, "%Y/%m/%d %H:%M:%S")
|
||||
hand.startTime = datetime.datetime.strptime(datetimestr, "%Y/%m/%d %H:%M:%S")
|
||||
# FIXME: some timezone correction required
|
||||
#tzShift = defaultdict(lambda:0, {'EDT': -5, 'EST': -6, 'MSKS': 3})
|
||||
#hand.starttime -= datetime.timedelta(hours=tzShift[m2.group('TZ')])
|
||||
|
@ -363,8 +364,14 @@ class PartyPoker(HandHistoryConverter):
|
|||
if hand.gametype['type'] == 'ring':
|
||||
try:
|
||||
assert noSmallBlind==False
|
||||
m = self.re_PostSB.search(hand.handText)
|
||||
liveBlind = True
|
||||
for m in self.re_PostSB.finditer(hand.handText):
|
||||
if liveBlind:
|
||||
hand.addBlind(m.group('PNAME'), 'small blind', m.group('SB'))
|
||||
liveBlind = False
|
||||
else:
|
||||
# Post dead blinds as ante
|
||||
hand.addBlind(m.group('PNAME'), 'secondsb', m.group('SB'))
|
||||
except: # no small blind
|
||||
hand.addBlind(None, None, None)
|
||||
|
||||
|
@ -436,7 +443,7 @@ class PartyPoker(HandHistoryConverter):
|
|||
if street == 'PREFLOP' and \
|
||||
playerName in [item[0] for item in hand.actions['BLINDSANTES'] if item[2]!='ante']:
|
||||
# preflop raise from blind
|
||||
hand.addRaiseBy( street, playerName, amount )
|
||||
hand.addCallandRaise( street, playerName, amount )
|
||||
else:
|
||||
hand.addCallandRaise( street, playerName, amount )
|
||||
elif actionType == 'calls':
|
||||
|
|
156
pyfpdb/PokerStarsSummary.py
Normal file
156
pyfpdb/PokerStarsSummary.py
Normal file
|
@ -0,0 +1,156 @@
|
|||
#!/usr/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
#Copyright 2008-2010 Steffen Schaumburg
|
||||
#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.
|
||||
|
||||
"""pokerstars-specific summary parsing code"""
|
||||
|
||||
from decimal import Decimal
|
||||
import datetime
|
||||
|
||||
from Exceptions import FpdbParseError
|
||||
from HandHistoryConverter import *
|
||||
import PokerStarsToFpdb
|
||||
from TourneySummary import *
|
||||
|
||||
class PokerStarsSummary(TourneySummary):
|
||||
limits = { 'No Limit':'nl', 'Pot Limit':'pl', 'Limit':'fl', 'LIMIT':'fl' }
|
||||
games = { # base, category
|
||||
"Hold'em" : ('hold','holdem'),
|
||||
'Omaha' : ('hold','omahahi'),
|
||||
'Omaha Hi/Lo' : ('hold','omahahilo'),
|
||||
'Razz' : ('stud','razz'),
|
||||
'RAZZ' : ('stud','razz'),
|
||||
'7 Card Stud' : ('stud','studhi'),
|
||||
'7 Card Stud Hi/Lo' : ('stud','studhilo'),
|
||||
'Badugi' : ('draw','badugi'),
|
||||
'Triple Draw 2-7 Lowball' : ('draw','27_3draw'),
|
||||
'5 Card Draw' : ('draw','fivedraw')
|
||||
}
|
||||
|
||||
re_TourNo = re.compile("\#[0-9]+,")
|
||||
re_Entries = re.compile("[0-9]+")
|
||||
re_Prizepool = re.compile("\$[0-9]+\.[0-9]+")
|
||||
re_Player = re.compile(u"""(?P<RANK>[0-9]+):\s(?P<NAME>.*)\s\(.*\),(\s)?(\$(?P<WINNINGS>[0-9]+\.[0-9]+))?(?P<STILLPLAYING>still\splaying)?""")
|
||||
re_BuyInFee = re.compile("(?P<BUYIN>[0-9]+\.[0-9]+).*(?P<FEE>[0-9]+\.[0-9]+)")
|
||||
re_FPP = re.compile("(?P<FPP>[0-9]+)\sFPP")
|
||||
#note: the dollar and cent in the below line are currency-agnostic
|
||||
re_Added = re.compile("(?P<DOLLAR>[0-9]+)\.(?P<CENT>[0-9]+)\s(?P<CURRENCY>[A-Z]+)(\sadded\sto\sthe\sprize\spool\sby\sPokerStars)")
|
||||
re_DateTime = re.compile("\[(?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]+)")
|
||||
re_DateTimeET = re.compile("(?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]+)")
|
||||
re_GameInfo = re.compile(u""".+(?P<LIMIT>No\sLimit|Limit|LIMIT|Pot\sLimit)\s(?P<GAME>Hold\'em|Razz|RAZZ|7\sCard\sStud|7\sCard\sStud\sHi/Lo|Omaha|Omaha\sHi/Lo|Badugi|Triple\sDraw\s2\-7\sLowball|5\sCard\sDraw)""")
|
||||
|
||||
def parseSummary(self):
|
||||
lines=self.summaryText.splitlines()
|
||||
|
||||
self.tourNo = self.re_TourNo.findall(lines[0])[0][1:-1] #ignore game and limit type as thats not recorded
|
||||
|
||||
result=self.re_GameInfo.search(lines[0])
|
||||
result=result.groupdict()
|
||||
self.gametype['limitType']=self.limits[result['LIMIT']]
|
||||
self.gametype['category']=self.games[result['GAME']][1]
|
||||
|
||||
if lines[1].find("$")!=-1: #TODO: move this into a method and call that from PokerStarsToFpdb.py:269 if hand.buyinCurrency=="USD" etc.
|
||||
self.currency="USD"
|
||||
elif lines[1].find(u"€")!=-1:
|
||||
self.currency="EUR"
|
||||
elif lines[1].find("FPP")!=-1:
|
||||
self.currency="PSFP"
|
||||
else:
|
||||
raise FpdbParseError("didn't recognise buyin currency in:"+lines[1])
|
||||
|
||||
if self.currency=="USD" or self.currency=="EUR":
|
||||
result=self.re_BuyInFee.search(lines[1])
|
||||
result=result.groupdict()
|
||||
self.buyin=int(100*Decimal(result['BUYIN']))
|
||||
self.fee=int(100*Decimal(result['FEE']))
|
||||
elif self.currency=="PSFP":
|
||||
result=self.re_FPP.search(lines[1])
|
||||
result=result.groupdict()
|
||||
self.buyin=int(Decimal(result['FPP']))
|
||||
self.fee=0
|
||||
|
||||
currentLine=2
|
||||
self.entries = self.re_Entries.findall(lines[currentLine])[0]
|
||||
currentLine+=1 #note that I chose to make the code keep state (the current line number)
|
||||
#as that means it'll fail rather than silently skip potentially valuable information
|
||||
#print "after entries lines[currentLine]", lines[currentLine]
|
||||
|
||||
result=self.re_Added.search(lines[currentLine])
|
||||
if result:
|
||||
result=result.groupdict()
|
||||
self.added=100*int(Decimal(result['DOLLAR']))+int(Decimal(result['CENT']))
|
||||
self.addedCurrency=result['CURRENCY']
|
||||
currentLine+=1
|
||||
else:
|
||||
self.added=0
|
||||
self.addedCurrency="NA"
|
||||
#print "after added/entries lines[currentLine]", lines[currentLine]
|
||||
|
||||
result=self.re_Prizepool.findall(lines[currentLine])
|
||||
if result:
|
||||
self.prizepool = result[0]
|
||||
self.prizepool = self.prizepool[1:-3]+self.prizepool[-2:]
|
||||
currentLine+=1
|
||||
#print "after prizepool lines[currentLine]", lines[currentLine]
|
||||
|
||||
useET=False
|
||||
result=self.re_DateTime.search(lines[currentLine])
|
||||
if not result:
|
||||
print "in not result starttime"
|
||||
useET=True
|
||||
result=self.re_DateTimeET.search(lines[currentLine])
|
||||
result=result.groupdict()
|
||||
datetimestr = "%s/%s/%s %s:%s:%s" % (result['Y'], result['M'],result['D'],result['H'],result['MIN'],result['S'])
|
||||
self.startTime= datetime.datetime.strptime(datetimestr, "%Y/%m/%d %H:%M:%S") # also timezone at end, e.g. " ET"
|
||||
self.startTime = HandHistoryConverter.changeTimezone(self.startTime, "ET", "UTC")
|
||||
currentLine+=1
|
||||
|
||||
if useET:
|
||||
result=self.re_DateTimeET.search(lines[currentLine])
|
||||
else:
|
||||
result=self.re_DateTime.search(lines[currentLine])
|
||||
if result:
|
||||
result=result.groupdict()
|
||||
datetimestr = "%s/%s/%s %s:%s:%s" % (result['Y'], result['M'],result['D'],result['H'],result['MIN'],result['S'])
|
||||
self.endTime= datetime.datetime.strptime(datetimestr, "%Y/%m/%d %H:%M:%S") # also timezone at end, e.g. " ET"
|
||||
self.endTime = HandHistoryConverter.changeTimezone(self.endTime, "ET", "UTC")
|
||||
currentLine+=1
|
||||
|
||||
if lines[currentLine].find("Tournament is still in progress")!=-1:
|
||||
currentLine+=1
|
||||
|
||||
for i in range(currentLine,len(lines)-2): #lines with rank and winnings info
|
||||
if lines[i].find(":")==-1:
|
||||
break
|
||||
result=self.re_Player.search(lines[i])
|
||||
result=result.groupdict()
|
||||
rank=result['RANK']
|
||||
name=result['NAME']
|
||||
winnings=result['WINNINGS']
|
||||
|
||||
if winnings:
|
||||
winnings=int(100*Decimal(winnings))
|
||||
else:
|
||||
winnings=0
|
||||
|
||||
if result['STILLPLAYING']:
|
||||
#print "stillplaying"
|
||||
rank=None
|
||||
winnings=None
|
||||
|
||||
self.addPlayer(rank, name, winnings, self.currency, None, None, None)#TODO: currency, ko/addon/rebuy count -> need examples!
|
||||
#end def parseSummary
|
||||
#end class PokerStarsSummary
|
|
@ -1,7 +1,7 @@
|
|||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# Copyright 2008, Carl Gherardi
|
||||
# Copyright 2008-2010, 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
|
||||
|
@ -22,6 +22,7 @@
|
|||
|
||||
import sys
|
||||
from HandHistoryConverter import *
|
||||
from decimal import Decimal
|
||||
|
||||
# PokerStars HH Format
|
||||
|
||||
|
@ -41,18 +42,44 @@ class PokerStars(HandHistoryConverter):
|
|||
'LS' : "\$|\xe2\x82\xac|" # legal currency symbols - Euro(cp1252, utf-8)
|
||||
}
|
||||
|
||||
# translations from captured groups to fpdb info strings
|
||||
Lim_Blinds = { '0.04': ('0.01', '0.02'), '0.10': ('0.02', '0.05'), '0.20': ('0.05', '0.10'),
|
||||
'0.40': ('0.10', '0.20'), '0.50': ('0.10', '0.25'), '1.00': ('0.25', '0.50'),
|
||||
'2.00': ('0.50', '1.00'), '2': ('0.50', '1.00'), '4' : ('1.00', '2.00'),
|
||||
'4.00': ('1.00', '2.00'), '6': ('1.00', '3.00'), '6.00': ('1.00', '3.00'),
|
||||
'10.00': ('2.00', '5.00'), '20.00': ('5.00', '10.00'), '30.00': ('10.00', '15.00'),
|
||||
'60.00': ('15.00', '30.00'), '100.00': ('25.00', '50.00'), '200.00': ('50.00', '100.00'),
|
||||
'400.00': ('100.00', '200.00'), '1000.00': ('250.00', '500.00')}
|
||||
|
||||
limits = { 'No Limit':'nl', 'Pot Limit':'pl', 'Limit':'fl', 'LIMIT':'fl' }
|
||||
games = { # base, category
|
||||
"Hold'em" : ('hold','holdem'),
|
||||
'Omaha' : ('hold','omahahi'),
|
||||
'Omaha Hi/Lo' : ('hold','omahahilo'),
|
||||
'Razz' : ('stud','razz'),
|
||||
'RAZZ' : ('stud','razz'),
|
||||
'7 Card Stud' : ('stud','studhi'),
|
||||
'7 Card Stud Hi/Lo' : ('stud','studhilo'),
|
||||
'Badugi' : ('draw','badugi'),
|
||||
'Triple Draw 2-7 Lowball' : ('draw','27_3draw'),
|
||||
'5 Card Draw' : ('draw','fivedraw')
|
||||
}
|
||||
currencies = { u'€':'EUR', '$':'USD', '':'T$' }
|
||||
|
||||
# Static regexes
|
||||
re_GameInfo = re.compile(u"""
|
||||
PokerStars\sGame\s\#(?P<HID>[0-9]+):\s+
|
||||
(Tournament\s\# # open paren of tournament info
|
||||
(?P<TOURNO>\d+),\s
|
||||
# here's how I plan to use LS
|
||||
(?P<BUYIN>([%(LS)s\+\d\.]+\s?(?P<TOUR_ISO>%(LEGAL_ISO)s)?)|Freeroll)\s+)?
|
||||
(?P<BUYIN>(?P<BIAMT>[%(LS)s\d\.]+)?\+?(?P<BIRAKE>[%(LS)s\d\.]+)?\+?(?P<BOUNTY>[%(LS)s\d\.]+)?\s?(?P<TOUR_ISO>%(LEGAL_ISO)s)?|Freeroll)\s+)?
|
||||
# close paren of tournament info
|
||||
(?P<MIXED>HORSE|8\-Game|HOSE)?\s?\(?
|
||||
(?P<GAME>Hold\'em|Razz|7\sCard\sStud|7\sCard\sStud\sHi/Lo|Omaha|Omaha\sHi/Lo|Badugi|Triple\sDraw\s2\-7\sLowball|5\sCard\sDraw)\s
|
||||
(?P<LIMIT>No\sLimit|Limit|Pot\sLimit)\)?,?\s
|
||||
(-\sLevel\s(?P<LEVEL>[IVXLC]+)\s)?
|
||||
(?P<GAME>Hold\'em|Razz|RAZZ|7\sCard\sStud|7\sCard\sStud\sHi/Lo|Omaha|Omaha\sHi/Lo|Badugi|Triple\sDraw\s2\-7\sLowball|5\sCard\sDraw)\s
|
||||
(?P<LIMIT>No\sLimit|Limit|LIMIT|Pot\sLimit)\)?,?\s
|
||||
(-\s)?
|
||||
(Match.*)? #TODO: waiting for reply from user as to what this means
|
||||
(Level\s(?P<LEVEL>[IVXLC]+)\s)?
|
||||
\(? # open paren of the stakes
|
||||
(?P<CURRENCY>%(LS)s|)?
|
||||
(?P<SB>[.0-9]+)/(%(LS)s)?
|
||||
|
@ -82,6 +109,8 @@ class PokerStars(HandHistoryConverter):
|
|||
# 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]+)')
|
||||
|
||||
re_DateTime = re.compile("""(?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]+)""", re.MULTILINE)
|
||||
# revised re including timezone (not currently used):
|
||||
#re_DateTime = re.compile("""(?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]+) \(?(?P<TZ>[A-Z0-9]+)""", re.MULTILINE)
|
||||
|
||||
def compilePlayerRegexs(self, hand):
|
||||
players = set([player[1] for player in hand.players])
|
||||
|
@ -135,46 +164,26 @@ class PokerStars(HandHistoryConverter):
|
|||
info = {}
|
||||
m = self.re_GameInfo.search(handText)
|
||||
if not m:
|
||||
print "DEBUG: determineGameType(): did not match"
|
||||
return None
|
||||
tmp = handText[0:100]
|
||||
log.error("determineGameType: Unable to recognise gametype from: '%s'" % tmp)
|
||||
log.error("determineGameType: Raising FpdbParseError")
|
||||
raise FpdbParseError("Unable to recognise gametype from: '%s'" % tmp)
|
||||
|
||||
mg = m.groupdict()
|
||||
# translations from captured groups to fpdb info strings
|
||||
Lim_Blinds = { '0.04': ('0.01', '0.02'), '0.10': ('0.02', '0.05'), '0.20': ('0.05', '0.10'),
|
||||
'0.50': ('0.10', '0.25'), '1.00': ('0.25', '0.50'), '2.00': ('0.50', '1.00'),
|
||||
'4.00': ('1.00', '2.00'), '6.00': ('1.00', '3.00'), '10.00': ('2.00', '5.00'),
|
||||
'20.00': ('5.00', '10.00'), '30.00': ('10.00', '15.00'), '60.00': ('15.00', '30.00'),
|
||||
'100.00': ('25.00', '50.00'),'200.00': ('50.00', '100.00'),'400.00': ('100.00', '200.00'),
|
||||
'1000.00': ('250.00', '500.00')}
|
||||
|
||||
|
||||
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'),
|
||||
'7 Card Stud Hi/Lo' : ('stud','studhilo'),
|
||||
'Badugi' : ('draw','badugi'),
|
||||
'Triple Draw 2-7 Lowball' : ('draw','27_3draw'),
|
||||
'5 Card Draw' : ('draw','fivedraw')
|
||||
}
|
||||
currencies = { u'€':'EUR', '$':'USD', '':'T$' }
|
||||
# I don't think this is doing what we think. mg will always have all
|
||||
# the expected keys, but the ones that didn't match in the regex will
|
||||
# have a value of None. It is OK if it throws an exception when it
|
||||
# runs across an unknown game or limit or whatever.
|
||||
if 'LIMIT' in mg:
|
||||
info['limitType'] = limits[mg['LIMIT']]
|
||||
info['limitType'] = self.limits[mg['LIMIT']]
|
||||
if 'GAME' in mg:
|
||||
(info['base'], info['category']) = games[mg['GAME']]
|
||||
(info['base'], info['category']) = self.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']]
|
||||
info['currency'] = self.currencies[mg['CURRENCY']]
|
||||
|
||||
if 'TOURNO' in mg and mg['TOURNO'] is None:
|
||||
info['type'] = 'ring'
|
||||
|
@ -182,10 +191,14 @@ class PokerStars(HandHistoryConverter):
|
|||
info['type'] = 'tour'
|
||||
|
||||
if info['limitType'] == 'fl' and info['bb'] is not None and info['type'] == 'ring' and info['base'] != 'stud':
|
||||
info['sb'] = Lim_Blinds[mg['BB']][0]
|
||||
info['bb'] = Lim_Blinds[mg['BB']][1]
|
||||
try:
|
||||
info['sb'] = self.Lim_Blinds[mg['BB']][0]
|
||||
info['bb'] = self.Lim_Blinds[mg['BB']][1]
|
||||
except KeyError:
|
||||
log.error("determineGameType: Lim_Blinds has no lookup for '%s'" % mg['BB'])
|
||||
log.error("determineGameType: Raising FpdbParseError")
|
||||
raise FpdbParseError("Lim_Blinds has no lookup for '%s'" % mg['BB'])
|
||||
|
||||
# NB: SB, BB must be interpreted as blinds or bets depending on limit type.
|
||||
return info
|
||||
|
||||
def readHandInfo(self, hand):
|
||||
|
@ -193,37 +206,72 @@ class PokerStars(HandHistoryConverter):
|
|||
m = self.re_HandInfo.search(hand.handText,re.DOTALL)
|
||||
if m:
|
||||
info.update(m.groupdict())
|
||||
# hand.maxseats = int(m2.group(1))
|
||||
else:
|
||||
pass # throw an exception here, eh?
|
||||
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
|
||||
|
||||
log.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/11/12 10:00:48 CET [2008/11/12 4:00:48 ET] # (both dates are parsed so ET date overrides the other)
|
||||
#2008/08/17 - 01:14:43 (ET)
|
||||
#2008/09/07 06:23:14 ET
|
||||
m1 = self.re_DateTime.finditer(info[key])
|
||||
# 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])
|
||||
datetimestr = "2000/01/01 00:00:00" # default used if time not found
|
||||
for a in m1:
|
||||
datetimestr = "%s/%s/%s %s:%s:%s" % (a.group('Y'), a.group('M'),a.group('D'),a.group('H'),a.group('MIN'),a.group('S'))
|
||||
hand.starttime = datetime.datetime.strptime(datetimestr, "%Y/%m/%d %H:%M:%S")
|
||||
#tz = a.group('TZ') # just assume ET??
|
||||
#print " tz = ", tz, " datetime =", datetimestr
|
||||
hand.startTime = datetime.datetime.strptime(datetimestr, "%Y/%m/%d %H:%M:%S") # also timezone at end, e.g. " ET"
|
||||
hand.startTime = HandHistoryConverter.changeTimezone(hand.startTime, "ET", "UTC")
|
||||
if key == 'HID':
|
||||
hand.handid = info[key]
|
||||
if key == 'TOURNO':
|
||||
hand.tourNo = info[key]
|
||||
if key == 'BUYIN':
|
||||
if hand.tourNo!=None:
|
||||
#print "DEBUG: info['BUYIN']: %s" % info['BUYIN']
|
||||
#print "DEBUG: info['BIAMT']: %s" % info['BIAMT']
|
||||
#print "DEBUG: info['BIRAKE']: %s" % info['BIRAKE']
|
||||
#print "DEBUG: info['BOUNTY']: %s" % info['BOUNTY']
|
||||
if info[key] == 'Freeroll':
|
||||
hand.buyin = '$0+$0'
|
||||
hand.buyin = 0
|
||||
hand.fee = 0
|
||||
hand.buyinCurrency = "FREE"
|
||||
else:
|
||||
#FIXME: The key looks like: '€0.82+€0.18 EUR'
|
||||
# This should be parsed properly and used
|
||||
hand.buyin = info[key]
|
||||
if info[key].find("$")!=-1:
|
||||
hand.buyinCurrency="USD"
|
||||
elif info[key].find(u"€")!=-1:
|
||||
hand.buyinCurrency="EUR"
|
||||
elif info[key].find("FPP")!=-1:
|
||||
hand.buyinCurrency="PSFP"
|
||||
else:
|
||||
#FIXME: handle other currencies, FPP, play money
|
||||
raise FpdbParseError("failed to detect currency")
|
||||
|
||||
info['BIAMT'] = info['BIAMT'].strip(u'$€FPP')
|
||||
|
||||
if hand.buyinCurrency!="PSFP":
|
||||
if info['BOUNTY'] != None:
|
||||
# There is a bounty, Which means we need to switch BOUNTY and BIRAKE values
|
||||
tmp = info['BOUNTY']
|
||||
info['BOUNTY'] = info['BIRAKE']
|
||||
info['BIRAKE'] = tmp
|
||||
info['BOUNTY'] = info['BOUNTY'].strip(u'$€') # Strip here where it isn't 'None'
|
||||
hand.koBounty = int(100*Decimal(info['BOUNTY']))
|
||||
hand.isKO = True
|
||||
else:
|
||||
hand.isKO = False
|
||||
|
||||
info['BIRAKE'] = info['BIRAKE'].strip(u'$€')
|
||||
|
||||
hand.buyin = int(100*Decimal(info['BIAMT']))
|
||||
hand.fee = int(100*Decimal(info['BIRAKE']))
|
||||
else:
|
||||
hand.buyin = int(Decimal(info['BIAMT']))
|
||||
hand.fee = 0
|
||||
if key == 'LEVEL':
|
||||
hand.level = info[key]
|
||||
|
||||
|
|
1006
pyfpdb/SQL.py
1006
pyfpdb/SQL.py
File diff suppressed because it is too large
Load Diff
188
pyfpdb/Stats.py
188
pyfpdb/Stats.py
|
@ -1,8 +1,9 @@
|
|||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
"""Manage collecting and formatting of stats and tooltips.
|
||||
"""
|
||||
# Copyright 2008, Ray E. Barker
|
||||
# Copyright 2008-2010, Ray E. Barker
|
||||
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
|
@ -57,6 +58,7 @@ import re
|
|||
# FreePokerTools modules
|
||||
import Configuration
|
||||
import Database
|
||||
import Charset
|
||||
|
||||
|
||||
re_Places = re.compile("_[0-9]$")
|
||||
|
@ -67,7 +69,7 @@ import codecs
|
|||
encoder = codecs.lookup(Configuration.LOCALE_ENCODING)
|
||||
|
||||
def do_tip(widget, tip):
|
||||
(_tip, _len) = encoder.encode(tip)
|
||||
_tip = Charset.to_utf8(tip)
|
||||
widget.set_tooltip_text(_tip)
|
||||
|
||||
def do_stat(stat_dict, player = 24, stat = 'vpip'):
|
||||
|
@ -113,7 +115,7 @@ def playername(stat_dict, player):
|
|||
stat_dict[player]['screen_name'])
|
||||
|
||||
def vpip(stat_dict, player):
|
||||
""" Voluntarily put $ in the pot."""
|
||||
""" Voluntarily put $ in the pot pre-flop."""
|
||||
stat = 0.0
|
||||
try:
|
||||
stat = float(stat_dict[player]['vpip'])/float(stat_dict[player]['n'])
|
||||
|
@ -122,14 +124,14 @@ def vpip(stat_dict, player):
|
|||
'v=%3.1f' % (100*stat) + '%',
|
||||
'vpip=%3.1f' % (100*stat) + '%',
|
||||
'(%d/%d)' % (stat_dict[player]['vpip'], stat_dict[player]['n']),
|
||||
'Voluntarily Put In Pot %'
|
||||
'Voluntarily Put In Pot Pre-Flop%'
|
||||
)
|
||||
except: return (stat,
|
||||
'%3.1f' % (0) + '%',
|
||||
'v=%3.1f' % (0) + '%',
|
||||
'vpip=%3.1f' % (0) + '%',
|
||||
'(%d/%d)' % (0, 0),
|
||||
'Voluntarily Put In Pot %'
|
||||
'Voluntarily Put In Pot Pre-Flop%'
|
||||
)
|
||||
|
||||
def pfr(stat_dict, player):
|
||||
|
@ -277,7 +279,7 @@ def fold_f(stat_dict, player):
|
|||
""" Folded flop/4th."""
|
||||
stat = 0.0
|
||||
try:
|
||||
stat = float(stat_dict[player]['fold_2'])/fold(stat_dict[player]['saw_f'])
|
||||
stat = float(stat_dict[player]['fold_2'])/float(stat_dict[player]['saw_f'])
|
||||
return (stat,
|
||||
'%3.1f' % (100*stat) + '%',
|
||||
'ff=%3.1f' % (100*stat) + '%',
|
||||
|
@ -349,6 +351,29 @@ def f_BB_steal(stat_dict, player):
|
|||
'(0/0)',
|
||||
'% folded BB to steal')
|
||||
|
||||
def f_steal(stat_dict, player):
|
||||
""" Folded blind to steal."""
|
||||
stat = 0.0
|
||||
try:
|
||||
folded_blind = stat_dict[player]['sbnotdef'] + stat_dict[player]['bbnotdef']
|
||||
blind_stolen = stat_dict[player]['sbstolen'] + stat_dict[player]['bbstolen']
|
||||
|
||||
stat = float(folded_blind)/float(blind_stolen)
|
||||
return (stat,
|
||||
'%3.1f' % (100*stat) + '%',
|
||||
'fB=%3.1f' % (100*stat) + '%',
|
||||
'fB_s=%3.1f' % (100*stat) + '%',
|
||||
'(%d/%d)' % (folded_blind, blind_stolen),
|
||||
'% folded blind to steal'
|
||||
)
|
||||
except:
|
||||
return (stat,
|
||||
'NA',
|
||||
'fB=NA',
|
||||
'fB_s=NA',
|
||||
'(0/0)',
|
||||
'% folded blind to steal')
|
||||
|
||||
def three_B(stat_dict, player):
|
||||
""" Three bet preflop/3rd."""
|
||||
stat = 0.0
|
||||
|
@ -503,6 +528,91 @@ def a_freq_123(stat_dict, player):
|
|||
'Post-Flop Aggression Freq'
|
||||
)
|
||||
|
||||
def agg_freq(stat_dict, player):
|
||||
""" Post-Flop aggression frequency."""
|
||||
""" Aggression frequency % = (times bet or raised post-flop) * 100 / (times bet, raised, called, or folded post-flop) """
|
||||
stat = 0.0
|
||||
try:
|
||||
""" Agression on the flop and all streets """
|
||||
bet_raise = stat_dict[player]['aggr_1'] + stat_dict[player]['aggr_2'] + stat_dict[player]['aggr_3'] + stat_dict[player]['aggr_4']
|
||||
""" number post flop streets seen, this must be number of post-flop calls !! """
|
||||
post_call = stat_dict[player]['call_1'] + stat_dict[player]['call_2'] + stat_dict[player]['call_3'] + stat_dict[player]['call_4']
|
||||
""" Number of post flop folds this info is not yet in the database """
|
||||
post_fold = stat_dict[player]['f_freq_1'] + stat_dict[player]['f_freq_2'] + stat_dict[player]['f_freq_3'] + stat_dict[player]['f_freq_4']
|
||||
|
||||
stat = float (bet_raise) / float(post_call + post_fold + bet_raise)
|
||||
|
||||
return (stat,
|
||||
'%3.1f' % (100*stat) + '%',
|
||||
'afr=%3.1f' % (100*stat) + '%',
|
||||
'agg_fr=%3.1f' % (100*stat) + '%',
|
||||
'(%d/%d)' % (bet_raise, (post_call + post_fold + bet_raise)),
|
||||
'Aggression Freq'
|
||||
)
|
||||
except:
|
||||
return (stat,
|
||||
'%2.1f' % (0) + '%',
|
||||
'af=%3.1f' % (0) + '%',
|
||||
'agg_f=%3.1f' % (0) + '%',
|
||||
'(%d/%d)' % (0, 0),
|
||||
'Aggression Freq'
|
||||
)
|
||||
|
||||
def agg_fact(stat_dict, player):
|
||||
""" Post-Flop aggression frequency."""
|
||||
""" Aggression factor = (times bet or raised post-flop) / (times called post-flop) """
|
||||
stat = 0.0
|
||||
try:
|
||||
bet_raise = stat_dict[player]['aggr_1'] + stat_dict[player]['aggr_2'] + stat_dict[player]['aggr_3'] + stat_dict[player]['aggr_4']
|
||||
post_call = stat_dict[player]['call_1'] + stat_dict[player]['call_2'] + stat_dict[player]['call_3'] + stat_dict[player]['call_4']
|
||||
|
||||
if post_call > 0:
|
||||
stat = float (bet_raise) / float(post_call)
|
||||
else:
|
||||
stat = float (bet_raise)
|
||||
return (stat,
|
||||
'%2.2f' % (stat) ,
|
||||
'afa=%2.2f' % (stat) ,
|
||||
'agg_fa=%2.2f' % (stat) ,
|
||||
'(%d/%d)' % (bet_raise, post_call),
|
||||
'Aggression Factor'
|
||||
)
|
||||
except:
|
||||
return (stat,
|
||||
'%2.2f' % (0) ,
|
||||
'afa=%2.2f' % (0) ,
|
||||
'agg_fa=%2.2f' % (0),
|
||||
'(%d/%d)' % (0, 0),
|
||||
'Aggression Factor'
|
||||
)
|
||||
|
||||
|
||||
def cbet(stat_dict, player):
|
||||
|
||||
""" Total continuation bet."""
|
||||
""" Continuation bet % = (times made a continuation bet on any street) * 100 / (number of opportunities to make a continuation bet on any street) """
|
||||
|
||||
stat = 0.0
|
||||
try:
|
||||
cbets = stat_dict[player]['cb_1']+stat_dict[player]['cb_2']+stat_dict[player]['cb_3']+stat_dict[player]['cb_4']
|
||||
oppt = stat_dict[player]['cb_opp_1']+stat_dict[player]['cb_opp_2']+stat_dict[player]['cb_opp_3']+stat_dict[player]['cb_opp_4']
|
||||
stat = float(cbets)/float(oppt)
|
||||
return (stat,
|
||||
'%3.1f' % (100*stat) + '%',
|
||||
'cbet=%3.1f' % (100*stat) + '%',
|
||||
'cbet=%3.1f' % (100*stat) + '%',
|
||||
'(%d/%d)' % (cbets, oppt),
|
||||
'% continuation bet '
|
||||
)
|
||||
except:
|
||||
return (stat,
|
||||
'%3.1f' % (0) + '%',
|
||||
'cbet=%3.1f' % (0) + '%',
|
||||
'cbet=%3.1f' % (0) + '%',
|
||||
'(%d/%d)' % (0, 0),
|
||||
'% continuation bet '
|
||||
)
|
||||
|
||||
def cb1(stat_dict, player):
|
||||
""" Flop continuation bet."""
|
||||
stat = 0.0
|
||||
|
@ -673,38 +783,40 @@ def ffreq4(stat_dict, player):
|
|||
|
||||
if __name__== "__main__":
|
||||
c = Configuration.Config()
|
||||
db_connection = Database.Database(c)
|
||||
h = db_connection.get_last_hand()
|
||||
stat_dict = db_connection.get_stats_from_hand(h, "ring")
|
||||
#TODO: restore the below code. somehow it creates a version 119 DB but commenting this out makes it print a stat list
|
||||
#db_connection = Database.Database(c)
|
||||
#h = db_connection.get_last_hand()
|
||||
#stat_dict = db_connection.get_stats_from_hand(h, "ring")
|
||||
|
||||
for player in stat_dict.keys():
|
||||
print "player = ", player, do_stat(stat_dict, player = player, stat = 'vpip')
|
||||
print "player = ", player, do_stat(stat_dict, player = player, stat = 'pfr')
|
||||
print "player = ", player, do_stat(stat_dict, player = player, stat = 'wtsd')
|
||||
print "player = ", player, do_stat(stat_dict, player = player, stat = 'profit100')
|
||||
print "player = ", player, do_stat(stat_dict, player = player, stat = 'saw_f')
|
||||
print "player = ", player, do_stat(stat_dict, player = player, stat = 'n')
|
||||
print "player = ", player, do_stat(stat_dict, player = player, stat = 'fold_f')
|
||||
print "player = ", player, do_stat(stat_dict, player = player, stat = 'wmsd')
|
||||
print "player = ", player, do_stat(stat_dict, player = player, stat = 'steal')
|
||||
print "player = ", player, do_stat(stat_dict, player = player, stat = 'f_SB_steal')
|
||||
print "player = ", player, do_stat(stat_dict, player = player, stat = 'f_BB_steal')
|
||||
print "player = ", player, do_stat(stat_dict, player = player, stat = 'three_B')
|
||||
print "player = ", player, do_stat(stat_dict, player = player, stat = 'WMsF')
|
||||
print "player = ", player, do_stat(stat_dict, player = player, stat = 'a_freq1')
|
||||
print "player = ", player, do_stat(stat_dict, player = player, stat = 'a_freq2')
|
||||
print "player = ", player, do_stat(stat_dict, player = player, stat = 'a_freq3')
|
||||
print "player = ", player, do_stat(stat_dict, player = player, stat = 'a_freq4')
|
||||
print "player = ", player, do_stat(stat_dict, player = player, stat = 'a_freq_123')
|
||||
print "player = ", player, do_stat(stat_dict, player = player, stat = 'cb1')
|
||||
print "player = ", player, do_stat(stat_dict, player = player, stat = 'cb2')
|
||||
print "player = ", player, do_stat(stat_dict, player = player, stat = 'cb3')
|
||||
print "player = ", player, do_stat(stat_dict, player = player, stat = 'cb4')
|
||||
print "player = ", player, do_stat(stat_dict, player = player, stat = 'ffreq1')
|
||||
print "player = ", player, do_stat(stat_dict, player = player, stat = 'ffreq2')
|
||||
print "player = ", player, do_stat(stat_dict, player = player, stat = 'ffreq3')
|
||||
print "player = ", player, do_stat(stat_dict, player = player, stat = 'ffreq4')
|
||||
print "\n"
|
||||
#for player in stat_dict.keys():
|
||||
#print "player = ", player, do_stat(stat_dict, player = player, stat = 'vpip')
|
||||
#print "player = ", player, do_stat(stat_dict, player = player, stat = 'pfr')
|
||||
#print "player = ", player, do_stat(stat_dict, player = player, stat = 'wtsd')
|
||||
#print "player = ", player, do_stat(stat_dict, player = player, stat = 'profit100')
|
||||
#print "player = ", player, do_stat(stat_dict, player = player, stat = 'saw_f')
|
||||
#print "player = ", player, do_stat(stat_dict, player = player, stat = 'n')
|
||||
#print "player = ", player, do_stat(stat_dict, player = player, stat = 'fold_f')
|
||||
#print "player = ", player, do_stat(stat_dict, player = player, stat = 'wmsd')
|
||||
#print "player = ", player, do_stat(stat_dict, player = player, stat = 'steal')
|
||||
#print "player = ", player, do_stat(stat_dict, player = player, stat = 'f_SB_steal')
|
||||
#print "player = ", player, do_stat(stat_dict, player = player, stat = 'f_BB_steal')
|
||||
#print "player = ", player, do_stat(stat_dict, player = player, stat = 'f_steal')
|
||||
#print "player = ", player, do_stat(stat_dict, player = player, stat = 'three_B')
|
||||
#print "player = ", player, do_stat(stat_dict, player = player, stat = 'WMsF')
|
||||
#print "player = ", player, do_stat(stat_dict, player = player, stat = 'a_freq1')
|
||||
#print "player = ", player, do_stat(stat_dict, player = player, stat = 'a_freq2')
|
||||
#print "player = ", player, do_stat(stat_dict, player = player, stat = 'a_freq3')
|
||||
#print "player = ", player, do_stat(stat_dict, player = player, stat = 'a_freq4')
|
||||
#print "player = ", player, do_stat(stat_dict, player = player, stat = 'a_freq_123')
|
||||
#print "player = ", player, do_stat(stat_dict, player = player, stat = 'cb1')
|
||||
#print "player = ", player, do_stat(stat_dict, player = player, stat = 'cb2')
|
||||
#print "player = ", player, do_stat(stat_dict, player = player, stat = 'cb3')
|
||||
#print "player = ", player, do_stat(stat_dict, player = player, stat = 'cb4')
|
||||
#print "player = ", player, do_stat(stat_dict, player = player, stat = 'ffreq1')
|
||||
#print "player = ", player, do_stat(stat_dict, player = player, stat = 'ffreq2')
|
||||
#print "player = ", player, do_stat(stat_dict, player = player, stat = 'ffreq3')
|
||||
#print "player = ", player, do_stat(stat_dict, player = player, stat = 'ffreq4')
|
||||
#print "\n"
|
||||
|
||||
print "\n\nLegal stats:"
|
||||
print "(add _0 to name to display with 0 decimal places, _1 to display with 1, etc)\n"
|
||||
|
@ -717,5 +829,5 @@ if __name__== "__main__":
|
|||
# print " <pu_stat pu_stat_name = \"%s\"> </pu_stat>" % (attr)
|
||||
print
|
||||
|
||||
db_connection.close_connection
|
||||
#db_connection.close_connection
|
||||
|
||||
|
|
66
pyfpdb/Summaries.py
Normal file
66
pyfpdb/Summaries.py
Normal file
|
@ -0,0 +1,66 @@
|
|||
#!/usr/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
#Copyright 2008-2010 Steffen Schaumburg
|
||||
#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.
|
||||
|
||||
"""This file is to fetch summaries through IMAP and pass them on to the appropriate parser"""
|
||||
#see http://docs.python.org/library/imaplib.html for the python interface
|
||||
#see http://tools.ietf.org/html/rfc2060#section-6.4.4 for IMAP4 search criteria
|
||||
|
||||
import sys
|
||||
from imaplib import IMAP4_SSL
|
||||
from Summaries import Summaries
|
||||
from PokerStarsSummaries import PokerStarsSummaries
|
||||
|
||||
#TODO: move all these into the config file. until then usage is: ./ImapSummaries.py YourImapHost YourImapUser YourImapPw
|
||||
configHost=sys.argv[1]
|
||||
configUser=sys.argv[2]
|
||||
configPw=sys.argv[3]
|
||||
|
||||
server = IMAP4_SSL(configHost) #TODO: optionally non-SSL
|
||||
response = server.login(configUser, configPw) #TODO catch authentication error
|
||||
#print "response to logging in:",response
|
||||
#print "server.list():",server.list() #prints list of folders
|
||||
|
||||
response = server.select("INBOX")
|
||||
#print "response to selecting INBOX:",response
|
||||
if response[0]!="OK":
|
||||
raise error #TODO: show error message
|
||||
|
||||
neededMessages=[]
|
||||
response, searchData = server.search(None, "SUBJECT", "PokerStars Tournament History Request")
|
||||
for messageNumber in searchData[0].split(" "):
|
||||
response, headerData = server.fetch(messageNumber, "(BODY[HEADER.FIELDS (SUBJECT)])")
|
||||
#print "response to fetch subject:",response
|
||||
if response!="OK":
|
||||
raise error #TODO: show error message
|
||||
if headerData[1].find("Subject: PokerStars Tournament History Request - Last x")!=1:
|
||||
neededMessages.append((messageNumber, "PS")
|
||||
|
||||
tourneys=[]
|
||||
if len(neededMessages)==0:
|
||||
raise error #TODO: show error message
|
||||
for messageData in neededMessages:
|
||||
response, bodyData = server.fetch(messageData[0], "(UID BODY[TEXT])")
|
||||
if response!="OK":
|
||||
raise error #TODO: show error message
|
||||
if messageData[0]=="PS":
|
||||
tourneys.append(PokerStarsSummaries.PokerStarsSummaries(bodyData)
|
||||
|
||||
for tourney in tourneys:
|
||||
print "tourney:",tourney
|
||||
|
||||
server.close()
|
||||
server.logout()
|
|
@ -1,6 +1,7 @@
|
|||
#!/usr/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# Copyright (c) 2009 Eric Blade, and the FPDB team.
|
||||
# Copyright (c) 2009-2010 Eric Blade, and the FPDB team.
|
||||
|
||||
#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
|
||||
|
@ -13,8 +14,7 @@
|
|||
#
|
||||
#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.
|
||||
#In the "official" distribution you can find the license in agpl-3.0.txt.
|
||||
|
||||
import urllib, htmllib, formatter
|
||||
|
||||
|
@ -51,7 +51,7 @@ class SummaryParser(htmllib.HTMLParser): # derive new HTML parser
|
|||
self.nextPool = False
|
||||
self.TourneyPool = None
|
||||
self.nextPlayers = False
|
||||
self.TourneyPlayers = None
|
||||
self.TourneysPlayers = None
|
||||
self.nextAllowRebuys = False
|
||||
self.TourneyRebuys = None
|
||||
self.parseResultsA = False
|
||||
|
@ -134,7 +134,7 @@ class SummaryParser(htmllib.HTMLParser): # derive new HTML parser
|
|||
if not self.nextPlayers and x == "Player Count:":
|
||||
self.nextPlayers = True
|
||||
elif self.nextPlayers:
|
||||
self.TourneyPlayers = x
|
||||
self.TourneysPlayers = x
|
||||
self.nextPlayers = False
|
||||
|
||||
if not self.nextAllowRebuys and x == "Rebuys possible?:":
|
||||
|
@ -179,7 +179,7 @@ class EverleafSummary:
|
|||
print "site=",self.parser.SiteName, "tourneyname=", self.parser.TourneyName, "tourneyid=", self.parser.TourneyId
|
||||
print "start time=",self.parser.TourneyStartTime, "end time=",self.parser.TourneyEndTime
|
||||
print "structure=", self.parser.TourneyStructure, "game type=",self.parser.TourneyGameType
|
||||
print "buy-in=", self.parser.TourneyBuyIn, "rebuys=", self.parser.TourneyRebuys, "total players=", self.parser.TourneyPlayers, "pool=", self.parser.TourneyPool
|
||||
print "buy-in=", self.parser.TourneyBuyIn, "rebuys=", self.parser.TourneyRebuys, "total players=", self.parser.TourneysPlayers, "pool=", self.parser.TourneyPool
|
||||
print "results=", self.parser.Results
|
||||
|
||||
|
||||
|
|
|
@ -1,11 +1,12 @@
|
|||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
"""Discover_TableWindow.py
|
||||
|
||||
Inspects the currently open windows and finds those of interest to us--that is
|
||||
poker table windows from supported sites. Returns a list
|
||||
of Table_Window objects representing the windows found.
|
||||
"""
|
||||
# Copyright 2008 - 2009, Ray E. Barker
|
||||
# Copyright 2008-2010, 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
|
||||
|
|
|
@ -1,11 +1,12 @@
|
|||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
"""Discover_Tables.py
|
||||
|
||||
Inspects the currently open windows and finds those of interest to us--that is
|
||||
poker table windows from supported sites. Returns a list
|
||||
of Table_Window objects representing the windows found.
|
||||
"""
|
||||
# Copyright 2008, Ray E. Barker
|
||||
# Copyright 2008-2010, 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
|
||||
|
|
|
@ -1,9 +1,10 @@
|
|||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
"""Tables_Demo.py
|
||||
|
||||
Main program module to test/demo the Tables subclasses.
|
||||
"""
|
||||
# Copyright 2008 - 2009, Ray E. Barker
|
||||
# Copyright 2008-2010, 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
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
"""TourneyTracker.py
|
||||
Based on HUD_main .. who knows if we want to actually use this or not
|
||||
"""
|
||||
# Copyright 2008, 2009, Eric Blade
|
||||
# Copyright 2008-2010, Eric Blade
|
||||
#
|
||||
# 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
|
||||
|
@ -86,7 +87,7 @@ class Tournament:
|
|||
self.buyin = summary.parser.TourneyBuyIn # need to remember to parse the Fee out of this and move it to self.fee
|
||||
self.rebuys = (summary.parser.TourneyRebuys == "yes")
|
||||
self.prizepool = summary.parser.TourneyPool
|
||||
self.numplayers = summary.parser.TourneyPlayers
|
||||
self.numplayers = summary.parser.TourneysPlayers
|
||||
|
||||
self.openwindow() # let's start by getting any info we need.. meh
|
||||
|
||||
|
|
202
pyfpdb/TourneyFilters.py
Normal file
202
pyfpdb/TourneyFilters.py
Normal file
|
@ -0,0 +1,202 @@
|
|||
#!/usr/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
#Copyright 2010 Steffen Schaumburg
|
||||
#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.
|
||||
|
||||
import threading
|
||||
import pygtk
|
||||
pygtk.require('2.0')
|
||||
import gtk
|
||||
import gobject
|
||||
#import os
|
||||
#import sys
|
||||
#from optparse import OptionParser
|
||||
from time import gmtime, mktime, strftime, strptime
|
||||
#import pokereval
|
||||
|
||||
import logging #logging has been set up in fpdb.py or HUD_main.py, use their settings:
|
||||
log = logging.getLogger("filter")
|
||||
|
||||
|
||||
#import Configuration
|
||||
#import Database
|
||||
#import SQL
|
||||
import Charset
|
||||
import Filters
|
||||
|
||||
class TourneyFilters(Filters.Filters):
|
||||
def __init__(self, db, config, qdict, display = {}, debug=True):
|
||||
self.debug = debug
|
||||
self.db = db
|
||||
self.cursor = db.cursor
|
||||
self.sql = db.sql
|
||||
self.conf = db.config
|
||||
self.display = display
|
||||
|
||||
self.filterText = {'playerstitle':'Hero:', 'sitestitle':'Sites:', 'seatstitle':'Number of Players:',
|
||||
'seatsbetween':'Between:', 'seatsand':'And:', 'datestitle':'Date:',
|
||||
'tourneyTypesTitle':'Tourney Type'}
|
||||
|
||||
gen = self.conf.get_general_params()
|
||||
self.day_start = 0
|
||||
if 'day_start' in gen:
|
||||
self.day_start = float(gen['day_start'])
|
||||
|
||||
# Outer Packing box
|
||||
self.mainVBox = gtk.VBox(False, 0)
|
||||
|
||||
self.label = {}
|
||||
self.callback = {}
|
||||
|
||||
self.make_filter()
|
||||
#end def __init__
|
||||
|
||||
def __refresh(self, widget, entry): #identical with Filters
|
||||
for w in self.mainVBox.get_children():
|
||||
w.destroy()
|
||||
self.make_filter()
|
||||
#end def __refresh
|
||||
|
||||
def __set_num_tourneys(self, w, val):
|
||||
try:
|
||||
self.numTourneys = int(w.get_text())
|
||||
except:
|
||||
self.numTourneys = 0
|
||||
print "setting numTourneys:", self.numTourneys
|
||||
#end def __set_num_tourneys
|
||||
|
||||
def __toggle_box(self, widget, entry): #identical with Filters
|
||||
if self.boxes[entry].props.visible:
|
||||
self.boxes[entry].hide()
|
||||
widget.set_label("show")
|
||||
else:
|
||||
self.boxes[entry].show()
|
||||
widget.set_label("hide")
|
||||
#end def __toggle_box
|
||||
|
||||
def make_filter(self):
|
||||
self.tourneyTypes = {}
|
||||
#self.tourneys = {}
|
||||
self.sites = {}
|
||||
self.seats = {}
|
||||
self.siteid = {}
|
||||
self.heroes = {}
|
||||
self.boxes = {}
|
||||
|
||||
for site in self.conf.get_supported_sites():
|
||||
#Get db site id for filtering later
|
||||
self.cursor.execute(self.sql.query['getSiteId'], (site,))
|
||||
result = self.db.cursor.fetchall()
|
||||
if len(result) == 1:
|
||||
self.siteid[site] = result[0][0]
|
||||
else:
|
||||
print "Either 0 or more than one site matched (%s) - EEK" % site
|
||||
|
||||
# For use in date ranges.
|
||||
self.start_date = gtk.Entry(max=12)
|
||||
self.end_date = gtk.Entry(max=12)
|
||||
self.start_date.set_property('editable', False)
|
||||
self.end_date.set_property('editable', False)
|
||||
|
||||
# For use in groups etc
|
||||
#self.sbGroups = {}
|
||||
self.numTourneys = 0
|
||||
|
||||
playerFrame = gtk.Frame()
|
||||
playerFrame.set_label_align(0.0, 0.0)
|
||||
vbox = gtk.VBox(False, 0)
|
||||
|
||||
self.fillPlayerFrame(vbox, self.display)
|
||||
playerFrame.add(vbox)
|
||||
|
||||
sitesFrame = gtk.Frame()
|
||||
sitesFrame.set_label_align(0.0, 0.0)
|
||||
vbox = gtk.VBox(False, 0)
|
||||
|
||||
self.fillSitesFrame(vbox)
|
||||
sitesFrame.add(vbox)
|
||||
|
||||
# Tourney types
|
||||
tourneyTypesFrame = gtk.Frame()
|
||||
tourneyTypesFrame.set_label_align(0.0, 0.0)
|
||||
tourneyTypesFrame.show()
|
||||
vbox = gtk.VBox(False, 0)
|
||||
|
||||
self.fillTourneyTypesFrame(vbox)
|
||||
tourneyTypesFrame.add(vbox)
|
||||
|
||||
# Seats
|
||||
seatsFrame = gtk.Frame()
|
||||
seatsFrame.show()
|
||||
vbox = gtk.VBox(False, 0)
|
||||
self.sbSeats = {}
|
||||
|
||||
self.fillSeatsFrame(vbox, self.display)
|
||||
seatsFrame.add(vbox)
|
||||
|
||||
# Date
|
||||
dateFrame = gtk.Frame()
|
||||
dateFrame.set_label_align(0.0, 0.0)
|
||||
dateFrame.show()
|
||||
vbox = gtk.VBox(False, 0)
|
||||
|
||||
self.fillDateFrame(vbox)
|
||||
dateFrame.add(vbox)
|
||||
|
||||
# Buttons
|
||||
#self.Button1=gtk.Button("Unnamed 1")
|
||||
#self.Button1.set_sensitive(False)
|
||||
|
||||
self.Button2=gtk.Button("Unnamed 2")
|
||||
self.Button2.set_sensitive(False)
|
||||
|
||||
self.mainVBox.add(playerFrame)
|
||||
self.mainVBox.add(sitesFrame)
|
||||
self.mainVBox.add(seatsFrame)
|
||||
self.mainVBox.add(dateFrame)
|
||||
#self.mainVBox.add(self.Button1)
|
||||
self.mainVBox.add(self.Button2)
|
||||
|
||||
self.mainVBox.show_all()
|
||||
|
||||
# Should do this cleaner
|
||||
if "Heroes" not in self.display or self.display["Heroes"] == False:
|
||||
playerFrame.hide()
|
||||
if "Sites" not in self.display or self.display["Sites"] == False:
|
||||
sitesFrame.hide()
|
||||
if "Seats" not in self.display or self.display["Seats"] == False:
|
||||
seatsFrame.hide()
|
||||
if "Dates" not in self.display or self.display["Dates"] == False:
|
||||
dateFrame.hide()
|
||||
#if "Button1" not in self.display or self.display["Button1"] == False:
|
||||
# self.Button1.hide()
|
||||
if "Button2" not in self.display or self.display["Button2"] == False:
|
||||
self.Button2.hide()
|
||||
|
||||
#if 'button1' in self.label and self.label['button1']:
|
||||
# self.Button1.set_label( self.label['button1'] )
|
||||
if 'button2' in self.label and self.label['button2']:
|
||||
self.Button2.set_label( self.label['button2'] )
|
||||
#if 'button1' in self.callback and self.callback['button1']:
|
||||
# self.Button1.connect("clicked", self.callback['button1'], "clicked")
|
||||
# self.Button1.set_sensitive(True)
|
||||
if 'button2' in self.callback and self.callback['button2']:
|
||||
self.Button2.connect("clicked", self.callback['button2'], "clicked")
|
||||
self.Button2.set_sensitive(True)
|
||||
|
||||
# make sure any locks on db are released:
|
||||
self.db.rollback()
|
||||
#end def make_filter
|
||||
#end class TourneyFilters
|
|
@ -1,6 +1,7 @@
|
|||
#!/usr/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
#Copyright 2009 Stephane Alessio
|
||||
#Copyright 2009-2010 Stephane Alessio
|
||||
#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.
|
||||
|
@ -12,8 +13,9 @@
|
|||
#
|
||||
#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.
|
||||
#In the "official" distribution you can find the license in agpl-3.0.txt.
|
||||
|
||||
"""parses and stores summary sections from e.g. eMail or summary files"""
|
||||
|
||||
# TODO: check to keep only the needed modules
|
||||
|
||||
|
@ -34,7 +36,7 @@ import Card
|
|||
|
||||
log = logging.getLogger("parser")
|
||||
|
||||
class Tourney(object):
|
||||
class TourneySummary(object):
|
||||
|
||||
################################################################
|
||||
# Class Variables
|
||||
|
@ -45,63 +47,87 @@ class Tourney(object):
|
|||
SITEIDS = {'Fulltilt':1, 'PokerStars':2, 'Everleaf':3, 'Win2day':4, 'OnGame':5, 'UltimateBet':6, 'Betfair':7, 'Absolute':8, 'PartyPoker':9 }
|
||||
|
||||
|
||||
def __init__(self, sitename, gametype, summaryText, builtFrom = "HHC"):
|
||||
self.sitename = sitename
|
||||
self.siteId = self.SITEIDS[sitename]
|
||||
self.gametype = gametype
|
||||
self.starttime = None
|
||||
self.endtime = None
|
||||
def __init__(self, db, config, siteName, summaryText, builtFrom = "HHC"):
|
||||
self.db = db
|
||||
self.config = config
|
||||
self.siteName = siteName
|
||||
self.siteId = self.SITEIDS[siteName]
|
||||
|
||||
self.summaryText = summaryText
|
||||
self.tourneyName = None
|
||||
self.tourneyTypeId = None
|
||||
self.tourneyId = None
|
||||
self.startTime = None
|
||||
self.endTime = None
|
||||
self.tourNo = None
|
||||
self.currency = None
|
||||
self.buyin = None
|
||||
self.fee = None # the Database code is looking for this one .. ?
|
||||
self.fee = None
|
||||
self.hero = None
|
||||
self.maxseats = None
|
||||
self.entries = 0
|
||||
self.speed = "Normal"
|
||||
self.prizepool = None # Make it a dict in order to deal (eventually later) with non-money winnings : {'MONEY' : amount, 'OTHER' : Value ??}
|
||||
self.buyInChips = None
|
||||
self.prizepool = 0 # Make it a dict in order to deal (eventually later) with non-money winnings : {'MONEY' : amount, 'OTHER' : Value ??}
|
||||
self.buyInChips = 0
|
||||
self.mixed = None
|
||||
self.isRebuy = False
|
||||
self.isAddOn = False
|
||||
self.isKO = False
|
||||
self.isHU = False
|
||||
self.isMatrix = False
|
||||
self.isShootout = False
|
||||
self.matrixMatchId = None # For Matrix tourneys : 1-4 => match tables (traditionnal), 0 => Positional winnings info
|
||||
self.matrixIdProcessed = None
|
||||
self.subTourneyBuyin = None
|
||||
self.subTourneyFee = None
|
||||
self.rebuyChips = 0
|
||||
self.addOnChips = 0
|
||||
self.rebuyAmount = 0
|
||||
self.addOnAmount = 0
|
||||
self.totalRebuys = 0
|
||||
self.totalAddOns = 0
|
||||
self.koBounty = 0
|
||||
self.rebuyChips = None
|
||||
self.addOnChips = None
|
||||
self.rebuyCost = None
|
||||
self.addOnCost = None
|
||||
self.totalRebuyCount = None
|
||||
self.totalAddOnCount = None
|
||||
self.koBounty = None
|
||||
self.tourneyComment = None
|
||||
self.players = []
|
||||
self.isSng = False
|
||||
self.isSatellite = False
|
||||
self.isDoubleOrNothing = False
|
||||
self.guarantee = None
|
||||
self.added = None
|
||||
self.addedCurrency = None
|
||||
self.gametype = {'category':None, 'limitType':None}
|
||||
self.comment = None
|
||||
self.commentTs = None
|
||||
|
||||
# Collections indexed by player names
|
||||
self.finishPositions = {}
|
||||
self.playerIds = {}
|
||||
self.tourneysPlayersIds = {}
|
||||
self.ranks = {}
|
||||
self.winnings = {}
|
||||
self.payinAmounts = {}
|
||||
self.countRebuys = {}
|
||||
self.countAddOns = {}
|
||||
self.countKO = {}
|
||||
self.winningsCurrency = {}
|
||||
self.rebuyCounts = {}
|
||||
self.addOnCounts = {}
|
||||
self.koCounts = {}
|
||||
|
||||
# currency symbol for this summary
|
||||
self.sym = None
|
||||
#self.sym = self.SYMBOL[self.gametype['currency']] # save typing! delete this attr when done
|
||||
|
||||
if builtFrom=="IMAP":
|
||||
self.parseSummary()
|
||||
self.insertOrUpdate()
|
||||
#end def __init__
|
||||
|
||||
def __str__(self):
|
||||
#TODO : Update
|
||||
vars = ( ("SITE", self.sitename),
|
||||
("START TIME", self.starttime),
|
||||
("END TIME", self.endtime),
|
||||
vars = ( ("SITE", self.siteName),
|
||||
("START TIME", self.startTime),
|
||||
("END TIME", self.endTime),
|
||||
("TOURNEY NAME", self.tourneyName),
|
||||
("TOURNEY NO", self.tourNo),
|
||||
("TOURNEY TYPE ID", self.tourneyTypeId),
|
||||
("TOURNEY ID", self.tourneyId),
|
||||
("BUYIN", self.buyin),
|
||||
("FEE", self.fee),
|
||||
("CURRENCY", self.currency),
|
||||
("HERO", self.hero),
|
||||
("MAXSEATS", self.maxseats),
|
||||
("ENTRIES", self.entries),
|
||||
|
@ -109,32 +135,42 @@ class Tourney(object):
|
|||
("PRIZE POOL", self.prizepool),
|
||||
("STARTING CHIP COUNT", self.buyInChips),
|
||||
("MIXED", self.mixed),
|
||||
("REBUY ADDON", self.isRebuy),
|
||||
("REBUY", self.isRebuy),
|
||||
("ADDON", self.isAddOn),
|
||||
("KO", self.isKO),
|
||||
("HU", self.isHU),
|
||||
("MATRIX", self.isMatrix),
|
||||
("MATRIX ID PROCESSED", self.matrixIdProcessed),
|
||||
("SHOOTOUT", self.isShootout),
|
||||
("MATRIX MATCH ID", self.matrixMatchId),
|
||||
("SUB TOURNEY BUY IN", self.subTourneyBuyin),
|
||||
("SUB TOURNEY FEE", self.subTourneyFee),
|
||||
("REBUY CHIPS", self.rebuyChips),
|
||||
("ADDON CHIPS", self.addOnChips),
|
||||
("REBUY AMOUNT", self.rebuyAmount),
|
||||
("ADDON AMOUNT", self.addOnAmount),
|
||||
("TOTAL REBUYS", self.totalRebuys),
|
||||
("TOTAL ADDONS", self.totalAddOns),
|
||||
("REBUY COST", self.rebuyCost),
|
||||
("ADDON COST", self.addOnCost),
|
||||
("TOTAL REBUYS", self.totalRebuyCount),
|
||||
("TOTAL ADDONS", self.totalAddOnCount),
|
||||
("KO BOUNTY", self.koBounty),
|
||||
("TOURNEY COMMENT", self.tourneyComment)
|
||||
("TOURNEY COMMENT", self.tourneyComment),
|
||||
("SNG", self.isSng),
|
||||
("SATELLITE", self.isSatellite),
|
||||
("DOUBLE OR NOTHING", self.isDoubleOrNothing),
|
||||
("GUARANTEE", self.guarantee),
|
||||
("ADDED", self.added),
|
||||
("ADDED CURRENCY", self.addedCurrency),
|
||||
("COMMENT", self.comment),
|
||||
("COMMENT TIMESTAMP", self.commentTs)
|
||||
)
|
||||
|
||||
structs = ( ("GAMETYPE", self.gametype),
|
||||
structs = ( ("PLAYER IDS", self.playerIds),
|
||||
("PLAYERS", self.players),
|
||||
("PAYIN AMOUNTS", self.payinAmounts),
|
||||
("POSITIONS", self.finishPositions),
|
||||
("TOURNEYS PLAYERS IDS", self.tourneysPlayersIds),
|
||||
("RANKS", self.ranks),
|
||||
("WINNINGS", self.winnings),
|
||||
("COUNT REBUYS", self.countRebuys),
|
||||
("COUNT ADDONS", self.countAddOns),
|
||||
("NB OF KO", self.countKO)
|
||||
("WINNINGS CURRENCY", self.winningsCurrency),
|
||||
("COUNT REBUYS", self.rebuyCounts),
|
||||
("COUNT ADDONS", self.addOnCounts),
|
||||
("NB OF KO", self.koCounts)
|
||||
)
|
||||
str = ''
|
||||
for (name, var) in vars:
|
||||
|
@ -143,14 +179,15 @@ class Tourney(object):
|
|||
for (name, struct) in structs:
|
||||
str = str + "\n%s =\n" % name + pprint.pformat(struct, 4)
|
||||
return str
|
||||
#end def __str__
|
||||
|
||||
def parseSummary(self): abstract
|
||||
"""should fill the class variables with the parsed information"""
|
||||
|
||||
def getSummaryText(self):
|
||||
return self.summaryText
|
||||
|
||||
def prepInsert(self, db):
|
||||
pass
|
||||
|
||||
def insert(self, db):
|
||||
def insertOrUpdate(self):
|
||||
# First : check all needed info is filled in the object, especially for the initial select
|
||||
|
||||
# Notes on DB Insert
|
||||
|
@ -161,18 +198,29 @@ class Tourney(object):
|
|||
# Starttime may not match the one in the Summary file : HH = time of the first Hand / could be slighltly different from the one in the summary file
|
||||
# Note: If the TourneyNo could be a unique id .... this would really be a relief to deal with matrix matches ==> Ask on the IRC / Ask Fulltilt ??
|
||||
|
||||
dbTourneyTypeId = db.tRecogniseTourneyType(self)
|
||||
logging.debug("Tourney Type ID = %d" % dbTourneyTypeId)
|
||||
dbTourneyId = db.tRecognizeTourney(self, dbTourneyTypeId)
|
||||
logging.debug("Tourney ID = %d" % dbTourneyId)
|
||||
dbTourneysPlayersIds = db.tStoreTourneyPlayers(self, dbTourneyId)
|
||||
logging.debug("TourneysPlayersId = %s" % dbTourneysPlayersIds)
|
||||
db.tUpdateTourneysHandsPlayers(self, dbTourneysPlayersIds, dbTourneyTypeId)
|
||||
logging.debug("tUpdateTourneysHandsPlayers done")
|
||||
logging.debug("Tourney Insert done")
|
||||
for player in self.players:
|
||||
id=self.db.get_player_id(self.config, self.siteName, player)
|
||||
if not id:
|
||||
id=self.db.insertPlayer(unicode(player), self.siteId)
|
||||
self.playerIds.update({player:id})
|
||||
|
||||
#print "TS.insert players",self.players,"playerIds",self.playerIds
|
||||
|
||||
self.buyinCurrency=self.currency
|
||||
self.dbid_pids=self.playerIds #TODO:rename this field in Hand so this silly renaming can be removed
|
||||
|
||||
#print "TS.self before starting insert",self
|
||||
self.tourneyTypeId = self.db.createTourneyType(self)
|
||||
self.db.commit()
|
||||
self.tourneyId = self.db.createOrUpdateTourney(self, "TS")
|
||||
self.db.commit()
|
||||
self.tourneysPlayersIds = self.db.createOrUpdateTourneysPlayers(self, "TS")
|
||||
self.db.commit()
|
||||
|
||||
logging.debug("Tourney Insert/Update done")
|
||||
|
||||
# TO DO : Return what has been done (tourney created, updated, nothing)
|
||||
# ?? stored = 1 if tourney is fully created / duplicates = 1, if everything was already here and correct / partial=1 if some things were already here (between tourney, tourneyPlayers and handsplayers)
|
||||
# ?? stored = 1 if tourney is fully created / duplicates = 1, if everything was already here and correct / partial=1 if some things were already here (between tourney, tourneysPlayers and handsPlayers)
|
||||
# if so, prototypes may need changes to know what has been done or make some kind of dict in Tourney object that could be updated during the insert process to store that information
|
||||
stored = 0
|
||||
duplicates = 0
|
||||
|
@ -182,82 +230,7 @@ class Tourney(object):
|
|||
return (stored, duplicates, partial, errors, ttime)
|
||||
|
||||
|
||||
def old_insert_from_Hand(self, db):
|
||||
""" Function to insert Hand into database
|
||||
Should not commit, and do minimal selects. Callers may want to cache commits
|
||||
db: a connected Database object"""
|
||||
# TODO:
|
||||
# Players - base playerid and siteid tuple
|
||||
sqlids = db.getSqlPlayerIDs([p[1] for p in self.players], self.siteId)
|
||||
|
||||
#Gametypes
|
||||
gtid = db.getGameTypeId(self.siteId, self.gametype)
|
||||
|
||||
# HudCache data to come from DerivedStats class
|
||||
# HandsActions - all actions for all players for all streets - self.actions
|
||||
# Hands - Summary information of hand indexed by handId - gameinfo
|
||||
#This should be moved to prepInsert
|
||||
hh = {}
|
||||
hh['siteHandNo'] = self.handid
|
||||
hh['handStart'] = self.starttime
|
||||
hh['gameTypeId'] = gtid
|
||||
# seats TINYINT NOT NULL,
|
||||
hh['tableName'] = self.tablename
|
||||
hh['maxSeats'] = self.maxseats
|
||||
hh['seats'] = len(sqlids)
|
||||
# Flop turn and river may all be empty - add (likely) too many elements and trim with range
|
||||
boardcards = self.board['FLOP'] + self.board['TURN'] + self.board['RIVER'] + [u'0x', u'0x', u'0x', u'0x', u'0x']
|
||||
cards = [Card.encodeCard(c) for c in boardcards[0:5]]
|
||||
hh['boardcard1'] = cards[0]
|
||||
hh['boardcard2'] = cards[1]
|
||||
hh['boardcard3'] = cards[2]
|
||||
hh['boardcard4'] = cards[3]
|
||||
hh['boardcard5'] = cards[4]
|
||||
|
||||
# texture smallint,
|
||||
# playersVpi SMALLINT NOT NULL, /* num of players vpi */
|
||||
# Needs to be recorded
|
||||
# playersAtStreet1 SMALLINT NOT NULL, /* num of players seeing flop/street4 */
|
||||
# Needs to be recorded
|
||||
# playersAtStreet2 SMALLINT NOT NULL,
|
||||
# Needs to be recorded
|
||||
# playersAtStreet3 SMALLINT NOT NULL,
|
||||
# Needs to be recorded
|
||||
# playersAtStreet4 SMALLINT NOT NULL,
|
||||
# Needs to be recorded
|
||||
# playersAtShowdown SMALLINT NOT NULL,
|
||||
# Needs to be recorded
|
||||
# street0Raises TINYINT NOT NULL, /* num small bets paid to see flop/street4, including blind */
|
||||
# Needs to be recorded
|
||||
# street1Raises TINYINT NOT NULL, /* num small bets paid to see turn/street5 */
|
||||
# Needs to be recorded
|
||||
# street2Raises TINYINT NOT NULL, /* num big bets paid to see river/street6 */
|
||||
# Needs to be recorded
|
||||
# street3Raises TINYINT NOT NULL, /* num big bets paid to see sd/street7 */
|
||||
# Needs to be recorded
|
||||
# street4Raises TINYINT NOT NULL, /* num big bets paid to see showdown */
|
||||
# Needs to be recorded
|
||||
|
||||
#print "DEBUG: self.getStreetTotals = (%s, %s, %s, %s, %s)" % self.getStreetTotals()
|
||||
#FIXME: Pot size still in decimal, needs to be converted to cents
|
||||
(hh['street1Pot'], hh['street2Pot'], hh['street3Pot'], hh['street4Pot'], hh['showdownPot']) = self.getStreetTotals()
|
||||
|
||||
# comment TEXT,
|
||||
# commentTs DATETIME
|
||||
#print hh
|
||||
handid = db.storeHand(hh)
|
||||
# HandsPlayers - ? ... Do we fix winnings?
|
||||
# Tourneys ?
|
||||
# TourneysPlayers
|
||||
|
||||
pass
|
||||
|
||||
def select(self, tourneyId):
|
||||
""" Function to create Tourney object from database """
|
||||
|
||||
|
||||
|
||||
def addPlayer(self, rank, name, winnings, payinAmount, nbRebuys, nbAddons, nbKO):
|
||||
def addPlayer(self, rank, name, winnings, winningsCurrency, rebuyCount, addOnCount, koCount):
|
||||
"""\
|
||||
Adds a player to the tourney, and initialises data structures indexed by player.
|
||||
rank (int) indicating the finishing rank (can be -1 if unknown)
|
||||
|
@ -266,13 +239,29 @@ winnings (decimal) the money the player ended the tourney with (can be 0, or
|
|||
"""
|
||||
log.debug("addPlayer: rank:%s - name : '%s' - Winnings (%s)" % (rank, name, winnings))
|
||||
self.players.append(name)
|
||||
self.finishPositions.update( { name : Decimal(rank) } )
|
||||
if rank:
|
||||
self.ranks.update( { name : Decimal(rank) } )
|
||||
self.winnings.update( { name : Decimal(winnings) } )
|
||||
self.payinAmounts.update( {name : Decimal(payinAmount) } )
|
||||
self.countRebuys.update( {name: Decimal(nbRebuys) } )
|
||||
self.countAddOns.update( {name: Decimal(nbAddons) } )
|
||||
self.countKO.update( {name : Decimal(nbKO) } )
|
||||
self.winningsCurrency.update( { name : winningsCurrency } )
|
||||
else:
|
||||
self.ranks.update( { name : None } )
|
||||
self.winnings.update( { name : None } )
|
||||
self.winningsCurrency.update( { name : None } )
|
||||
if rebuyCount:
|
||||
self.rebuyCounts.update( {name: Decimal(rebuyCount) } )
|
||||
else:
|
||||
self.rebuyCounts.update( {name: None } )
|
||||
|
||||
if addOnCount:
|
||||
self.addOnCounts.update( {name: Decimal(addOnCount) } )
|
||||
else:
|
||||
self.addOnCounts.update( {name: None } )
|
||||
|
||||
if koCount:
|
||||
self.koCounts.update( {name : Decimal(koCount) } )
|
||||
else:
|
||||
self.koCounts.update( {name: None } )
|
||||
#end def addPlayer
|
||||
|
||||
def incrementPlayerWinnings(self, name, additionnalWinnings):
|
||||
log.debug("incrementPlayerWinnings: name : '%s' - Add Winnings (%s)" % (name, additionnalWinnings))
|
||||
|
@ -289,35 +278,6 @@ winnings (decimal) the money the player ended the tourney with (can be 0, or
|
|||
print "checkPlayerExists", player, "fail"
|
||||
raise FpdbParseError
|
||||
|
||||
|
||||
def getGameTypeAsString(self):
|
||||
"""\
|
||||
Map the tuple self.gametype onto the pokerstars string describing it
|
||||
"""
|
||||
# currently it appears to be something like ["ring", "hold", "nl", sb, bb]:
|
||||
gs = {"holdem" : "Hold'em",
|
||||
"omahahi" : "Omaha",
|
||||
"omahahilo" : "Omaha Hi/Lo",
|
||||
"razz" : "Razz",
|
||||
"studhi" : "7 Card Stud",
|
||||
"studhilo" : "7 Card Stud Hi/Lo",
|
||||
"fivedraw" : "5 Card Draw",
|
||||
"27_1draw" : "FIXME",
|
||||
"27_3draw" : "Triple Draw 2-7 Lowball",
|
||||
"badugi" : "Badugi"
|
||||
}
|
||||
ls = {"nl" : "No Limit",
|
||||
"pl" : "Pot Limit",
|
||||
"fl" : "Limit",
|
||||
"cn" : "Cap No Limit",
|
||||
"cp" : "Cap Pot Limit"
|
||||
}
|
||||
|
||||
log.debug("gametype: %s" %(self.gametype))
|
||||
retstring = "%s %s" %(gs[self.gametype['category']], ls[self.gametype['limitType']])
|
||||
return retstring
|
||||
|
||||
|
||||
def writeSummary(self, fh=sys.__stdout__):
|
||||
print >>fh, "Override me"
|
||||
|
||||
|
@ -325,11 +285,11 @@ Map the tuple self.gametype onto the pokerstars string describing it
|
|||
self.writeSummary(sys.stdout)
|
||||
|
||||
|
||||
def assemble(cnxn, tourneyId):
|
||||
def assemble(cnxn, tourneyId): #TODO: move this method to Hand or Database
|
||||
# TODO !!
|
||||
c = cnxn.cursor()
|
||||
|
||||
# We need at least sitename, gametype, handid
|
||||
# We need at least siteName, gametype, handid
|
||||
# for the Hand.__init__
|
||||
c.execute("""
|
||||
select
|
||||
|
@ -365,7 +325,7 @@ limit 1""", {'handid':handid})
|
|||
#TODO: siteid should be in hands table - we took the scenic route through players here.
|
||||
res = c.fetchone()
|
||||
gametype = {'category':res[1],'base':res[2],'type':res[3],'limitType':res[4],'hilo':res[5],'sb':res[6],'bb':res[7], 'currency':res[10]}
|
||||
h = HoldemOmahaHand(hhc = None, sitename=res[0], gametype = gametype, handText=None, builtFrom = "DB", handid=handid)
|
||||
h = HoldemOmahaHand(hhc = None, siteName=res[0], gametype = gametype, handText=None, builtFrom = "DB", handid=handid)
|
||||
cards = map(Card.valueSuitFromCard, res[11:16] )
|
||||
if cards[0]:
|
||||
h.setCommunityCards('FLOP', cards[0:3])
|
||||
|
@ -383,15 +343,15 @@ limit 1""", {'handid':handid})
|
|||
SELECT
|
||||
h.sitehandno as hid,
|
||||
h.tablename as table,
|
||||
h.handstart as starttime
|
||||
h.startTime as startTime
|
||||
FROM
|
||||
hands as h
|
||||
Hands as h
|
||||
WHERE h.id = %(handid)s
|
||||
""", {'handid':handid})
|
||||
res = c.fetchone()
|
||||
h.handid = res[0]
|
||||
h.tablename = res[1]
|
||||
h.starttime = res[2] # automatically a datetime
|
||||
h.startTime = res[2] # automatically a datetime
|
||||
|
||||
# PlayerStacks
|
||||
c.execute("""
|
|
@ -1,7 +1,7 @@
|
|||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# Copyright 2008, Carl Gherardi
|
||||
# Copyright 2008-2010 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
|
||||
|
@ -128,7 +128,7 @@ follow : whether to tail -f the input"""
|
|||
#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")
|
||||
hand.startTime = time.strptime(datetime, "%Y/%m/%d %H:%M:%S")
|
||||
if key == 'HID':
|
||||
hand.handid = info[key]
|
||||
if key == 'TABLE':
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# Copyright 2008, Carl Gherardi
|
||||
# Copyright 2008-2010, 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
|
||||
|
@ -137,7 +137,7 @@ class Win2day(HandHistoryConverter):
|
|||
for key in info:
|
||||
if key == 'DATETIME':
|
||||
# Win2day uses UTC timestamp
|
||||
hand.starttime = datetime.datetime.fromtimestamp(int(info[key]))
|
||||
hand.startTime = datetime.datetime.fromtimestamp(int(info[key]))
|
||||
if key == 'HID':
|
||||
hand.handid = info[key]
|
||||
if key == 'TABLE':
|
||||
|
|
|
@ -1,9 +1,10 @@
|
|||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
"""WinTables.py
|
||||
|
||||
Routines for detecting and handling poker client windows for MS Windows.
|
||||
"""
|
||||
# Copyright 2008 - 2009, Ray E. Barker
|
||||
# Copyright 2008-2010, 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
|
||||
|
|
|
@ -1,11 +1,12 @@
|
|||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
"""Discover_Tables.py
|
||||
|
||||
Inspects the currently open windows and finds those of interest to us--that is
|
||||
poker table windows from supported sites. Returns a list
|
||||
of Table_Window objects representing the windows found.
|
||||
"""
|
||||
# Copyright 2008 - 2009, Ray E. Barker
|
||||
# Copyright 2008-2010, 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
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#!/usr/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
#Copyright 2008 Steffen Jobbagy-Felso
|
||||
#Copyright 2008-2010 Steffen Schaumburg
|
||||
#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.
|
||||
|
@ -12,8 +13,7 @@
|
|||
#
|
||||
#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.
|
||||
#In the "official" distribution you can find the license in agpl-3.0.txt.
|
||||
|
||||
import os
|
||||
import sys
|
||||
|
@ -35,7 +35,10 @@ if os.name == 'nt' and sys.version[0:3] not in ('2.5', '2.6') and '-r' not in sy
|
|||
os.environ['PATH'] = tmppath
|
||||
print "Python " + sys.version[0:3] + ' - press return to continue\n'
|
||||
sys.stdin.readline()
|
||||
os.execvpe('python.exe', ('python.exe', 'fpdb.py', '-r'), os.environ) # first arg is ignored (name of program being run)
|
||||
if os.name=='nt':
|
||||
os.execvpe('pythonw.exe', ('pythonw.exe', 'fpdb.pyw', '-r'), os.environ) # first arg is ignored (name of program being run)
|
||||
else:
|
||||
os.execvpe('python', ('python', 'fpdb.pyw', '-r'), os.environ) # first arg is ignored (name of program being run)
|
||||
else:
|
||||
print "\npython 2.5 not found, please install python 2.5 or 2.6 for fpdb\n"
|
||||
raw_input("Press ENTER to continue.")
|
||||
|
@ -63,6 +66,7 @@ cl_options = string.join(sys.argv[1:])
|
|||
(options, argv) = Options.fpdb_options()
|
||||
|
||||
import logging, logging.config
|
||||
log = logging.getLogger("fpdb")
|
||||
|
||||
try:
|
||||
import pygtk
|
||||
|
@ -99,9 +103,10 @@ import GuiPrefs
|
|||
import GuiLogView
|
||||
import GuiDatabase
|
||||
import GuiBulkImport
|
||||
import GuiPlayerStats
|
||||
import ImapFetcher
|
||||
import GuiRingPlayerStats
|
||||
import GuiTourneyPlayerStats
|
||||
import GuiPositionalStats
|
||||
import GuiTableViewer
|
||||
import GuiAutoImport
|
||||
import GuiGraphViewer
|
||||
import GuiSessionViewer
|
||||
|
@ -109,8 +114,9 @@ import SQL
|
|||
import Database
|
||||
import Configuration
|
||||
import Exceptions
|
||||
import Stats
|
||||
|
||||
VERSION = "0.12"
|
||||
VERSION = "0.20.903 plus git"
|
||||
|
||||
|
||||
class fpdb:
|
||||
|
@ -222,15 +228,15 @@ class fpdb:
|
|||
self.quit(widget)
|
||||
|
||||
def dia_about(self, widget, data=None):
|
||||
#self.warning_box("About FPDB:\n\nFPDB was originally created by a guy named Steffen, sometime in 2008, \nand is mostly worked on these days by people named Eratosthenes, s0rrow, _mt, EricBlade, sqlcoder, and other strange people.\n\n", "ABOUT FPDB")
|
||||
dia = gtk.AboutDialog()
|
||||
dia.set_name("Free Poker Database (FPDB)")
|
||||
dia.set_version(VERSION)
|
||||
dia.set_copyright("2008-2010, Steffen, Eratosthenes, s0rrow, EricBlade, _mt, sqlcoder, Bostik, and others")
|
||||
dia.set_comments("GTK AboutDialog comments here")
|
||||
dia.set_license("GPL v3")
|
||||
dia.set_copyright("Copyright 2008-2010, Steffen, Eratosthenes, Carl Gherardi, Eric Blade, _mt, sqlcoder, Bostik, and others")
|
||||
dia.set_comments("You are free to change and distribute original or changed versions of fpdb within the rules set out by the license")
|
||||
dia.set_license("Please see fpdb's start screen for license information")
|
||||
dia.set_website("http://fpdb.sourceforge.net/")
|
||||
dia.set_authors(['Steffen', 'Eratosthenes', 's0rrow',
|
||||
|
||||
dia.set_authors(['Steffen', 'Eratosthenes', 'Carl Gherardi',
|
||||
'Eric Blade', '_mt', 'sqlcoder', 'Bostik', 'and others'])
|
||||
dia.set_program_name("Free Poker Database (FPDB)")
|
||||
|
||||
|
@ -256,6 +262,12 @@ class fpdb:
|
|||
view.modify_font(pango.FontDescription('monospace 10'))
|
||||
view.show()
|
||||
dia.vbox.pack_end(view, True, True, 2)
|
||||
|
||||
l = gtk.Label("Your config file is: "+self.config.file)
|
||||
l.set_alignment(0.5, 0.5)
|
||||
l.show()
|
||||
dia.vbox.pack_end(l, True, True, 2)
|
||||
|
||||
l = gtk.Label('Version Information:')
|
||||
l.set_alignment(0.5, 0.5)
|
||||
l.show()
|
||||
|
@ -275,7 +287,7 @@ class fpdb:
|
|||
gtk.STOCK_SAVE, gtk.RESPONSE_ACCEPT))
|
||||
dia.set_default_size(700, 500)
|
||||
|
||||
prefs = GuiPrefs.GuiPrefs(self.config, self.window, dia.vbox)
|
||||
prefs = GuiPrefs.GuiPrefs(self.config, self.window, dia.vbox, dia)
|
||||
response = dia.run()
|
||||
if response == gtk.RESPONSE_ACCEPT:
|
||||
# save updated config
|
||||
|
@ -283,17 +295,19 @@ class fpdb:
|
|||
if len(self.nb_tab_names) == 1:
|
||||
# only main tab open, reload profile
|
||||
self.load_profile()
|
||||
dia.destroy()
|
||||
else:
|
||||
dia.destroy() # destroy prefs before raising warning, otherwise parent is dia rather than self.window
|
||||
self.warning_box("Updated preferences have not been loaded because "
|
||||
+ "windows are open. Re-start fpdb to load them.")
|
||||
|
||||
else:
|
||||
dia.destroy()
|
||||
|
||||
def dia_maintain_dbs(self, widget, data=None):
|
||||
self.warning_box("Unimplemented: Maintain Databases")
|
||||
return
|
||||
#self.warning_box("Unimplemented: Maintain Databases")
|
||||
#return
|
||||
if len(self.tab_names) == 1:
|
||||
if self.obtain_global_lock(): # returns true if successful
|
||||
if self.obtain_global_lock("dia_maintain_dbs"): # returns true if successful
|
||||
# only main tab has been opened, open dialog
|
||||
dia = gtk.Dialog("Maintain Databases",
|
||||
self.window,
|
||||
|
@ -305,8 +319,14 @@ class fpdb:
|
|||
prefs = GuiDatabase.GuiDatabase(self.config, self.window, dia)
|
||||
response = dia.run()
|
||||
if response == gtk.RESPONSE_ACCEPT:
|
||||
log.info('saving updated db data')
|
||||
# save updated config
|
||||
self.config.save()
|
||||
self.load_profile()
|
||||
for name in self.config.supported_databases: #db_ip/db_user/db_pass/db_server
|
||||
log.info('fpdb: name,desc='+name+','+self.config.supported_databases[name].db_desc)
|
||||
else:
|
||||
log.info('guidb response was '+str(response))
|
||||
|
||||
self.release_global_lock()
|
||||
|
||||
|
@ -315,59 +335,179 @@ class fpdb:
|
|||
self.warning_box("Cannot open Database Maintenance window because "
|
||||
+ "other windows have been opened. Re-start fpdb to use this option.")
|
||||
|
||||
def dia_create_del_user(self, widget, data=None):
|
||||
self.warning_box("Unimplemented: Create/Delete user")
|
||||
self.obtain_global_lock()
|
||||
self.release_global_lock()
|
||||
|
||||
def dia_database_stats(self, widget, data=None):
|
||||
self.warning_box("Unimplemented: Database Stats")
|
||||
self.warning_box(str="Number of Hands: "+str(self.db.getHandCount())+
|
||||
"\nNumber of Tourneys: "+str(self.db.getTourneyCount())+
|
||||
"\nNumber of TourneyTypes: "+str(self.db.getTourneyTypeCount()),
|
||||
diatitle="Database Statistics")
|
||||
#end def dia_database_stats
|
||||
|
||||
def dia_delete_db_parts(self, widget, data=None):
|
||||
self.warning_box("Unimplemented: Delete Database Parts")
|
||||
self.obtain_global_lock()
|
||||
def diaHudConfigurator(self, widget, data=None):
|
||||
"""Opens dialog to set parameters (game category, row count, column count for HUD stat configurator"""
|
||||
self.hudConfiguratorRows=None
|
||||
self.hudConfiguratorColumns=None
|
||||
self.hudConfiguratorGame=None
|
||||
|
||||
diaSelections = gtk.Dialog("HUD Configurator - choose category",
|
||||
self.window,
|
||||
gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT,
|
||||
(gtk.STOCK_OK, gtk.RESPONSE_ACCEPT,
|
||||
gtk.STOCK_CANCEL, gtk.RESPONSE_REJECT))
|
||||
|
||||
label=gtk.Label("Please select the game category for which you want to configure HUD stats:")
|
||||
diaSelections.vbox.add(label)
|
||||
label.show()
|
||||
|
||||
comboGame = gtk.combo_box_new_text()
|
||||
comboGame.connect("changed", self.hudConfiguratorComboSelection)
|
||||
diaSelections.vbox.add(comboGame)
|
||||
games=self.config.get_supported_games()
|
||||
for game in games:
|
||||
comboGame.append_text(game)
|
||||
comboGame.set_active(0)
|
||||
comboGame.show()
|
||||
|
||||
comboRows = gtk.combo_box_new_text()
|
||||
comboRows.connect("changed", self.hudConfiguratorComboSelection)
|
||||
diaSelections.vbox.add(comboRows)
|
||||
for i in range(1,8):
|
||||
comboRows.append_text(str(i)+" rows")
|
||||
comboRows.set_active(0)
|
||||
comboRows.show()
|
||||
|
||||
comboColumns = gtk.combo_box_new_text()
|
||||
comboColumns.connect("changed", self.hudConfiguratorComboSelection)
|
||||
diaSelections.vbox.add(comboColumns)
|
||||
for i in range(1,8):
|
||||
comboColumns.append_text(str(i)+" columns")
|
||||
comboColumns.set_active(0)
|
||||
comboColumns.show()
|
||||
|
||||
response=diaSelections.run()
|
||||
diaSelections.destroy()
|
||||
|
||||
if response == gtk.RESPONSE_ACCEPT and self.hudConfiguratorRows!=None and self.hudConfiguratorColumns!=None and self.hudConfiguratorGame!=None:
|
||||
#print "clicked ok and selected:", self.hudConfiguratorGame,"with", str(self.hudConfiguratorRows), "rows and", str(self.hudConfiguratorColumns), "columns"
|
||||
self.diaHudConfiguratorTable()
|
||||
#end def diaHudConfigurator
|
||||
|
||||
def hudConfiguratorComboSelection(self, widget):
|
||||
#TODO: remove this and handle it directly in diaHudConfigurator
|
||||
result=widget.get_active_text()
|
||||
if result.endswith(" rows"):
|
||||
self.hudConfiguratorRows=int(result[0])
|
||||
elif result.endswith(" columns"):
|
||||
self.hudConfiguratorColumns=int(result[0])
|
||||
else:
|
||||
self.hudConfiguratorGame=result
|
||||
#end def hudConfiguratorComboSelection
|
||||
|
||||
def diaHudConfiguratorTable(self):
|
||||
"""shows dialogue with Table of ComboBoxes to allow choosing of HUD stats"""
|
||||
#TODO: add notices to hud configurator: no duplicates, no empties, display options
|
||||
#TODO: show explanation of what each stat means
|
||||
diaHudTable = gtk.Dialog("HUD Configurator - please choose your stats",
|
||||
self.window,
|
||||
gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT,
|
||||
(gtk.STOCK_SAVE, gtk.RESPONSE_ACCEPT,
|
||||
gtk.STOCK_CANCEL, gtk.RESPONSE_REJECT))
|
||||
|
||||
label=gtk.Label("Please choose the stats you wish to use in the below table.")
|
||||
diaHudTable.vbox.add(label)
|
||||
label.show()
|
||||
|
||||
label=gtk.Label("Note that you may not select any stat more than once or it will crash.")
|
||||
diaHudTable.vbox.add(label)
|
||||
label.show()
|
||||
|
||||
label=gtk.Label("It is not currently possible to select \"empty\" or anything else to that end.")
|
||||
diaHudTable.vbox.add(label)
|
||||
label.show()
|
||||
|
||||
label=gtk.Label("To configure things like colouring you will still have to manually edit your HUD_config.xml.")
|
||||
diaHudTable.vbox.add(label)
|
||||
label.show()
|
||||
|
||||
self.hudConfiguratorTableContents=[]
|
||||
table= gtk.Table(rows=self.hudConfiguratorRows+1, columns=self.hudConfiguratorColumns+1, homogeneous=True)
|
||||
|
||||
statDir=dir(Stats)
|
||||
statDict={}
|
||||
for attr in statDir:
|
||||
if attr.startswith('__'): continue
|
||||
if attr in ("Charset", "Configuration", "Database", "GInitiallyUnowned", "gtk", "pygtk",
|
||||
"player", "c", "db_connection", "do_stat", "do_tip", "stat_dict",
|
||||
"h", "re", "re_Percent", "re_Places", ): continue
|
||||
statDict[attr]=eval("Stats.%s.__doc__" % (attr))
|
||||
|
||||
for rowNumber in range(self.hudConfiguratorRows+1):
|
||||
newRow=[]
|
||||
for columnNumber in range(self.hudConfiguratorColumns+1):
|
||||
if rowNumber==0:
|
||||
if columnNumber==0:
|
||||
pass
|
||||
else:
|
||||
label=gtk.Label("column "+str(columnNumber))
|
||||
table.attach(child=label, left_attach=columnNumber, right_attach=columnNumber+1, top_attach=rowNumber, bottom_attach=rowNumber+1)
|
||||
label.show()
|
||||
elif columnNumber==0:
|
||||
label=gtk.Label("row "+str(rowNumber))
|
||||
table.attach(child=label, left_attach=columnNumber, right_attach=columnNumber+1, top_attach=rowNumber, bottom_attach=rowNumber+1)
|
||||
label.show()
|
||||
else:
|
||||
comboBox = gtk.combo_box_new_text()
|
||||
|
||||
for stat in statDict.keys():
|
||||
comboBox.append_text(stat)
|
||||
comboBox.set_active(0)
|
||||
|
||||
newRow.append(comboBox)
|
||||
table.attach(child=comboBox, left_attach=columnNumber, right_attach=columnNumber+1, top_attach=rowNumber, bottom_attach=rowNumber+1)
|
||||
|
||||
comboBox.show()
|
||||
if rowNumber!=0:
|
||||
self.hudConfiguratorTableContents.append(newRow)
|
||||
diaHudTable.vbox.add(table)
|
||||
table.show()
|
||||
|
||||
response=diaHudTable.run()
|
||||
diaHudTable.destroy()
|
||||
|
||||
if response == gtk.RESPONSE_ACCEPT:
|
||||
self.storeNewHudStatConfig()
|
||||
#end def diaHudConfiguratorTable
|
||||
|
||||
def storeNewHudStatConfig(self):
|
||||
"""stores selections made in diaHudConfiguratorTable"""
|
||||
self.obtain_global_lock("diaHudConfiguratorTable")
|
||||
statTable=[]
|
||||
for row in self.hudConfiguratorTableContents:
|
||||
newRow=[]
|
||||
for column in row:
|
||||
newField = column.get_active_text()
|
||||
newRow.append(newField)
|
||||
statTable.append(newRow)
|
||||
|
||||
self.config.editStats(self.hudConfiguratorGame,statTable)
|
||||
self.config.save() #TODO: make it not store in horrible formatting
|
||||
self.release_global_lock()
|
||||
#end def storeNewHudStatConfig
|
||||
|
||||
def dia_edit_profile(self, widget=None, data=None, create_default=False, path=None):
|
||||
self.warning_box("Unimplemented: Edit Profile")
|
||||
self.obtain_global_lock()
|
||||
self.release_global_lock()
|
||||
def dia_dump_db(self, widget, data=None):
|
||||
filename = "database-dump.sql"
|
||||
result = self.db.dumpDatabase()
|
||||
|
||||
def dia_export_db(self, widget, data=None):
|
||||
self.warning_box("Unimplemented: Export Database")
|
||||
self.obtain_global_lock()
|
||||
self.release_global_lock()
|
||||
|
||||
def dia_get_db_root_credentials(self):
|
||||
"""obtains db root credentials from user"""
|
||||
self.warning_box("Unimplemented: Get Root Database Credentials")
|
||||
# user, pw=None, None
|
||||
#
|
||||
# dialog=gtk.Dialog(title="DB Credentials needed", parent=None, flags=0,
|
||||
# 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_user=gtk.Label("Username")
|
||||
# dialog.vbox.add(label_user)
|
||||
# label_user.show()
|
||||
#
|
||||
# response=dialog.run()
|
||||
# dialog.destroy()
|
||||
# return (user, pw, response)
|
||||
|
||||
def dia_import_db(self, widget, data=None):
|
||||
self.warning_box("Unimplemented: Import Database")
|
||||
self.obtain_global_lock()
|
||||
self.release_global_lock()
|
||||
dumpFile = open(filename, 'w')
|
||||
dumpFile.write(result)
|
||||
dumpFile.close()
|
||||
#end def dia_database_stats
|
||||
|
||||
def dia_licensing(self, widget, data=None):
|
||||
self.warning_box("Unimplemented: Licensing")
|
||||
|
||||
def dia_load_profile(self, widget, data=None):
|
||||
"""Dialogue to select a file to load a profile from"""
|
||||
if self.obtain_global_lock(): # returns true if successful
|
||||
if self.obtain_global_lock("fpdb.dia_load_profile"): # returns true if successful
|
||||
#try:
|
||||
# chooser = gtk.FileChooserDialog(title="Please select a profile file to load",
|
||||
# action=gtk.FILE_CHOOSER_ACTION_OPEN,
|
||||
|
@ -390,14 +530,16 @@ class fpdb:
|
|||
|
||||
def dia_recreate_tables(self, widget, data=None):
|
||||
"""Dialogue that asks user to confirm that he wants to delete and recreate the tables"""
|
||||
if self.obtain_global_lock(): # returns true if successful
|
||||
if self.obtain_global_lock("fpdb.dia_recreate_tables"): # returns true if successful
|
||||
|
||||
#lock_released = False
|
||||
dia_confirm = gtk.MessageDialog(parent=None, flags=0, type=gtk.MESSAGE_WARNING,
|
||||
dia_confirm = gtk.MessageDialog(parent=self.window, flags=gtk.DIALOG_DESTROY_WITH_PARENT, 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."
|
||||
+self.db.database+" on "+self.db.host+" they will be deleted.\nThis may take a while."
|
||||
dia_confirm.format_secondary_text(diastring)#todo: make above string with bold for db, host and deleted
|
||||
# disable windowclose, do not want the the underlying processing interrupted mid-process
|
||||
dia_confirm.set_deletable(False)
|
||||
|
||||
response = dia_confirm.run()
|
||||
dia_confirm.destroy()
|
||||
|
@ -409,19 +551,27 @@ class fpdb:
|
|||
# self.release_global_lock()
|
||||
# lock_released = True
|
||||
self.db.recreate_tables()
|
||||
# find any guibulkimport/guiautoimport windows and clear player cache:
|
||||
for t in self.threads:
|
||||
if isinstance(t, GuiBulkImport.GuiBulkImport) or isinstance(t, GuiAutoImport.GuiAutoImport):
|
||||
t.importer.database.resetPlayerIDs()
|
||||
self.release_global_lock()
|
||||
#else:
|
||||
# for other dbs use same connection as holds global lock
|
||||
# self.fdb_lock.fdb.recreate_tables()
|
||||
elif response == gtk.RESPONSE_NO:
|
||||
self.release_global_lock()
|
||||
print 'User cancelled recreating tables'
|
||||
#if not lock_released:
|
||||
self.release_global_lock()
|
||||
#end def dia_recreate_tables
|
||||
|
||||
def dia_recreate_hudcache(self, widget, data=None):
|
||||
if self.obtain_global_lock():
|
||||
self.dia_confirm = gtk.MessageDialog(parent=None, flags=0, type=gtk.MESSAGE_WARNING, buttons=(gtk.BUTTONS_YES_NO), message_format="Confirm recreating HUD cache")
|
||||
if self.obtain_global_lock("dia_recreate_hudcache"):
|
||||
self.dia_confirm = gtk.MessageDialog(parent=self.window, flags=gtk.DIALOG_DESTROY_WITH_PARENT, type=gtk.MESSAGE_WARNING, buttons=(gtk.BUTTONS_YES_NO), message_format="Confirm recreating HUD cache")
|
||||
diastring = "Please confirm that you want to re-create the HUD cache."
|
||||
self.dia_confirm.format_secondary_text(diastring)
|
||||
# disable windowclose, do not want the the underlying processing interrupted mid-process
|
||||
self.dia_confirm.set_deletable(False)
|
||||
|
||||
hb1 = gtk.HBox(True, 1)
|
||||
self.h_start_date = gtk.Entry(max=12)
|
||||
|
@ -468,17 +618,20 @@ class fpdb:
|
|||
self.release_global_lock()
|
||||
|
||||
def dia_rebuild_indexes(self, widget, data=None):
|
||||
if self.obtain_global_lock():
|
||||
self.dia_confirm = gtk.MessageDialog(parent=None
|
||||
,flags=0
|
||||
if self.obtain_global_lock("dia_rebuild_indexes"):
|
||||
self.dia_confirm = gtk.MessageDialog(parent=self.window
|
||||
,flags=gtk.DIALOG_DESTROY_WITH_PARENT
|
||||
,type=gtk.MESSAGE_WARNING
|
||||
,buttons=(gtk.BUTTONS_YES_NO)
|
||||
,message_format="Confirm rebuilding database indexes")
|
||||
diastring = "Please confirm that you want to rebuild the database indexes."
|
||||
self.dia_confirm.format_secondary_text(diastring)
|
||||
# disable windowclose, do not want the the underlying processing interrupted mid-process
|
||||
self.dia_confirm.set_deletable(False)
|
||||
|
||||
response = self.dia_confirm.run()
|
||||
if response == gtk.RESPONSE_YES:
|
||||
#FIXME these progress messages do not seem to work in *nix
|
||||
lbl = gtk.Label(" Rebuilding Indexes ... ")
|
||||
self.dia_confirm.vbox.add(lbl)
|
||||
lbl.show()
|
||||
|
@ -506,7 +659,7 @@ class fpdb:
|
|||
"""opens the log viewer window"""
|
||||
|
||||
#lock_set = False
|
||||
#if self.obtain_global_lock():
|
||||
#if self.obtain_global_lock("dia_logs"):
|
||||
# lock_set = True
|
||||
|
||||
# remove members from self.threads if close messages received
|
||||
|
@ -550,8 +703,13 @@ class fpdb:
|
|||
pass
|
||||
|
||||
def __calendar_dialog(self, widget, entry):
|
||||
self.dia_confirm.set_modal(False)
|
||||
# do not alter the modality of the parent
|
||||
# self.dia_confirm.set_modal(False)
|
||||
d = gtk.Window(gtk.WINDOW_TOPLEVEL)
|
||||
d.set_transient_for(self.dia_confirm)
|
||||
d.set_destroy_with_parent(True)
|
||||
d.set_modal(True)
|
||||
|
||||
d.set_title('Pick a date')
|
||||
|
||||
vb = gtk.VBox()
|
||||
|
@ -587,8 +745,8 @@ class fpdb:
|
|||
|
||||
def dia_regression_test(self, widget, data=None):
|
||||
self.warning_box("Unimplemented: Regression Test")
|
||||
self.obtain_global_lock()
|
||||
self.release_global_lock()
|
||||
#self.obtain_global_lock("dia_regression_test")
|
||||
#self.release_global_lock()
|
||||
|
||||
def dia_save_profile(self, widget, data=None):
|
||||
self.warning_box("Unimplemented: Save Profile (try saving a HUD layout, that should do it)")
|
||||
|
@ -618,8 +776,8 @@ class fpdb:
|
|||
<menubar name="MenuBar">
|
||||
<menu action="main">
|
||||
<menuitem action="LoadProf"/>
|
||||
<menuitem action="EditProf"/>
|
||||
<menuitem action="SaveProf"/>
|
||||
<menuitem action="hudConfigurator"/>
|
||||
<menuitem action="Preferences"/>
|
||||
<separator/>
|
||||
<menuitem action="Quit"/>
|
||||
|
@ -627,34 +785,30 @@ class fpdb:
|
|||
<menu action="import">
|
||||
<menuitem action="sethharchive"/>
|
||||
<menuitem action="bulkimp"/>
|
||||
<menuitem action="imapsummaries"/>
|
||||
<menuitem action="autoimp"/>
|
||||
<menuitem action="autorate"/>
|
||||
</menu>
|
||||
<menu action="viewers">
|
||||
<menuitem action="autoimp"/>
|
||||
<menuitem action="hudConfigurator"/>
|
||||
<menuitem action="graphs"/>
|
||||
<menuitem action="handreplay"/>
|
||||
<menuitem action="playerdetails"/>
|
||||
<menuitem action="playerstats"/>
|
||||
<menuitem action="ringplayerstats"/>
|
||||
<menuitem action="tourneyplayerstats"/>
|
||||
<menuitem action="posnstats"/>
|
||||
<menuitem action="sessionstats"/>
|
||||
<menuitem action="sessionreplay"/>
|
||||
<menuitem action="tableviewer"/>
|
||||
</menu>
|
||||
<menu action="database">
|
||||
<menuitem action="maintaindbs"/>
|
||||
<menuitem action="createuser"/>
|
||||
<menuitem action="createtabs"/>
|
||||
<menuitem action="rebuildhudcache"/>
|
||||
<menuitem action="rebuildindexes"/>
|
||||
<menuitem action="stats"/>
|
||||
<menuitem action="databasestats"/>
|
||||
<menuitem action="dumptofile"/>
|
||||
</menu>
|
||||
<menu action="help">
|
||||
<menuitem action="Abbrev"/>
|
||||
<menuitem action="Logs"/>
|
||||
<separator/>
|
||||
<menuitem action="About"/>
|
||||
<menuitem action="License"/>
|
||||
</menu>
|
||||
</menubar>
|
||||
</ui>"""
|
||||
|
@ -667,35 +821,30 @@ class fpdb:
|
|||
actiongroup.add_actions([('main', None, '_Main'),
|
||||
('Quit', gtk.STOCK_QUIT, '_Quit', None, 'Quit the Program', self.quit),
|
||||
('LoadProf', None, '_Load Profile (broken)', '<control>L', 'Load your profile', self.dia_load_profile),
|
||||
('EditProf', None, '_Edit Profile (todo)', '<control>E', 'Edit your profile', self.dia_edit_profile),
|
||||
('SaveProf', None, '_Save Profile (todo)', '<control>S', 'Save your profile', self.dia_save_profile),
|
||||
('Preferences', None, 'Pre_ferences', '<control>F', 'Edit your preferences', self.dia_preferences),
|
||||
('import', None, '_Import'),
|
||||
('sethharchive', None, '_Set HandHistory Archive Directory', None, 'Set HandHistory Archive Directory', self.select_hhArchiveBase),
|
||||
('bulkimp', None, '_Bulk Import', '<control>B', 'Bulk Import', self.tab_bulk_import),
|
||||
('autorate', None, 'Auto _Rating (todo)', '<control>R', 'Auto Rating (todo)', self.not_implemented),
|
||||
('imapsummaries', None, '_Import Tourney Summaries through eMail/IMAP', '<control>I', 'Auto Import and HUD', self.import_imap_summaries),
|
||||
('viewers', None, '_Viewers'),
|
||||
('autoimp', None, '_Auto Import and HUD', '<control>A', 'Auto Import and HUD', self.tab_auto_import),
|
||||
('hudConfigurator', None, '_HUD Configurator', '<control>H', 'HUD Configurator', self.diaHudConfigurator),
|
||||
('graphs', None, '_Graphs', '<control>G', 'Graphs', self.tabGraphViewer),
|
||||
('handreplay', None, 'Hand _Replayer (todo)', None, 'Hand Replayer (todo)', self.not_implemented),
|
||||
('playerdetails', None, 'Player _Details (todo)', None, 'Player Details (todo)', self.not_implemented),
|
||||
('playerstats', None, '_Player Stats (tabulated view)', '<control>P', 'Player Stats (tabulated view)', self.tab_player_stats),
|
||||
('ringplayerstats', None, 'Ring _Player Stats (tabulated view)', '<control>P', 'Ring Player Stats (tabulated view)', self.tab_ring_player_stats),
|
||||
('tourneyplayerstats', None, '_Tourney Player Stats (tabulated view, mysql only)', '<control>T', 'Tourney Player Stats (tabulated view, mysql only)', self.tab_tourney_player_stats),
|
||||
('posnstats', None, 'P_ositional Stats (tabulated view)', '<control>O', 'Positional Stats (tabulated view)', self.tab_positional_stats),
|
||||
('sessionstats', None, 'Session Stats', None, 'Session Stats', self.tab_session_stats),
|
||||
('sessionreplay', None, '_Session Replayer (todo)', None, 'Session Replayer (todo)', self.not_implemented),
|
||||
('tableviewer', None, 'Poker_table Viewer (mostly obselete)', None, 'Poker_table Viewer (mostly obselete)', self.tab_table_viewer),
|
||||
('database', None, '_Database'),
|
||||
('maintaindbs', None, '_Maintain Databases (todo)', None, 'Maintain Databases', self.dia_maintain_dbs),
|
||||
('createuser', None, 'Create or Delete _User (todo)', None, 'Create or Delete User', self.dia_create_del_user),
|
||||
('maintaindbs', None, '_Maintain Databases', None, 'Maintain Databases', self.dia_maintain_dbs),
|
||||
('createtabs', None, 'Create or Recreate _Tables', None, 'Create or Recreate Tables ', self.dia_recreate_tables),
|
||||
('rebuildhudcache', None, 'Rebuild HUD Cache', None, 'Rebuild HUD Cache', self.dia_recreate_hudcache),
|
||||
('rebuildindexes', None, 'Rebuild DB Indexes', None, 'Rebuild DB Indexes', self.dia_rebuild_indexes),
|
||||
('stats', None, '_Statistics (todo)', None, 'View Database Statistics', self.dia_database_stats),
|
||||
('databasestats', None, '_Statistics', None, 'View Database Statistics', self.dia_database_stats),
|
||||
('dumptofile', None, 'Dump Database to Textfile (takes ALOT of time)', None, 'Dump Database to Textfile (takes ALOT of time)', self.dia_dump_db),
|
||||
('help', None, '_Help'),
|
||||
('Abbrev', None, '_Abbrevations (todo)', None, 'List of Abbrevations', self.tab_abbreviations),
|
||||
('Logs', None, '_Log Messages', None, 'Log and Debug Messages', self.dia_logs),
|
||||
('About', None, 'A_bout', None, 'About the program', self.dia_about),
|
||||
('License', None, '_License and Copying (todo)', None, 'License and Copying', self.dia_licensing),
|
||||
('About', None, 'A_bout, License, Copying', None, 'About the program', self.dia_about),
|
||||
])
|
||||
actiongroup.get_action('Quit').set_property('short-label', '_Quit')
|
||||
|
||||
|
@ -706,6 +855,12 @@ class fpdb:
|
|||
menubar = uimanager.get_widget('/MenuBar')
|
||||
window.add_accel_group(accel_group)
|
||||
return menubar
|
||||
#end def get_menu
|
||||
|
||||
def import_imap_summaries(self, widget, data=None):
|
||||
result=ImapFetcher.run(self.config, self.db)
|
||||
#print "import imap summaries result:", result
|
||||
#end def import_imap_summaries
|
||||
|
||||
def load_profile(self, create_db = False):
|
||||
"""Loads profile from the provided path name."""
|
||||
|
@ -714,7 +869,7 @@ class fpdb:
|
|||
self.warning_box( "There is an error in your config file\n" + self.config.file
|
||||
+ "\n\nError is: " + str(self.config.file_error)
|
||||
, diatitle="CONFIG FILE ERROR" )
|
||||
exit()
|
||||
sys.exit()
|
||||
|
||||
log = Configuration.get_logger("logging.conf", "fpdb", log_dir=self.config.dir_log)
|
||||
print "Logfile is " + os.path.join(self.config.dir_log, self.config.log_file) + "\n"
|
||||
|
@ -810,55 +965,73 @@ class fpdb:
|
|||
def not_implemented(self, widget, data=None):
|
||||
self.warning_box("Unimplemented menu entry")
|
||||
|
||||
def obtain_global_lock(self):
|
||||
ret = self.lock.acquire(False) # will return false if lock is already held
|
||||
def obtain_global_lock(self, source):
|
||||
ret = self.lock.acquire(source=source) # will return false if lock is already held
|
||||
if ret:
|
||||
print "\nGlobal lock taken ..."
|
||||
print "\nGlobal lock taken by", source
|
||||
self.lockTakenBy=source
|
||||
else:
|
||||
print "\nFailed to get global lock."
|
||||
print "\nFailed to get global lock, it is currently held by", source
|
||||
return ret
|
||||
# need to release it later:
|
||||
# self.lock.release()
|
||||
|
||||
def quit(self, widget, data=None):
|
||||
# TODO: can we get some / all of the stuff done in this function to execute on any kind of abort?
|
||||
#FIXME get two "quitting normally" messages, following the addition of the self.window.destroy() call
|
||||
# ... because self.window.destroy() leads to self.destroy() which calls this!
|
||||
if not self.quitting:
|
||||
print "Quitting normally"
|
||||
self.quitting = True
|
||||
# TODO: check if current settings differ from profile, if so offer to save or abort
|
||||
|
||||
if self.db!=None:
|
||||
if self.db.backend==self.db.MYSQL_INNODB:
|
||||
try:
|
||||
if self.db is not None and self.db.connected:
|
||||
if self.db is not None and self.db.connected():
|
||||
self.db.disconnect()
|
||||
except _mysql_exceptions.OperationalError: # oh, damn, we're already disconnected
|
||||
pass
|
||||
else:
|
||||
if self.db is not None and self.db.connected():
|
||||
self.db.disconnect()
|
||||
else:
|
||||
pass
|
||||
self.statusIcon.set_visible(False)
|
||||
|
||||
self.window.destroy() # explicitly destroy to allow child windows to close cleanly
|
||||
gtk.main_quit()
|
||||
|
||||
def release_global_lock(self):
|
||||
self.lock.release()
|
||||
self.lockTakenBy=None
|
||||
print "Global lock released.\n"
|
||||
|
||||
def tab_abbreviations(self, widget, data=None):
|
||||
print "todo: implement tab_abbreviations"
|
||||
|
||||
def tab_auto_import(self, widget, data=None):
|
||||
"""opens the auto import tab"""
|
||||
new_aimp_thread = GuiAutoImport.GuiAutoImport(self.settings, self.config, self.sql)
|
||||
new_aimp_thread = GuiAutoImport.GuiAutoImport(self.settings, self.config, self.sql, self.window)
|
||||
self.threads.append(new_aimp_thread)
|
||||
aimp_tab=new_aimp_thread.get_vbox()
|
||||
self.add_and_display_tab(aimp_tab, "Auto Import")
|
||||
|
||||
def tab_bulk_import(self, widget, data=None):
|
||||
"""opens a tab for bulk importing"""
|
||||
#print "start of tab_bulk_import"
|
||||
new_import_thread = GuiBulkImport.GuiBulkImport(self.settings, self.config, self.sql)
|
||||
self.threads.append(new_import_thread)
|
||||
bulk_tab=new_import_thread.get_vbox()
|
||||
self.add_and_display_tab(bulk_tab, "Bulk Import")
|
||||
|
||||
def tab_player_stats(self, widget, data=None):
|
||||
new_ps_thread = GuiPlayerStats.GuiPlayerStats(self.config, self.sql, self.window)
|
||||
def tab_ring_player_stats(self, widget, data=None):
|
||||
new_ps_thread = GuiRingPlayerStats.GuiRingPlayerStats(self.config, self.sql, self.window)
|
||||
self.threads.append(new_ps_thread)
|
||||
ps_tab=new_ps_thread.get_vbox()
|
||||
self.add_and_display_tab(ps_tab, "Player Stats")
|
||||
self.add_and_display_tab(ps_tab, "Ring Player Stats")
|
||||
|
||||
def tab_tourney_player_stats(self, widget, data=None):
|
||||
new_ps_thread = GuiTourneyPlayerStats.GuiTourneyPlayerStats(self.config, self.db, self.sql, self.window)
|
||||
self.threads.append(new_ps_thread)
|
||||
ps_tab=new_ps_thread.get_vbox()
|
||||
self.add_and_display_tab(ps_tab, "Tourney Player Stats")
|
||||
|
||||
def tab_positional_stats(self, widget, data=None):
|
||||
new_ps_thread = GuiPositionalStats.GuiPositionalStats(self.config, self.sql)
|
||||
|
@ -875,21 +1048,24 @@ class fpdb:
|
|||
def tab_main_help(self, widget, data=None):
|
||||
"""Displays a tab with the main fpdb help screen"""
|
||||
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.
|
||||
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")
|
||||
self.add_and_display_tab(mh_tab, "Help")
|
||||
To be notified of new snapshots and releases go to https://lists.sourceforge.net/lists/listinfo/fpdb-announce and subscribe.
|
||||
If you want to follow development more closely go to https://lists.sourceforge.net/lists/listinfo/fpdb-main and subscribe.
|
||||
|
||||
def tab_table_viewer(self, widget, data=None):
|
||||
"""opens a table viewer tab"""
|
||||
new_tv_thread = GuiTableViewer.GuiTableViewer(self.db, self.settings, self.config)
|
||||
self.threads.append(new_tv_thread)
|
||||
tv_tab = new_tv_thread.get_vbox()
|
||||
self.add_and_display_tab(tv_tab, "Table Viewer")
|
||||
This program is currently in an alpha-state, so our database format is still sometimes changed.
|
||||
You should therefore always keep your hand history files so that you can re-import after an update, if necessary.
|
||||
|
||||
For documentation please visit our website at http://fpdb.sourceforge.net/.
|
||||
If you need help click on Contact - Get Help on our website.
|
||||
Please note that default.conf is no longer needed nor used, all configuration now happens in HUD_config.xml.
|
||||
|
||||
This program is free/libre open source software licensed partially under the AGPL3, and partially under GPL2 or later.
|
||||
The Windows installer package includes code licensed under the MIT license.
|
||||
You can find the full license texts in agpl-3.0.txt, gpl-2.0.txt, gpl-3.0.txt and mit.txt in the fpdb installation directory.""")
|
||||
self.add_and_display_tab(mh_tab, "Help")
|
||||
|
||||
def tabGraphViewer(self, widget, data=None):
|
||||
"""opens a graph viewer tab"""
|
||||
new_gv_thread = GuiGraphViewer.GuiGraphViewer(self.sql, self.config)
|
||||
new_gv_thread = GuiGraphViewer.GuiGraphViewer(self.sql, self.config, self.window)
|
||||
self.threads.append(new_gv_thread)
|
||||
gv_tab = new_gv_thread.get_vbox()
|
||||
self.add_and_display_tab(gv_tab, "Graphs")
|
||||
|
@ -899,13 +1075,18 @@ This program is licensed under the AGPL3, see docs"""+os.sep+"agpl-3.0.txt")
|
|||
self.lock = interlocks.InterProcessLock(name="fpdb_global_lock")
|
||||
self.db = None
|
||||
self.status_bar = None
|
||||
self.quitting = False
|
||||
|
||||
self.window = gtk.Window(gtk.WINDOW_TOPLEVEL)
|
||||
self.window.connect("delete_event", self.delete_event)
|
||||
self.window.connect("destroy", self.destroy)
|
||||
self.window.set_title("Free Poker DB - v%s or higher" % (VERSION, ))
|
||||
self.window.set_title("Free Poker DB - v%s" % (VERSION, ))
|
||||
self.window.set_border_width(1)
|
||||
self.window.set_default_size(900,720)
|
||||
defx, defy = 900, 720
|
||||
sx, sy = gtk.gdk.screen_width(), gtk.gdk.screen_height()
|
||||
if sx < defx: defx = sx
|
||||
if sy < defy: defy = sy
|
||||
self.window.set_default_size(defx, defy)
|
||||
self.window.set_resizable(True)
|
||||
|
||||
self.main_vbox = gtk.VBox(False, 1)
|
||||
|
@ -957,9 +1138,11 @@ This program is licensed under the AGPL3, see docs"""+os.sep+"agpl-3.0.txt")
|
|||
menuItem = gtk.ImageMenuItem(gtk.STOCK_ABOUT)
|
||||
menuItem.connect('activate', self.dia_about)
|
||||
self.statusMenu.append(menuItem)
|
||||
|
||||
menuItem = gtk.ImageMenuItem(gtk.STOCK_QUIT)
|
||||
menuItem.connect('activate', self.quit)
|
||||
self.statusMenu.append(menuItem)
|
||||
|
||||
self.statusIcon.connect('popup-menu', self.statusicon_menu, self.statusMenu)
|
||||
self.statusIcon.set_visible(True)
|
||||
|
||||
|
@ -1006,7 +1189,7 @@ This program is licensed under the AGPL3, see docs"""+os.sep+"agpl-3.0.txt")
|
|||
self.window.present()
|
||||
|
||||
def info_box(self, str1, str2):
|
||||
diapath = gtk.MessageDialog( parent=None, flags=0, type=gtk.MESSAGE_INFO
|
||||
diapath = gtk.MessageDialog( parent=self.window, flags=gtk.DIALOG_DESTROY_WITH_PARENT, type=gtk.MESSAGE_INFO
|
||||
, buttons=(gtk.BUTTONS_OK), message_format=str1 )
|
||||
diapath.format_secondary_text(str2)
|
||||
response = diapath.run()
|
||||
|
@ -1014,7 +1197,7 @@ This program is licensed under the AGPL3, see docs"""+os.sep+"agpl-3.0.txt")
|
|||
return response
|
||||
|
||||
def warning_box(self, str, diatitle="FPDB WARNING"):
|
||||
diaWarning = gtk.Dialog(title=diatitle, parent=None, flags=0, buttons=(gtk.STOCK_OK,gtk.RESPONSE_OK))
|
||||
diaWarning = gtk.Dialog(title=diatitle, parent=self.window, flags=gtk.DIALOG_DESTROY_WITH_PARENT, buttons=(gtk.STOCK_OK,gtk.RESPONSE_OK))
|
||||
|
||||
label = gtk.Label(str)
|
||||
diaWarning.vbox.add(label)
|
|
@ -1,21 +0,0 @@
|
|||
#!/usr/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
#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.
|
||||
|
||||
|
||||
|
||||
#end class fpdb_db
|
|
@ -1,6 +1,7 @@
|
|||
#!/usr/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
#Copyright 2008 Steffen Jobbagy-Felso
|
||||
#Copyright 2008-2010 Steffen Schaumburg
|
||||
#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.
|
||||
|
@ -12,10 +13,7 @@
|
|||
#
|
||||
#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.
|
||||
|
||||
#see status.txt for site/games support info
|
||||
#In the "official" distribution you can find the license in agpl-3.0.txt.
|
||||
|
||||
# Standard Library modules
|
||||
|
||||
|
@ -154,6 +152,8 @@ class Importer:
|
|||
#Add an individual file to filelist
|
||||
def addImportFile(self, filename, site = "default", filter = "passthrough"):
|
||||
#TODO: test it is a valid file -> put that in config!!
|
||||
#print "addimportfile: filename is a", filename.__class__
|
||||
# filename now comes in as unicode
|
||||
if filename in self.filelist or not os.path.exists(filename):
|
||||
return
|
||||
self.filelist[filename] = [site] + [filter]
|
||||
|
@ -179,10 +179,11 @@ class Importer:
|
|||
if os.path.isdir(inputPath):
|
||||
for subdir in os.walk(inputPath):
|
||||
for file in subdir[2]:
|
||||
self.addImportFile(os.path.join(subdir[0], file), site=site,
|
||||
filter=filter)
|
||||
self.addImportFile(unicode(os.path.join(subdir[0], file),'utf-8'),
|
||||
site=site, filter=filter)
|
||||
else:
|
||||
self.addImportFile(inputPath, site=site, filter=filter)
|
||||
|
||||
self.addImportFile(unicode(inputPath,'utf-8'), site=site, filter=filter)
|
||||
#Add a directory of files to filelist
|
||||
#Only one import directory per site supported.
|
||||
#dirlist is a hash of lists:
|
||||
|
@ -408,7 +409,8 @@ class Importer:
|
|||
conv = None
|
||||
(stored, duplicates, partial, errors, ttime) = (0, 0, 0, 0, time())
|
||||
|
||||
file = file.decode(Configuration.LOCALE_ENCODING)
|
||||
# sc: is there any need to decode this? maybe easier to skip it than guess at the encoding?
|
||||
#file = file.decode("utf-8") #(Configuration.LOCALE_ENCODING)
|
||||
|
||||
# Load filter, process file, pass returned filename to import_fpdb_file
|
||||
if self.settings['threads'] > 0 and self.writeq is not None:
|
||||
|
@ -462,12 +464,16 @@ class Importer:
|
|||
|
||||
#pipe the Hands.id out to the HUD
|
||||
for hid in to_hud:
|
||||
try:
|
||||
print "fpdb_import: sending hand to hud", hand.dbid_hands, "pipe =", self.caller.pipe_to_hud
|
||||
self.caller.pipe_to_hud.stdin.write("%s" % (hid) + os.linesep)
|
||||
except IOError, e:
|
||||
log.error("Failed to send hand to HUD: %s" % e)
|
||||
|
||||
errors = getattr(hhc, 'numErrors')
|
||||
stored = getattr(hhc, 'numHands')
|
||||
stored -= duplicates
|
||||
stored -= errors
|
||||
else:
|
||||
# conversion didn't work
|
||||
# TODO: appropriate response?
|
||||
|
@ -484,9 +490,9 @@ class Importer:
|
|||
|
||||
def printEmailErrorMessage(self, errors, filename, line):
|
||||
traceback.print_exc(file=sys.stderr)
|
||||
print "Error No.",errors,", please send the hand causing this to steffen@sycamoretest.info so I can fix it."
|
||||
print "Error No.",errors,", please send the hand causing this to fpdb-main@lists.sourceforge.net so we can fix the problem."
|
||||
print "Filename:", filename
|
||||
print "Here is the first line so you can identify it. Please mention that the error was a ValueError:"
|
||||
print "Here is the first line of the hand so you can identify it. Please mention that the error was a ValueError:"
|
||||
print self.hand[0]
|
||||
print "Hand logged to hand-errors.txt"
|
||||
logfile = open('hand-errors.txt', 'a')
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
# Code from http://ender.snowburst.org:4747/~jjohns/interlocks.py
|
||||
# Thanks JJ!
|
||||
|
@ -34,19 +35,24 @@ class InterProcessLockBase:
|
|||
if not name:
|
||||
name = sys.argv[0]
|
||||
self.name = name
|
||||
self.heldBy = None
|
||||
|
||||
def getHashedName(self):
|
||||
return base64.b64encode(self.name).replace('=','')
|
||||
|
||||
def acquire_impl(self, wait): abstract
|
||||
|
||||
def acquire(self, wait=False, retry_time=1):
|
||||
def acquire(self, wait=False, retry_time=1, source=None):
|
||||
if source == None:
|
||||
source="Unknown"
|
||||
if self._has_lock: # make sure 2nd acquire in same process fails
|
||||
print "lock already held by:",self.heldBy
|
||||
return False
|
||||
while not self._has_lock:
|
||||
try:
|
||||
self.acquire_impl(wait)
|
||||
self._has_lock = True
|
||||
self.heldBy=source
|
||||
#print 'i have the lock'
|
||||
except SingleInstanceError:
|
||||
if not wait:
|
||||
|
@ -58,6 +64,7 @@ class InterProcessLockBase:
|
|||
def release(self):
|
||||
self.release_impl()
|
||||
self._has_lock = False
|
||||
self.heldBy=None
|
||||
|
||||
def locked(self):
|
||||
if self.acquire():
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
[loggers]
|
||||
keys=root,fpdb,logview,parser,importer,config,db,hud,filter
|
||||
keys=root,fpdb,logview,parser,importer,config,db,hud,filter,maintdbs
|
||||
|
||||
[handlers]
|
||||
keys=consoleHandler,rotatingFileHandler
|
||||
|
@ -17,6 +17,12 @@ handlers=consoleHandler,rotatingFileHandler
|
|||
qualname=fpdb
|
||||
propagate=0
|
||||
|
||||
[logger_maintdbs]
|
||||
level=INFO
|
||||
handlers=consoleHandler,rotatingFileHandler
|
||||
qualname=maintdbs
|
||||
propagate=0
|
||||
|
||||
[logger_logview]
|
||||
level=INFO
|
||||
handlers=consoleHandler,rotatingFileHandler
|
||||
|
|
|
@ -1 +0,0 @@
|
|||
python makeexe.py py2exe
|
|
@ -1,10 +0,0 @@
|
|||
from distutils.core import setup
|
||||
import py2exe
|
||||
opts = {
|
||||
'py2exe': {
|
||||
'includes': "pango,atk,gobject",
|
||||
}
|
||||
}
|
||||
|
||||
setup(name='Free Poker Database', version='0.12', console=[{"script":"fpdb.py"}])
|
||||
|
|
@ -1,10 +1,11 @@
|
|||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
"""setup.py
|
||||
|
||||
Py2exe script for fpdb.
|
||||
"""
|
||||
# Copyright 2009, Ray E. Barker
|
||||
# Copyright 2009-2010, 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
|
||||
|
@ -39,16 +40,14 @@ Py2exe script for fpdb.
|
|||
# MSVCP90.dll. These are somewhere in your windows install, so you
|
||||
# can just copy them to your working folder. (or just assume other
|
||||
# person will have them? any copyright issues with including them?)
|
||||
#- [ If it works, you'll have 3 new folders, build and dist and gfx. Build is
|
||||
# working space and should be deleted. Dist and gfx contain the files to be
|
||||
# distributed. ]
|
||||
# If it works, you'll have a new dir fpdb-XXX-YYYYMMDD-exe which should
|
||||
#- If it works, you'll have a new dir fpdb-YYYYMMDD-exe which should
|
||||
# contain 2 dirs; gfx and pyfpdb and run_fpdb.bat
|
||||
#- Last, you must copy the etc/, lib/ and share/ folders from your
|
||||
#- [ This bit is now automated:
|
||||
# Last, you must copy the etc/, lib/ and share/ folders from your
|
||||
# gtk/bin/ (just /gtk/?) folder to the pyfpdb folder. (the whole folders,
|
||||
# not just the contents)
|
||||
# not just the contents) ]
|
||||
#- You can (should) then prune the etc/, lib/ and share/ folders to
|
||||
# remove components we don't need.
|
||||
# remove components we don't need. (see output at end of program run)
|
||||
|
||||
# sqlcoder notes: this worked for me with the following notes:
|
||||
#- I used the following versions:
|
||||
|
@ -65,10 +64,22 @@ Py2exe script for fpdb.
|
|||
#
|
||||
# libgobject-2.0-0.dll
|
||||
# libgdk-win32-2.0-0.dll
|
||||
#
|
||||
# Now updated to work with python 2.6 + related dependencies
|
||||
# See walkthrough in packaging directory for versions used
|
||||
# Updates to this script have broken python 2.5 compatibility (gio module, msvcr71 references now msvcp90)
|
||||
|
||||
|
||||
import os
|
||||
import sys
|
||||
|
||||
# get out now if parameter not passed
|
||||
try:
|
||||
sys.argv[1] <> ""
|
||||
except:
|
||||
print "A parameter is required, quitting now"
|
||||
quit()
|
||||
|
||||
from distutils.core import setup
|
||||
import py2exe
|
||||
import glob
|
||||
|
@ -79,7 +90,8 @@ from datetime import date
|
|||
|
||||
origIsSystemDLL = py2exe.build_exe.isSystemDLL
|
||||
def isSystemDLL(pathname):
|
||||
if os.path.basename(pathname).lower() in ("msvcp71.dll", "dwmapi.dll"):
|
||||
#dwmapi appears to be vista-specific file, not XP
|
||||
if os.path.basename(pathname).lower() in ("dwmapi.dll"):
|
||||
return 0
|
||||
return origIsSystemDLL(pathname)
|
||||
py2exe.build_exe.isSystemDLL = isSystemDLL
|
||||
|
@ -92,7 +104,7 @@ def remove_tree(top):
|
|||
# could delete all your disk files.
|
||||
# sc: Nicked this from somewhere, added the if statement to try
|
||||
# make it a bit safer
|
||||
if top in ('build','dist','gfx') and os.path.basename(os.getcwd()) == 'pyfpdb':
|
||||
if top in ('build','dist','pyfpdb',dist_dirname) and os.path.basename(os.getcwd()) == 'pyfpdb':
|
||||
#print "removing directory '"+top+"' ..."
|
||||
for root, dirs, files in os.walk(top, topdown=False):
|
||||
for name in files:
|
||||
|
@ -109,35 +121,35 @@ def test_and_remove(top):
|
|||
print "Unexpected file '"+top+"' found. Exiting."
|
||||
exit()
|
||||
|
||||
today = date.today().strftime('%Y%m%d')
|
||||
print "\n" + r"Output will be created in \pyfpdb\ and \fpdb_"+today+'\\'
|
||||
#print "Enter value for XXX (any length): ", # the comma means no newline
|
||||
#xxx = sys.stdin.readline().rstrip()
|
||||
dist_dirname = r'fpdb-' + today + '-exe'
|
||||
dist_dir = r'..\fpdb-' + today + '-exe'
|
||||
print
|
||||
|
||||
# remove build and dist dirs if they exist
|
||||
test_and_remove('dist')
|
||||
test_and_remove('build')
|
||||
#test_and_remove('gfx')
|
||||
test_and_remove('pyfpdb')
|
||||
|
||||
test_and_remove(dist_dirname)
|
||||
|
||||
today = date.today().strftime('%Y%m%d')
|
||||
print "\n" + r"Output will be created in \pyfpdb\ and \fpdb_XXX_"+today+'\\'
|
||||
print "Enter value for XXX (any length): ", # the comma means no newline
|
||||
xxx = sys.stdin.readline().rstrip()
|
||||
dist_dirname = r'fpdb-' + xxx + '-' + today + '-exe'
|
||||
dist_dir = r'..\fpdb-' + xxx + '-' + today + '-exe'
|
||||
print
|
||||
|
||||
test_and_remove(dist_dir)
|
||||
|
||||
setup(
|
||||
name = 'fpdb',
|
||||
description = 'Free Poker DataBase',
|
||||
version = '0.12',
|
||||
version = '0.20.903',
|
||||
|
||||
console = [ {'script': 'fpdb.py', "icon_resources": [(1, "../gfx/fpdb_large_icon.ico")]},
|
||||
{'script': 'HUD_main.py', },
|
||||
windows = [ {'script': 'fpdb.pyw', "icon_resources": [(1, "../gfx/fpdb_large_icon.ico")]},
|
||||
{'script': 'HUD_main.pyw', },
|
||||
{'script': 'Configuration.py', }
|
||||
],
|
||||
|
||||
options = {'py2exe': {
|
||||
'packages' : ['encodings', 'matplotlib'],
|
||||
'includes' : ['cairo', 'pango', 'pangocairo', 'atk', 'gobject'
|
||||
'includes' : ['gio', 'cairo', 'pango', 'pangocairo', 'atk', 'gobject'
|
||||
,'matplotlib.numerix.random_array'
|
||||
,'AbsoluteToFpdb', 'BetfairToFpdb'
|
||||
,'CarbonToFpdb', 'EverleafToFpdb'
|
||||
|
@ -146,13 +158,14 @@ setup(
|
|||
,'UltimateBetToFpdb', 'Win2dayToFpdb'
|
||||
],
|
||||
'excludes' : ['_tkagg', '_agg2', 'cocoaagg', 'fltkagg'], # surely we need this? '_gtkagg'
|
||||
'dll_excludes': ['libglade-2.0-0.dll', 'libgdk-win32-2.0-0.dll'
|
||||
,'libgobject-2.0-0.dll'],
|
||||
'dll_excludes': ['libglade-2.0-0.dll', 'libgdk-win32-2.0-0.dll', 'libgobject-2.0-0.dll'
|
||||
, 'msvcr90.dll', 'MSVCP90.dll', 'MSVCR90.dll','msvcr90.dll'], # these are vis c / c++ runtimes, and must not be redistributed
|
||||
}
|
||||
},
|
||||
|
||||
# files in 2nd value in tuple are moved to dir named in 1st value
|
||||
data_files = [('', ['HUD_config.xml.example', 'Cards01.png', 'logging.conf', '../docs/readme.txt'])
|
||||
#data_files updated for new locations of licences + readme nolonger exists
|
||||
data_files = [('', ['HUD_config.xml.example', 'Cards01.png', 'logging.conf', '../agpl-3.0.txt', '../fdl-1.2.txt', '../gpl-3.0.txt', '../gpl-2.0.txt', '../mit.txt', '../readme.txt'])
|
||||
,(dist_dir, [r'..\run_fpdb.bat'])
|
||||
,( dist_dir + r'\gfx', glob.glob(r'..\gfx\*.*') )
|
||||
# line below has problem with fonts subdir ('not a regular file')
|
||||
|
@ -160,25 +173,29 @@ setup(
|
|||
] + matplotlib.get_py2exe_datafiles()
|
||||
)
|
||||
|
||||
|
||||
# rename completed output package as pyfpdb
|
||||
os.rename('dist', 'pyfpdb')
|
||||
|
||||
print '\n' + 'If py2exe was successful add the \\etc \\lib and \\share dirs '
|
||||
print 'from your gtk dir to \\%s\\pyfpdb\\\n' % dist_dirname
|
||||
print 'Also copy libgobject-2.0-0.dll and libgdk-win32-2.0-0.dll from <gtk_dir>\\bin'
|
||||
print 'into there'
|
||||
# pull pytz zoneinfo into pyfpdb package folder
|
||||
src_dir = r'c:\python26\Lib\site-packages\pytz\zoneinfo'
|
||||
src_dir = src_dir.replace('\\', '\\\\')
|
||||
dest_dir = os.path.join(r'pyfpdb', 'zoneinfo')
|
||||
shutil.copytree( src_dir, dest_dir )
|
||||
|
||||
# shunt pyfpdb package over to the distribution folder
|
||||
dest = os.path.join(dist_dirname, 'pyfpdb')
|
||||
# print "try renaming pyfpdb to", dest
|
||||
dest = dest.replace('\\', '\\\\')
|
||||
# print "dest is now", dest
|
||||
os.rename( 'pyfpdb', dest )
|
||||
|
||||
# prompt for gtk location
|
||||
|
||||
print "Enter directory name for GTK 2.14 (e.g. c:\code\gtk_2.14.7-20090119)\n: ", # the comma means no newline
|
||||
gtk_dir = ""
|
||||
while not os.path.exists(gtk_dir):
|
||||
print "Enter directory name for GTK (e.g. c:\code\gtk_2.14.7-20090119)\n: ", # the comma means no newline
|
||||
gtk_dir = sys.stdin.readline().rstrip()
|
||||
|
||||
|
||||
print "\ncopying files and dirs from ", gtk_dir, "to", dest.replace('\\\\', '\\'), "..."
|
||||
src = os.path.join(gtk_dir, 'bin', 'libgdk-win32-2.0-0.dll')
|
||||
src = src.replace('\\', '\\\\')
|
||||
|
@ -188,7 +205,6 @@ src = os.path.join(gtk_dir, 'bin', 'libgobject-2.0-0.dll')
|
|||
src = src.replace('\\', '\\\\')
|
||||
shutil.copy( src, dest )
|
||||
|
||||
|
||||
src_dir = os.path.join(gtk_dir, 'etc')
|
||||
src_dir = src_dir.replace('\\', '\\\\')
|
||||
dest_dir = os.path.join(dest, 'etc')
|
||||
|
@ -207,4 +223,24 @@ dest_dir = os.path.join(dest, 'share')
|
|||
dest_dir = dest_dir.replace('\\', '\\\\')
|
||||
shutil.copytree( src_dir, dest_dir )
|
||||
|
||||
print "\nIf py2exe was successful you should now have a new dir"
|
||||
print dist_dirname+" in your pyfpdb dir"
|
||||
print """
|
||||
The following dirs can probably removed to make the final package smaller:
|
||||
|
||||
pyfpdb/lib/glib-2.0
|
||||
pyfpdb/lib/gtk-2.0/include
|
||||
pyfpdb/lib/pkgconfig
|
||||
pyfpdb/share/aclocal
|
||||
pyfpdb/share/doc
|
||||
pyfpdb/share/glib-2.0
|
||||
pyfpdb/share/gtk-2.0
|
||||
pyfpdb/share/gtk-doc
|
||||
pyfpdb/share/locale
|
||||
pyfpdb/share/man
|
||||
pyfpdb/share/themes/Default
|
||||
|
||||
Use 7-zip to zip up the distribution and create a self extracting archive and that's it!
|
||||
"""
|
||||
|
||||
|
||||
|
|
|
@ -0,0 +1,665 @@
|
|||
Full Tilt Poker Game #11111111813: Table Fpdb - $2/$4 Ante $0.40 - Limit Stud Hi - 13:14:27 ET - 2010/06/10
|
||||
Seat 1: Player4 ($7.40)
|
||||
Seat 2: Player13 ($77.20)
|
||||
Seat 3: Player1 ($111.80)
|
||||
Seat 5: Player5 ($118.70)
|
||||
Seat 7: Player6 ($36.30)
|
||||
Player1 antes $0.40
|
||||
Player4 antes $0.40
|
||||
Player13 antes $0.40
|
||||
Player5 antes $0.40
|
||||
Player6 antes $0.40
|
||||
*** 3RD STREET ***
|
||||
Dealt to Player4 [9c]
|
||||
Dealt to Player13 [8s]
|
||||
Dealt to Player1 [Ac 9h] [3s]
|
||||
Dealt to Player5 [3c]
|
||||
Dealt to Player6 [Qs]
|
||||
Player5 is low with [3c]
|
||||
Player5 brings in for $0.50
|
||||
Player6 folds
|
||||
Player4 completes it to $2
|
||||
Player14 sits down
|
||||
Player13 folds
|
||||
Player1 folds
|
||||
Player14 adds $152
|
||||
Player5 calls $1.50
|
||||
*** 4TH STREET ***
|
||||
Dealt to Player4 [9c] [9d]
|
||||
Dealt to Player5 [3c] [8d]
|
||||
Player4 bets $4
|
||||
Player5 folds
|
||||
Uncalled bet of $4 returned to Player4
|
||||
Player4 mucks
|
||||
Player4 wins the pot ($6)
|
||||
*** SUMMARY ***
|
||||
Total pot $6 | Rake $0
|
||||
Seat 1: Player4 collected ($6), mucked
|
||||
Seat 2: Player13 folded on 3rd St.
|
||||
Seat 3: Player1 folded on 3rd St.
|
||||
Seat 5: Player5 folded on 4th St.
|
||||
Seat 7: Player6 folded on 3rd St.
|
||||
|
||||
|
||||
|
||||
Full Tilt Poker Game #11111111538: Table Fpdb - $2/$4 Ante $0.40 - Limit Stud Hi - 13:15:56 ET - 2010/06/10
|
||||
Seat 1: Player4 ($12.60)
|
||||
Seat 2: Player13 ($89.90)
|
||||
Seat 3: Player1 ($110.60)
|
||||
Seat 5: Player5 ($115.50)
|
||||
Seat 6: Player14 ($138.70)
|
||||
Seat 7: Player6 ($35.10)
|
||||
Player1 antes $0.40
|
||||
Player4 antes $0.40
|
||||
Player13 antes $0.40
|
||||
Player5 antes $0.40
|
||||
Player14 antes $0.40
|
||||
Player6 antes $0.40
|
||||
*** 3RD STREET ***
|
||||
Dealt to Player4 [Qc]
|
||||
Dealt to Player13 [5s]
|
||||
Dealt to Player1 [6c 5d] [3d]
|
||||
Dealt to Player5 [9d]
|
||||
Dealt to Player14 [8h]
|
||||
Dealt to Player6 [Ts]
|
||||
Player1 is low with [3d]
|
||||
Player1 brings in for $0.50
|
||||
Player5 folds
|
||||
Player14 folds
|
||||
Player6 completes it to $2
|
||||
Player4 folds
|
||||
Player13 folds
|
||||
Player1 calls $1.50
|
||||
*** 4TH STREET ***
|
||||
Dealt to Player1 [6c 5d 3d] [7c]
|
||||
Dealt to Player6 [Ts] [6d]
|
||||
Player6 bets $2
|
||||
Player1 calls $2
|
||||
*** 5TH STREET ***
|
||||
Dealt to Player1 [6c 5d 3d 7c] [Qd]
|
||||
Dealt to Player6 [Ts 6d] [9s]
|
||||
Player1 checks
|
||||
Player6 bets $4
|
||||
Player1 folds
|
||||
Uncalled bet of $4 returned to Player6
|
||||
Player6 mucks
|
||||
Player6 wins the pot ($10.40)
|
||||
*** SUMMARY ***
|
||||
Total pot $10.40 | Rake $0
|
||||
Seat 1: Player4 folded on 3rd St.
|
||||
Seat 2: Player13 folded on 3rd St.
|
||||
Seat 3: Player1 folded on 5th St.
|
||||
Seat 5: Player5 folded on 3rd St.
|
||||
Seat 6: Player14 folded on 3rd St.
|
||||
Seat 7: Player6 collected ($10.40), mucked
|
||||
|
||||
|
||||
Full Tilt Poker Game #11111111649: Table Fpdb - $2/$4 Ante $0.40 - Limit Stud Hi - 13:17:24 ET - 2010/06/10
|
||||
Seat 1: Player4 ($16.30)
|
||||
Seat 2: Player13 ($88.70)
|
||||
Seat 3: Player1 ($107.30)
|
||||
Seat 5: Player5 ($114.30)
|
||||
Seat 6: Player14 ($135.50)
|
||||
Seat 7: Player6 ($40.30)
|
||||
Player1 antes $0.40
|
||||
Player4 antes $0.40
|
||||
Player13 antes $0.40
|
||||
Player5 antes $0.40
|
||||
Player14 antes $0.40
|
||||
Player6 antes $0.40
|
||||
*** 3RD STREET ***
|
||||
Dealt to Player4 [9s]
|
||||
Dealt to Player13 [9h]
|
||||
Dealt to Player1 [8h Kd] [6s]
|
||||
Dealt to Player5 [4c]
|
||||
Dealt to Player14 [8d]
|
||||
Dealt to Player6 [6c]
|
||||
Player5 is low with [4c]
|
||||
Player10 sits down
|
||||
Player10 adds $40
|
||||
Player5 brings in for $0.50
|
||||
Player14 folds
|
||||
Player6 folds
|
||||
Player4 folds
|
||||
Player13 completes it to $2
|
||||
Player1 folds
|
||||
Player5 folds
|
||||
Uncalled bet of $1.50 returned to Player13
|
||||
Player13 mucks
|
||||
Player13 wins the pot ($3.40)
|
||||
*** SUMMARY ***
|
||||
Total pot $3.40 | Rake $0
|
||||
Seat 1: Player4 folded on 3rd St.
|
||||
Seat 2: Player13 collected ($3.40), mucked
|
||||
Seat 3: Player1 folded on 3rd St.
|
||||
Seat 5: Player5 folded on 3rd St.
|
||||
Seat 6: Player14 folded on 3rd St.
|
||||
Seat 7: Player6 folded on 3rd St.
|
||||
|
||||
|
||||
|
||||
Full Tilt Poker Game #11111112277: Table Fpdb - $2/$4 Ante $0.40 - Limit Stud Hi - 13:17:41 ET - 2010/06/10
|
||||
Seat 1: Player4 ($15.90)
|
||||
Seat 2: Player13 ($91.20)
|
||||
Seat 3: Player1 ($106.90)
|
||||
Seat 5: Player5 ($113.40)
|
||||
Seat 6: Player14 ($135.10)
|
||||
Seat 7: Player6 ($39.90)
|
||||
Seat 8: Player10 ($40)
|
||||
Player1 antes $0.40
|
||||
Player4 antes $0.40
|
||||
Player13 antes $0.40
|
||||
Player5 antes $0.40
|
||||
Player14 antes $0.40
|
||||
Player6 antes $0.40
|
||||
Player10 antes $0.40
|
||||
*** 3RD STREET ***
|
||||
Dealt to Player4 [Qs]
|
||||
Dealt to Player13 [8s]
|
||||
Dealt to Player1 [3h 9c] [Ah]
|
||||
Dealt to Player5 [Qc]
|
||||
Dealt to Player14 [Kc]
|
||||
Dealt to Player6 [Jh]
|
||||
Dealt to Player10 [6d]
|
||||
Player10 is low with [6d]
|
||||
Player10 brings in for $0.50
|
||||
Player4 folds
|
||||
Player13 folds
|
||||
Player1 folds
|
||||
Player5 completes it to $2
|
||||
Player14 raises to $4
|
||||
Player6 folds
|
||||
Player10 calls $3.50
|
||||
Player5 calls $2
|
||||
*** 4TH STREET ***
|
||||
Dealt to Player5 [Qc] [3c]
|
||||
Dealt to Player14 [Kc] [Kh]
|
||||
Dealt to Player10 [6d] [Td]
|
||||
Player14 has 15 seconds left to act
|
||||
Player14 bets $4
|
||||
Player10 folds
|
||||
Player5 folds
|
||||
Uncalled bet of $4 returned to Player14
|
||||
Player14 mucks
|
||||
Player14 wins the pot ($14.80)
|
||||
*** SUMMARY ***
|
||||
Total pot $14.80 | Rake $0
|
||||
Seat 1: Player4 folded on 3rd St.
|
||||
Seat 2: Player13 folded on 3rd St.
|
||||
Seat 3: Player1 folded on 3rd St.
|
||||
Seat 5: Player5 folded on 4th St.
|
||||
Seat 6: Player14 collected ($14.80), mucked
|
||||
Seat 7: Player6 folded on 3rd St.
|
||||
Seat 8: Player10 folded on 4th St.
|
||||
|
||||
|
||||
|
||||
Full Tilt Poker Game #11111110428: Table Fpdb - $2/$4 Ante $0.40 - Limit Stud Hi - 13:18:23 ET - 2010/06/10
|
||||
Seat 1: Player4 ($15.50)
|
||||
Seat 2: Player13 ($90.80)
|
||||
Seat 3: Player1 ($106.50)
|
||||
Seat 5: Player5 ($109)
|
||||
Seat 6: Player14 ($145.50)
|
||||
Seat 7: Player6 ($39.50)
|
||||
Seat 8: Player10 ($35.60)
|
||||
Player10 antes $0.40
|
||||
Player13 antes $0.40
|
||||
Player1 antes $0.40
|
||||
Player4 antes $0.40
|
||||
Player5 antes $0.40
|
||||
Player14 antes $0.40
|
||||
Player6 antes $0.40
|
||||
*** 3RD STREET ***
|
||||
Dealt to Player4 [Th]
|
||||
Dealt to Player13 [Kc]
|
||||
Dealt to Player1 [Kh 9c] [5h]
|
||||
Dealt to Player5 [6h]
|
||||
Dealt to Player14 [Js]
|
||||
Dealt to Player6 [Ac]
|
||||
Dealt to Player10 [Ah]
|
||||
Player1 is low with [5h]
|
||||
Player1 brings in for $0.50
|
||||
Player5 folds
|
||||
Player14 folds
|
||||
Player6 folds
|
||||
Player10 completes it to $2
|
||||
Player4 calls $2
|
||||
Player13 folds
|
||||
Player1 folds
|
||||
*** 4TH STREET ***
|
||||
Dealt to Player4 [Th] [4h]
|
||||
Dealt to Player10 [Ah] [3c]
|
||||
Player10 bets $2
|
||||
Player4 calls $2
|
||||
*** 5TH STREET ***
|
||||
Dealt to Player4 [Th 4h] [9h]
|
||||
Dealt to Player10 [Ah 3c] [8h]
|
||||
Player10 has 15 seconds left to act
|
||||
Player10 bets $4
|
||||
Player4 raises to $8
|
||||
Player10 folds
|
||||
Uncalled bet of $4 returned to Player4
|
||||
Player4 mucks
|
||||
Player4 wins the pot ($19.30)
|
||||
*** SUMMARY ***
|
||||
Total pot $19.30 | Rake $0
|
||||
Seat 1: Player4 collected ($19.30), mucked
|
||||
Seat 2: Player13 folded on 3rd St.
|
||||
Seat 3: Player1 folded on 3rd St.
|
||||
Seat 5: Player5 folded on 3rd St.
|
||||
Seat 6: Player14 folded on 3rd St.
|
||||
Seat 7: Player6 folded on 3rd St.
|
||||
Seat 8: Player10 folded on 5th St.
|
||||
|
||||
|
||||
|
||||
Full Tilt Poker Game #11111112961: Table Fpdb - $2/$4 Ante $0.40 - Limit Stud Hi - 13:19:27 ET - 2010/06/10
|
||||
Seat 1: Player4 ($26)
|
||||
Seat 2: Player13 ($90)
|
||||
Seat 3: Player1 ($105.20)
|
||||
Seat 5: Player5 ($108.20)
|
||||
Seat 6: Player14 ($144.70)
|
||||
Seat 7: Player6 ($41.50)
|
||||
Seat 8: Player10 ($26.80)
|
||||
Player4 antes $0.40
|
||||
Player13 antes $0.40
|
||||
Player1 antes $0.40
|
||||
Player5 antes $0.40
|
||||
Player10 antes $0.40
|
||||
Player14 antes $0.40
|
||||
Player6 antes $0.40
|
||||
*** 3RD STREET ***
|
||||
Dealt to Player4 [9d]
|
||||
Dealt to Player13 [Qs]
|
||||
Dealt to Player1 [9h 9s] [5c]
|
||||
Dealt to Player5 [Th]
|
||||
Dealt to Player14 [6c]
|
||||
Dealt to Player6 [2d]
|
||||
Dealt to Player10 [Qh]
|
||||
Player6 is low with [2d]
|
||||
Player6 brings in for $0.50
|
||||
Player10 folds
|
||||
Player4 folds
|
||||
Player13 folds
|
||||
Player1 completes it to $2
|
||||
Player5 folds
|
||||
Player14 folds
|
||||
Player6 calls $1.50
|
||||
*** 4TH STREET ***
|
||||
Dealt to Player1 [9h 9s 5c] [3s]
|
||||
Dealt to Player6 [2d] [Ah]
|
||||
Player6 checks
|
||||
Player1 bets $2
|
||||
Player6 calls $2
|
||||
*** 5TH STREET ***
|
||||
Dealt to Player1 [9h 9s 5c 3s] [Kh]
|
||||
Dealt to Player6 [2d Ah] [Kc]
|
||||
Player6 checks
|
||||
Player1 bets $4
|
||||
Player6 raises to $8
|
||||
Player1 calls $4
|
||||
*** 6TH STREET ***
|
||||
Dealt to Player1 [9h 9s 5c 3s Kh] [5d]
|
||||
Dealt to Player6 [2d Ah Kc] [4d]
|
||||
Player1 bets $4
|
||||
Player6 calls $4
|
||||
*** 7TH STREET ***
|
||||
Dealt to Player1 [9h 9s 5c 3s Kh 5d] [8s]
|
||||
Player1 bets $4
|
||||
Player6 calls $4
|
||||
*** SHOW DOWN ***
|
||||
Player1 shows [9s 9h 5c 3s Kh 5d 8s] two pair, Nines and Fives
|
||||
Player6 shows [Ad Kd 2d Ah Kc 4d 8h] two pair, Aces and Kings
|
||||
Player6 wins the pot ($40.80) with two pair, Aces and Kings
|
||||
*** SUMMARY ***
|
||||
Total pot $42.80 | Rake $2
|
||||
Seat 1: Player4 folded on 3rd St.
|
||||
Seat 2: Player13 folded on 3rd St.
|
||||
Seat 3: Player1 showed [9s 9h 5c 3s Kh 5d 8s] and lost with two pair, Nines and Fives
|
||||
Seat 5: Player5 folded on 3rd St.
|
||||
Seat 6: Player14 folded on 3rd St.
|
||||
Seat 7: Player6 showed [Ad Kd 2d Ah Kc 4d 8h] and won ($40.80) with two pair, Aces and Kings
|
||||
Seat 8: Player10 folded on 3rd St.
|
||||
|
||||
|
||||
|
||||
Full Tilt Poker Game #11111110018: Table Fpdb - $2/$4 Ante $0.40 - Limit Stud Hi - 13:26:21 ET - 2010/06/10
|
||||
Seat 1: Player12 ($66.10)
|
||||
Seat 2: Player13 ($85.50)
|
||||
Seat 3: Player1 ($81.10)
|
||||
Seat 4: Player11 ($283.75)
|
||||
Seat 5: Player5 ($109.40)
|
||||
Seat 6: Player14 ($140.20)
|
||||
Seat 7: Player6 ($59.80)
|
||||
Seat 8: Player10 ($62.10)
|
||||
Player10 antes $0.40
|
||||
Player13 antes $0.40
|
||||
Player1 antes $0.40
|
||||
Player5 antes $0.40
|
||||
Player14 antes $0.40
|
||||
Player12 antes $0.40
|
||||
Player11 antes $0.40
|
||||
Player6 antes $0.40
|
||||
*** 3RD STREET ***
|
||||
Dealt to Player12 [Qh]
|
||||
Dealt to Player13 [Kd]
|
||||
Dealt to Player1 [2d Kc] [5h]
|
||||
Dealt to Player11 [9d]
|
||||
Dealt to Player5 [6d]
|
||||
Dealt to Player14 [Ad]
|
||||
Dealt to Player6 [6h]
|
||||
Dealt to Player10 [7h]
|
||||
Player1 is low with [5h]
|
||||
Player1 brings in for $0.50
|
||||
Player11 folds
|
||||
Player5 folds
|
||||
Player14 folds
|
||||
Player6 folds
|
||||
Player10 folds
|
||||
Player12 folds
|
||||
Player13 completes it to $2
|
||||
Player1 folds
|
||||
Uncalled bet of $1.50 returned to Player13
|
||||
Player13 mucks
|
||||
Player13 wins the pot ($4.20)
|
||||
*** SUMMARY ***
|
||||
Total pot $4.20 | Rake $0
|
||||
Seat 1: Player12 folded on 3rd St.
|
||||
Seat 2: Player13 collected ($4.20), mucked
|
||||
Seat 3: Player1 folded on 3rd St.
|
||||
Seat 4: Player11 folded on 3rd St.
|
||||
Seat 5: Player5 folded on 3rd St.
|
||||
Seat 6: Player14 folded on 3rd St.
|
||||
Seat 7: Player6 folded on 3rd St.
|
||||
Seat 8: Player10 folded on 3rd St.
|
||||
|
||||
|
||||
|
||||
Full Tilt Poker Game #11111111146: Table Fpdb - $2/$4 Ante $0.40 - Limit Stud Hi - 13:26:47 ET - 2010/06/10
|
||||
Seat 1: Player12 ($65.70)
|
||||
Seat 2: Player13 ($88.80)
|
||||
Seat 3: Player1 ($80.20)
|
||||
Seat 4: Player11 ($283.35)
|
||||
Seat 5: Player5 ($109)
|
||||
Seat 6: Player14 ($139.80)
|
||||
Seat 7: Player6 ($59.40)
|
||||
Seat 8: Player10 ($61.70)
|
||||
Player10 antes $0.40
|
||||
Player1 antes $0.40
|
||||
Player13 antes $0.40
|
||||
Player5 antes $0.40
|
||||
Player11 antes $0.40
|
||||
Player12 antes $0.40
|
||||
Player14 antes $0.40
|
||||
Player6 antes $0.40
|
||||
*** 3RD STREET ***
|
||||
Dealt to Player12 [Qd]
|
||||
Dealt to Player13 [5c]
|
||||
Dealt to Player1 [4d 3s] [9s]
|
||||
Dealt to Player11 [Ks]
|
||||
Dealt to Player5 [2c]
|
||||
Dealt to Player14 [3d]
|
||||
Dealt to Player6 [2h]
|
||||
Dealt to Player10 [2d]
|
||||
Player5 is low with [2c]
|
||||
Player5 brings in for $0.50
|
||||
Player14 folds
|
||||
Player6 folds
|
||||
Player10 folds
|
||||
Player12 folds
|
||||
Player13 folds
|
||||
Player1 folds
|
||||
Player11 completes it to $2
|
||||
Player5 calls $1.50
|
||||
*** 4TH STREET ***
|
||||
Dealt to Player11 [Ks] [Ah]
|
||||
Dealt to Player5 [2c] [5s]
|
||||
Player11 bets $2
|
||||
Player5 folds
|
||||
Uncalled bet of $2 returned to Player11
|
||||
Player11 mucks
|
||||
Player11 wins the pot ($7.20)
|
||||
*** SUMMARY ***
|
||||
Total pot $7.20 | Rake $0
|
||||
Seat 1: Player12 folded on 3rd St.
|
||||
Seat 2: Player13 folded on 3rd St.
|
||||
Seat 3: Player1 folded on 3rd St.
|
||||
Seat 4: Player11 collected ($7.20), mucked
|
||||
Seat 5: Player5 folded on 4th St.
|
||||
Seat 6: Player14 folded on 3rd St.
|
||||
Seat 7: Player6 folded on 3rd St.
|
||||
Seat 8: Player10 folded on 3rd St.
|
||||
|
||||
|
||||
|
||||
Full Tilt Poker Game #11111111633: Table Fpdb - $2/$4 Ante $0.40 - Limit Stud Hi - 13:37:55 ET - 2010/06/10
|
||||
Seat 1: Player12 ($72)
|
||||
Seat 2: Player9 ($40), is sitting out
|
||||
Seat 3: Player1 ($89.20)
|
||||
Seat 4: Player2 ($96.10)
|
||||
Seat 5: Player5 ($105.50), is sitting out
|
||||
Seat 6: Player14 ($131.70)
|
||||
Seat 7: Player6 ($54.70)
|
||||
Seat 8: Player10 ($96.40)
|
||||
Player10 antes $0.40
|
||||
Player1 antes $0.40
|
||||
Player12 antes $0.40
|
||||
Player14 antes $0.40
|
||||
Player6 antes $0.40
|
||||
5 seconds left to act
|
||||
Player2 is sitting out
|
||||
*** 3RD STREET ***
|
||||
Dealt to Player12 [5c]
|
||||
Dealt to Player1 [Td 9d] [Kc]
|
||||
Dealt to Player14 [5h]
|
||||
Dealt to Player6 [4s]
|
||||
Dealt to Player10 [7s]
|
||||
Player6 is low with [4s]
|
||||
Player2 stands up
|
||||
Player6 brings in for $0.50
|
||||
Player10 folds
|
||||
Player12 folds
|
||||
Player1 completes it to $2
|
||||
Player14 calls $2
|
||||
Player6 folds
|
||||
*** 4TH STREET ***
|
||||
Dealt to Player1 [Td 9d Kc] [9s]
|
||||
Dealt to Player14 [5h] [9h]
|
||||
Player1 bets $2
|
||||
Player14 raises to $4
|
||||
Player1 calls $2
|
||||
*** 5TH STREET ***
|
||||
Dealt to Player1 [Td 9d Kc 9s] [Tc]
|
||||
Dealt to Player14 [5h 9h] [3d]
|
||||
Player1 checks
|
||||
Player14 checks
|
||||
*** 6TH STREET ***
|
||||
Dealt to Player1 [Td 9d Kc 9s Tc] [9c]
|
||||
Dealt to Player14 [5h 9h 3d] [Th]
|
||||
Player1 bets $4
|
||||
Player14 calls $4
|
||||
*** 7TH STREET ***
|
||||
Dealt to Player1 [Td 9d Kc 9s Tc 9c] [7h]
|
||||
Player1 bets $4
|
||||
Player14 calls $4
|
||||
*** SHOW DOWN ***
|
||||
Player1 shows [Td 9d Kc 9s Tc 9c 7h] a full house, Nines full of Tens
|
||||
Player14 mucks
|
||||
Player1 wins the pot ($29.50) with a full house, Nines full of Tens
|
||||
*** SUMMARY ***
|
||||
Total pot $30.50 | Rake $1
|
||||
Seat 1: Player12 folded on 3rd St.
|
||||
Seat 2: Player9 is sitting out
|
||||
Seat 3: Player1 showed [Td 9d Kc 9s Tc 9c 7h] and won ($29.50) with a full house, Nines full of Tens
|
||||
Seat 4: Player2 is sitting out
|
||||
Seat 5: Player5 is sitting out
|
||||
Seat 6: Player14 mucked [8h 6h 5h 9h 3d Th 3h] - a flush, Ten high
|
||||
Seat 7: Player6 folded on 3rd St.
|
||||
Seat 8: Player10 folded on 3rd St.
|
||||
|
||||
|
||||
|
||||
Full Tilt Poker Game #11111113928: Table Fpdb - $2/$4 Ante $0.40 - Limit Stud Hi - 13:39:41 ET - 2010/06/10
|
||||
Seat 1: Player12 ($68.70)
|
||||
Seat 2: Player9 ($40), is sitting out
|
||||
Seat 3: Player1 ($103.90)
|
||||
Seat 6: Player14 ($116.40)
|
||||
Seat 7: Player6 ($58.40)
|
||||
Seat 8: Player10 ($95.60)
|
||||
Player10 antes $0.40
|
||||
Player1 antes $0.40
|
||||
Player6 antes $0.40
|
||||
Player3 sits down
|
||||
Player14 antes $0.40
|
||||
Player12 antes $0.40
|
||||
*** 3RD STREET ***
|
||||
Dealt to Player12 [9c]
|
||||
Dealt to Player1 [Ts 4h] [9h]
|
||||
Dealt to Player14 [7c]
|
||||
Dealt to Player6 [7s]
|
||||
Dealt to Player10 [2h]
|
||||
Player10 is low with [2h]
|
||||
Player3 adds $40
|
||||
Player10 brings in for $0.50
|
||||
Player12 folds
|
||||
Player1 completes it to $2
|
||||
Player14 folds
|
||||
Player6 folds
|
||||
Player10 folds
|
||||
Uncalled bet of $1.50 returned to Player1
|
||||
Player1 mucks
|
||||
Player1 wins the pot ($3)
|
||||
*** SUMMARY ***
|
||||
Total pot $3 | Rake $0
|
||||
Seat 1: Player12 folded on 3rd St.
|
||||
Seat 2: Player9 is sitting out
|
||||
Seat 3: Player1 collected ($3), mucked
|
||||
Seat 6: Player14 folded on 3rd St.
|
||||
Seat 7: Player6 folded on 3rd St.
|
||||
Seat 8: Player10 folded on 3rd St.
|
||||
|
||||
|
||||
|
||||
|
||||
Full Tilt Poker Game #11111111062: Table Fpdb - $2/$4 Ante $0.40 - Limit Stud Hi - 13:51:45 ET - 2010/06/10
|
||||
Seat 1: Player12 ($83.40)
|
||||
Seat 2: Player9 ($24.35)
|
||||
Seat 3: Player1 ($147.90)
|
||||
Seat 4: Player3 ($74.10)
|
||||
Seat 5: Player8 ($63.10)
|
||||
Seat 6: Player14 ($103)
|
||||
Seat 7: Player6 ($63.20)
|
||||
Seat 8: Player7 ($48.40)
|
||||
Player7 antes $0.40
|
||||
Player1 antes $0.40
|
||||
Player8 antes $0.40
|
||||
Player3 antes $0.40
|
||||
Player9 antes $0.40
|
||||
Player12 antes $0.40
|
||||
Player14 antes $0.40
|
||||
Player6 antes $0.40
|
||||
*** 3RD STREET ***
|
||||
Dealt to Player12 [As]
|
||||
Dealt to Player9 [7s]
|
||||
Dealt to Player1 [7h 6s] [8d]
|
||||
Dealt to Player3 [2d]
|
||||
Dealt to Player8 [3c]
|
||||
Dealt to Player14 [7c]
|
||||
Dealt to Player6 [8h]
|
||||
Dealt to Player7 [Qs]
|
||||
Player3 is low with [2d]
|
||||
Player3 brings in for $0.50
|
||||
Player8 folds
|
||||
Player14 folds
|
||||
Player6 folds
|
||||
Player7 folds
|
||||
Player12 completes it to $2
|
||||
Player9 folds
|
||||
Player1 calls $2
|
||||
Player3 calls $1.50
|
||||
*** 4TH STREET ***
|
||||
Dealt to Player12 [As] [5d]
|
||||
Dealt to Player1 [7h 6s 8d] [Qc]
|
||||
Dealt to Player3 [2d] [3h]
|
||||
Player12 bets $2
|
||||
Player1 folds
|
||||
Player3 calls $2
|
||||
*** 5TH STREET ***
|
||||
Dealt to Player12 [As 5d] [4c]
|
||||
Dealt to Player3 [2d 3h] [5s]
|
||||
Player12 bets $4
|
||||
Player3 folds
|
||||
Uncalled bet of $4 returned to Player12
|
||||
Player12 mucks
|
||||
Player12 wins the pot ($13.20)
|
||||
*** SUMMARY ***
|
||||
Total pot $13.20 | Rake $0
|
||||
Seat 1: Player12 collected ($13.20), mucked
|
||||
Seat 2: Player9 folded on 3rd St.
|
||||
Seat 3: Player1 folded on 4th St.
|
||||
Seat 4: Player3 folded on 5th St.
|
||||
Seat 5: Player8 folded on 3rd St.
|
||||
Seat 6: Player14 folded on 3rd St.
|
||||
Seat 7: Player6 folded on 3rd St.
|
||||
Seat 8: Player7 folded on 3rd St.
|
||||
|
||||
|
||||
|
||||
Full Tilt Poker Game #11111115744: Table Fpdb - $2/$4 Ante $0.40 - Limit Stud Hi - 14:02:17 ET - 2010/06/10
|
||||
Seat 2: Player0 ($60)
|
||||
Seat 3: Player1 ($129.30)
|
||||
Seat 4: Player3 ($125.75)
|
||||
Seat 5: Player8 ($40.10)
|
||||
Seat 7: Player6 ($72)
|
||||
Seat 8: Player7 ($32.20)
|
||||
Player0 antes $0.40
|
||||
Player8 antes $0.40
|
||||
Player7 antes $0.40
|
||||
Player1 antes $0.40
|
||||
Player3 antes $0.40
|
||||
Player6 antes $0.40
|
||||
*** 3RD STREET ***
|
||||
Dealt to Player0 [Th]
|
||||
Dealt to Player1 [9s Qc] [7d]
|
||||
Dealt to Player3 [Qh]
|
||||
Dealt to Player8 [Kd]
|
||||
Dealt to Player6 [Jd]
|
||||
Dealt to Player7 [Jh]
|
||||
Player1 is low with [7d]
|
||||
Player1 brings in for $0.50
|
||||
Player3 folds
|
||||
Player8 folds
|
||||
Player6 folds
|
||||
Player7 completes it to $2
|
||||
Player0 calls $2
|
||||
Player1 folds
|
||||
*** 4TH STREET ***
|
||||
Dealt to Player0 [Th] [As]
|
||||
Dealt to Player7 [Jh] [8c]
|
||||
Player0 bets $2
|
||||
Player7 calls $2
|
||||
*** 5TH STREET ***
|
||||
Dealt to Player0 [Th As] [Kh]
|
||||
Dealt to Player7 [Jh 8c] [2s]
|
||||
Player0 checks
|
||||
Player7 checks
|
||||
*** 6TH STREET ***
|
||||
Dealt to Player0 [Th As Kh] [7h]
|
||||
Dealt to Player7 [Jh 8c 2s] [9h]
|
||||
Player0 bets $4
|
||||
Player7 folds
|
||||
Uncalled bet of $4 returned to Player0
|
||||
Player0 mucks
|
||||
Player0 wins the pot ($10.90)
|
||||
*** SUMMARY ***
|
||||
Total pot $10.90 | Rake $0
|
||||
Seat 2: Player0 collected ($10.90), mucked
|
||||
Seat 3: Player1 folded on 3rd St.
|
||||
Seat 4: Player3 folded on 3rd St.
|
||||
Seat 5: Player8 folded on 3rd St.
|
||||
Seat 7: Player6 folded on 3rd St.
|
||||
Seat 8: Player7 folded on 6th St.
|
||||
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,137 @@
|
|||
PokerStars Game #14732633821: Hold'em No Limit ($0.25/$0.50 USD) - 2010/05/23 22:39:16 WET [2010/05/23 17:39:16 ET]
|
||||
Table '99999999 II' 2-max Seat #1 is the button
|
||||
Seat 1: Player0 ($20 in chips)
|
||||
Seat 2: Player1 ($50.50 in chips)
|
||||
Player0: posts small blind $0.25
|
||||
Player1: posts big blind $0.50
|
||||
*** HOLE CARDS ***
|
||||
Dealt to Player0 [2h Th]
|
||||
Player0: calls $0.25
|
||||
Player1: checks
|
||||
*** FLOP *** [4c 8c Ac]
|
||||
Player1: checks
|
||||
Player0: checks
|
||||
*** TURN *** [4c 8c Ac] [7s]
|
||||
Player1: checks
|
||||
Player0: bets $1
|
||||
Player1: folds
|
||||
Uncalled bet ($1) returned to Player0
|
||||
Player0 collected $0.95 from pot
|
||||
Player0: doesn't show hand
|
||||
*** SUMMARY ***
|
||||
Total pot $1 | Rake $0.05
|
||||
Board [4c 8c Ac 7s]
|
||||
Seat 1: Player0 (button) (small blind) collected ($0.95)
|
||||
Seat 2: Player1 (big blind) folded on the Turn
|
||||
|
||||
|
||||
|
||||
PokerStars Game #28140199921: Hold'em No Limit ($0.25/$0.50 USD) - 2010/05/23 22:39:59 WET [2010/05/23 17:39:59 ET]
|
||||
Table '99999999 II' 2-max Seat #2 is the button
|
||||
Seat 1: Player0 ($20.45 in chips)
|
||||
Seat 2: Player1 ($50 in chips)
|
||||
Player1: posts small blind $0.25
|
||||
Player0: posts big blind $0.50
|
||||
*** HOLE CARDS ***
|
||||
Dealt to Player0 [7h Kh]
|
||||
Player1: raises $1 to $1.50
|
||||
Player0: folds
|
||||
Uncalled bet ($1) returned to Player1
|
||||
Player1 collected $1 from pot
|
||||
Player1: doesn't show hand
|
||||
*** SUMMARY ***
|
||||
Total pot $1 | Rake $0
|
||||
Seat 1: Player0 (big blind) folded before Flop
|
||||
Seat 2: Player1 (button) (small blind) collected ($1)
|
||||
|
||||
|
||||
|
||||
PokerStars Game #29402240709: Hold'em No Limit ($0.25/$0.50 USD) - 2010/05/23 22:40:22 WET [2010/05/23 17:40:22 ET]
|
||||
Table '99999999 II' 2-max Seat #1 is the button
|
||||
Seat 1: Player0 ($19.95 in chips)
|
||||
Seat 2: Player1 ($50.50 in chips)
|
||||
Player0: posts small blind $0.25
|
||||
Player1: posts big blind $0.50
|
||||
*** HOLE CARDS ***
|
||||
Dealt to Player0 [5c 8c]
|
||||
Player0: folds
|
||||
Uncalled bet ($0.25) returned to Player1
|
||||
Player1 collected $0.50 from pot
|
||||
Player1: doesn't show hand
|
||||
*** SUMMARY ***
|
||||
Total pot $0.50 | Rake $0
|
||||
Seat 1: Player0 (button) (small blind) folded before Flop
|
||||
Seat 2: Player1 (big blind) collected ($0.50)
|
||||
|
||||
|
||||
|
||||
PokerStars Game #31842149327: Hold'em No Limit ($0.25/$0.50 USD) - 2010/05/23 22:40:29 WET [2010/05/23 17:40:29 ET]
|
||||
Table '99999999 II' 2-max Seat #2 is the button
|
||||
Seat 1: Player0 ($19.70 in chips)
|
||||
Seat 2: Player1 ($50.75 in chips)
|
||||
Player1: posts small blind $0.25
|
||||
Player0: posts big blind $0.50
|
||||
*** HOLE CARDS ***
|
||||
Dealt to Player0 [Ks 9c]
|
||||
Player1: raises $1 to $1.50
|
||||
Player0: calls $1
|
||||
*** FLOP *** [3d As 4s]
|
||||
Player0: checks
|
||||
Player1: bets $2
|
||||
Player0: calls $2
|
||||
*** TURN *** [3d As 4s] [Jd]
|
||||
Player0: checks
|
||||
Player1: checks
|
||||
*** RIVER *** [3d As 4s Jd] [3h]
|
||||
Player0: checks
|
||||
Player1: checks
|
||||
*** SHOW DOWN ***
|
||||
Player0: shows [Ks 9c] (a pair of Threes)
|
||||
Player1: mucks hand
|
||||
Player0 collected $6.70 from pot
|
||||
*** SUMMARY ***
|
||||
Total pot $7 | Rake $0.30
|
||||
Board [3d As 4s Jd 3h]
|
||||
Seat 1: Player0 (big blind) showed [Ks 9c] and won ($6.70) with a pair of Threes
|
||||
Seat 2: Player1 (button) (small blind) mucked [6c 5s]
|
||||
|
||||
|
||||
|
||||
PokerStars Game #10697227103: Hold'em No Limit ($0.25/$0.50 USD) - 2010/05/23 22:41:10 WET [2010/05/23 17:41:10 ET]
|
||||
Table '99999999 II' 2-max Seat #1 is the button
|
||||
Seat 1: Player0 ($22.90 in chips)
|
||||
Seat 2: Player1 ($50 in chips)
|
||||
Player0: posts small blind $0.25
|
||||
Player1: posts big blind $0.50
|
||||
*** HOLE CARDS ***
|
||||
Dealt to Player0 [Ts 3d]
|
||||
Player0: folds
|
||||
Uncalled bet ($0.25) returned to Player1
|
||||
Player1 collected $0.50 from pot
|
||||
Player1: doesn't show hand
|
||||
*** SUMMARY ***
|
||||
Total pot $0.50 | Rake $0
|
||||
Seat 1: Player0 (button) (small blind) folded before Flop
|
||||
Seat 2: Player1 (big blind) collected ($0.50)
|
||||
|
||||
|
||||
|
||||
PokerStars Game #27159326072: Hold'em No Limit ($0.25/$0.50 USD) - 2010/05/23 22:41:17 WET [2010/05/23 17:41:17 ET]
|
||||
Table '99999999 II' 2-max Seat #2 is the button
|
||||
Seat 1: Player0 ($22.65 in chips)
|
||||
Seat 2: Player1 ($50.25 in chips)
|
||||
Player1: posts small blind $0.25
|
||||
Player0: posts big blind $0.50
|
||||
*** HOLE CARDS ***
|
||||
Dealt to Player0 [4h Ks]
|
||||
Player1: raises $1 to $1.50
|
||||
Player0: folds
|
||||
Uncalled bet ($1) returned to Player1
|
||||
Player1 collected $1 from pot
|
||||
Player1: doesn't show hand
|
||||
*** SUMMARY ***
|
||||
Total pot $1 | Rake $0
|
||||
Seat 1: Player0 (big blind) folded before Flop
|
||||
Seat 2: Player1 (button) (small blind) collected ($1)
|
||||
|
||||
|
|
@ -0,0 +1,49 @@
|
|||
PokerStars Game #42738187409: Hold'em No Limit ($0.01/$0.02 USD) - 2010/04/16 11:14:06 WET [2010/04/16 6:14:06 ET]
|
||||
Table 'Circinus V' 9-max Seat #4 is the button
|
||||
Seat 1: Player2 ($4.26 in chips)
|
||||
Seat 2: Player1 ($0.35 in chips)
|
||||
Seat 3: Player7 ($8.34 in chips)
|
||||
Seat 4: Player5 ($3.70 in chips)
|
||||
Seat 5: Player6 ($4.98 in chips)
|
||||
Seat 7: Player3 ($2.55 in chips)
|
||||
Seat 8: Player0 ($4.91 in chips)
|
||||
Seat 9: Player4 ($1.31 in chips)
|
||||
Player6: posts small blind $0.01
|
||||
Alehta: is sitting out
|
||||
Player3: posts big blind $0.02
|
||||
*** HOLE CARDS ***
|
||||
Dealt to Player1 [3d Ks]
|
||||
Alehta leaves the table
|
||||
Player0: calls $0.02
|
||||
Player4: raises $0.06 to $0.08
|
||||
Player2: raises $0.16 to $0.24
|
||||
AFMAT joins the table at seat #6
|
||||
Player1: folds
|
||||
Player7: folds
|
||||
Player5: folds
|
||||
Player6: folds
|
||||
Player3: folds
|
||||
Player0: calls $0.22
|
||||
Player4: raises $1.07 to $1.31 and is all-in
|
||||
Player2: calls $1.07
|
||||
Player0: folds
|
||||
*** FLOP *** [7c Ac 6s]
|
||||
*** TURN *** [7c Ac 6s] [5d]
|
||||
*** RIVER *** [7c Ac 6s 5d] [Qh]
|
||||
*** SHOW DOWN ***
|
||||
Player4: shows [As Qs] (two pair, Aces and Queens)
|
||||
Player2: shows [Jc Jd] (a pair of Jacks)
|
||||
Player4 collected $2.79 from pot
|
||||
*** SUMMARY ***
|
||||
Total pot $2.89 | Rake $0.10
|
||||
Board [7c Ac 6s 5d Qh]
|
||||
Seat 1: Player2 showed [Jc Jd] and lost with a pair of Jacks
|
||||
Seat 2: Player1 folded before Flop (didn't bet)
|
||||
Seat 3: Player7 folded before Flop (didn't bet)
|
||||
Seat 4: Player5 (button) folded before Flop (didn't bet)
|
||||
Seat 5: Player6 (small blind) folded before Flop
|
||||
Seat 7: Player3 (big blind) folded before Flop
|
||||
Seat 8: Player0 folded before Flop
|
||||
Seat 9: Player4 showed [As Qs] and won ($2.79) with two pair, Aces and Queens
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,45 @@
|
|||
PokerStars Game #24782122321: Hold'em No Limit ($0.01/$0.02 USD) - 2010/06/06 22:24:02 WET [2010/06/06 17:24:02 ET]
|
||||
Table '999999999' 9-max Seat #1 is the button
|
||||
Seat 1: Player2 ($0.88 in chips)
|
||||
Seat 2: Player0 ($1.61 in chips)
|
||||
Seat 3: Player5 ($5.27 in chips)
|
||||
Seat 5: Player1 ($2.15 in chips)
|
||||
Seat 6: Player3 ($2.55 in chips)
|
||||
Seat 7: Player6 ($2.90 in chips)
|
||||
Seat 9: Player4 ($1.93 in chips)
|
||||
Player0: posts small blind $0.01
|
||||
Player5: posts big blind $0.02
|
||||
*** HOLE CARDS ***
|
||||
Dealt to Player0 [Td Qc]
|
||||
Player1: folds
|
||||
Player3: calls $0.02
|
||||
Player3 said, "":D""
|
||||
Player6: folds
|
||||
Player4: folds
|
||||
Player2 has timed out
|
||||
Player2: folds
|
||||
Player0: calls $0.01
|
||||
Player5: checks
|
||||
*** FLOP *** [7d 2s Jc]
|
||||
Player0: checks
|
||||
Player5: checks
|
||||
Player3: checks
|
||||
*** TURN *** [7d 2s Jc] [2h]
|
||||
Player0: folds
|
||||
Player5: bets $0.06
|
||||
Player3: folds
|
||||
Uncalled bet ($0.06) returned to Player5
|
||||
Player5 collected $0.06 from pot
|
||||
Player5: doesn't show hand
|
||||
*** SUMMARY ***
|
||||
Total pot $0.06 | Rake $0
|
||||
Board [7d 2s Jc 2h]
|
||||
Seat 1: Player2 (button) folded before Flop (didn't bet)
|
||||
Seat 2: Player0 (small blind) folded on the Turn
|
||||
Seat 3: Player5 (big blind) collected ($0.06)
|
||||
Seat 5: Player1 folded before Flop (didn't bet)
|
||||
Seat 6: Player3 folded on the Turn
|
||||
Seat 7: Player6 folded before Flop (didn't bet)
|
||||
Seat 9: Player4 folded before Flop (didn't bet)
|
||||
|
||||
|
|
@ -0,0 +1,33 @@
|
|||
PokerStars Game #42875758685: Hold'em No Limit ($0.05/$0.10 USD) - 2010/04/19 0:19:11 WET [2010/04/18 19:19:11 ET]
|
||||
Table 'gimick VI' 9-max Seat #4 is the button
|
||||
Seat 3: Player1 ($5.55 in chips)
|
||||
Seat 4: Player0 ($2.40 in chips)
|
||||
Seat 8: Player2 ($3.90 in chips)
|
||||
Player2: posts small blind $0.05
|
||||
Player1: posts big blind $0.10
|
||||
*** HOLE CARDS ***
|
||||
Dealt to Player0 [7d 8d]
|
||||
Player0: raises $0.30 to $0.40
|
||||
Player2: calls $0.35
|
||||
Player1: folds
|
||||
*** FLOP *** [2h 2d Qd]
|
||||
Player2: checks
|
||||
Player0: bets $0.60
|
||||
Player2: raises $0.60 to $1.20
|
||||
Player0: calls $0.60
|
||||
*** TURN *** [2h 2d Qd] [5d]
|
||||
Player2: bets $0.90
|
||||
Player0: calls $0.80 and is all-in
|
||||
Uncalled bet ($0.10) returned to Player2
|
||||
*** RIVER *** [2h 2d Qd 5d] [4d]
|
||||
*** SHOW DOWN ***
|
||||
Player2: shows [9d As] (a flush, Queen high)
|
||||
Player0: shows [7d 8d] (a flush, Queen high - lower cards)
|
||||
Player2 collected $4.70 from pot
|
||||
*** SUMMARY ***
|
||||
Total pot $4.90 | Rake $0.20
|
||||
Board [2h 2d Qd 5d 4d]
|
||||
Seat 3: Player1 (big blind) folded before Flop
|
||||
Seat 4: Player0 (button) showed [7d 8d] and lost with a flush, Queen high
|
||||
Seat 8: Player2 (small blind) showed [9d As] and won ($4.70) with a flush, Queen high
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user