Merge branch 'master' of git://git.assembla.com/fpdb.git
This commit is contained in:
commit
978464e7c6
|
@ -1,3 +1,16 @@
|
|||
free-poker-tools (0.20.906-1) unstable; urgency=low
|
||||
|
||||
* New snapshot
|
||||
|
||||
-- Mika Bostrom <bostik@iki.fi> Fri, 27 Aug 2010 08:26:05 +0300
|
||||
|
||||
free-poker-tools (0.20.905-1) unstable; urgency=low
|
||||
|
||||
* New snapshot
|
||||
* Hungarian translation
|
||||
|
||||
-- Mika Bostrom <bostik@iki.fi> Wed, 25 Aug 2010 10:05:36 +0300
|
||||
|
||||
free-poker-tools (0.20.904-2) unstable; urgency=low
|
||||
|
||||
* On fpdb start, copy example HUD_config.xml in place if none is present
|
||||
|
|
|
@ -26,8 +26,7 @@ install: build
|
|||
# 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/py2exe_setup.py
|
||||
rm debian/$(PACKAGE)/usr/lib/python2.6/site-packages/fpdb/windows_make_bats.py
|
||||
|
||||
|
||||
binary-indep: build install
|
||||
|
|
|
@ -2,6 +2,19 @@
|
|||
# Distributed under the terms of the GNU General Public License v2
|
||||
# created by Steffen Schaumburg, steffen@schaumburger.info
|
||||
|
||||
29 Aug 2010; Erki Ferenc <erkiferenc@gmail.com>
|
||||
fpdb-0.20.906.ebuild, fpdb-9999.ebuild:
|
||||
improve l10n handling
|
||||
|
||||
29 Aug 2010; Steffen Schaumburg <steffen@schaumburger.info>
|
||||
fpdb-0.20.1.ebuild, fpdb-0.20.906.ebuild, fpdb-9999.ebuild:
|
||||
change required python version to 2.6
|
||||
|
||||
*fpdb-0.20.906 (29 Aug 2010)
|
||||
29 Aug 2010; Steffen Schaumburg <steffen@schaumburger.info>
|
||||
+fpdb-0.20.906.ebuild -fpdb-0.20.904.ebuild:
|
||||
Bump version
|
||||
|
||||
*fpdb-0.20.1 fpdb-0.20.904 fpdb-9999 (17 Aug 2010)
|
||||
|
||||
17 Aug 2010; Steffen Schaumburg <steffen@schaumburger.info>
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
DIST fpdb-0.20.1.tar.bz2 662807 RMD160 b5f22a684c605ddbba7d2154005a822b02a19490 SHA1 e4cc40de5849d3ae33a680d917b340ab37c6448b SHA256 46eff0625f300c070ce88c519ae6019f6e1c98a7725733c5e16b50a058247fe3
|
||||
DIST fpdb-0.20.904.tar.bz2 632871 RMD160 6af83a9b30e8b3f394b011a4dc92937f130b9e15 SHA1 083c51f1627f901e24801bf6abebf1d07646bd89 SHA256 5e72055fe7ebb0c6048282f8edc972ee01be21063d6f8071abef22111f3e82f9
|
||||
EBUILD fpdb-0.20.1.ebuild 1591 RMD160 56ccbca72353e56718a927178e58d148177f5846 SHA1 770df692b29b7314d70703010e1f6afac623c3f3 SHA256 e3f434df58d98760a118458166f9fdfcf3612712c78c704f089f6e8ec72bd224
|
||||
EBUILD fpdb-0.20.904.ebuild 1595 RMD160 b5cbcdb8d2984b149c833db8b6aee362168e9c7d SHA1 7151fd3cef087c38060b44adb622843a84209f33 SHA256 41c6ed71aa0ff727d670c94cc72cf595bcd038f601121e51222532df727a6d01
|
||||
EBUILD fpdb-9999.ebuild 1618 RMD160 843d309bbc2ccdd95dbb4b0eb08571d8e16d06ad SHA1 b1ebdbe0e40bd6c0d4ec417dd2b8a135884547a6 SHA256 72205c1f94bcf2c3f310d396928e357fabaee4861773044c1dac71f98f6596bf
|
||||
MISC ChangeLog 395 RMD160 b195ccf198011356ca79b16071093c4d92e5927a SHA1 9aa56e5dc9c5d03b62fb60bc81069f3440b1f606 SHA256 b7ba8c180da0e6a405d939c4485f9c8e52fdcafb04207ef6de217a807015bd03
|
||||
DIST fpdb-0.20.906.tar.bz2 702558 RMD160 bc5d01ef4899502aea33f286ac4274ef7ef498ef SHA1 9791680d53de1b276dc0297ac43a0e11758d3e19 SHA256 9ae706d5e9c2a2ee031d2b222ba46e088993cc892fc08b5276bbfd5e44a0436b
|
||||
EBUILD fpdb-0.20.1.ebuild 1508 RMD160 7585cd1de73172649e182782d427a476afed4036 SHA1 3c92d6dbb868b8b4c26b75539771641087742761 SHA256 9a7d302016e4c4d6cc18af14514bd5112d18aeb7dc6390a3413e3e4cc71da6bd
|
||||
EBUILD fpdb-0.20.906.ebuild 1643 RMD160 ed44ee49d715458b54edbbe054eb5c9775c6ac7a SHA1 ebd8ea291ace0671d4eb264754dfb0616373a51a SHA256 a9bdad768a0ab5ef065f3e6e2e1bd89dded6e0d3b64c4771944c4aae7d163efd
|
||||
EBUILD fpdb-9999.ebuild 1685 RMD160 f06457ead33dca99c0acf830f26bbf2f8ca12cd1 SHA1 70444fa4a88439955472407ec0b072970993631a SHA256 2df59120b376bb4e5966f8a719bc881c756b3210b7a30d394ee1753efbfd706e
|
||||
MISC ChangeLog 831 RMD160 efd32886d09b0750e680716030c0034c3a280a25 SHA1 82f3eda3cd83cbba3e45d4b75593e74f3dd4f568 SHA256 d74efef05cf51ef3840ef043218c8a30c1bcccfa9d9d2e4ca1b7198ed1c91f29
|
||||
MISC metadata.xml 550 RMD160 a6fa8799f644c0882f832a12cc9e6a0f4f09ae7f SHA1 3a40c442cadb1f532e0299040c2da79e9721dd4f SHA256 b5a1c538de3786446a87479b1023cdb4f084085feb7290959619739969ce7d3b
|
||||
|
|
|
@ -4,10 +4,7 @@
|
|||
|
||||
EAPI="2"
|
||||
|
||||
inherit eutils
|
||||
inherit games
|
||||
|
||||
NEED_PYTHON=2.5
|
||||
inherit eutils games
|
||||
|
||||
DESCRIPTION="A free/open source tracker/HUD for use with online poker"
|
||||
HOMEPAGE="http://fpdb.wiki.sourceforge.net/"
|
||||
|
@ -49,7 +46,7 @@ src_install() {
|
|||
newicon gfx/fpdb-icon.png ${PN}.png
|
||||
make_desktop_entry ${PN}
|
||||
|
||||
chmod +x "${D}/${GAMES_DATADIR}"/${PN}/pyfpdb/*.pyw
|
||||
fperms +x "${GAMES_DATADIR}"/${PN}/pyfpdb/*.pyw
|
||||
prepgamesdirs
|
||||
}
|
||||
|
||||
|
|
|
@ -4,10 +4,7 @@
|
|||
|
||||
EAPI="2"
|
||||
|
||||
inherit eutils
|
||||
inherit games
|
||||
|
||||
NEED_PYTHON=2.5
|
||||
inherit eutils games
|
||||
|
||||
DESCRIPTION="A free/open source tracker/HUD for use with online poker"
|
||||
HOMEPAGE="http://fpdb.wiki.sourceforge.net/"
|
||||
|
@ -18,7 +15,7 @@ SLOT="0"
|
|||
KEYWORDS="~amd64 ~x86"
|
||||
#note: this should work on other architectures too, please send me your experiences
|
||||
|
||||
IUSE="graph mysql postgres sqlite linguas_hu linguas_it"
|
||||
IUSE="graph mysql postgres sqlite linguas_hu"
|
||||
RDEPEND="
|
||||
mysql? ( virtual/mysql
|
||||
dev-python/mysql-python )
|
||||
|
@ -36,29 +33,27 @@ DEPEND="${RDEPEND}"
|
|||
|
||||
src_install() {
|
||||
insinto "${GAMES_DATADIR}"/${PN}
|
||||
doins -r gfx
|
||||
doins -r pyfpdb
|
||||
doins -r gfx || die "failed to install gfx directory"
|
||||
doins -r pyfpdb || die "failed to install pyfpdb directory"
|
||||
|
||||
if use linguas_hu; then
|
||||
dosym "${GAMES_DATADIR}"/${PN}/pyfpdb/locale/hu/LC_MESSAGES/${PN}.mo /usr/share/locale/hu/LC_MESSAGES/${PN}.mo
|
||||
msgfmt pyfpdb/locale/fpdb-hu_HU.po -o pyfpdb/locale/hu.mo || die "failed to create hungarian mo file"
|
||||
fi
|
||||
|
||||
if use linguas_it; then
|
||||
dosym "${GAMES_DATADIR}"/${PN}/pyfpdb/locale/it/LC_MESSAGES/${PN}.mo /usr/share/locale/it/LC_MESSAGES/${PN}.mo
|
||||
fi
|
||||
domo pyfpdb/locale/*.mo || die "failed to install mo files"
|
||||
|
||||
doins readme.txt
|
||||
doins readme.txt || die "failed to install readme.txt file"
|
||||
|
||||
exeinto "${GAMES_DATADIR}"/${PN}
|
||||
doexe run_fpdb.py
|
||||
doexe run_fpdb.py || die "failed to install executable run_fpdb.py"
|
||||
|
||||
dodir "${GAMES_BINDIR}"
|
||||
dosym "${GAMES_DATADIR}"/${PN}/run_fpdb.py "${GAMES_BINDIR}"/${PN}
|
||||
dosym "${GAMES_DATADIR}"/${PN}/run_fpdb.py "${GAMES_BINDIR}"/${PN} || die "failed to create symlink for starting fpdb"
|
||||
|
||||
newicon gfx/fpdb-icon.png ${PN}.png
|
||||
make_desktop_entry ${PN}
|
||||
newicon gfx/fpdb-icon.png ${PN}.png || die "failed to install fpdb icon"
|
||||
make_desktop_entry ${PN} || die "failed to create desktop entry"
|
||||
|
||||
chmod +x "${D}/${GAMES_DATADIR}"/${PN}/pyfpdb/*.pyw
|
||||
fperms +x "${GAMES_DATADIR}"/${PN}/pyfpdb/*.pyw
|
||||
prepgamesdirs
|
||||
}
|
||||
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
Repoman currently gives the following errors for our ebuilds:
|
||||
ebuild.allmasked: This error can be ignored, as all our packages are supposed to be masked
|
||||
ebuild.badheader 3
|
||||
games-util/fpdb/fpdb-0.20.1.ebuild: Malformed CVS Header on line: 3
|
||||
games-util/fpdb/fpdb-0.20.904.ebuild: Malformed CVS Header on line: 3
|
||||
games-util/fpdb/fpdb-9999.ebuild: Malformed CVS Header on line: 3
|
||||
not sure what the correct header is for a sunrise ebuild so leaving as-is for now
|
||||
|
||||
Useful Links:
|
||||
http://overlays.gentoo.org/proj/sunrise/wiki/SunriseFaq
|
||||
|
|
|
@ -4,11 +4,7 @@
|
|||
|
||||
EAPI="2"
|
||||
|
||||
inherit eutils
|
||||
inherit games
|
||||
inherit git
|
||||
|
||||
NEED_PYTHON=2.5
|
||||
inherit eutils games git
|
||||
|
||||
DESCRIPTION="A free/open source tracker/HUD for use with online poker"
|
||||
HOMEPAGE="http://fpdb.wiki.sourceforge.net/"
|
||||
|
@ -17,9 +13,8 @@ EGIT_REPO_URI="git://git.assembla.com/fpdb.git"
|
|||
LICENSE="AGPL-3"
|
||||
SLOT="0"
|
||||
KEYWORDS=""
|
||||
#note: this should work on other architectures too, please send me your experiences
|
||||
|
||||
IUSE="graph mysql postgres sqlite linguas_hu linguas_it"
|
||||
IUSE="graph mysql postgres sqlite linguas_de linguas_hu"
|
||||
RDEPEND="
|
||||
mysql? ( virtual/mysql
|
||||
dev-python/mysql-python )
|
||||
|
@ -44,14 +39,16 @@ src_install() {
|
|||
doins -r gfx
|
||||
doins -r pyfpdb
|
||||
|
||||
if use linguas_hu; then
|
||||
dosym "${GAMES_DATADIR}"/${PN}/pyfpdb/locale/hu/LC_MESSAGES/${PN}.mo /usr/share/locale/hu/LC_MESSAGES/${PN}.mo
|
||||
if use linguas_de; then
|
||||
msgfmt pyfpdb/locale/fpdb-de_DE.po -o pyfpdb/locale/de.mo
|
||||
fi
|
||||
|
||||
if use linguas_it; then
|
||||
dosym "${GAMES_DATADIR}"/${PN}/pyfpdb/locale/it/LC_MESSAGES/${PN}.mo /usr/share/locale/it/LC_MESSAGES/${PN}.mo
|
||||
if use linguas_hu; then
|
||||
msgfmt pyfpdb/locale/fpdb-hu_HU.po -o pyfpdb/locale/hu.mo
|
||||
fi
|
||||
|
||||
domo pyfpdb/locale/*.mo
|
||||
|
||||
doins readme.txt
|
||||
|
||||
exeinto "${GAMES_DATADIR}"/${PN}
|
||||
|
@ -63,7 +60,7 @@ src_install() {
|
|||
newicon gfx/fpdb-icon.png ${PN}.png
|
||||
make_desktop_entry ${PN}
|
||||
|
||||
chmod +x "${D}/${GAMES_DATADIR}"/${PN}/pyfpdb/*.pyw
|
||||
fperms +x "${GAMES_DATADIR}"/${PN}/pyfpdb/*.pyw
|
||||
prepgamesdirs
|
||||
}
|
||||
|
||||
|
|
|
@ -164,7 +164,7 @@ class Absolute(HandHistoryConverter):
|
|||
def readHandInfo(self, hand):
|
||||
m = self.re_HandInfo.search(hand.handText)
|
||||
if(m == None):
|
||||
logging.info("Didn't match re_HandInfo")
|
||||
logging.info(_("Didn't match re_HandInfo"))
|
||||
logging.info(hand.handText)
|
||||
return None
|
||||
logging.debug("HID %s, Table %s" % (m.group('HID'), m.group('TABLE')))
|
||||
|
@ -221,7 +221,7 @@ class Absolute(HandHistoryConverter):
|
|||
hand.setCommunityCards(street=street, cards=cards)
|
||||
|
||||
def readAntes(self, hand):
|
||||
logging.debug("reading antes")
|
||||
logging.debug(_("reading antes"))
|
||||
m = self.re_Antes.finditer(hand.handText)
|
||||
for player in m:
|
||||
logging.debug("hand.addAnte(%s,%s)" %(player.group('PNAME'), player.group('ANTE')))
|
||||
|
@ -230,17 +230,17 @@ class Absolute(HandHistoryConverter):
|
|||
def readBringIn(self, hand):
|
||||
m = self.re_BringIn.search(hand.handText,re.DOTALL)
|
||||
if m:
|
||||
logging.debug("Player bringing in: %s for %s" %(m.group('PNAME'), m.group('BRINGIN')))
|
||||
logging.debug(_("Player bringing in: %s for %s" %(m.group('PNAME'), m.group('BRINGIN'))))
|
||||
hand.addBringIn(m.group('PNAME'), m.group('BRINGIN'))
|
||||
else:
|
||||
logging.warning("No bringin found.")
|
||||
logging.warning(_("No bringin found."))
|
||||
|
||||
def readBlinds(self, hand):
|
||||
m = self.re_PostSB.search(hand.handText)
|
||||
if m is not None:
|
||||
hand.addBlind(m.group('PNAME'), 'small blind', m.group('SB'))
|
||||
else:
|
||||
logging.debug("No small blind")
|
||||
logging.debug(_("No small blind"))
|
||||
hand.addBlind(None, None, None)
|
||||
for a in self.re_PostBB.finditer(hand.handText):
|
||||
hand.addBlind(a.group('PNAME'), 'big blind', a.group('BB'))
|
||||
|
@ -267,7 +267,7 @@ class Absolute(HandHistoryConverter):
|
|||
|
||||
def readStudPlayerCards(self, hand, street):
|
||||
# lol. see Plymouth.txt
|
||||
logging.warning("Absolute readStudPlayerCards is only a stub.")
|
||||
logging.warning(_("Absolute readStudPlayerCards is only a stub."))
|
||||
#~ if street in ('THIRD', 'FOURTH', 'FIFTH', 'SIXTH'):
|
||||
#~ hand.addPlayerCards(player = player.group('PNAME'), street = street, closed = [], open = [])
|
||||
|
||||
|
@ -290,7 +290,7 @@ class Absolute(HandHistoryConverter):
|
|||
elif action.group('ATYPE') == ' complete to': # TODO: not supported yet ?
|
||||
hand.addComplete( street, action.group('PNAME'), action.group('BET'))
|
||||
else:
|
||||
logging.debug("Unimplemented readAction: %s %s" %(action.group('PNAME'),action.group('ATYPE'),))
|
||||
logging.debug(_("Unimplemented readAction: %s %s" %(action.group('PNAME'),action.group('ATYPE'),)))
|
||||
|
||||
|
||||
def readShowdownActions(self, hand):
|
||||
|
@ -334,9 +334,9 @@ if __name__ == "__main__":
|
|||
config = Configuration.Config(None)
|
||||
|
||||
parser = OptionParser()
|
||||
parser.add_option("-i", "--input", dest="ipath", help="parse input hand history", default="-")
|
||||
parser.add_option("-o", "--output", dest="opath", help="output translation to", default="-")
|
||||
parser.add_option("-f", "--follow", dest="follow", help="follow (tail -f) the input", action="store_true", default=False)
|
||||
parser.add_option("-i", "--input", dest="ipath", help=_("parse input hand history"), default="-")
|
||||
parser.add_option("-o", "--output", dest="opath", help=_("output translation to"), default="-")
|
||||
parser.add_option("-f", "--follow", dest="follow", help=_("follow (tail -f) the input"), action="store_true", default=False)
|
||||
parser.add_option("-q", "--quiet",
|
||||
action="store_const", const=logging.CRITICAL, dest="verbosity", default=logging.INFO)
|
||||
parser.add_option("-v", "--verbose",
|
||||
|
|
|
@ -127,7 +127,7 @@ class Betfair(HandHistoryConverter):
|
|||
|
||||
#Shouldn't really dip into the Hand object, but i've no idea how to tell the length of iter m
|
||||
if len(hand.players) < 2:
|
||||
logging.info("readPlayerStacks: Less than 2 players found in a hand")
|
||||
logging.info(_("readPlayerStacks: Less than 2 players found in a hand"))
|
||||
|
||||
def markStreets(self, hand):
|
||||
m = re.search(r"\*\* Dealing down cards \*\*(?P<PREFLOP>.+(?=\*\* Dealing Flop \*\*)|.+)"
|
||||
|
@ -164,7 +164,7 @@ class Betfair(HandHistoryConverter):
|
|||
def readBringIn(self, hand):
|
||||
m = self.re_BringIn.search(hand.handText,re.DOTALL)
|
||||
if m:
|
||||
logging.debug("Player bringing in: %s for %s" %(m.group('PNAME'), m.group('BRINGIN')))
|
||||
logging.debug(_("Player bringing in: %s for %s" %(m.group('PNAME'), m.group('BRINGIN'))))
|
||||
hand.addBringIn(m.group('PNAME'), m.group('BRINGIN'))
|
||||
else:
|
||||
logging.warning(_("No bringin found"))
|
||||
|
|
|
@ -148,7 +148,7 @@ or None if we fail to get the info """
|
|||
def readHandInfo(self, hand):
|
||||
m = self.re_HandInfo.search(hand.handText)
|
||||
if m is None:
|
||||
logging.info("Didn't match re_HandInfo")
|
||||
logging.info(_("Didn't match re_HandInfo"))
|
||||
logging.info(hand.handText)
|
||||
return None
|
||||
logging.debug("HID %s-%s, Table %s" % (m.group('HID1'),
|
||||
|
@ -254,8 +254,8 @@ or None if we fail to get the info """
|
|||
elif action.group('ATYPE') == 'ALL_IN':
|
||||
hand.addAllIn(street, player, action.group('BET'))
|
||||
else:
|
||||
logging.debug("Unimplemented readAction: %s %s"
|
||||
% (action.group('PSEAT'),action.group('ATYPE'),))
|
||||
logging.debug(_("Unimplemented readAction: %s %s"
|
||||
% (action.group('PSEAT'),action.group('ATYPE'),)))
|
||||
|
||||
def readShowdownActions(self, hand):
|
||||
for shows in self.re_ShowdownAction.finditer(hand.handText):
|
||||
|
@ -285,9 +285,9 @@ or None if we fail to get the info """
|
|||
|
||||
if __name__ == "__main__":
|
||||
parser = OptionParser()
|
||||
parser.add_option("-i", "--input", dest="ipath", help="parse input hand history", default="-")
|
||||
parser.add_option("-o", "--output", dest="opath", help="output translation to", default="-")
|
||||
parser.add_option("-f", "--follow", dest="follow", help="follow (tail -f) the input", action="store_true", default=False)
|
||||
parser.add_option("-i", "--input", dest="ipath", help=_("parse input hand history"), default="-")
|
||||
parser.add_option("-o", "--output", dest="opath", help=_("output translation to"), default="-")
|
||||
parser.add_option("-f", "--follow", dest="follow", help=_("follow (tail -f) the input"), action="store_true", default=False)
|
||||
parser.add_option("-q", "--quiet", action="store_const", const=logging.CRITICAL, dest="verbosity", default=logging.INFO)
|
||||
parser.add_option("-v", "--verbose", action="store_const", const=logging.INFO, dest="verbosity")
|
||||
parser.add_option("--vv", action="store_const", const=logging.DEBUG, dest="verbosity")
|
||||
|
|
|
@ -82,6 +82,11 @@ def get_exec_path():
|
|||
|
||||
def get_config(file_name, fallback = True):
|
||||
"""Looks in cwd and in self.default_config_path for a config file."""
|
||||
|
||||
# look for example file even if not used here, path is returned to caller
|
||||
config_found,example_found,example_copy = False,False,False
|
||||
config_path, example_path = None,None
|
||||
|
||||
exec_dir = get_exec_path()
|
||||
if file_name == 'logging.conf' and not hasattr(sys, "frozen"):
|
||||
config_path = os.path.join(exec_dir, 'pyfpdb', file_name)
|
||||
|
@ -89,17 +94,13 @@ def get_config(file_name, fallback = True):
|
|||
config_path = os.path.join(exec_dir, file_name)
|
||||
# print "config_path=", config_path
|
||||
if os.path.exists(config_path): # there is a file in the cwd
|
||||
return (config_path,False) # so we use it
|
||||
config_found = True # so we use it
|
||||
else: # no file in the cwd, look where it should be in the first place
|
||||
default_dir = get_default_config_path()
|
||||
config_path = os.path.join(default_dir, file_name)
|
||||
# print "config path 2=", config_path
|
||||
if os.path.exists(config_path):
|
||||
return (config_path,False)
|
||||
|
||||
# No file found
|
||||
if not fallback:
|
||||
return (False,False)
|
||||
config_found = True
|
||||
|
||||
# Example configuration for debian package
|
||||
if os.name == 'posix':
|
||||
|
@ -108,38 +109,43 @@ def get_config(file_name, fallback = True):
|
|||
# the config directory for us so there's no need to check it
|
||||
# again
|
||||
example_path = '/usr/share/python-fpdb/' + file_name + '.example'
|
||||
try:
|
||||
shutil.copyfile(example_path, config_path)
|
||||
msg = _("Config file has been created at %s.\n") % config_path
|
||||
logging.info(msg)
|
||||
return (config_path,False)
|
||||
except IOError:
|
||||
pass
|
||||
if not config_found and fallback:
|
||||
try:
|
||||
shutil.copyfile(example_path, config_path)
|
||||
example_copy = True
|
||||
msg = _("Config file has been created at %s.\n") % config_path
|
||||
logging.info(msg)
|
||||
except IOError:
|
||||
pass
|
||||
|
||||
# OK, fall back to the .example file, should be in the start dir
|
||||
if os.path.exists(file_name + ".example"):
|
||||
elif os.path.exists(file_name + ".example"):
|
||||
try:
|
||||
print ""
|
||||
example_path = file_name + ".example"
|
||||
check_dir(default_dir)
|
||||
shutil.copyfile(file_name + ".example", config_path)
|
||||
msg = _("No %s found\n in %s\n or %s\n") % (file_name, exec_dir, default_dir) \
|
||||
+ _("Config file has been created at %s.\n") % config_path
|
||||
print msg
|
||||
logging.info(msg)
|
||||
file_name = config_path
|
||||
if not config_found and fallback:
|
||||
shutil.copyfile(example_path, config_path)
|
||||
example_copy = True
|
||||
msg = _("No %s found\n in %s\n or %s\n") % (file_name, exec_dir, default_dir) \
|
||||
+ _("Config file has been created at %s.\n") % config_path
|
||||
print msg
|
||||
logging.info(msg)
|
||||
except:
|
||||
print _("Error copying .example file, cannot fall back. Exiting.\n")
|
||||
sys.stderr.write(_("Error copying .example file, cannot fall back. Exiting.\n"))
|
||||
print _("Error copying .example config file, cannot fall back. Exiting.\n")
|
||||
sys.stderr.write(_("Error copying .example config file, cannot fall back. Exiting.\n"))
|
||||
sys.stderr.write( str(sys.exc_info()) )
|
||||
sys.exit()
|
||||
else:
|
||||
elif fallback:
|
||||
print _("No %s found, cannot fall back. Exiting.\n") % file_name
|
||||
sys.stderr.write(_("No %s found, cannot fall back. Exiting.\n") % file_name)
|
||||
sys.exit()
|
||||
return (file_name,True)
|
||||
|
||||
#print "get_config: returning "+str( (config_path,example_copy,example_path) )
|
||||
return (config_path,example_copy,example_path)
|
||||
|
||||
def get_logger(file_name, config = "config", fallback = False, log_dir=None, log_file=None):
|
||||
(conf_file,copied) = get_config(file_name, fallback = fallback)
|
||||
(conf_file,copied,example_file) = get_config(file_name, fallback = fallback)
|
||||
|
||||
if log_dir is None:
|
||||
log_dir = os.path.join(get_exec_path(), u'log')
|
||||
|
@ -674,7 +680,7 @@ class Config:
|
|||
sys.stderr.write(_("Configuration file %s not found. Using defaults.") % (file))
|
||||
file = None
|
||||
|
||||
if file is None: (file,self.example_copy) = get_config("HUD_config.xml", True)
|
||||
if file is None: (file,self.example_copy,example_file) = get_config("HUD_config.xml", True)
|
||||
|
||||
self.file = file
|
||||
self.dir_self = get_exec_path()
|
||||
|
@ -685,27 +691,6 @@ class Config:
|
|||
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
|
||||
# If using the example, we'll edit it later
|
||||
log.info(_("Reading configuration file %s") % file)
|
||||
print _("\nReading configuration file %s\n") % file
|
||||
try:
|
||||
doc = xml.dom.minidom.parse(file)
|
||||
self.file_error = None
|
||||
except:
|
||||
log.error(_("Error parsing %s. See error log file.") % (file))
|
||||
traceback.print_exc(file=sys.stderr)
|
||||
self.file_error = sys.exc_info()[1]
|
||||
# we could add a parameter to decide whether to return or read a line and exit?
|
||||
return
|
||||
#print "press enter to continue"
|
||||
#sys.stdin.readline()
|
||||
#sys.exit()
|
||||
#ExpatError: not well-formed (invalid token): line 511, column 4
|
||||
#sys.exc_info = (<class 'xml.parsers.expat.ExpatError'>, ExpatError('not well-formed (invalid token): line 511,
|
||||
# column 4',), <traceback object at 0x024503A0>)
|
||||
|
||||
self.doc = doc
|
||||
self.supported_sites = {}
|
||||
self.supported_games = {}
|
||||
self.supported_databases = {} # databaseName --> Database instance
|
||||
|
@ -717,6 +702,32 @@ class Config:
|
|||
self.emails = {}
|
||||
self.gui_cash_stats = GUICashStats()
|
||||
|
||||
added,n = 1,0 # use n to prevent infinite loop if add_missing_elements() fails somehow
|
||||
while added > 0 and n < 2:
|
||||
n = n + 1
|
||||
log.info(_("Reading configuration file %s") % file)
|
||||
print _("\nReading configuration file %s\n") % file
|
||||
try:
|
||||
doc = xml.dom.minidom.parse(file)
|
||||
self.doc = doc
|
||||
self.file_error = None
|
||||
except:
|
||||
log.error(_("Error parsing %s. See error log file.") % (file))
|
||||
traceback.print_exc(file=sys.stderr)
|
||||
self.file_error = sys.exc_info()[1]
|
||||
# we could add a parameter to decide whether to return or read a line and exit?
|
||||
return
|
||||
#print "press enter to continue"
|
||||
#sys.stdin.readline()
|
||||
#sys.exit()
|
||||
#ExpatError: not well-formed (invalid token): line 511, column 4
|
||||
#sys.exc_info = (<class 'xml.parsers.expat.ExpatError'>, ExpatError('not well-formed (invalid token): line 511,
|
||||
# column 4',), <traceback object at 0x024503A0>)
|
||||
|
||||
if not self.example_copy and example_file is not None:
|
||||
# reads example file and adds missing elements into current config
|
||||
added = self.add_missing_elements(doc, example_file)
|
||||
|
||||
if doc.getElementsByTagName("general") == []:
|
||||
self.general.get_defaults()
|
||||
for gen_node in doc.getElementsByTagName("general"):
|
||||
|
@ -749,6 +760,7 @@ class Config:
|
|||
raise ValueError("Database names must be unique")
|
||||
if self.db_selected is None or db.db_selected:
|
||||
self.db_selected = db.db_name
|
||||
db_node.setAttribute("default", "True")
|
||||
self.supported_databases[db.db_name] = db
|
||||
#TODO: if the user may passes '' (empty string) as database name via command line, his choice is ignored
|
||||
# ..when we parse the xml we allow for ''. there has to be a decission if to allow '' or not
|
||||
|
@ -791,7 +803,7 @@ class Config:
|
|||
self.set_db_parameters(db_name = 'fpdb', db_ip = df_parms['db-host'],
|
||||
db_user = df_parms['db-user'],
|
||||
db_pass = df_parms['db-password'])
|
||||
self.save(file=os.path.join(self.default_config_path, "HUD_config.xml"))
|
||||
self.save(file=os.path.join(self.dir_config, "HUD_config.xml"))
|
||||
|
||||
if doc.getElementsByTagName("raw_hands") == []:
|
||||
self.raw_hands = RawHands()
|
||||
|
@ -806,6 +818,40 @@ class Config:
|
|||
print ""
|
||||
#end def __init__
|
||||
|
||||
def add_missing_elements(self, doc, example_file):
|
||||
""" Look through example config file and add any elements that are not in the config
|
||||
May need to add some 'enabled' attributes to turn things off - can't just delete a
|
||||
config section now because this will add it back in"""
|
||||
|
||||
nodes_added = 0
|
||||
|
||||
try:
|
||||
example_doc = xml.dom.minidom.parse(example_file)
|
||||
except:
|
||||
log.error(_("Error parsing example file %s. See error log file.") % (example_file))
|
||||
return nodes_added
|
||||
|
||||
for cnode in doc.getElementsByTagName("FreePokerToolsConfig"):
|
||||
for example_cnode in example_doc.childNodes:
|
||||
if example_cnode.localName == "FreePokerToolsConfig":
|
||||
for e in example_cnode.childNodes:
|
||||
#print "nodetype", e.nodeType, "name", e.localName, "found", len(doc.getElementsByTagName(e.localName))
|
||||
if e.nodeType == e.ELEMENT_NODE and doc.getElementsByTagName(e.localName) == []:
|
||||
new = doc.importNode(e, True) # True means do deep copy
|
||||
t_node = self.doc.createTextNode(" ")
|
||||
cnode.appendChild(t_node)
|
||||
cnode.appendChild(new)
|
||||
t_node = self.doc.createTextNode("\r\n\r\n")
|
||||
cnode.appendChild(t_node)
|
||||
print "... adding missing config section: " + e.localName
|
||||
nodes_added = nodes_added + 1
|
||||
|
||||
if nodes_added > 0:
|
||||
print "Added %d missing config sections\n" % nodes_added
|
||||
self.save()
|
||||
|
||||
return nodes_added
|
||||
|
||||
def set_hhArchiveBase(self, path):
|
||||
self.imp.node.setAttribute("hhArchiveBase", path)
|
||||
|
||||
|
@ -1039,7 +1085,11 @@ class Config:
|
|||
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 defaultb: db_node.setAttribute("default", default)
|
||||
if defaultb or self.db_selected == db_name:
|
||||
db_node.setAttribute("default", "True")
|
||||
for dbn in self.doc.getElementsByTagName("database"):
|
||||
if dbn.getAttribute('db_name') != db_name and dbn.hasAttribute("default"):
|
||||
dbn.removeAttribute("default")
|
||||
elif db_node.hasAttribute("default"):
|
||||
db_node.removeAttribute("default")
|
||||
if self.supported_databases.has_key(db_name):
|
||||
|
@ -1052,6 +1102,64 @@ class Config:
|
|||
if defaultb:
|
||||
self.db_selected = db_name
|
||||
return
|
||||
|
||||
def add_db_parameters(self, db_name = 'fpdb', db_ip = None, db_user = None,
|
||||
db_pass = None, db_desc = None, db_server = None,
|
||||
default = "False"):
|
||||
default = default.lower()
|
||||
defaultb = string_to_bool(default, False)
|
||||
if db_name in self.supported_databases:
|
||||
raise ValueError("Database names must be unique")
|
||||
|
||||
db_node = self.get_db_node(db_name)
|
||||
if db_node is None:
|
||||
for db_node in self.doc.getElementsByTagName("supported_databases"):
|
||||
# should only be one supported_databases element, use last one if there are several
|
||||
suppdb_node = db_node
|
||||
t_node = self.doc.createTextNode(" ")
|
||||
suppdb_node.appendChild(t_node)
|
||||
db_node = self.doc.createElement("database")
|
||||
suppdb_node.appendChild(db_node)
|
||||
t_node = self.doc.createTextNode("\r\n ")
|
||||
suppdb_node.appendChild(t_node)
|
||||
db_node.setAttribute("db_name", db_name)
|
||||
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 defaultb:
|
||||
db_node.setAttribute("default", "True")
|
||||
for dbn in self.doc.getElementsByTagName("database"):
|
||||
if dbn.getAttribute('db_name') != db_name and dbn.hasAttribute("default"):
|
||||
dbn.removeAttribute("default")
|
||||
elif db_node.hasAttribute("default"):
|
||||
db_node.removeAttribute("default")
|
||||
else:
|
||||
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 defaultb or self.db_selected == db_name:
|
||||
db_node.setAttribute("default", "True")
|
||||
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
|
||||
self.supported_databases[db_name].db_selected = defaultb
|
||||
else:
|
||||
db = Database(node=db_node)
|
||||
self.supported_databases[db.db_name] = db
|
||||
|
||||
if defaultb:
|
||||
self.db_selected = db_name
|
||||
return
|
||||
|
||||
def get_backend(self, name):
|
||||
"""Returns the number of the currently used backend"""
|
||||
|
|
|
@ -19,6 +19,10 @@
|
|||
import Card
|
||||
from decimal import Decimal
|
||||
|
||||
import logging
|
||||
# logging has been set up in fpdb.py or HUD_main.py, use their settings:
|
||||
log = logging.getLogger("parser")
|
||||
|
||||
DEBUG = False
|
||||
|
||||
if DEBUG:
|
||||
|
|
|
@ -22,6 +22,18 @@ import sys
|
|||
import logging
|
||||
from HandHistoryConverter import *
|
||||
|
||||
import locale
|
||||
lang=locale.getdefaultlocale()[0][0:2]
|
||||
if lang=="en":
|
||||
def _(string): return string
|
||||
else:
|
||||
import gettext
|
||||
try:
|
||||
trans = gettext.translation("fpdb", localedir="locale", languages=[lang])
|
||||
trans.install()
|
||||
except IOError:
|
||||
def _(string): return string
|
||||
|
||||
# Class for converting Everleaf HH format.
|
||||
|
||||
class Everleaf(HandHistoryConverter):
|
||||
|
@ -133,7 +145,7 @@ or None if we fail to get the info """
|
|||
def readHandInfo(self, hand):
|
||||
m = self.re_HandInfo.search(hand.handText)
|
||||
if(m == None):
|
||||
logging.info("Didn't match re_HandInfo")
|
||||
logging.info(_("Didn't match re_HandInfo"))
|
||||
logging.info(hand.handText)
|
||||
return None
|
||||
logging.debug("HID %s, Table %s" % (m.group('HID'), m.group('TABLE')))
|
||||
|
@ -202,7 +214,7 @@ or None if we fail to get the info """
|
|||
hand.setCommunityCards(street=street, cards=cards)
|
||||
|
||||
def readAntes(self, hand):
|
||||
logging.debug("reading antes")
|
||||
logging.debug(_("reading antes"))
|
||||
m = self.re_Antes.finditer(hand.handText)
|
||||
for player in m:
|
||||
logging.debug("hand.addAnte(%s,%s)" %(player.group('PNAME'), player.group('ANTE')))
|
||||
|
@ -214,14 +226,14 @@ or None if we fail to get the info """
|
|||
logging.debug("Player bringing in: %s for %s" %(m.group('PNAME'), m.group('BRINGIN')))
|
||||
hand.addBringIn(m.group('PNAME'), m.group('BRINGIN'))
|
||||
else:
|
||||
logging.warning("No bringin found.")
|
||||
logging.warning(_("No bringin found."))
|
||||
|
||||
def readBlinds(self, hand):
|
||||
m = self.re_PostSB.search(hand.handText)
|
||||
if m is not None:
|
||||
hand.addBlind(m.group('PNAME'), 'small blind', m.group('SB'))
|
||||
else:
|
||||
logging.debug("No small blind")
|
||||
logging.debug(_("No small blind"))
|
||||
hand.addBlind(None, None, None)
|
||||
for a in self.re_PostBB.finditer(hand.handText):
|
||||
hand.addBlind(a.group('PNAME'), 'big blind', a.group('BB'))
|
||||
|
@ -249,7 +261,7 @@ or None if we fail to get the info """
|
|||
|
||||
def readStudPlayerCards(self, hand, street):
|
||||
# lol. see Plymouth.txt
|
||||
logging.warning("Everleaf readStudPlayerCards is only a stub.")
|
||||
logging.warning(_("Everleaf readStudPlayerCards is only a stub."))
|
||||
#~ if street in ('THIRD', 'FOURTH', 'FIFTH', 'SIXTH'):
|
||||
#~ hand.addPlayerCards(player = player.group('PNAME'), street = street, closed = [], open = [])
|
||||
|
||||
|
@ -272,7 +284,7 @@ or None if we fail to get the info """
|
|||
elif action.group('ATYPE') == ' complete to':
|
||||
hand.addComplete( street, action.group('PNAME'), action.group('BET'))
|
||||
else:
|
||||
logging.debug("Unimplemented readAction: %s %s" %(action.group('PNAME'),action.group('ATYPE'),))
|
||||
logging.debug(_("Unimplemented readAction: %s %s" %(action.group('PNAME'),action.group('ATYPE'),)))
|
||||
|
||||
|
||||
def readShowdownActions(self, hand):
|
||||
|
@ -281,7 +293,7 @@ or None if we fail to get the info """
|
|||
for shows in self.re_ShowdownAction.finditer(hand.handText):
|
||||
cards = shows.group('CARDS')
|
||||
cards = cards.split(', ')
|
||||
logging.debug("readShowdownActions %s %s" %(cards, shows.group('PNAME')))
|
||||
logging.debug(_("readShowdownActions %s %s" %(cards, shows.group('PNAME'))))
|
||||
hand.addShownCards(cards, shows.group('PNAME'))
|
||||
|
||||
|
||||
|
@ -310,9 +322,9 @@ or None if we fail to get the info """
|
|||
|
||||
if __name__ == "__main__":
|
||||
parser = OptionParser()
|
||||
parser.add_option("-i", "--input", dest="ipath", help="parse input hand history", default="-")
|
||||
parser.add_option("-o", "--output", dest="opath", help="output translation to", default="-")
|
||||
parser.add_option("-f", "--follow", dest="follow", help="follow (tail -f) the input", action="store_true", default=False)
|
||||
parser.add_option("-i", "--input", dest="ipath", help=_("parse input hand history"), default="-")
|
||||
parser.add_option("-o", "--output", dest="opath", help=_("output translation to"), default="-")
|
||||
parser.add_option("-f", "--follow", dest="follow", help=_("follow (tail -f) the input"), action="store_true", default=False)
|
||||
parser.add_option("-q", "--quiet",
|
||||
action="store_const", const=logging.CRITICAL, dest="verbosity", default=logging.INFO)
|
||||
parser.add_option("-v", "--verbose",
|
||||
|
|
|
@ -63,7 +63,7 @@ class Filters(threading.Thread):
|
|||
,'seatsbetween':_('Between:'), 'seatsand':_('And:'), 'seatsshow':_('Show Number of _Players')
|
||||
,'playerstitle':_('Hero:'), 'sitestitle':_('Sites:'), 'gamestitle':_('Games:')
|
||||
,'limitstitle':_('Limits:'), 'seatstitle':_('Number of Players:')
|
||||
,'groupstitle':_('Grouping:'), 'posnshow':_('Show Position Stats:')
|
||||
,'groupstitle':_('Grouping:'), 'posnshow':_('Show Position Stats')
|
||||
,'datestitle':_('Date:')
|
||||
,'groupsall':_('All Players')
|
||||
,'limitsFL':'FL', 'limitsNL':'NL', 'limitsPL':'PL', 'ring':_('Ring'), 'tour':_('Tourney')
|
||||
|
@ -891,7 +891,7 @@ class Filters(threading.Thread):
|
|||
hbox = gtk.HBox()
|
||||
vbox1.pack_start(hbox, False, True, 0)
|
||||
|
||||
lbl_start = gtk.Label('From:')
|
||||
lbl_start = gtk.Label(_('From:'))
|
||||
|
||||
btn_start = gtk.Button()
|
||||
btn_start.set_image(gtk.image_new_from_stock(gtk.STOCK_INDEX, gtk.ICON_SIZE_BUTTON))
|
||||
|
@ -905,7 +905,7 @@ class Filters(threading.Thread):
|
|||
hbox = gtk.HBox()
|
||||
vbox1.pack_start(hbox, False, True, 0)
|
||||
|
||||
lbl_end = gtk.Label(' To:')
|
||||
lbl_end = gtk.Label(_('To:'))
|
||||
btn_end = gtk.Button()
|
||||
btn_end.set_image(gtk.image_new_from_stock(gtk.STOCK_INDEX, gtk.ICON_SIZE_BUTTON))
|
||||
btn_end.connect('clicked', self.__calendar_dialog, self.end_date)
|
||||
|
|
|
@ -18,6 +18,18 @@
|
|||
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
########################################################################
|
||||
|
||||
import locale
|
||||
lang=locale.getdefaultlocale()[0][0:2]
|
||||
if lang=="en":
|
||||
def _(string): return string
|
||||
else:
|
||||
import gettext
|
||||
try:
|
||||
trans = gettext.translation("fpdb", localedir="locale", languages=[lang])
|
||||
trans.install()
|
||||
except IOError:
|
||||
def _(string): return string
|
||||
|
||||
import logging
|
||||
from HandHistoryConverter import *
|
||||
#import TourneySummary
|
||||
|
@ -206,10 +218,9 @@ class Fulltilt(HandHistoryConverter):
|
|||
def readHandInfo(self, hand):
|
||||
m = self.re_HandInfo.search(hand.handText)
|
||||
if m is None:
|
||||
logging.info("Didn't match re_HandInfo")
|
||||
logging.info(_("Didn't match re_HandInfo"))
|
||||
logging.info(hand.handText)
|
||||
# Should this throw an exception? - CG
|
||||
return None
|
||||
raise FpdbParseError("No match in readHandInfo.")
|
||||
hand.handid = m.group('HID')
|
||||
hand.tablename = m.group('TABLE')
|
||||
|
||||
|
@ -337,7 +348,7 @@ class Fulltilt(HandHistoryConverter):
|
|||
hand.addBlind(a.group('PNAME'), 'small & big blinds', a.group('SBBB'))
|
||||
|
||||
def readAntes(self, hand):
|
||||
logging.debug("reading antes")
|
||||
logging.debug(_("reading antes"))
|
||||
m = self.re_Antes.finditer(hand.handText)
|
||||
for player in m:
|
||||
logging.debug("hand.addAnte(%s,%s)" %(player.group('PNAME'), player.group('ANTE')))
|
||||
|
@ -347,10 +358,10 @@ class Fulltilt(HandHistoryConverter):
|
|||
def readBringIn(self, hand):
|
||||
m = self.re_BringIn.search(hand.handText,re.DOTALL)
|
||||
if m:
|
||||
logging.debug("Player bringing in: %s for %s" %(m.group('PNAME'), m.group('BRINGIN')))
|
||||
logging.debug(_("Player bringing in: %s for %s") %(m.group('PNAME'), m.group('BRINGIN')))
|
||||
hand.addBringIn(m.group('PNAME'), m.group('BRINGIN'))
|
||||
else:
|
||||
logging.warning("No bringin found, handid =%s" % hand.handid)
|
||||
logging.warning(_("No bringin found, handid =%s") % hand.handid)
|
||||
|
||||
def readButton(self, hand):
|
||||
hand.buttonpos = int(self.re_Button.search(hand.handText).group('BUTTON'))
|
||||
|
@ -407,7 +418,7 @@ class Fulltilt(HandHistoryConverter):
|
|||
elif action.group('ATYPE') == ' checks':
|
||||
hand.addCheck( street, action.group('PNAME'))
|
||||
else:
|
||||
print "FullTilt: DEBUG: unimplemented readAction: '%s' '%s'" %(action.group('PNAME'),action.group('ATYPE'),)
|
||||
print _("FullTilt: DEBUG: unimplemented readAction: '%s' '%s'") %(action.group('PNAME'),action.group('ATYPE'),)
|
||||
|
||||
|
||||
def readShowdownActions(self, hand):
|
||||
|
@ -483,7 +494,7 @@ class Fulltilt(HandHistoryConverter):
|
|||
|
||||
m = self.re_TourneyInfo.search(tourneyText)
|
||||
if not m:
|
||||
log.info( "determineTourneyType : Parsing NOK" )
|
||||
log.info(_("determineTourneyType : Parsing NOK"))
|
||||
return False
|
||||
mg = m.groupdict()
|
||||
#print mg
|
||||
|
@ -541,7 +552,7 @@ class Fulltilt(HandHistoryConverter):
|
|||
if mg['TOURNO'] is not None:
|
||||
tourney.tourNo = mg['TOURNO']
|
||||
else:
|
||||
log.info( "Unable to get a valid Tournament ID -- File rejected" )
|
||||
log.info(_("Unable to get a valid Tournament ID -- File rejected"))
|
||||
return False
|
||||
if tourney.isMatrix:
|
||||
if mg['MATCHNO'] is not None:
|
||||
|
@ -572,18 +583,18 @@ class Fulltilt(HandHistoryConverter):
|
|||
tourney.buyin = 100*Decimal(re.sub(u',', u'', "%s" % mg['BUYIN']))
|
||||
else :
|
||||
if 100*Decimal(re.sub(u',', u'', "%s" % mg['BUYIN'])) != tourney.buyin:
|
||||
log.error( "Conflict between buyins read in topline (%s) and in BuyIn field (%s)" % (tourney.buyin, 100*Decimal(re.sub(u',', u'', "%s" % mg['BUYIN']))) )
|
||||
log.error(_("Conflict between buyins read in topline (%s) and in BuyIn field (%s)") % (tourney.buyin, 100*Decimal(re.sub(u',', u'', "%s" % mg['BUYIN']))) )
|
||||
tourney.subTourneyBuyin = 100*Decimal(re.sub(u',', u'', "%s" % mg['BUYIN']))
|
||||
if mg['FEE'] is not None:
|
||||
if tourney.fee is None:
|
||||
tourney.fee = 100*Decimal(re.sub(u',', u'', "%s" % mg['FEE']))
|
||||
else :
|
||||
if 100*Decimal(re.sub(u',', u'', "%s" % mg['FEE'])) != tourney.fee:
|
||||
log.error( "Conflict between fees read in topline (%s) and in BuyIn field (%s)" % (tourney.fee, 100*Decimal(re.sub(u',', u'', "%s" % mg['FEE']))) )
|
||||
log.error(_("Conflict between fees read in topline (%s) and in BuyIn field (%s)") % (tourney.fee, 100*Decimal(re.sub(u',', u'', "%s" % mg['FEE']))) )
|
||||
tourney.subTourneyFee = 100*Decimal(re.sub(u',', u'', "%s" % mg['FEE']))
|
||||
|
||||
if tourney.buyin is None:
|
||||
log.info( "Unable to affect a buyin to this tournament : assume it's a freeroll" )
|
||||
log.info(_("Unable to affect a buyin to this tournament : assume it's a freeroll"))
|
||||
tourney.buyin = 0
|
||||
tourney.fee = 0
|
||||
else:
|
||||
|
@ -684,7 +695,7 @@ class Fulltilt(HandHistoryConverter):
|
|||
|
||||
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
|
||||
print (_("FullTilt: Player finishing stats unreadable : %s") % a)
|
||||
|
||||
# Find Hero
|
||||
n = self.re_TourneyHeroFinishingP.search(playersText)
|
||||
|
@ -693,17 +704,17 @@ class Fulltilt(HandHistoryConverter):
|
|||
tourney.hero = heroName
|
||||
# Is this really useful ?
|
||||
if heroName not in tourney.ranks:
|
||||
print "FullTilt:", heroName, "not found in tourney.ranks ..."
|
||||
print (_("FullTilt: %s not found in tourney.ranks ...") % heroName)
|
||||
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'))
|
||||
print (_("FullTilt: Bad parsing : finish position incoherent : %s / %s") % (tourney.ranks[heroName], n.group('HERO_FINISHING_POS')))
|
||||
|
||||
return True
|
||||
|
||||
if __name__ == "__main__":
|
||||
parser = OptionParser()
|
||||
parser.add_option("-i", "--input", dest="ipath", help="parse input hand history", default="regression-test-files/fulltilt/razz/FT20090223 Danville - $0.50-$1 Ante $0.10 - Limit Razz.txt")
|
||||
parser.add_option("-o", "--output", dest="opath", help="output translation to", default="-")
|
||||
parser.add_option("-f", "--follow", dest="follow", help="follow (tail -f) the input", action="store_true", default=False)
|
||||
parser.add_option("-i", "--input", dest="ipath", help=_("parse input hand history"), default="regression-test-files/fulltilt/razz/FT20090223 Danville - $0.50-$1 Ante $0.10 - Limit Razz.txt")
|
||||
parser.add_option("-o", "--output", dest="opath", help=_("output translation to"), default="-")
|
||||
parser.add_option("-f", "--follow", dest="follow", help=_("follow (tail -f) the input"), action="store_true", default=False)
|
||||
parser.add_option("-q", "--quiet",
|
||||
action="store_const", const=logging.CRITICAL, dest="verbosity", default=logging.INFO)
|
||||
parser.add_option("-v", "--verbose",
|
||||
|
|
|
@ -113,7 +113,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 _Auto Import "))
|
||||
self.startButton.connect("clicked", self.startClicked, "start clicked")
|
||||
hbox.pack_start(self.startButton, expand=False, fill=False)
|
||||
|
||||
|
@ -132,7 +132,7 @@ class GuiAutoImport (threading.Thread):
|
|||
scrolledwindow.add(self.textview)
|
||||
|
||||
self.mainVBox.show_all()
|
||||
self.addText(_("AutoImport Ready."))
|
||||
self.addText(_("Auto Import Ready."))
|
||||
|
||||
def addText(self, text):
|
||||
end_iter = self.textbuffer.get_end_iter()
|
||||
|
@ -145,7 +145,7 @@ class GuiAutoImport (threading.Thread):
|
|||
"""runs when user clicks one of the browse buttons in the auto import tab"""
|
||||
current_path=data[1].get_text()
|
||||
|
||||
dia_chooser = gtk.FileChooserDialog(title=_("Please choose the path that you want to auto import"),
|
||||
dia_chooser = gtk.FileChooserDialog(title=_("Please choose the path that you want to Auto Import"),
|
||||
action=gtk.FILE_CHOOSER_ACTION_SELECT_FOLDER,
|
||||
buttons=(gtk.STOCK_CANCEL,gtk.RESPONSE_CANCEL,gtk.STOCK_OPEN,gtk.RESPONSE_OK))
|
||||
#dia_chooser.set_current_folder(pathname)
|
||||
|
@ -179,9 +179,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 _Auto Import '))
|
||||
else:
|
||||
self.startButton.set_label(_(u' Start _Autoimport '))
|
||||
self.startButton.set_label(_(u' Start _Auto Import '))
|
||||
|
||||
return False
|
||||
|
||||
|
@ -206,7 +206,7 @@ class GuiAutoImport (threading.Thread):
|
|||
if self.settings['global_lock'].acquire(False): # returns false immediately if lock not acquired
|
||||
self.addText(_("\nGlobal lock taken ... Auto Import Started.\n"))
|
||||
self.doAutoImportBool = True
|
||||
widget.set_label(_(u' _Stop Autoimport '))
|
||||
widget.set_label(_(u' _Stop Auto Import '))
|
||||
if self.pipe_to_hud is None:
|
||||
if Configuration.FROZEN:
|
||||
path = Configuration.EXEC_PATH
|
||||
|
@ -246,19 +246,19 @@ class GuiAutoImport (threading.Thread):
|
|||
self.importtimer = gobject.timeout_add(interval * 1000, self.do_import)
|
||||
|
||||
else:
|
||||
self.addText(_("\nauto-import aborted - global lock not available"))
|
||||
self.addText(_("\nAuto Import aborted - global lock not available"))
|
||||
else: # toggled off
|
||||
gobject.source_remove(self.importtimer)
|
||||
self.settings['global_lock'].release()
|
||||
self.doAutoImportBool = False # do_import will return this and stop the gobject callback timer
|
||||
self.addText(_("\nStopping autoimport - global lock released."))
|
||||
self.addText(_("\nStopping Auto Import - global lock released."))
|
||||
if self.pipe_to_hud.poll() is not None:
|
||||
self.addText(_("\n * Stop Autoimport: HUD already terminated"))
|
||||
self.addText(_("\n * Stop Auto Import: HUD already terminated"))
|
||||
else:
|
||||
#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 _Auto Import '))
|
||||
|
||||
#end def GuiAutoImport.startClicked
|
||||
|
||||
|
|
|
@ -136,7 +136,7 @@ class GuiBulkImport():
|
|||
#self.settings['global_lock'].release()
|
||||
self.settings['global_lock'].release()
|
||||
else:
|
||||
print _("bulk-import aborted - global lock not available")
|
||||
print _("bulk import aborted - global lock not available")
|
||||
|
||||
def get_vbox(self):
|
||||
"""returns the vbox of this thread"""
|
||||
|
|
|
@ -19,6 +19,7 @@ import os
|
|||
import sys
|
||||
import traceback
|
||||
import Queue
|
||||
import re
|
||||
|
||||
import pygtk
|
||||
pygtk.require('2.0')
|
||||
|
@ -32,6 +33,7 @@ log = logging.getLogger("maintdbs")
|
|||
|
||||
|
||||
import Exceptions
|
||||
import Configuration
|
||||
import Database
|
||||
import SQL
|
||||
|
||||
|
@ -79,8 +81,17 @@ class GuiDatabase:
|
|||
try:
|
||||
#self.dia.set_modal(True)
|
||||
self.vbox = self.dia.vbox
|
||||
self.action_area = self.dia.action_area
|
||||
#gtk.Widget.set_size_request(self.vbox, 700, 400);
|
||||
|
||||
h = gtk.HBox(False, spacing=3)
|
||||
h.show()
|
||||
self.vbox.pack_start(h, padding=3)
|
||||
|
||||
vbtn = gtk.VBox(True, spacing=3)
|
||||
vbtn.show()
|
||||
h.pack_start(vbtn, expand=False, fill=False, padding=2)
|
||||
|
||||
# list of databases in self.config.supported_databases:
|
||||
self.liststore = gtk.ListStore(str, str, str, str, str
|
||||
,str, str, str, str, str)
|
||||
|
@ -101,12 +112,15 @@ class GuiDatabase:
|
|||
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)
|
||||
h.pack_start(self.scrolledwindow, expand=True, fill=True, padding=0)
|
||||
|
||||
refreshbutton = gtk.Button(_("Refresh"))
|
||||
refreshbutton.connect("clicked", self.refresh, None)
|
||||
self.vbox.pack_start(refreshbutton, False, False, 3)
|
||||
refreshbutton.show()
|
||||
add_button = SideButton(_("_Add"), gtk.STOCK_ADD)
|
||||
add_button.connect("clicked", self.addDB, None)
|
||||
vbtn.pack_start(add_button, False, False, 3)
|
||||
|
||||
refresh_button = SideButton(_("_Refresh"), gtk.STOCK_REFRESH)
|
||||
refresh_button.connect("clicked", self.refresh, None)
|
||||
vbtn.pack_start(refresh_button, False, False, 3)
|
||||
|
||||
col = self.addTextColumn(_("Type"), 0, False)
|
||||
col = self.addTextColumn(_("Name"), 1, False)
|
||||
|
@ -114,7 +128,7 @@ class GuiDatabase:
|
|||
col = self.addTextColumn(_("Username"), 3, True)
|
||||
col = self.addTextColumn(_("Password"), 4, True)
|
||||
col = self.addTextColumn(_("Host"), 5, True)
|
||||
col = self.addTextObjColumn(_("Default"), 6, 6)
|
||||
col = self.addTextObjColumn(_("Open"), 6, 6)
|
||||
col = self.addTextObjColumn(_("Status"), 7, 8)
|
||||
|
||||
#self.listview.get_selection().set_mode(gtk.SELECTION_SINGLE)
|
||||
|
@ -122,6 +136,7 @@ class GuiDatabase:
|
|||
self.listview.add_events(gtk.gdk.BUTTON_PRESS_MASK)
|
||||
self.listview.connect('button_press_event', self.selectTest)
|
||||
|
||||
self.dia.show_all()
|
||||
self.loadDbs()
|
||||
|
||||
#self.dia.connect('response', self.dialog_response_cb)
|
||||
|
@ -248,9 +263,9 @@ class GuiDatabase:
|
|||
|
||||
self.liststore.clear()
|
||||
#self.listcols = []
|
||||
dia = self.info_box2(None, _('Testing database connections ... '), "", False, False)
|
||||
dia = InfoBox( parent=self.dia, str1=_('Testing database connections ... ') )
|
||||
while gtk.events_pending():
|
||||
gtk.mainiteration()
|
||||
gtk.main_iteration()
|
||||
|
||||
try:
|
||||
# want to fill: dbms, name, comment, user, passwd, host, default, status, icon
|
||||
|
@ -268,57 +283,14 @@ class GuiDatabase:
|
|||
default = (name == self.config.db_selected)
|
||||
default_icon = None
|
||||
if default: default_icon = gtk.STOCK_APPLY
|
||||
status = ""
|
||||
icon = None
|
||||
err_msg = ""
|
||||
|
||||
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"
|
||||
icon = gtk.STOCK_CANCEL
|
||||
except Exceptions.FpdbMySQLNoDatabase:
|
||||
err_msg = _("MySQL client reports: 2002 or 2003 error. Unable to connect - Please check that the MySQL service has been started")
|
||||
status = "failed"
|
||||
icon = gtk.STOCK_CANCEL
|
||||
except Exceptions.FpdbPostgresqlAccessDenied:
|
||||
err_msg = _("Postgres Server reports: Access denied. Are your permissions set correctly?")
|
||||
status = "failed"
|
||||
except Exceptions.FpdbPostgresqlNoDatabase:
|
||||
err_msg = _("Postgres client reports: Unable to connect - Please check that the Postgres service has been started")
|
||||
status = "failed"
|
||||
icon = gtk.STOCK_CANCEL
|
||||
except:
|
||||
err = traceback.extract_tb(sys.exc_info()[2])[-1]
|
||||
log.info( 'db connection to '+str(dbms_num)+','+host+','+name+','+user+','+passwd+' failed: '
|
||||
+ err[2] + "(" + str(err[1]) + "): " + str(sys.exc_info()[1]) )#TODO Gettextify
|
||||
status = "failed"
|
||||
icon = gtk.STOCK_CANCEL
|
||||
if err_msg:
|
||||
log.info( 'db connection to '+str(dbms_num)+','+host+','+name+','+user+','+passwd+' failed: '
|
||||
+ err_msg )#TODO Gettextify
|
||||
status, err_msg, icon = GuiDatabase.testDB(self.config, dbms, dbms_num, name, user, passwd, host)
|
||||
|
||||
b = gtk.Button(name)
|
||||
b.show()
|
||||
iter = self.liststore.append( (dbms, name, comment, user, passwd, host, "", default_icon, status, icon) )
|
||||
|
||||
self.info_box2(dia[0], _("finished."), "", False, True)
|
||||
dia.add_msg( _("finished."), False, True )
|
||||
self.listview.show()
|
||||
self.scrolledwindow.show()
|
||||
self.vbox.show()
|
||||
|
@ -328,7 +300,7 @@ class GuiDatabase:
|
|||
self.dia.show()
|
||||
except:
|
||||
err = traceback.extract_tb(sys.exc_info()[2])[-1]
|
||||
print _('loaddbs error: ')+str(dbms_num)+','+host+','+name+','+user+','+passwd+' failed: ' \
|
||||
print _('loadDbs error: ')+str(dbms_num)+','+host+','+name+','+user+','+passwd+' failed: ' \
|
||||
+ err[2] + "(" + str(err[1]) + "): " + str(sys.exc_info()[1])
|
||||
|
||||
def sortCols(self, col, n):
|
||||
|
@ -356,64 +328,369 @@ class GuiDatabase:
|
|||
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 %s'% 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 addDB(self, widget, data):
|
||||
adb = AddDB(self.config, self.dia)
|
||||
(status, err_msg, icon, dbms, dbms_num, name, comment, user, passwd, host) = adb.run()
|
||||
adb.destroy()
|
||||
|
||||
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
|
||||
# save in liststore
|
||||
if status == 'ok':
|
||||
iter = self.liststore.append( (dbms, name, comment, user, passwd, host, "", None, status, icon) )
|
||||
|
||||
# keep config save code in line with edited_cb()? call common routine?
|
||||
|
||||
valid = True
|
||||
# Validate new value (only for dbms so far, but dbms now not updateable so no validation at all!)
|
||||
#if col == self.COL_DBMS:
|
||||
# if new_text not in Configuration.DATABASE_TYPES:
|
||||
# valid = False
|
||||
|
||||
if valid:
|
||||
self.config.add_db_parameters( db_server = dbms
|
||||
, db_name = name
|
||||
, db_desc = comment
|
||||
, db_ip = host
|
||||
, db_user = user
|
||||
, db_pass = passwd )
|
||||
self.config.save()
|
||||
self.changes = False
|
||||
|
||||
|
||||
@staticmethod
|
||||
def testDB(config, dbms, dbms_num, name, user, passwd, host):
|
||||
status = ""
|
||||
icon = None
|
||||
err_msg = ""
|
||||
|
||||
sql = SQL.Sql(db_server=dbms)
|
||||
db = Database.Database(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(_("testDB: 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"
|
||||
icon = gtk.STOCK_CANCEL
|
||||
except Exceptions.FpdbMySQLNoDatabase:
|
||||
err_msg = _("MySQL client reports: 2002 or 2003 error. Unable to connect - ") \
|
||||
+ _("Please check that the MySQL service has been started")
|
||||
status = "failed"
|
||||
icon = gtk.STOCK_CANCEL
|
||||
except Exceptions.FpdbPostgresqlAccessDenied:
|
||||
err_msg = _("PostgreSQL Server reports: Access denied. Are your permissions set correctly?")
|
||||
status = "failed"
|
||||
except Exceptions.FpdbPostgresqlNoDatabase:
|
||||
err_msg = _("PostgreSQL client reports: Unable to connect - ") \
|
||||
+ _("Please check that the PostgreSQL service has been started")
|
||||
status = "failed"
|
||||
icon = gtk.STOCK_CANCEL
|
||||
except:
|
||||
# add more specific exceptions here if found (e.g. for sqlite?)
|
||||
err = traceback.extract_tb(sys.exc_info()[2])[-1]
|
||||
err_msg = err[2] + "(" + str(err[1]) + "): " + str(sys.exc_info()[1])
|
||||
status = "failed"
|
||||
icon = gtk.STOCK_CANCEL
|
||||
if err_msg:
|
||||
log.info( _('db connection to %s, %s, %s, %s, %s failed: %s') % (str(dbms_num), host, name, user, passwd, err_msg))
|
||||
|
||||
return( status, err_msg, icon )
|
||||
|
||||
|
||||
class AddDB(gtk.Dialog):
|
||||
|
||||
def __init__(self, config, parent):
|
||||
log.debug(_("AddDB starting"))
|
||||
self.dbnames = { 'Sqlite' : Configuration.DATABASE_TYPE_SQLITE
|
||||
, 'MySQL' : Configuration.DATABASE_TYPE_MYSQL
|
||||
, 'PostgreSQL' : Configuration.DATABASE_TYPE_POSTGRESQL
|
||||
}
|
||||
self.config = config
|
||||
# create dialog and add icon and label
|
||||
super(AddDB,self).__init__( parent=parent
|
||||
, flags=gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT
|
||||
, title=_("Add New Database")
|
||||
, buttons = (gtk.STOCK_CANCEL, gtk.RESPONSE_REJECT
|
||||
,gtk.STOCK_SAVE, gtk.RESPONSE_ACCEPT)
|
||||
) # , buttons=btns
|
||||
self.set_default_size(450, 280)
|
||||
#self.connect('response', self.response_cb)
|
||||
|
||||
t = gtk.Table(5, 3, True)
|
||||
self.vbox.pack_start(t, expand=False, fill=False, padding=3)
|
||||
|
||||
l = gtk.Label( _("DB Type") )
|
||||
l.set_alignment(1.0, 0.5)
|
||||
t.attach(l, 0, 1, 0, 1, xpadding=3)
|
||||
self.cb_dbms = gtk.combo_box_new_text()
|
||||
for s in ('Sqlite',): # keys(self.dbnames):
|
||||
self.cb_dbms.append_text(s)
|
||||
self.cb_dbms.set_active(0)
|
||||
t.attach(self.cb_dbms, 1, 3, 0, 1, xpadding=3)
|
||||
self.cb_dbms.connect("changed", self.db_type_changed, None)
|
||||
|
||||
l = gtk.Label( _("DB Name") )
|
||||
l.set_alignment(1.0, 0.5)
|
||||
t.attach(l, 0, 1, 1, 2, xpadding=3)
|
||||
self.e_db_name = gtk.Entry()
|
||||
self.e_db_name.set_width_chars(15)
|
||||
t.attach(self.e_db_name, 1, 3, 1, 2, xpadding=3)
|
||||
self.e_db_name.connect("focus-out-event", self.db_name_changed, None)
|
||||
|
||||
l = gtk.Label( _("DB Description") )
|
||||
l.set_alignment(1.0, 0.5)
|
||||
t.attach(l, 0, 1, 2, 3, xpadding=3)
|
||||
self.e_db_desc = gtk.Entry()
|
||||
self.e_db_desc.set_width_chars(15)
|
||||
t.attach(self.e_db_desc, 1, 3, 2, 3, xpadding=3)
|
||||
|
||||
self.l_username = gtk.Label( _("Username") )
|
||||
self.l_username.set_alignment(1.0, 0.5)
|
||||
t.attach(self.l_username, 0, 1, 3, 4, xpadding=3)
|
||||
self.e_username = gtk.Entry()
|
||||
self.e_username.set_width_chars(15)
|
||||
t.attach(self.e_username, 1, 3, 3, 4, xpadding=3)
|
||||
|
||||
self.l_password = gtk.Label( _("Password") )
|
||||
self.l_password.set_alignment(1.0, 0.5)
|
||||
t.attach(self.l_password, 0, 1, 4, 5, xpadding=3)
|
||||
self.e_password = gtk.Entry()
|
||||
self.e_password.set_width_chars(15)
|
||||
t.attach(self.e_password, 1, 3, 4, 5, xpadding=3)
|
||||
|
||||
self.l_host = gtk.Label( _("Host Computer") )
|
||||
self.l_host.set_alignment(1.0, 0.5)
|
||||
t.attach(self.l_host, 0, 1, 5, 6, xpadding=3)
|
||||
self.e_host = gtk.Entry()
|
||||
self.e_host.set_width_chars(15)
|
||||
self.e_host.set_text("localhost")
|
||||
t.attach(self.e_host, 1, 3, 5, 6, xpadding=3)
|
||||
|
||||
parent.show_all()
|
||||
self.show_all()
|
||||
|
||||
# hide username/password fields as not used by sqlite
|
||||
self.l_username.hide()
|
||||
self.e_username.hide()
|
||||
self.l_password.hide()
|
||||
self.e_password.hide()
|
||||
|
||||
def run(self):
|
||||
response = super(AddDB,self).run()
|
||||
log.debug(_("addDB.run: response is %s accept is %s" % (str(response), str(int(gtk.RESPONSE_ACCEPT)))))
|
||||
|
||||
ok,retry = False,True
|
||||
while response == gtk.RESPONSE_ACCEPT:
|
||||
ok,retry = self.check_fields()
|
||||
if retry:
|
||||
response = super(AddDB,self).run()
|
||||
else:
|
||||
response = gtk.RESPONSE_REJECT
|
||||
|
||||
(status, err_msg, icon, dbms, dbms_num
|
||||
,name, db_desc, user, passwd, host) = ("error", "error", None, None, None
|
||||
,None, None, None, None, None)
|
||||
if ok:
|
||||
log.debug(_("start creating new db"))
|
||||
# add a new db
|
||||
master_password = None
|
||||
dbms = self.dbnames[ self.cb_dbms.get_active_text() ]
|
||||
dbms_num = self.config.get_backend(dbms)
|
||||
name = self.e_db_name.get_text()
|
||||
db_desc = self.e_db_desc.get_text()
|
||||
user = self.e_username.get_text()
|
||||
passwd = self.e_password.get_text()
|
||||
host = self.e_host.get_text()
|
||||
|
||||
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)
|
||||
# TODO:
|
||||
# if self.cb_dbms.get_active_text() == 'Postgres':
|
||||
# <ask for postgres master password>
|
||||
|
||||
# create_db() in Database.py or here? ... TODO
|
||||
|
||||
# test db after creating?
|
||||
status, err_msg, icon = GuiDatabase.testDB(self.config, dbms, dbms_num, name, user, passwd, host)
|
||||
log.debug(_('tested new db, result=%s') % str((status,err_msg)))
|
||||
if status == 'ok':
|
||||
#dia = InfoBox( parent=self, str1=_('Database created') )
|
||||
str1 = _('Database created')
|
||||
else:
|
||||
#dia = InfoBox( parent=self, str1=_('Database creation failed') )
|
||||
str1 = _('Database creation failed')
|
||||
#dia.add_msg("", True, True)
|
||||
btns = (gtk.BUTTONS_OK)
|
||||
dia = gtk.MessageDialog( parent=self, flags=gtk.DIALOG_DESTROY_WITH_PARENT
|
||||
, type=gtk.MESSAGE_INFO, buttons=(btns), message_format=str1 )
|
||||
dia.run()
|
||||
|
||||
return( (status, err_msg, icon, dbms, dbms_num, name, db_desc, user, passwd, host) )
|
||||
|
||||
def check_fields(self):
|
||||
"""check fields and return true/false according to whether user wants to try again
|
||||
return False if fields are ok
|
||||
"""
|
||||
log.debug(_("check_fields: starting"))
|
||||
try_again = False
|
||||
ok = True
|
||||
|
||||
# checks for all db's
|
||||
if self.e_db_name.get_text() == "":
|
||||
msg = _("No Database Name given")
|
||||
ok = False
|
||||
elif self.e_db_desc.get_text() is None or self.e_db_desc.get_text() == "":
|
||||
msg = _("No Database Description given")
|
||||
ok = False
|
||||
elif self.cb_dbms.get_active_text() != 'Sqlite' and self.e_username.get_text() == "":
|
||||
msg = _("No Username given")
|
||||
ok = False
|
||||
elif self.cb_dbms.get_active_text() != 'Sqlite' and self.e_password.get_text() == "":
|
||||
msg = _("No Password given")
|
||||
ok = False
|
||||
elif self.e_host.get_text() == "":
|
||||
msg = _("No Host given")
|
||||
ok = False
|
||||
|
||||
if ok:
|
||||
if self.cb_dbms.get_active_text() == 'Sqlite':
|
||||
# checks for sqlite
|
||||
pass
|
||||
elif self.cb_dbms.get_active_text() == 'MySQL':
|
||||
# checks for mysql
|
||||
pass
|
||||
elif self.cb_dbms.get_active_text() == 'Postgres':
|
||||
# checks for postgres
|
||||
pass
|
||||
else:
|
||||
msg = _("Unknown Database Type selected")
|
||||
ok = False
|
||||
|
||||
if not ok:
|
||||
log.debug(_("check_fields: open dialog"))
|
||||
dia = gtk.MessageDialog( parent=self
|
||||
, flags=gtk.DIALOG_DESTROY_WITH_PARENT
|
||||
, type=gtk.MESSAGE_ERROR
|
||||
, message_format=msg
|
||||
, buttons = gtk.BUTTONS_YES_NO
|
||||
)
|
||||
#l = gtk.Label(msg)
|
||||
#dia.vbox.add(l)
|
||||
l = gtk.Label( _("Do you want to try again?") )
|
||||
dia.vbox.add(l)
|
||||
dia.show_all()
|
||||
ret = dia.run()
|
||||
log.debug(_("check_fields: ret is %s cancel is %s" % (str(ret), str(int(gtk.RESPONSE_CANCEL)))))
|
||||
if ret == gtk.RESPONSE_YES:
|
||||
try_again = True
|
||||
log.debug(_("check_fields: destroy dialog"))
|
||||
dia.hide()
|
||||
dia.destroy()
|
||||
|
||||
log.debug(_("check_fields: returning ok as %s, try_again as %s") % (str(ok), str(try_again)))
|
||||
return(ok,try_again)
|
||||
|
||||
def db_type_changed(self, widget, data):
|
||||
if self.cb_dbms.get_active_text() == 'Sqlite':
|
||||
self.l_username.hide()
|
||||
self.e_username.hide()
|
||||
self.e_username.set_text("")
|
||||
self.l_password.hide()
|
||||
self.e_password.hide()
|
||||
self.e_password.set_text("")
|
||||
else:
|
||||
# add extra label
|
||||
vbox = dia.vbox
|
||||
vbox.pack_start( gtk.Label(str1) )
|
||||
dia.show_all()
|
||||
self.l_username.show()
|
||||
self.e_username.show()
|
||||
self.l_password.show()
|
||||
self.e_password.show()
|
||||
return(response)
|
||||
|
||||
def db_name_changed(self, widget, event, data):
|
||||
log.debug('db_name_changed: text='+widget.get_text())
|
||||
if not re.match('\....$', widget.get_text()):
|
||||
widget.set_text(widget.get_text()+'.db3')
|
||||
widget.show()
|
||||
|
||||
#def response_cb(self, dialog, data):
|
||||
# dialog.destroy()
|
||||
# return(data)
|
||||
|
||||
|
||||
class InfoBox(gtk.Dialog):
|
||||
|
||||
def __init__(self, parent, str1):
|
||||
# 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 )
|
||||
# so just use Dialog instead
|
||||
super(InfoBox,self).__init__( parent=parent
|
||||
, flags=gtk.DIALOG_DESTROY_WITH_PARENT
|
||||
, title="" ) # , buttons=btns
|
||||
|
||||
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)
|
||||
self.vbox.pack_start(h)
|
||||
parent.show_all()
|
||||
self.show_all()
|
||||
|
||||
def add_msg(self, str1, run, destroy):
|
||||
# add extra label
|
||||
self.vbox.pack_start( gtk.Label(str1) )
|
||||
self.show_all()
|
||||
response = None
|
||||
if run: response = dia.run()
|
||||
if destroy: dia.destroy()
|
||||
return (dia, response)
|
||||
if run: response = self.run()
|
||||
if destroy: self.destroy()
|
||||
return (response)
|
||||
|
||||
|
||||
class SideButton(gtk.Button):
|
||||
"""Create a button with the label below the icon"""
|
||||
|
||||
# to change label on buttons:
|
||||
# ( see http://faq.pygtk.org/index.py?req=show&file=faq09.005.htp )
|
||||
# gtk.stock_add([(gtk.STOCK_ADD, _("Add"), 0, 0, "")])
|
||||
|
||||
# alternatively:
|
||||
# button = gtk.Button(stock=gtk.STOCK_CANCEL)
|
||||
# button.show()
|
||||
# alignment = button.get_children()[0]
|
||||
# hbox = alignment.get_children()[0]
|
||||
# image, label = hbox.get_children()
|
||||
# label.set_text('Hide')
|
||||
|
||||
def __init__(self, label=None, stock=None, use_underline=True):
|
||||
gtk.stock_add([(stock, label, 0, 0, "")])
|
||||
|
||||
super(SideButton, self).__init__(label=label, stock=stock, use_underline=True)
|
||||
alignment = self.get_children()[0]
|
||||
hbox = alignment.get_children()[0]
|
||||
image, label = hbox.get_children()
|
||||
#label.set_text('Hide')
|
||||
hbox.remove(image)
|
||||
hbox.remove(label)
|
||||
v = gtk.VBox(False, spacing=3)
|
||||
v.pack_start(image, 3)
|
||||
v.pack_start(label, 3)
|
||||
alignment.remove(hbox)
|
||||
alignment.add(v)
|
||||
self.show_all()
|
||||
|
||||
|
||||
|
||||
if __name__=="__main__":
|
||||
|
|
|
@ -62,6 +62,7 @@ class Hand(object):
|
|||
|
||||
|
||||
def __init__(self, config, sitename, gametype, handText, builtFrom = "HHC"):
|
||||
#log.debug( _("Hand.init(): handText is ") + str(handText) )
|
||||
self.config = config
|
||||
#log = Configuration.get_logger("logging.conf", "db", log_dir=self.config.dir_log)
|
||||
self.sitename = sitename
|
||||
|
@ -314,7 +315,7 @@ If a player has None chips he won't be added."""
|
|||
log.debug("markStreets:\n"+ str(self.streets))
|
||||
else:
|
||||
tmp = self.handText[0:100]
|
||||
log.error(_("markstreets didn't match - Assuming hand cancelled"))
|
||||
log.error(_("markstreets didn't match - Assuming hand %s was cancelled") % self.handid)
|
||||
self.cancelled = True
|
||||
raise FpdbParseError(_("FpdbParseError: markStreets appeared to fail: First 100 chars: '%s'") % tmp)
|
||||
|
||||
|
|
|
@ -55,7 +55,6 @@ else:
|
|||
def _(string): return string
|
||||
|
||||
# FreePokerTools modules
|
||||
import Tables # needed for testing only
|
||||
import Configuration
|
||||
import Stats
|
||||
import Mucked
|
||||
|
@ -587,7 +586,7 @@ class Hud:
|
|||
|
||||
self.stat_dict = stat_dict
|
||||
self.cards = cards
|
||||
sys.stderr.write(_("------------------------------------------------------------\nCreating hud from hand %s\n") % hand)
|
||||
log.info(_('Creating hud from hand ')+str(hand))
|
||||
adj = self.adj_seats(hand, config)
|
||||
loc = self.config.get_locations(self.table.site, self.max)
|
||||
if loc is None and self.max != 10:
|
||||
|
@ -941,26 +940,3 @@ class Popup_window:
|
|||
# window.present()
|
||||
|
||||
|
||||
if __name__== "__main__":
|
||||
main_window = gtk.Window()
|
||||
main_window.connect("destroy", destroy)
|
||||
label = gtk.Label(_('Fake main window, blah blah, blah\nblah, blah'))
|
||||
main_window.add(label)
|
||||
main_window.show_all()
|
||||
|
||||
c = Configuration.Config()
|
||||
#tables = Tables.discover(c)
|
||||
t = Tables.discover_table_by_name(c, "Corona")
|
||||
if t is None:
|
||||
print _("Table not found.")
|
||||
db = Database.Database(c, 'fpdb', 'holdem')
|
||||
|
||||
stat_dict = db.get_stats_from_hand(1)
|
||||
|
||||
# for t in tables:
|
||||
win = Hud(None, t, 10, 'holdem', c, db) # parent, table, max, poker_game, config, db_connection
|
||||
win.create(1, c, stat_dict, None) # hand, config, stat_dict, cards):
|
||||
# t.get_details()
|
||||
win.update(8300, c) # self, hand, config):
|
||||
|
||||
gtk.main()
|
||||
|
|
|
@ -19,6 +19,13 @@
|
|||
########################################################################
|
||||
|
||||
import sys
|
||||
import exceptions
|
||||
|
||||
import logging
|
||||
# logging has been set up in fpdb.py or HUD_main.py, use their settings:
|
||||
log = logging.getLogger("parser")
|
||||
|
||||
|
||||
import Configuration
|
||||
from HandHistoryConverter import *
|
||||
from decimal import Decimal
|
||||
|
@ -65,7 +72,6 @@ class OnGame(HandHistoryConverter):
|
|||
# '5 Card Draw' : ('draw','fivedraw')
|
||||
}
|
||||
|
||||
#self.rexx.setGameInfoRegex('.*Blinds \$?(?P<SB>[.0-9]+)/\$?(?P<BB>[.0-9]+)')
|
||||
# Static regexes
|
||||
# ***** End of hand R5-75443872-57 *****
|
||||
re_SplitHands = re.compile(u'\*\*\*\*\*\sEnd\sof\shand\s[-A-Z\d]+.*\n(?=\*)')
|
||||
|
@ -73,6 +79,18 @@ class OnGame(HandHistoryConverter):
|
|||
# ***** History for hand R5-75443872-57 *****
|
||||
# Start hand: Wed Aug 18 19:29:10 GMT+0100 2010
|
||||
# Table: someplace [75443872] (LIMIT TEXAS_HOLDEM 0.50/1, Real money)
|
||||
#***** History for hand R5-78042004-262 *****
|
||||
#Start hand: Fri Aug 27 21:40:46 GMT+0100 2010
|
||||
#Table: Bamako [78042004] (LIMIT TEXAS_HOLDEM $0.25/$0.50, Real money)
|
||||
#User: sagi34
|
||||
#{ u'BB': None
|
||||
#, u'DATETIME': u'Fri Aug 27 22:38:26 GMT+0100 2010\\n'
|
||||
#, u'GAME': None
|
||||
#, u'HID': u'R5-78042004-346'
|
||||
#, u'TABLE': u'Bamako'
|
||||
#, u'LIMIT': None
|
||||
#, u'SB': None
|
||||
#}
|
||||
re_HandInfo = re.compile(u"""
|
||||
\*\*\*\*\*\sHistory\sfor\shand\s(?P<HID>[-A-Z\d]+).*
|
||||
Start\shand:\s(?P<DATETIME>.*)
|
||||
|
@ -80,8 +98,8 @@ class OnGame(HandHistoryConverter):
|
|||
(
|
||||
(?P<LIMIT>NO_LIMIT|Limit|LIMIT|Pot\sLimit)\s
|
||||
(?P<GAME>TEXAS_HOLDEM|RAZZ)\s
|
||||
(?P<SB>[.0-9]+)/
|
||||
(?P<BB>[.0-9]+)
|
||||
(%(LS)s)?(?P<SB>[.0-9]+)/
|
||||
(%(LS)s)?(?P<BB>[.0-9]+)
|
||||
)?
|
||||
""" % substitutions, re.MULTILINE|re.DOTALL|re.VERBOSE)
|
||||
|
||||
|
@ -102,7 +120,9 @@ class OnGame(HandHistoryConverter):
|
|||
# self.rexx.button_re = re.compile('#SUMMARY\nDealer: (?P<BUTTONPNAME>.*)\n')
|
||||
|
||||
#Seat 1: .Lucchess ($4.17 in chips)
|
||||
re_PlayerInfo = re.compile(u'Seat (?P<SEAT>[0-9]+): (?P<PNAME>.*) \((?P<CASH>[.0-9]+)\)')
|
||||
#Seat 1: phantomaas ($27.11)
|
||||
#Seat 5: mleo17 ($9.37)
|
||||
re_PlayerInfo = re.compile(u'Seat (?P<SEAT>[0-9]+):\s(?P<PNAME>.*)\s\((%(LS)s)?(?P<CASH>[.0-9]+)\)' % substitutions)
|
||||
|
||||
def compilePlayerRegexs(self, hand):
|
||||
players = set([player[1] for player in hand.players])
|
||||
|
@ -117,23 +137,28 @@ class OnGame(HandHistoryConverter):
|
|||
#helander2222 posts blind ($0.25), lopllopl posts blind ($0.50).
|
||||
player_re = "(?P<PNAME>" + "|".join(map(re.escape, players)) + ")"
|
||||
subst = {'PLYR': player_re, 'CUR': self.sym[hand.gametype['currency']]}
|
||||
self.re_PostSB = re.compile('(?P<PNAME>.*) posts small blind \(\$?(?P<SB>[.0-9]+)\)')
|
||||
self.re_PostBB = re.compile('\), (?P<PNAME>.*) posts big blind \(\$?(?P<BB>[.0-9]+)\)')
|
||||
self.re_Antes = re.compile(r"^%(PLYR)s: posts the ante %(CUR)s(?P<ANTE>[.0-9]+)" % subst, re.MULTILINE)
|
||||
self.re_BringIn = re.compile(r"^%(PLYR)s: brings[- ]in( low|) for %(CUR)s(?P<BRINGIN>[.0-9]+)" % subst, re.MULTILINE)
|
||||
self.re_PostBoth = re.compile('.*\n(?P<PNAME>.*): posts small \& big blinds \(\$? (?P<SBBB>[.0-9]+)\)')
|
||||
self.re_PostSB = re.compile('(?P<PNAME>.*) posts small blind \((%(CUR)s)?(?P<SB>[\.0-9]+)\)' % subst, re.MULTILINE)
|
||||
self.re_PostBB = re.compile('\), (?P<PNAME>.*) posts big blind \((%(CUR)s)?(?P<BB>[\.0-9]+)\)' % subst, re.MULTILINE)
|
||||
self.re_Antes = re.compile(r"^%(PLYR)s: posts the ante (%(CUR)s)?(?P<ANTE>[\.0-9]+)" % subst, re.MULTILINE)
|
||||
self.re_BringIn = re.compile(r"^%(PLYR)s: brings[- ]in( low|) for (%(CUR)s)?(?P<BRINGIN>[\.0-9]+)" % subst, re.MULTILINE)
|
||||
self.re_PostBoth = re.compile('.*\n(?P<PNAME>.*): posts small \& big blinds \( (%(CUR)s)?(?P<SBBB>[\.0-9]+)\)' % subst)
|
||||
self.re_HeroCards = re.compile('Dealing\sto\s%(PLYR)s:\s\[(?P<CARDS>.*)\]' % subst)
|
||||
|
||||
#lopllopl checks, Eurolll checks, .Lucchess checks.
|
||||
self.re_Action = re.compile('(, )?(?P<PNAME>.*?)(?P<ATYPE> bets| checks| raises| calls| folds)( (?P<BET>\d*\.?\d*))?( and is all-in)?')
|
||||
#chumley. calls $0.25
|
||||
self.re_Action = re.compile('(, )?(?P<PNAME>.*?)(?P<ATYPE> bets| checks| raises| calls| folds)( (%(CUR)s)?(?P<BET>[\d\.]+))?( and is all-in)?' % subst)
|
||||
#self.re_Board = re.compile(r"\[board cards (?P<CARDS>.+) \]")
|
||||
|
||||
#Uchilka shows [ KC,JD ]
|
||||
self.re_ShowdownAction = re.compile('(?P<PNAME>.*) shows \[ (?P<CARDS>.+) \]')
|
||||
|
||||
# TODO: read SUMMARY correctly for collected pot stuff.
|
||||
# Main pot: 6.75 won by player3 (6.45)
|
||||
self.re_CollectPot = re.compile('Main pot: (?P<POT>\d*\.?\d*) won by %(PLYR)s' % subst)
|
||||
#Main pot: $3.57 won by mleo17 ($3.40)
|
||||
#Side pot 1: $3.26 won by maac_5 ($3.10)
|
||||
#Main pot: $2.87 won by maac_5 ($1.37), sagi34 ($1.36)
|
||||
self.re_Pot = re.compile('(Main|Side)\spot(\s\d+)?:\s.*won\sby\s(?P<POT>.*$)', re.MULTILINE)
|
||||
self.re_CollectPot = re.compile('\s*(?P<PNAME>.*)\s\((%(CUR)s)?(?P<POT>[\.\d]+)\)' % subst)
|
||||
#Seat 5: mleo17 ($3.40), net: +$2.57, [Jd, Qd] (TWO_PAIR QUEEN, JACK)
|
||||
self.re_ShownCards = re.compile("^Seat (?P<SEAT>[0-9]+): (?P<PNAME>.*) \(.*\), net:.* \[(?P<CARDS>.*)\].*" % subst, re.MULTILINE)
|
||||
self.re_sitsOut = re.compile('(?P<PNAME>.*) sits out')
|
||||
|
||||
def readSupportedGames(self):
|
||||
|
@ -160,7 +185,13 @@ class OnGame(HandHistoryConverter):
|
|||
info['currency'] = 'USD'
|
||||
|
||||
if 'LIMIT' in mg:
|
||||
info['limitType'] = self.limits[mg['LIMIT']]
|
||||
if mg['LIMIT'] in self.limits:
|
||||
info['limitType'] = self.limits[mg['LIMIT']]
|
||||
else:
|
||||
tmp = handText[0:100]
|
||||
log.error(_("determineGameType: limit not found in self.limits(%s). hand: '%s'") % (str(mg),tmp))
|
||||
log.error(_("determineGameType: Raising FpdbParseError"))
|
||||
raise FpdbParseError(_("limit not found in self.limits(%s). hand: '%s'") % (str(mg),tmp))
|
||||
if 'GAME' in mg:
|
||||
(info['base'], info['category']) = self.games[mg['GAME']]
|
||||
if 'SB' in mg:
|
||||
|
@ -168,6 +199,7 @@ class OnGame(HandHistoryConverter):
|
|||
if 'BB' in mg:
|
||||
info['bb'] = mg['BB']
|
||||
|
||||
#log.debug("determinegametype: returning "+str(info))
|
||||
return info
|
||||
|
||||
def readHandInfo(self, hand):
|
||||
|
@ -177,7 +209,7 @@ class OnGame(HandHistoryConverter):
|
|||
if m:
|
||||
info.update(m.groupdict())
|
||||
|
||||
log.debug("readHandInfo: %s" % info)
|
||||
#log.debug("readHandInfo: %s" % info)
|
||||
for key in info:
|
||||
if key == 'DATETIME':
|
||||
#'Wed Aug 18 19:45:30 GMT+0100 2010
|
||||
|
@ -203,6 +235,7 @@ class OnGame(HandHistoryConverter):
|
|||
hand.mixed = None
|
||||
|
||||
def readPlayerStacks(self, hand):
|
||||
#log.debug("readplayerstacks: re is '%s'" % self.re_PlayerInfo)
|
||||
m = self.re_PlayerInfo.finditer(hand.handText)
|
||||
for a in m:
|
||||
hand.addPlayer(int(a.group('SEAT')), a.group('PNAME'), a.group('CASH'))
|
||||
|
@ -247,15 +280,13 @@ class OnGame(HandHistoryConverter):
|
|||
hand.setCommunityCards(street, m.group('CARDS').split(', '))
|
||||
|
||||
def readBlinds(self, hand):
|
||||
log.debug( _("readBlinds starting") )
|
||||
#log.debug( _("readBlinds starting, hand=") + "\n["+hand.handText+"]" )
|
||||
try:
|
||||
m = self.re_PostSB.search(hand.handText)
|
||||
if m is None:
|
||||
log.debug( _("re_postSB failed, hand=") + hand.handText )
|
||||
hand.addBlind(m.group('PNAME'), 'small blind', m.group('SB'))
|
||||
except: # no small blind
|
||||
log.debug( _("readBlinds in noSB exception")+str(sys.exc_info()) )
|
||||
hand.addBlind(None, None, None)
|
||||
except exceptions.AttributeError: # no small blind
|
||||
log.debug( _("readBlinds in noSB exception - no SB created")+str(sys.exc_info()) )
|
||||
#hand.addBlind(None, None, None)
|
||||
for a in self.re_PostBB.finditer(hand.handText):
|
||||
hand.addBlind(a.group('PNAME'), 'big blind', a.group('BB'))
|
||||
for a in self.re_PostBoth.finditer(hand.handText):
|
||||
|
@ -289,7 +320,7 @@ class OnGame(HandHistoryConverter):
|
|||
m = self.re_Action.finditer(hand.streets[street])
|
||||
for action in m:
|
||||
acts = action.groupdict()
|
||||
#print "DEBUG: acts: %s" %acts
|
||||
#log.debug("readaction: acts: %s" %acts)
|
||||
if action.group('ATYPE') == ' raises':
|
||||
hand.addRaiseBy( street, action.group('PNAME'), action.group('BET') )
|
||||
elif action.group('ATYPE') == ' calls':
|
||||
|
@ -314,18 +345,22 @@ class OnGame(HandHistoryConverter):
|
|||
hand.addShownCards(cards, shows.group('PNAME'))
|
||||
|
||||
def readCollectPot(self,hand):
|
||||
for m in self.re_CollectPot.finditer(hand.handText):
|
||||
hand.addCollectPot(player=m.group('PNAME'),pot=m.group('POT'))
|
||||
for m in self.re_Pot.finditer(hand.handText):
|
||||
for splitpot in m.group('POT').split(','):
|
||||
for m in self.re_CollectPot.finditer(splitpot):
|
||||
hand.addCollectPot(player=m.group('PNAME'),pot=m.group('POT'))
|
||||
|
||||
def readShownCards(self,hand):
|
||||
return
|
||||
#for m in self.rexx.collect_pot_re.finditer(hand.string):
|
||||
#if m.group('CARDS') is not None:
|
||||
#cards = m.group('CARDS')
|
||||
#cards = set(cards.split(','))
|
||||
#hand.addShownCards(cards=None, player=m.group('PNAME'), holeandboard=cards)
|
||||
for m in self.re_ShownCards.finditer(hand.handText):
|
||||
cards = m.group('CARDS')
|
||||
cards = cards.split(', ') # needs to be a list, not a set--stud needs the order
|
||||
|
||||
(shown, mucked) = (False, False)
|
||||
if m.group('CARDS') is not None:
|
||||
shown = True
|
||||
hand.addShownCards(cards=cards, player=m.group('PNAME'), shown=shown, mucked=mucked)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
|
|
@ -502,7 +502,10 @@ class PartyPoker(HandHistoryConverter):
|
|||
if type=="tour":
|
||||
TableName = table_name.split(" ")
|
||||
print 'party', 'getTableTitleRe', "%s.+Table\s#%s" % (TableName[0], table_number)
|
||||
return "%s.+Table\s#%s" % (TableName[0], table_number)
|
||||
if len(TableName[1]) > 6:
|
||||
return "#%s" % (table_number)
|
||||
else:
|
||||
return "%s.+Table\s#%s" % (TableName[0], table_number)
|
||||
else:
|
||||
print 'party', 'getTableTitleRe', table_number
|
||||
return table_name
|
||||
|
|
|
@ -224,14 +224,15 @@ class PokerStars(HandHistoryConverter):
|
|||
|
||||
def readHandInfo(self, hand):
|
||||
info = {}
|
||||
m = self.re_HandInfo.search(hand.handText,re.DOTALL)
|
||||
if m:
|
||||
info.update(m.groupdict())
|
||||
else:
|
||||
pass # throw an exception here, eh?
|
||||
m = self.re_GameInfo.search(hand.handText)
|
||||
if m:
|
||||
info.update(m.groupdict())
|
||||
m = self.re_HandInfo.search(hand.handText,re.DOTALL)
|
||||
m2 = self.re_GameInfo.search(hand.handText)
|
||||
if m is None or m2 is None:
|
||||
logging.info("Didn't match re_HandInfo")
|
||||
logging.info(hand.handText)
|
||||
raise FpdbParseError("No match in readHandInfo.")
|
||||
|
||||
info.update(m.groupdict())
|
||||
info.update(m2.groupdict())
|
||||
|
||||
log.debug("readHandInfo: %s" % info)
|
||||
for key in info:
|
||||
|
|
262
pyfpdb/Stats.py
262
pyfpdb/Stats.py
|
@ -78,7 +78,6 @@ log = logging.getLogger("db")
|
|||
|
||||
|
||||
re_Places = re.compile("_[0-9]$")
|
||||
re_Percent = re.compile("%$")
|
||||
|
||||
# String manipulation
|
||||
import codecs
|
||||
|
@ -88,35 +87,26 @@ def do_tip(widget, tip):
|
|||
_tip = Charset.to_utf8(tip)
|
||||
widget.set_tooltip_text(_tip)
|
||||
|
||||
|
||||
def do_stat(stat_dict, player = 24, stat = 'vpip'):
|
||||
match = re_Places.search(stat)
|
||||
if match is None:
|
||||
result = eval("%(stat)s(stat_dict, %(player)d)" % {'stat': stat, 'player': player})
|
||||
else:
|
||||
result = eval("%(stat)s(stat_dict, %(player)d)" % {'stat': stat, 'player': player})
|
||||
|
||||
# If decimal places have been defined, override result[1]
|
||||
# NOTE: decimal place override ALWAYS assumes the raw result is a
|
||||
# fraction (x/100); manual decimal places really only make sense for
|
||||
# percentage values. Also, profit/100 hands (bb/BB) already default
|
||||
# to three decimal places anyhow, so they are unlikely override
|
||||
# candidates.
|
||||
if match:
|
||||
base = stat[0:-2]
|
||||
places = int(stat[-1:])
|
||||
result = (0.0, '0.0', 'notset=0', 'notset=0', '0', 'not set')
|
||||
try:
|
||||
result = eval("%(stat)s(stat_dict, %(player)d)" % {'stat': base, 'player': player})
|
||||
except:
|
||||
pass #
|
||||
log.info(_("exception getting stat %s for player %s %s") % (base, str(player), str(sys.exc_info())))
|
||||
log.debug(_("Stats.do_stat result = %s") % str(result) )
|
||||
|
||||
match = re_Percent.search(result[1])
|
||||
try:
|
||||
if match is None:
|
||||
result = (result[0], "%.*f" % (places, result[0]), result[2], result[3], result[4], result[5])
|
||||
else:
|
||||
result = (result[0], "%.*f%%" % (places, 100*result[0]), result[2], result[3], result[4], result[5])
|
||||
except:
|
||||
log.info(_("error: %s") % str(sys.exc_info()))
|
||||
raise
|
||||
result[1] = '%.*f' % (places, 100.0*result[0])
|
||||
return result
|
||||
|
||||
# OK, for reference the tuple returned by the stat is:
|
||||
# 0 - The stat, raw, no formating, eg 0.33333333
|
||||
# 1 - formatted stat with appropriate precision and punctuation, eg 33%
|
||||
# 1 - formatted stat with appropriate precision, eg. 33; shown in HUD
|
||||
# 2 - formatted stat with appropriate precision, punctuation and a hint, eg v=33%
|
||||
# 3 - same as #2 except name of stat instead of hint, eg vpip=33%
|
||||
# 4 - the calculation that got the stat, eg 9/27
|
||||
|
@ -147,10 +137,10 @@ def vpip(stat_dict, player):
|
|||
try:
|
||||
stat = float(stat_dict[player]['vpip'])/float(stat_dict[player]['n'])
|
||||
return (stat,
|
||||
'%3.1f' % (100*stat) + '%',
|
||||
'v=%3.1f' % (100*stat) + '%',
|
||||
'vpip=%3.1f' % (100*stat) + '%',
|
||||
'(%d/%d)' % (stat_dict[player]['vpip'], stat_dict[player]['n']),
|
||||
'%3.1f' % (100.0*stat),
|
||||
'v=%3.1f%%' % (100.0*stat),
|
||||
'vpip=%3.1f%%' % (100.0*stat),
|
||||
'(%d/%d)' % (stat_dict[player]['vpip'], stat_dict[player]['n']),
|
||||
_('Voluntarily Put In Pot Pre-Flop%')
|
||||
)
|
||||
except: return (stat,
|
||||
|
@ -167,9 +157,9 @@ def pfr(stat_dict, player):
|
|||
try:
|
||||
stat = float(stat_dict[player]['pfr'])/float(stat_dict[player]['n'])
|
||||
return (stat,
|
||||
'%3.1f' % (100*stat) + '%',
|
||||
'p=%3.1f' % (100*stat) + '%',
|
||||
'pfr=%3.1f' % (100*stat) + '%',
|
||||
'%3.1f' % (100.0*stat),
|
||||
'p=%3.1f%%' % (100.0*stat),
|
||||
'pfr=%3.1f%%' % (100.0*stat),
|
||||
'(%d/%d)' % (stat_dict[player]['pfr'], stat_dict[player]['n']),
|
||||
_('Pre-Flop Raise %')
|
||||
)
|
||||
|
@ -188,10 +178,10 @@ def wtsd(stat_dict, player):
|
|||
try:
|
||||
stat = float(stat_dict[player]['sd'])/float(stat_dict[player]['saw_f'])
|
||||
return (stat,
|
||||
'%3.1f' % (100*stat) + '%',
|
||||
'w=%3.1f' % (100*stat) + '%',
|
||||
'wtsd=%3.1f' % (100*stat) + '%',
|
||||
'(%d/%d)' % (stat_dict[player]['sd'], stat_dict[player]['saw_f']),
|
||||
'%3.1f' % (100.0*stat),
|
||||
'w=%3.1f%%' % (100.0*stat),
|
||||
'wtsd=%3.1f%%' % (100.0*stat),
|
||||
'(%d/%d)' % (stat_dict[player]['sd'], stat_dict[player]['saw_f']),
|
||||
_('% went to showdown')
|
||||
)
|
||||
except:
|
||||
|
@ -209,9 +199,9 @@ def wmsd(stat_dict, player):
|
|||
try:
|
||||
stat = float(stat_dict[player]['wmsd'])/float(stat_dict[player]['sd'])
|
||||
return (stat,
|
||||
'%3.1f' % (100*stat) + '%',
|
||||
'w=%3.1f' % (100*stat) + '%',
|
||||
'wmsd=%3.1f' % (100*stat) + '%',
|
||||
'%3.1f' % (100.0*stat),
|
||||
'w=%3.1f%%' % (100.0*stat),
|
||||
'wmsd=%3.1f%%' % (100.0*stat),
|
||||
'(%5.1f/%d)' % (float(stat_dict[player]['wmsd']), stat_dict[player]['sd']),
|
||||
_('% won money at showdown')
|
||||
)
|
||||
|
@ -230,9 +220,9 @@ def profit100(stat_dict, player):
|
|||
try:
|
||||
stat = float(stat_dict[player]['net'])/float(stat_dict[player]['n'])
|
||||
return (stat,
|
||||
'%.0f' % (100.0*stat),
|
||||
'p=%.0f' % (100.0*stat),
|
||||
'p/100=%.0f' % (100.0*stat),
|
||||
'%.0f' % (100.0*stat),
|
||||
'p=%.0f' % (100.0*stat),
|
||||
'p/100=%.0f' % (100.0*stat),
|
||||
'%d/%d' % (stat_dict[player]['net'], stat_dict[player]['n']),
|
||||
_('profit/100hands')
|
||||
)
|
||||
|
@ -252,10 +242,10 @@ def bbper100(stat_dict, player):
|
|||
try:
|
||||
stat = 100.0 * float(stat_dict[player]['net']) / float(stat_dict[player]['bigblind'])
|
||||
return (stat,
|
||||
'%5.3f' % (stat),
|
||||
'bb100=%5.3f' % (stat),
|
||||
'bb100=%5.3f' % (stat),
|
||||
'(%d,%d)' % (100*stat_dict[player]['net'],stat_dict[player]['bigblind']),
|
||||
'%5.3f' % (stat),
|
||||
'bb100=%5.3f' % (stat),
|
||||
'bb100=%5.3f' % (stat),
|
||||
'(%d,%d)' % (100*stat_dict[player]['net'],stat_dict[player]['bigblind']),
|
||||
_('big blinds/100 hands')
|
||||
)
|
||||
except:
|
||||
|
@ -274,10 +264,10 @@ def BBper100(stat_dict, player):
|
|||
try:
|
||||
stat = 50 * float(stat_dict[player]['net']) / float(stat_dict[player]['bigblind'])
|
||||
return (stat,
|
||||
'%5.3f' % (stat),
|
||||
'BB100=%5.3f' % (stat),
|
||||
'BB100=%5.3f' % (stat),
|
||||
'(%d,%d)' % (100*stat_dict[player]['net'],2*stat_dict[player]['bigblind']),
|
||||
'%5.3f' % (stat),
|
||||
'BB100=%5.3f' % (stat),
|
||||
'BB100=%5.3f' % (stat),
|
||||
'(%d,%d)' % (100*stat_dict[player]['net'],2*stat_dict[player]['bigblind']),
|
||||
_('Big Bets/100 hands')
|
||||
)
|
||||
except:
|
||||
|
@ -297,10 +287,10 @@ def saw_f(stat_dict, player):
|
|||
den = float(stat_dict[player]['n'])
|
||||
stat = num/den
|
||||
return (stat,
|
||||
'%3.1f' % (100*stat) + '%',
|
||||
'sf=%3.1f' % (100*stat) + '%',
|
||||
'saw_f=%3.1f' % (100*stat) + '%',
|
||||
'(%d/%d)' % (stat_dict[player]['saw_f'], stat_dict[player]['n']),
|
||||
'%3.1f' % (100.0*stat),
|
||||
'sf=%3.1f%%' % (100.0*stat),
|
||||
'saw_f=%3.1f%%' % (100.0*stat),
|
||||
'(%d/%d)' % (stat_dict[player]['saw_f'], stat_dict[player]['n']),
|
||||
_('Flop Seen %')
|
||||
)
|
||||
except:
|
||||
|
@ -351,10 +341,10 @@ def fold_f(stat_dict, player):
|
|||
try:
|
||||
stat = float(stat_dict[player]['fold_2'])/float(stat_dict[player]['saw_f'])
|
||||
return (stat,
|
||||
'%3.1f' % (100*stat) + '%',
|
||||
'ff=%3.1f' % (100*stat) + '%',
|
||||
'fold_f=%3.1f' % (100*stat) + '%',
|
||||
'(%d/%d)' % (stat_dict[player]['fold_2'], stat_dict[player]['saw_f']),
|
||||
'%3.1f' % (100.0*stat),
|
||||
'ff=%3.1f%%' % (100.0*stat),
|
||||
'fold_f=%3.1f%%' % (100.0*stat),
|
||||
'(%d/%d)' % (stat_dict[player]['fold_2'], stat_dict[player]['saw_f']),
|
||||
_('folded flop/4th')
|
||||
)
|
||||
except:
|
||||
|
@ -372,10 +362,10 @@ def steal(stat_dict, player):
|
|||
try:
|
||||
stat = float(stat_dict[player]['steal'])/float(stat_dict[player]['steal_opp'])
|
||||
return (stat,
|
||||
'%3.1f' % (100*stat) + '%',
|
||||
'st=%3.1f' % (100*stat) + '%',
|
||||
'steal=%3.1f' % (100*stat) + '%',
|
||||
'(%d/%d)' % (stat_dict[player]['steal'], stat_dict[player]['steal_opp']),
|
||||
'%3.1f' % (100.0*stat),
|
||||
'st=%3.1f%%' % (100.0*stat),
|
||||
'steal=%3.1f%%' % (100.0*stat),
|
||||
'(%d/%d)' % (stat_dict[player]['steal'], stat_dict[player]['steal_opp']),
|
||||
_('% steal attempted')
|
||||
)
|
||||
except:
|
||||
|
@ -387,10 +377,10 @@ def f_SB_steal(stat_dict, player):
|
|||
try:
|
||||
stat = float(stat_dict[player]['sbnotdef'])/float(stat_dict[player]['sbstolen'])
|
||||
return (stat,
|
||||
'%3.1f' % (100*stat) + '%',
|
||||
'fSB=%3.1f' % (100*stat) + '%',
|
||||
'fSB_s=%3.1f' % (100*stat) + '%',
|
||||
'(%d/%d)' % (stat_dict[player]['sbnotdef'], stat_dict[player]['sbstolen']),
|
||||
'%3.1f' % (100.0*stat),
|
||||
'fSB=%3.1f%%' % (100.0*stat),
|
||||
'fSB_s=%3.1f%%' % (100.0*stat),
|
||||
'(%d/%d)' % (stat_dict[player]['sbnotdef'], stat_dict[player]['sbstolen']),
|
||||
_('% folded SB to steal'))
|
||||
except:
|
||||
return (stat,
|
||||
|
@ -406,10 +396,10 @@ def f_BB_steal(stat_dict, player):
|
|||
try:
|
||||
stat = float(stat_dict[player]['bbnotdef'])/float(stat_dict[player]['bbstolen'])
|
||||
return (stat,
|
||||
'%3.1f' % (100*stat) + '%',
|
||||
'fBB=%3.1f' % (100*stat) + '%',
|
||||
'fBB_s=%3.1f' % (100*stat) + '%',
|
||||
'(%d/%d)' % (stat_dict[player]['bbnotdef'], stat_dict[player]['bbstolen']),
|
||||
'%3.1f' % (100.0*stat),
|
||||
'fBB=%3.1f%%' % (100.0*stat),
|
||||
'fBB_s=%3.1f%%' % (100.0*stat),
|
||||
'(%d/%d)' % (stat_dict[player]['bbnotdef'], stat_dict[player]['bbstolen']),
|
||||
_('% folded BB to steal'))
|
||||
except:
|
||||
return (stat,
|
||||
|
@ -428,10 +418,10 @@ def f_steal(stat_dict, player):
|
|||
|
||||
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),
|
||||
'%3.1f' % (100.0*stat),
|
||||
'fB=%3.1f%%' % (100.0*stat),
|
||||
'fB_s=%3.1f%%' % (100.0*stat),
|
||||
'(%d/%d)' % (folded_blind, blind_stolen),
|
||||
_('% folded blind to steal'))
|
||||
except:
|
||||
return (stat,
|
||||
|
@ -447,10 +437,10 @@ def three_B(stat_dict, player):
|
|||
try:
|
||||
stat = float(stat_dict[player]['tb_0'])/float(stat_dict[player]['tb_opp_0'])
|
||||
return (stat,
|
||||
'%3.1f' % (100*stat) + '%',
|
||||
'3B=%3.1f' % (100*stat) + '%',
|
||||
'3B_pf=%3.1f' % (100*stat) + '%',
|
||||
'(%d/%d)' % (stat_dict[player]['tb_0'], stat_dict[player]['tb_opp_0']),
|
||||
'%3.1f' % (100.0*stat),
|
||||
'3B=%3.1f%%' % (100.0*stat),
|
||||
'3B_pf=%3.1f%%' % (100.0*stat),
|
||||
'(%d/%d)' % (stat_dict[player]['tb_0'], stat_dict[player]['tb_opp_0']),
|
||||
_('% 3/4 Bet preflop/3rd'))
|
||||
except:
|
||||
return (stat,
|
||||
|
@ -466,10 +456,10 @@ def WMsF(stat_dict, player):
|
|||
try:
|
||||
stat = float(stat_dict[player]['w_w_s_1'])/float(stat_dict[player]['saw_1'])
|
||||
return (stat,
|
||||
'%3.1f' % (100*stat) + '%',
|
||||
'wf=%3.1f' % (100*stat) + '%',
|
||||
'w_w_f=%3.1f' % (100*stat) + '%',
|
||||
'(%d/%d)' % (stat_dict[player]['w_w_s_1'], stat_dict[player]['saw_f']),
|
||||
'%3.1f' % (100.0*stat),
|
||||
'wf=%3.1f%%' % (100.0*stat),
|
||||
'w_w_f=%3.1f%%' % (100.0*stat),
|
||||
'(%d/%d)' % (stat_dict[player]['w_w_s_1'], stat_dict[player]['saw_f']),
|
||||
_('% won$/saw flop/4th'))
|
||||
except:
|
||||
return (stat,
|
||||
|
@ -485,9 +475,9 @@ def a_freq1(stat_dict, player):
|
|||
try:
|
||||
stat = float(stat_dict[player]['aggr_1'])/float(stat_dict[player]['saw_f'])
|
||||
return (stat,
|
||||
'%3.1f' % (100*stat) + '%',
|
||||
'a1=%3.1f' % (100*stat) + '%',
|
||||
'a_fq_1=%3.1f' % (100*stat) + '%',
|
||||
'%3.1f' % (100.0*stat),
|
||||
'a1=%3.1f%%' % (100.0*stat),
|
||||
'a_fq_1=%3.1f%%' % (100.0*stat),
|
||||
'(%d/%d)' % (stat_dict[player]['aggr_1'], stat_dict[player]['saw_f']),
|
||||
_('Aggression Freq flop/4th'))
|
||||
except:
|
||||
|
@ -504,10 +494,10 @@ def a_freq2(stat_dict, player):
|
|||
try:
|
||||
stat = float(stat_dict[player]['aggr_2'])/float(stat_dict[player]['saw_2'])
|
||||
return (stat,
|
||||
'%3.1f' % (100*stat) + '%',
|
||||
'a2=%3.1f' % (100*stat) + '%',
|
||||
'a_fq_2=%3.1f' % (100*stat) + '%',
|
||||
'(%d/%d)' % (stat_dict[player]['aggr_2'], stat_dict[player]['saw_2']),
|
||||
'%3.1f' % (100.0*stat),
|
||||
'a2=%3.1f%%' % (100.0*stat),
|
||||
'a_fq_2=%3.1f%%' % (100.0*stat),
|
||||
'(%d/%d)' % (stat_dict[player]['aggr_2'], stat_dict[player]['saw_2']),
|
||||
_('Aggression Freq turn/5th'))
|
||||
except:
|
||||
return (stat,
|
||||
|
@ -523,9 +513,9 @@ def a_freq3(stat_dict, player):
|
|||
try:
|
||||
stat = float(stat_dict[player]['aggr_3'])/float(stat_dict[player]['saw_3'])
|
||||
return (stat,
|
||||
'%3.1f' % (100*stat) + '%',
|
||||
'a3=%3.1f' % (100*stat) + '%',
|
||||
'a_fq_3=%3.1f' % (100*stat) + '%',
|
||||
'%3.1f' % (100.0*stat),
|
||||
'a3=%3.1f%%' % (100.0*stat),
|
||||
'a_fq_3=%3.1f%%' % (100.0*stat),
|
||||
'(%d/%d)' % (stat_dict[player]['aggr_3'], stat_dict[player]['saw_3']),
|
||||
_('Aggression Freq river/6th'))
|
||||
except:
|
||||
|
@ -542,10 +532,10 @@ def a_freq4(stat_dict, player):
|
|||
try:
|
||||
stat = float(stat_dict[player]['aggr_4'])/float(stat_dict[player]['saw_4'])
|
||||
return (stat,
|
||||
'%3.1f' % (100*stat) + '%',
|
||||
'a4=%3.1f' % (100*stat) + '%',
|
||||
'a_fq_4=%3.1f' % (100*stat) + '%',
|
||||
'(%d/%d)' % (stat_dict[player]['aggr_4'], stat_dict[player]['saw_4']),
|
||||
'%3.1f' % (100.0*stat),
|
||||
'a4=%3.1f%%' % (100.0*stat),
|
||||
'a_fq_4=%3.1f%%' % (100.0*stat),
|
||||
'(%d/%d)' % (stat_dict[player]['aggr_4'], stat_dict[player]['saw_4']),
|
||||
_('Aggression Freq 7th'))
|
||||
except:
|
||||
return (stat,
|
||||
|
@ -562,9 +552,9 @@ def a_freq_123(stat_dict, player):
|
|||
stat = float( stat_dict[player]['aggr_1'] + stat_dict[player]['aggr_2'] + stat_dict[player]['aggr_3']
|
||||
) / float( stat_dict[player]['saw_1'] + stat_dict[player]['saw_2'] + stat_dict[player]['saw_3']);
|
||||
return (stat,
|
||||
'%3.1f' % (100*stat) + '%',
|
||||
'afq=%3.1f' % (100*stat) + '%',
|
||||
'postf_aggfq=%3.1f' % (100*stat) + '%',
|
||||
'%3.1f' % (100.0*stat),
|
||||
'afq=%3.1f%%' % (100.0*stat),
|
||||
'postf_aggfq=%3.1f%%' % (100.0*stat),
|
||||
'(%d/%d)' % ( stat_dict[player]['aggr_1']
|
||||
+ stat_dict[player]['aggr_2']
|
||||
+ stat_dict[player]['aggr_3']
|
||||
|
@ -596,10 +586,10 @@ def agg_freq(stat_dict, player):
|
|||
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)),
|
||||
'%3.1f' % (100.0*stat),
|
||||
'afr=%3.1f%%' % (100.0*stat),
|
||||
'agg_fr=%3.1f%%' % (100.0*stat),
|
||||
'(%d/%d)' % (bet_raise, (post_call + post_fold + bet_raise)),
|
||||
_('Aggression Freq'))
|
||||
except:
|
||||
return (stat,
|
||||
|
@ -646,10 +636,10 @@ def cbet(stat_dict, player):
|
|||
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),
|
||||
'%3.1f' % (100.0*stat),
|
||||
'cbet=%3.1f%%' % (100.0*stat),
|
||||
'cbet=%3.1f%%' % (100.0*stat),
|
||||
'(%d/%d)' % (cbets, oppt),
|
||||
_('% continuation bet '))
|
||||
except:
|
||||
return (stat,
|
||||
|
@ -665,10 +655,10 @@ def cb1(stat_dict, player):
|
|||
try:
|
||||
stat = float(stat_dict[player]['cb_1'])/float(stat_dict[player]['cb_opp_1'])
|
||||
return (stat,
|
||||
'%3.1f' % (100*stat) + '%',
|
||||
'cb1=%3.1f' % (100*stat) + '%',
|
||||
'cb_1=%3.1f' % (100*stat) + '%',
|
||||
'(%d/%d)' % (stat_dict[player]['cb_1'], stat_dict[player]['cb_opp_1']),
|
||||
'%3.1f' % (100.0*stat),
|
||||
'cb1=%3.1f%%' % (100.0*stat),
|
||||
'cb_1=%3.1f%%' % (100.0*stat),
|
||||
'(%d/%d)' % (stat_dict[player]['cb_1'], stat_dict[player]['cb_opp_1']),
|
||||
_('% continuation bet flop/4th'))
|
||||
except:
|
||||
return (stat,
|
||||
|
@ -684,10 +674,10 @@ def cb2(stat_dict, player):
|
|||
try:
|
||||
stat = float(stat_dict[player]['cb_2'])/float(stat_dict[player]['cb_opp_2'])
|
||||
return (stat,
|
||||
'%3.1f' % (100*stat) + '%',
|
||||
'cb2=%3.1f' % (100*stat) + '%',
|
||||
'cb_2=%3.1f' % (100*stat) + '%',
|
||||
'(%d/%d)' % (stat_dict[player]['cb_2'], stat_dict[player]['cb_opp_2']),
|
||||
'%3.1f' % (100.0*stat),
|
||||
'cb2=%3.1f%%' % (100.0*stat),
|
||||
'cb_2=%3.1f%%' % (100.0*stat),
|
||||
'(%d/%d)' % (stat_dict[player]['cb_2'], stat_dict[player]['cb_opp_2']),
|
||||
_('% continuation bet turn/5th'))
|
||||
except:
|
||||
return (stat,
|
||||
|
@ -703,10 +693,10 @@ def cb3(stat_dict, player):
|
|||
try:
|
||||
stat = float(stat_dict[player]['cb_3'])/float(stat_dict[player]['cb_opp_3'])
|
||||
return (stat,
|
||||
'%3.1f' % (100*stat) + '%',
|
||||
'cb3=%3.1f' % (100*stat) + '%',
|
||||
'cb_3=%3.1f' % (100*stat) + '%',
|
||||
'(%d/%d)' % (stat_dict[player]['cb_3'], stat_dict[player]['cb_opp_3']),
|
||||
'%3.1f' % (100.0*stat),
|
||||
'cb3=%3.1f%%' % (100.0*stat),
|
||||
'cb_3=%3.1f%%' % (100.0*stat),
|
||||
'(%d/%d)' % (stat_dict[player]['cb_3'], stat_dict[player]['cb_opp_3']),
|
||||
_('% continuation bet river/6th'))
|
||||
except:
|
||||
return (stat,
|
||||
|
@ -722,9 +712,9 @@ def cb4(stat_dict, player):
|
|||
try:
|
||||
stat = float(stat_dict[player]['cb_4'])/float(stat_dict[player]['cb_opp_4'])
|
||||
return (stat,
|
||||
'%3.1f' % (100*stat) + '%',
|
||||
'cb4=%3.1f' % (100*stat) + '%',
|
||||
'cb_4=%3.1f' % (100*stat) + '%',
|
||||
'%3.1f' % (100.0*stat),
|
||||
'cb4=%3.1f%%' % (100.0*stat),
|
||||
'cb_4=%3.1f%%' % (100.0*stat),
|
||||
'(%d/%d)' % (stat_dict[player]['cb_4'], stat_dict[player]['cb_opp_4']),
|
||||
_('% continuation bet 7th'))
|
||||
except:
|
||||
|
@ -741,10 +731,10 @@ def ffreq1(stat_dict, player):
|
|||
try:
|
||||
stat = float(stat_dict[player]['f_freq_1'])/float(stat_dict[player]['was_raised_1'])
|
||||
return (stat,
|
||||
'%3.1f' % (100*stat) + '%',
|
||||
'ff1=%3.1f' % (100*stat) + '%',
|
||||
'ff_1=%3.1f' % (100*stat) + '%',
|
||||
'(%d/%d)' % (stat_dict[player]['f_freq_1'], stat_dict[player]['was_raised_1']),
|
||||
'%3.1f' % (100.0*stat),
|
||||
'ff1=%3.1f%%' % (100.0*stat),
|
||||
'ff_1=%3.1f%%' % (100.0*stat),
|
||||
'(%d/%d)' % (stat_dict[player]['f_freq_1'], stat_dict[player]['was_raised_1']),
|
||||
_('% fold frequency flop/4th'))
|
||||
except:
|
||||
return (stat,
|
||||
|
@ -760,10 +750,10 @@ def ffreq2(stat_dict, player):
|
|||
try:
|
||||
stat = float(stat_dict[player]['f_freq_2'])/float(stat_dict[player]['was_raised_2'])
|
||||
return (stat,
|
||||
'%3.1f' % (100*stat) + '%',
|
||||
'ff2=%3.1f' % (100*stat) + '%',
|
||||
'ff_2=%3.1f' % (100*stat) + '%',
|
||||
'(%d/%d)' % (stat_dict[player]['f_freq_2'], stat_dict[player]['was_raised_2']),
|
||||
'%3.1f' % (100.0*stat),
|
||||
'ff2=%3.1f%%' % (100.0*stat),
|
||||
'ff_2=%3.1f%%' % (100.0*stat),
|
||||
'(%d/%d)' % (stat_dict[player]['f_freq_2'], stat_dict[player]['was_raised_2']),
|
||||
_('% fold frequency turn/5th'))
|
||||
except:
|
||||
return (stat,
|
||||
|
@ -779,10 +769,10 @@ def ffreq3(stat_dict, player):
|
|||
try:
|
||||
stat = float(stat_dict[player]['f_freq_3'])/float(stat_dict[player]['was_raised_3'])
|
||||
return (stat,
|
||||
'%3.1f' % (100*stat) + '%',
|
||||
'ff3=%3.1f' % (100*stat) + '%',
|
||||
'ff_3=%3.1f' % (100*stat) + '%',
|
||||
'(%d/%d)' % (stat_dict[player]['f_freq_3'], stat_dict[player]['was_raised_3']),
|
||||
'%3.1f' % (100.0*stat),
|
||||
'ff3=%3.1f%%' % (100.0*stat),
|
||||
'ff_3=%3.1f%%' % (100.0*stat),
|
||||
'(%d/%d)' % (stat_dict[player]['f_freq_3'], stat_dict[player]['was_raised_3']),
|
||||
_('% fold frequency river/6th'))
|
||||
except:
|
||||
return (stat,
|
||||
|
@ -798,10 +788,10 @@ def ffreq4(stat_dict, player):
|
|||
try:
|
||||
stat = float(stat_dict[player]['f_freq_4'])/float(stat_dict[player]['was_raised_4'])
|
||||
return (stat,
|
||||
'%3.1f' % (100*stat) + '%',
|
||||
'ff4=%3.1f' % (100*stat) + '%',
|
||||
'ff_4=%3.1f' % (100*stat) + '%',
|
||||
'(%d/%d)' % (stat_dict[player]['f_freq_4'], stat_dict[player]['was_raised_4']),
|
||||
'%3.1f' % (100.0*stat),
|
||||
'ff4=%3.1f%%' % (100.0*stat),
|
||||
'ff_4=%3.1f%%' % (100.0*stat),
|
||||
'(%d/%d)' % (stat_dict[player]['f_freq_4'], stat_dict[player]['was_raised_4']),
|
||||
_('% fold frequency 7th'))
|
||||
except:
|
||||
return (stat,
|
||||
|
@ -815,7 +805,7 @@ if __name__== "__main__":
|
|||
statlist = dir()
|
||||
misslist = [ "Configuration", "Database", "Charset", "codecs", "encoder"
|
||||
, "do_stat", "do_tip", "GInitiallyUnowned", "gtk", "pygtk"
|
||||
, "re", "re_Percent", "re_Places"
|
||||
, "re", "re_Places"
|
||||
]
|
||||
statlist = [ x for x in statlist if x not in dir(sys) ]
|
||||
statlist = [ x for x in statlist if x not in dir(codecs) ]
|
||||
|
|
449
pyfpdb/Tables.py
449
pyfpdb/Tables.py
|
@ -1,449 +0,0 @@
|
|||
#!/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-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
|
||||
# the Free Software Foundation; either version 2 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
########################################################################
|
||||
|
||||
# Standard Library modules
|
||||
import os
|
||||
import sys
|
||||
import re
|
||||
|
||||
import locale
|
||||
lang=locale.getdefaultlocale()[0][0:2]
|
||||
if lang=="en":
|
||||
def _(string): return string
|
||||
else:
|
||||
import gettext
|
||||
try:
|
||||
trans = gettext.translation("fpdb", localedir="locale", languages=[lang])
|
||||
trans.install()
|
||||
except IOError:
|
||||
def _(string): return string
|
||||
|
||||
# Win32 modules
|
||||
if os.name == 'nt':
|
||||
import win32gui
|
||||
import win32process
|
||||
import win32api
|
||||
import win32con
|
||||
import win32security
|
||||
|
||||
# FreePokerTools modules
|
||||
import Configuration
|
||||
|
||||
# Each TableWindow object must have the following attributes correctly populated:
|
||||
# tw.name = the table name from the title bar, which must to match the table name
|
||||
# from the corresponding hand history.
|
||||
# tw.site = the site name, e.g. PokerStars, FullTilt. This must match the site
|
||||
# name specified in the config file.
|
||||
# tw.number = This is the system id number for the client table window in the
|
||||
# format that the system presents it. This is Xid in Xwindows and
|
||||
# hwnd in Microsoft Windows.
|
||||
# tw.title = The full title from the window title bar.
|
||||
# tw.width, tw.height = The width and height of the window in pixels. This is
|
||||
# the internal width and height, not including the title bar and
|
||||
# window borders.
|
||||
# tw.x, tw.y = The x, y (horizontal, vertical) location of the window relative
|
||||
# to the top left of the display screen. This also does not include the
|
||||
# title bar and window borders. To put it another way, this is the
|
||||
# screen location of (0, 0) in the working window.
|
||||
|
||||
class Table_Window:
|
||||
def __init__(self, info = {}):
|
||||
if 'number' in info: self.number = info['number']
|
||||
if 'exe' in info: self.exe = info['exe']
|
||||
if 'width' in info: self.width = info['width']
|
||||
if 'height' in info: self.height = info['height']
|
||||
if 'x' in info: self.x = info['x']
|
||||
if 'y' in info: self.y = info['y']
|
||||
if 'site' in info: self.site = info['site']
|
||||
if 'title' in info: self.title = info['title']
|
||||
if 'name' in info: self.name = info['name']
|
||||
self.gdkhandle = None
|
||||
|
||||
def __str__(self):
|
||||
# __str__ method for testing
|
||||
temp = 'TableWindow object\n'
|
||||
temp = temp + " name = %s\n site = %s\n number = %s\n title = %s\n" % (self.name, self.site, self.number, self.title)
|
||||
# temp = temp + " game = %s\n structure = %s\n max = %s\n" % (self.game, self.structure, self.max)
|
||||
temp = temp + " width = %d\n height = %d\n x = %d\n y = %d\n" % (self.width, self.height, self.x, self.y)
|
||||
if getattr(self, 'tournament', 0):
|
||||
temp = temp + " tournament = %d\n table = %d" % (self.tournament, self.table)
|
||||
return temp
|
||||
|
||||
############################################################################
|
||||
# Top-level discovery routines--these are the modules interface
|
||||
def discover(c):
|
||||
"""Dispatch routine for finding all potential poker client windows."""
|
||||
if os.name == 'posix':
|
||||
tables = discover_posix(c)
|
||||
elif os.name == 'nt':
|
||||
tables = discover_nt(c)
|
||||
elif os.name == 'mac':
|
||||
tables = discover_mac(c)
|
||||
else:
|
||||
tables = {}
|
||||
return tables
|
||||
|
||||
def discover_table_by_name(c, tablename):
|
||||
"""Dispatch routine for finding poker client windows with the given name."""
|
||||
if os.name == 'posix':
|
||||
info = discover_posix_by_name(c, tablename)
|
||||
elif os.name == 'nt':
|
||||
info = discover_nt_by_name(c, tablename)
|
||||
elif os.name == 'mac':
|
||||
info = discover_mac_by_name(c, tablename)
|
||||
else:
|
||||
return None
|
||||
if info is None:
|
||||
return None
|
||||
return Table_Window(info)
|
||||
|
||||
def discover_tournament_table(c, tour_number, tab_number):
|
||||
"""Dispatch routine for finding poker clients with tour and table number."""
|
||||
if os.name == 'posix':
|
||||
info = discover_posix_tournament(c, tour_number, tab_number)
|
||||
elif os.name == 'nt':
|
||||
info = discover_nt_tournament(c, tour_number, tab_number)
|
||||
elif os.name == 'mac':
|
||||
info = discover_mac_tournament(c, tour_number, tab_number)
|
||||
else:
|
||||
return None
|
||||
if info:
|
||||
return Table_Window(info)
|
||||
return None
|
||||
|
||||
#############################################################################
|
||||
# Posix (= XWindows) specific routines
|
||||
def discover_posix(c):
|
||||
"""Poker client table window finder for posix/Linux = XWindows."""
|
||||
tables = {}
|
||||
for listing in os.popen('xwininfo -root -tree').readlines():
|
||||
# xwininfo -root -tree -id 0xnnnnn gets the info on a single window
|
||||
for s in c.get_supported_sites():
|
||||
params = c.get_site_parameters(s)
|
||||
|
||||
# TODO: We need to make a list of phrases, shared between the WIndows and Unix code!!!!!!
|
||||
if re.search(params['table_finder'], listing):
|
||||
if 'Lobby' in listing: continue
|
||||
if 'Instant Hand History' in listing: continue
|
||||
# if '\"Full Tilt Poker\"' in listing: continue
|
||||
if 'History for table:' in listing: continue
|
||||
if 'has no name' in listing: continue
|
||||
info = decode_xwininfo(c, listing)
|
||||
if info['site'] is None: continue
|
||||
if info['title'] == info['exe']: continue
|
||||
# this appears to be a poker client, so make a table object for it
|
||||
tw = Table_Window(info)
|
||||
eval("%s(tw)" % params['decoder'])
|
||||
tables[tw.name] = tw
|
||||
return tables
|
||||
|
||||
def discover_posix_by_name(c, tablename):
|
||||
"""Find an XWindows poker client of the given name."""
|
||||
for listing in os.popen('xwininfo -root -tree').readlines():
|
||||
if tablename in listing:
|
||||
if 'History for table:' in listing: continue
|
||||
info = decode_xwininfo(c, listing)
|
||||
if not info['name'] == tablename: continue
|
||||
return info
|
||||
return None
|
||||
|
||||
def discover_posix_tournament(c, t_number, s_number):
|
||||
"""Finds the X window for a client, given tournament and table nos."""
|
||||
search_string = "%s.+Table.+%s" % (t_number, s_number)
|
||||
for listing in os.popen('xwininfo -root -tree').readlines():
|
||||
if re.search(search_string, listing):
|
||||
return decode_xwininfo(c, listing)
|
||||
return None
|
||||
|
||||
def decode_xwininfo(c, info_string):
|
||||
"""Gets window parameters from xwinifo string--XWindows."""
|
||||
info = {}
|
||||
mo = re.match('\s+([\dxabcdef]+) (.+):\s\(\"([a-zA-Z.]+)\".+ (\d+)x(\d+)\+\d+\+\d+ \+(\d+)\+(\d+)', info_string)
|
||||
if not mo:
|
||||
return None
|
||||
else:
|
||||
info['number'] = int( mo.group(1), 0)
|
||||
info['exe'] = mo.group(3)
|
||||
info['width'] = int( mo.group(4) )
|
||||
info['height'] = int( mo.group(5) )
|
||||
info['x'] = int( mo.group(6) )
|
||||
info['y'] = int( mo.group(7) )
|
||||
info['site'] = get_site_from_exe(c, info['exe'])
|
||||
info['title'] = re.sub('\"', '', mo.group(2))
|
||||
title_bits = re.split(' - ', info['title'])
|
||||
info['name'] = clean_title(title_bits[0])
|
||||
return info
|
||||
|
||||
##############################################################################
|
||||
# NT (= Windows) specific routines
|
||||
def discover_nt(c):
|
||||
""" Poker client table window finder for Windows."""
|
||||
#
|
||||
# I cannot figure out how to get the inside dimensions of the poker table
|
||||
# windows. So I just assume all borders are 3 thick and all title bars
|
||||
# are 29 high. No doubt this will be off when used with certain themes.
|
||||
#
|
||||
b_width = 3
|
||||
tb_height = 29
|
||||
titles = {}
|
||||
tables = {}
|
||||
win32gui.EnumWindows(win_enum_handler, titles)
|
||||
for hwnd in titles:
|
||||
if 'Logged In as' in titles[hwnd] and not 'Lobby' in titles[hwnd]:
|
||||
if 'Full Tilt Poker' in titles[hwnd]:
|
||||
continue
|
||||
tw = Table_Window()
|
||||
tw.number = hwnd
|
||||
(x, y, width, height) = win32gui.GetWindowRect(hwnd)
|
||||
tw.title = titles[hwnd]
|
||||
tw.width = int( width ) - 2*b_width
|
||||
tw.height = int( height ) - b_width - tb_height
|
||||
tw.x = int( x ) + b_width
|
||||
tw.y = int( y ) + tb_height
|
||||
|
||||
# TODO: Isn't the site being determined by the EXE name it belongs to? is this section of code even useful? cleaning it anyway
|
||||
if 'Logged In as' in titles[hwnd]:
|
||||
tw.site = "PokerStars"
|
||||
elif 'Logged In As' in titles[hwnd]:
|
||||
tw.site = "Full Tilt"
|
||||
else:
|
||||
tw.site = "Unknown"
|
||||
sys.stderr.write(_("Found unknown table = %s") % tw.title)
|
||||
if tw.site != "Unknown":
|
||||
eval("%s(tw)" % c.supported_sites[tw.site].decoder)
|
||||
else:
|
||||
tw.name = "Unknown"
|
||||
tables[len(tables)] = tw
|
||||
return tables
|
||||
|
||||
def discover_nt_by_name(c, tablename):
|
||||
"""Finds poker client window with the given table name."""
|
||||
titles = {}
|
||||
win32gui.EnumWindows(win_enum_handler, titles)
|
||||
|
||||
for hwnd in titles:
|
||||
#print "Tables.py: tablename =", tablename, "title =", titles[hwnd]
|
||||
try:
|
||||
# maybe it's better to make global titles[hwnd] decoding?
|
||||
# this can blow up in XP on some windows, eg firefox displaying http://docs.python.org/tutorial/classes.html
|
||||
if not tablename.lower() in titles[hwnd].decode(Configuration.LOCALE_ENCODING).lower():
|
||||
continue
|
||||
except:
|
||||
continue
|
||||
if 'History for table:' in titles[hwnd]: continue # Everleaf Network HH viewer window
|
||||
if 'HUD:' in titles[hwnd]: continue # FPDB HUD window
|
||||
if 'Chat:' in titles[hwnd]: continue # Some sites (FTP? PS? Others?) have seperable or seperately constructed chat windows
|
||||
if ' - Table ' in titles[hwnd]: continue # Absolute table Chat window.. sigh. TODO: Can we tell what site we're trying to discover for somehow in here, so i can limit this check just to AP searches?
|
||||
temp = decode_windows(c, titles[hwnd], hwnd)
|
||||
print _("attach to window"), temp
|
||||
return temp
|
||||
return None
|
||||
|
||||
def discover_nt_tournament(c, tour_number, tab_number):
|
||||
"""Finds the Windows window handle for the given tournament/table."""
|
||||
search_string = "%s.+%s" % (tour_number, tab_number)
|
||||
|
||||
titles ={}
|
||||
win32gui.EnumWindows(win_enum_handler, titles)
|
||||
for hwnd in titles:
|
||||
# Some sites (FTP? PS? Others?) have seperable or seperately constructed chat windows
|
||||
if 'Chat:' in titles[hwnd]: continue
|
||||
# Everleaf Network HH viewer window
|
||||
if 'History for table:' in titles[hwnd]: continue
|
||||
# FPDB HUD window
|
||||
if 'HUD:' in titles[hwnd]: continue
|
||||
|
||||
if re.search(search_string, titles[hwnd]):
|
||||
return decode_windows(c, titles[hwnd], hwnd)
|
||||
return None
|
||||
|
||||
def get_nt_exe(hwnd):
|
||||
"""Finds the name of the executable that the given window handle belongs to."""
|
||||
|
||||
# Request privileges to enable "debug process", so we can later use
|
||||
# PROCESS_VM_READ, retardedly required to GetModuleFileNameEx()
|
||||
priv_flags = win32security.TOKEN_ADJUST_PRIVILEGES | win32security.TOKEN_QUERY
|
||||
hToken = win32security.OpenProcessToken (win32api.GetCurrentProcess(),
|
||||
priv_flags)
|
||||
# enable "debug process"
|
||||
privilege_id = win32security.LookupPrivilegeValue(None,
|
||||
win32security.SE_DEBUG_NAME)
|
||||
old_privs = win32security.AdjustTokenPrivileges(hToken, 0,
|
||||
[(privilege_id,
|
||||
win32security.SE_PRIVILEGE_ENABLED)])
|
||||
|
||||
# Open the process, and query it's filename
|
||||
processid = win32process.GetWindowThreadProcessId(hwnd)
|
||||
pshandle = win32api.OpenProcess(win32con.PROCESS_QUERY_INFORMATION |
|
||||
win32con.PROCESS_VM_READ, False,
|
||||
processid[1])
|
||||
try:
|
||||
exename = win32process.GetModuleFileNameEx(pshandle, 0)
|
||||
except pywintypes.error:
|
||||
# insert code to call GetProcessImageName if we can find it..
|
||||
# returning None from here will hopefully break all following code
|
||||
exename = None
|
||||
finally:
|
||||
# clean up
|
||||
win32api.CloseHandle(pshandle)
|
||||
win32api.CloseHandle(hToken)
|
||||
|
||||
return exename
|
||||
|
||||
def decode_windows(c, title, hwnd):
|
||||
"""Gets window parameters from the window title and handle--Windows."""
|
||||
|
||||
# I cannot figure out how to get the inside dimensions of the poker table
|
||||
# windows. So I just assume all borders are 3 thick and all title bars
|
||||
# are 29 high. No doubt this will be off when used with certain themes.
|
||||
b_width = 3
|
||||
tb_height = 29
|
||||
|
||||
info = {}
|
||||
info['number'] = hwnd
|
||||
info['title'] = re.sub('\"', '', title)
|
||||
(x, y, width, height) = win32gui.GetWindowRect(hwnd)
|
||||
|
||||
info['x'] = int(x) + b_width
|
||||
info['y'] = int( y ) + tb_height
|
||||
info['width'] = int( width ) - 2*b_width
|
||||
info['height'] = int( height ) - b_width - tb_height
|
||||
info['exe'] = get_nt_exe(hwnd)
|
||||
print "get_nt_exe returned ", info['exe']
|
||||
# TODO: 'width' here is all sorts of screwed up.
|
||||
|
||||
title_bits = re.split(' - ', info['title'])
|
||||
info['name'] = title_bits[0]
|
||||
info['site'] = get_site_from_exe(c, info['exe'])
|
||||
|
||||
return info
|
||||
|
||||
def win_enum_handler(hwnd, titles):
|
||||
str = win32gui.GetWindowText(hwnd)
|
||||
if str != "":
|
||||
titles[hwnd] = win32gui.GetWindowText(hwnd)
|
||||
|
||||
###################################################################
|
||||
# Utility routines used by all the discoverers.
|
||||
def get_site_from_exe(c, exe):
|
||||
"""Look up the site from config, given the exe."""
|
||||
for s in c.get_supported_sites():
|
||||
params = c.get_site_parameters(s)
|
||||
if re.search(params['table_finder'], exe):
|
||||
return params['site_name']
|
||||
return None
|
||||
|
||||
def everleaf_decode_table(tw):
|
||||
# 2 - Tournament ID: 573256 - NL Hold'em - 150/300 blinds - Good luck <username>! - [Connection is ...]
|
||||
pass
|
||||
|
||||
def pokerstars_decode_table(tw):
|
||||
# Extract poker information from the window title. This is not needed for
|
||||
# fpdb, since all that information is available in the db via new_hand_number.
|
||||
# This is needed only when using the HUD with a backend less integrated.
|
||||
title_bits = re.split(' - ', tw.title)
|
||||
name = title_bits[0]
|
||||
mo = re.search('Tournament (\d+) Table (\d+)', name)
|
||||
if mo:
|
||||
tw.tournament = int( mo.group(1) )
|
||||
tw.table = int( mo.group(2) )
|
||||
tw.name = name
|
||||
else:
|
||||
tw.tournament = None
|
||||
tw.name = clean_title(name)
|
||||
mo = re.search('(Razz|Stud H/L|Stud|Omaha H/L|Omaha|Hold\'em|5-Card Draw|Triple Draw 2-7 Lowball|Badugi)', tw.title)
|
||||
|
||||
tw.game = mo.group(1).lower()
|
||||
tw.game = re.sub('\'', '', tw.game)
|
||||
tw.game = re.sub('h/l', 'hi/lo', tw.game)
|
||||
|
||||
mo = re.search('(No Limit|Pot Limit)', tw.title)
|
||||
if mo:
|
||||
tw.structure = mo.group(1).lower()
|
||||
else:
|
||||
tw.structure = 'limit'
|
||||
|
||||
tw.max = None
|
||||
if tw.game in ('razz', 'stud', 'stud hi/lo'):
|
||||
tw.max = 8
|
||||
elif tw.game in ('5-card draw', 'triple draw 2-7 lowball'):
|
||||
tw.max = 6
|
||||
elif tw.game == 'holdem':
|
||||
pass
|
||||
elif tw.game in ('omaha', 'omaha hi/lo'):
|
||||
pass
|
||||
|
||||
def fulltilt_decode_table(tw):
|
||||
# Extract poker information from the window title. This is not needed for
|
||||
# fpdb, since all that information is available in the db via new_hand_number.
|
||||
# This is needed only when using the HUD with a backend less integrated.
|
||||
title_bits = re.split(' - ', tw.title)
|
||||
name = title_bits[0]
|
||||
tw.tournament = None
|
||||
tw.name = clean_title(name)
|
||||
|
||||
def clean_title(name):
|
||||
"""Clean the little info strings from the table name."""
|
||||
# these strings could go in a config file
|
||||
for pattern in [' \(6 max\)', ' \(heads up\)', ' \(deep\)',
|
||||
' \(deep hu\)', ' \(deep 6\)', '\(6 max, deep\)', ' \(2\)',
|
||||
' \(edu\)', ' \(edu, 6 max\)', ' \(6\)',
|
||||
' \(speed\)', 'special', 'newVPP',
|
||||
' no all-in', ' fast', ',', ' 50BB min', '50bb min', '\s+$']:
|
||||
name = re.sub(pattern, '', name)
|
||||
name = name.rstrip()
|
||||
return name
|
||||
|
||||
###########################################################################
|
||||
# Mac specific routines....all stubs for now
|
||||
def discover_mac_tournament(c, tour_number, tab_number):
|
||||
"""Mac users need help."""
|
||||
return None
|
||||
|
||||
def discover_mac(c):
|
||||
"""Poker client table window finder for Macintosh."""
|
||||
tables = {}
|
||||
return tables
|
||||
|
||||
def discover_mac_by_name(c, tablename):
|
||||
"""Oh, the humanity."""
|
||||
# again, i have no mac to test this on, sorry -eric
|
||||
return None
|
||||
|
||||
###########################################################################
|
||||
# Main function used for testing
|
||||
if __name__=="__main__":
|
||||
c = Configuration.Config()
|
||||
|
||||
print discover_table_by_name(c, "Torino")
|
||||
# print discover_tournament_table(c, "118942908", "3")
|
||||
|
||||
tables = discover(c)
|
||||
for t in tables.keys():
|
||||
print tables[t]
|
||||
|
||||
print _("press enter to continue")
|
||||
sys.stdin.readline()
|
|
@ -12,7 +12,8 @@ import fpdb_import
|
|||
|
||||
|
||||
class FpdbError:
|
||||
def __init__(self):
|
||||
def __init__(self, sitename):
|
||||
self.site = sitename
|
||||
self.errorcount = 0
|
||||
self.histogram = {}
|
||||
|
||||
|
@ -28,6 +29,7 @@ class FpdbError:
|
|||
self.errorcount += 1
|
||||
|
||||
def print_histogram(self):
|
||||
print "%s:" % self.site
|
||||
for f in self.histogram:
|
||||
idx = f.find('regression')
|
||||
print "(%3d) : %s" %(self.histogram[f], f[idx:])
|
||||
|
@ -103,14 +105,25 @@ def main(argv=None):
|
|||
importer.setCallHud(False)
|
||||
importer.setFakeCacheHHC(True)
|
||||
|
||||
errors = FpdbError()
|
||||
PokerStarsErrors = FpdbError('PokerStars')
|
||||
FTPErrors = FpdbError('Full Tilt Poker')
|
||||
PartyPokerErrors = FpdbError('Party Poker')
|
||||
BetfairErrors = FpdbError('Betfair')
|
||||
|
||||
walk_testfiles("regression-test-files/cash/Stars/", compare, importer, errors)
|
||||
walk_testfiles("regression-test-files/cash/Stars/", compare, importer, PokerStarsErrors)
|
||||
walk_testfiles("regression-test-files/cash/FTP/", compare, importer, FTPErrors)
|
||||
walk_testfiles("regression-test-files/cash/PartyPoker/", compare, importer, PartyPokerErrors)
|
||||
walk_testfiles("regression-test-files/cash/Betfair/", compare, importer, BetfairErrors)
|
||||
|
||||
totalerrors = PokerStarsErrors.errorcount + FTPErrors.errorcount + PartyPokerErrors.errorcount + BetfairErrors.errorcount
|
||||
|
||||
print "---------------------"
|
||||
print "Total Errors: %d" % errors.errorcount
|
||||
print "Total Errors: %d" % totalerrors
|
||||
print "---------------------"
|
||||
errors.print_histogram()
|
||||
PokerStarsErrors.print_histogram()
|
||||
FTPErrors.print_histogram()
|
||||
PartyPokerErrors.print_histogram()
|
||||
BetfairErrors.print_histogram()
|
||||
|
||||
if __name__ == '__main__':
|
||||
sys.exit(main())
|
||||
|
|
|
@ -39,7 +39,7 @@ in_path (default '-' = sys.stdin)
|
|||
out_path (default '-' = sys.stdout)
|
||||
follow : whether to tail -f the input"""
|
||||
HandHistoryConverter.__init__(self, in_path, out_path, sitename="UltimateBet", follow=follow, index=index)
|
||||
logging.info("Initialising UltimateBetconverter class")
|
||||
logging.info(_("Initialising UltimateBetconverter class"))
|
||||
self.filetype = "text"
|
||||
self.codepage = "cp1252"
|
||||
self.siteId = 6 # Needs to match id entry in Sites database
|
||||
|
@ -141,7 +141,7 @@ follow : whether to tail -f the input"""
|
|||
if m:
|
||||
hand.buttonpos = int(m.group('BUTTON'))
|
||||
else:
|
||||
logging.info('readButton: not found')
|
||||
logging.info(_('readButton: not found'))
|
||||
|
||||
def readPlayerStacks(self, hand):
|
||||
logging.debug("readPlayerStacks")
|
||||
|
@ -180,7 +180,7 @@ follow : whether to tail -f the input"""
|
|||
hand.setCommunityCards(street, m.group('CARDS').split(' '))
|
||||
|
||||
def readAntes(self, hand):
|
||||
logging.debug("reading antes")
|
||||
logging.debug(_("reading antes"))
|
||||
m = self.re_Antes.finditer(hand.handText)
|
||||
for player in m:
|
||||
#~ logging.debug("hand.addAnte(%s,%s)" %(player.group('PNAME'), player.group('ANTE')))
|
||||
|
@ -290,7 +290,7 @@ follow : whether to tail -f the input"""
|
|||
#elif action.group('ATYPE') == ' stands pat':
|
||||
# hand.addStandsPat( street, action.group('PNAME'))
|
||||
else:
|
||||
print "DEBUG: unimplemented readAction: '%s' '%s'" %(action.group('PNAME'),action.group('ATYPE'),)
|
||||
print _("DEBUG: unimplemented readAction: '%s' '%s'" %(action.group('PNAME'),action.group('ATYPE'),))
|
||||
|
||||
|
||||
def readShowdownActions(self, hand):
|
||||
|
@ -312,9 +312,9 @@ follow : whether to tail -f the input"""
|
|||
|
||||
if __name__ == "__main__":
|
||||
parser = OptionParser()
|
||||
parser.add_option("-i", "--input", dest="ipath", help="parse input hand history", default="regression-test-files/pokerstars/HH20090226 Natalie V - $0.10-$0.20 - HORSE.txt")
|
||||
parser.add_option("-o", "--output", dest="opath", help="output translation to", default="-")
|
||||
parser.add_option("-f", "--follow", dest="follow", help="follow (tail -f) the input", action="store_true", default=False)
|
||||
parser.add_option("-i", "--input", dest="ipath", help=_("parse input hand history"), default="regression-test-files/pokerstars/HH20090226 Natalie V - $0.10-$0.20 - HORSE.txt")
|
||||
parser.add_option("-o", "--output", dest="opath", help=_("output translation to"), default="-")
|
||||
parser.add_option("-f", "--follow", dest="follow", help=_("follow (tail -f) the input"), action="store_true", default=False)
|
||||
parser.add_option("-q", "--quiet",
|
||||
action="store_const", const=logging.CRITICAL, dest="verbosity", default=logging.INFO)
|
||||
parser.add_option("-v", "--verbose",
|
||||
|
|
|
@ -153,7 +153,7 @@ class Win2day(HandHistoryConverter):
|
|||
hand.buttonpos = player[0]
|
||||
break
|
||||
else:
|
||||
logging.info('readButton: not found')
|
||||
logging.info(_('readButton: not found'))
|
||||
|
||||
def readPlayerStacks(self, hand):
|
||||
logging.debug("readPlayerStacks")
|
||||
|
@ -194,7 +194,7 @@ class Win2day(HandHistoryConverter):
|
|||
hand.setCommunityCards(street, boardCards)
|
||||
|
||||
def readAntes(self, hand):
|
||||
logging.debug("reading antes")
|
||||
logging.debug(_("reading antes"))
|
||||
m = self.re_Antes.finditer(hand.handText)
|
||||
for player in m:
|
||||
#~ logging.debug("hand.addAnte(%s,%s)" %(player.group('PNAME'), player.group('ANTE')))
|
||||
|
@ -332,7 +332,7 @@ class Win2day(HandHistoryConverter):
|
|||
elif action.group('ATYPE') == 'ACTION_STAND':
|
||||
hand.addStandsPat( street, action.group('PNAME'))
|
||||
else:
|
||||
print "DEBUG: unimplemented readAction: '%s' '%s'" %(action.group('PNAME'),action.group('ATYPE'),)
|
||||
print _("DEBUG: unimplemented readAction: '%s' '%s'" %(action.group('PNAME'),action.group('ATYPE'),))
|
||||
|
||||
|
||||
def readShowdownActions(self, hand):
|
||||
|
@ -359,9 +359,9 @@ class Win2day(HandHistoryConverter):
|
|||
|
||||
if __name__ == "__main__":
|
||||
parser = OptionParser()
|
||||
parser.add_option("-i", "--input", dest="ipath", help="parse input hand history", default="-")
|
||||
parser.add_option("-o", "--output", dest="opath", help="output translation to", default="-")
|
||||
parser.add_option("-f", "--follow", dest="follow", help="follow (tail -f) the input", action="store_true", default=False)
|
||||
parser.add_option("-i", "--input", dest="ipath", help=_("parse input hand history"), default="-")
|
||||
parser.add_option("-o", "--output", dest="opath", help=_("output translation to"), default="-")
|
||||
parser.add_option("-f", "--follow", dest="follow", help=_("follow (tail -f) the input"), action="store_true", default=False)
|
||||
parser.add_option("-q", "--quiet",
|
||||
action="store_const", const=logging.CRITICAL, dest="verbosity", default=logging.INFO)
|
||||
parser.add_option("-v", "--verbose",
|
||||
|
|
|
@ -544,8 +544,9 @@ class fpdb:
|
|||
#lock_released = False
|
||||
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 and you will have to re-import your histories.\nThis may take a while.")
|
||||
diastring = _("Please confirm that you want to (re-)create the tables.") \
|
||||
+ (_(" If there already are tables in the database %s on %s they will be deleted and you will have to re-import your histories.\n") % (self.db.database, self.db.host)) \
|
||||
+ _("This 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)
|
||||
|
@ -755,24 +756,6 @@ class fpdb:
|
|||
def dia_save_profile(self, widget, data=None):
|
||||
self.warning_box(_("Unimplemented: Save Profile (try saving a HUD layout, that should do it)"))
|
||||
|
||||
def diaSetupWizard(self, path):
|
||||
diaSetupWizard = gtk.Dialog(title=_("Fatal Error - Config File Missing"), parent=None, flags=0, buttons=(gtk.STOCK_QUIT,gtk.RESPONSE_OK))
|
||||
|
||||
label = gtk.Label(_("Please copy the config file from the docs folder to:"))
|
||||
diaSetupWizard.vbox.add(label)
|
||||
label.show()
|
||||
|
||||
label = gtk.Label(path)
|
||||
diaSetupWizard.vbox.add(label)
|
||||
label.show()
|
||||
|
||||
label = gtk.Label(_("and edit it according to the install documentation at http://fpdb.sourceforge.net"))
|
||||
diaSetupWizard.vbox.add(label)
|
||||
label.show()
|
||||
|
||||
response = diaSetupWizard.run()
|
||||
sys.exit(1)
|
||||
|
||||
def get_menu(self, window):
|
||||
"""returns the menu for this program"""
|
||||
fpdbmenu = """
|
||||
|
@ -876,8 +859,7 @@ class fpdb:
|
|||
if self.config.example_copy:
|
||||
self.info_box(_("Config file")
|
||||
, _("has been created at:\n%s.\n") % self.config.file
|
||||
+ _("Edit your screen_name and hand history path in the supported_sites ")
|
||||
+ _("section of the Preferences window (Main menu) before trying to import hands."))
|
||||
+ _("Edit your screen_name and hand history path in the supported_sites section of the Preferences window (Main menu) before trying to import hands."))
|
||||
self.settings = {}
|
||||
self.settings['global_lock'] = self.lock
|
||||
if (os.sep=="/"):
|
||||
|
@ -906,10 +888,10 @@ class fpdb:
|
|||
err_msg = _("MySQL client reports: 2002 or 2003 error. Unable to connect - ") \
|
||||
+ _("Please check that the MySQL service has been started")
|
||||
except Exceptions.FpdbPostgresqlAccessDenied:
|
||||
err_msg = _("Postgres Server reports: Access denied. Are your permissions set correctly?")
|
||||
err_msg = _("PostgreSQL Server reports: Access denied. Are your permissions set correctly?")
|
||||
except Exceptions.FpdbPostgresqlNoDatabase:
|
||||
err_msg = _("Postgres client reports: Unable to connect - ") \
|
||||
+ _("Please check that the Postgres service has been started")
|
||||
err_msg = _("PostgreSQL client reports: Unable to connect - ") \
|
||||
+ _("Please check that the PostgreSQL service has been started")
|
||||
if err_msg is not None:
|
||||
self.db = None
|
||||
self.warning_box(err_msg)
|
||||
|
@ -966,10 +948,10 @@ class fpdb:
|
|||
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 by"), source
|
||||
print (_("\nGlobal lock taken by %s") % source)
|
||||
self.lockTakenBy=source
|
||||
else:
|
||||
print _("\nFailed to get global lock, it is currently held by"), source
|
||||
print (_("\nFailed to get global lock, it is currently held by %s") % source)
|
||||
return ret
|
||||
# need to release it later:
|
||||
# self.lock.release()
|
||||
|
@ -1134,8 +1116,8 @@ You can find the full license texts in agpl-3.0.txt, gpl-2.0.txt, gpl-3.0.txt an
|
|||
|
||||
if not options.errorsToConsole:
|
||||
fileName = os.path.join(self.config.dir_log, 'fpdb-errors.txt')
|
||||
print _("\nNote: error output is being diverted to fpdb-errors.txt and HUD-errors.txt in:\n") \
|
||||
+ self.config.dir_log + _("\nAny major error will be reported there _only_.\n")
|
||||
print (_("\nNote: error output is being diverted to fpdb-errors.txt and HUD-errors.txt in: %s") % self.config.dir_log) \
|
||||
+ _("\nAny major error will be reported there _only_.\n")
|
||||
errorFile = open(fileName, 'w', 0)
|
||||
sys.stderr = errorFile
|
||||
|
||||
|
@ -1239,7 +1221,7 @@ You can find the full license texts in agpl-3.0.txt, gpl-2.0.txt, gpl-3.0.txt an
|
|||
hhdir = hhbase
|
||||
if not os.path.isdir(hhdir):
|
||||
diapath = gtk.MessageDialog(parent=None, flags=0, type=gtk.MESSAGE_WARNING, buttons=(gtk.BUTTONS_YES_NO), message_format="Setup hh dir")
|
||||
diastring = _("WARNING: Unable to find output hh directory %s\n\n Press YES to create this directory, or NO to select a new one.") % hhdir
|
||||
diastring = _("WARNING: Unable to find output hand history directory %s\n\n Press YES to create this directory, or NO to select a new one.") % hhdir
|
||||
diapath.format_secondary_text(diastring)
|
||||
response = diapath.run()
|
||||
diapath.destroy()
|
||||
|
|
|
@ -224,7 +224,7 @@ class Importer:
|
|||
#print " adding file ", file
|
||||
self.addImportFile(os.path.join(dir, file), site, filter)
|
||||
else:
|
||||
log.warning(_("Attempted to add non-directory: '%s' as an import directory") % str(dir))
|
||||
log.warning(_("Attempted to add non-directory '%s' as an import directory") % str(dir))
|
||||
|
||||
def runImport(self):
|
||||
""""Run full import on self.filelist. This is called from GuiBulkImport.py"""
|
||||
|
@ -310,7 +310,7 @@ class Importer:
|
|||
toterrors += errors
|
||||
|
||||
for i in xrange( self.settings['threads'] ):
|
||||
print _("sending finish msg qlen ="), q.qsize()
|
||||
print _("sending finish message queue length ="), q.qsize()
|
||||
db.send_finish_msg(q)
|
||||
|
||||
return (totstored, totdups, totpartial, toterrors)
|
||||
|
@ -436,9 +436,9 @@ class Importer:
|
|||
|
||||
# Load filter, process file, pass returned filename to import_fpdb_file
|
||||
if self.settings['threads'] > 0 and self.writeq is not None:
|
||||
log.info(_("Converting ") + file + " (" + str(q.qsize()) + ")")
|
||||
log.info((_("Converting %s") % file) + " (" + str(q.qsize()) + ")")
|
||||
else:
|
||||
log.info(_("Converting ") + file)
|
||||
log.info(_("Converting %s") % file)
|
||||
hhbase = self.config.get_import_parameters().get("hhArchiveBase")
|
||||
hhbase = os.path.expanduser(hhbase)
|
||||
hhdir = os.path.join(hhbase,site)
|
||||
|
|
|
@ -1,4 +0,0 @@
|
|||
cd ..
|
||||
python /usr/share/doc/python-2.7/examples/Tools/i18n/msgfmt.py --output-file=locale/hu/LC_MESSAGES/fpdb.mo locale/fpdb-hu_HU.po
|
||||
python /usr/share/doc/python-2.7/examples/Tools/i18n/msgfmt.py --output-file=locale/de/LC_MESSAGES/fpdb.mo locale/fpdb-de_DE.po
|
||||
|
|
@ -1,4 +0,0 @@
|
|||
cd ..
|
||||
rm *.pyc
|
||||
python /usr/share/doc/python-2.7/examples/Tools/i18n/pygettext.py --output-dir=locale --default-domain=fpdb --output=fpdb-en_GB.po *.py*
|
||||
|
Binary file not shown.
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
Binary file not shown.
15
pyfpdb/locale/localise.sh
Executable file
15
pyfpdb/locale/localise.sh
Executable file
|
@ -0,0 +1,15 @@
|
|||
cd ..
|
||||
rm *.pyc
|
||||
|
||||
echo "creating template po file"
|
||||
python /usr/share/doc/python-2.7/examples/Tools/i18n/pygettext.py --output-dir=locale --default-domain=fpdb --output=fpdb-en_GB.pot *.py*
|
||||
|
||||
echo "merging template with existing translations"
|
||||
msgmerge --update locale/fpdb-hu_HU.po locale/fpdb-en_GB.pot
|
||||
msgmerge --update locale/fpdb-de_DE.po locale/fpdb-en_GB.pot
|
||||
|
||||
echo "compiling mo files"
|
||||
python /usr/share/doc/python-2.7/examples/Tools/i18n/msgfmt.py --output-file=locale/hu/LC_MESSAGES/fpdb.mo locale/fpdb-hu_HU.po
|
||||
python /usr/share/doc/python-2.7/examples/Tools/i18n/msgfmt.py --output-file=locale/de/LC_MESSAGES/fpdb.mo locale/fpdb-de_DE.po
|
||||
|
||||
pocount locale/*.po
|
|
@ -1,3 +0,0 @@
|
|||
msgmerge --update fpdb-hu_HU.po fpdb-en_GB.po
|
||||
msgmerge --update fpdb-de_DE.po fpdb-en_GB.po
|
||||
|
Loading…
Reference in New Issue
Block a user