Commit Graph
100 Commits
Author SHA1 Message Date
Mika Bostrom ff9305924c Use proper encoding name
When system is unicode, the second item in locale.getdefaultlocale() is
"UTF8", not "utf-8".
2010-01-26 20:31:11 +01:00
Mika Bostrom 7f04ed88f4 Use proper encoding name
When system is unicode, the second item in locale.getdefaultlocale() is
"UTF8", not "utf-8".
2010-01-26 08:01:46 +02:00
Mika Bostrom 12367d6f37 Merge branch 'master' of git://git.assembla.com/fpdboz 2010-01-25 19:03:21 +02:00
Mika Bostrom b58edb53ae Write charmap-related errors directly to stderr
This change is needed to skip a nasty behaviour: if the string triggered
a decoding error, it will trigger one *AGAIN* if the string is printed
to console. By writing directly to sys.stderr we skip the
locale/conversion issues and get the troublesome string directly in a
file where it is stored as a raw sequence of octets.
2010-01-24 21:28:08 +01:00
Mika Bostrom 2c7287c351 Add new encoder
This encoder is used to handle input from HH conversion, which needs to
end up as UTF-8 in the database. Switch the open-coded routine from
Database.py to this common routine so all encodings now take place in
the same file.
2010-01-24 21:27:40 +01:00
Mika Bostrom 860b5737b7 Use common encoding routine everywhere
The string/locale manipulation in Database.py was open-coded and did not
use Charset.to_utf8() like the rest of the code.
2010-01-24 21:27:35 +01:00
Mika Bostrom 85c9070ec8 Write charmap-related errors directly to stderr
This change is needed to skip a nasty behaviour: if the string triggered
a decoding error, it will trigger one *AGAIN* if the string is printed
to console. By writing directly to sys.stderr we skip the
locale/conversion issues and get the troublesome string directly in a
file where it is stored as a raw sequence of octets.
2010-01-24 22:17:03 +02:00
Mika Bostrom 33277ce68b Add new encoder
This encoder is used to handle input from HH conversion, which needs to
end up as UTF-8 in the database. Switch the open-coded routine from
Database.py to this common routine so all encodings now take place in
the same file.
2010-01-24 21:11:46 +02:00
Mika Bostrom 6dcec48005 Use common encoding routine everywhere
The string/locale manipulation in Database.py was open-coded and did not
use Charset.to_utf8() like the rest of the code.
2010-01-24 19:59:49 +02:00
Mika Bostrom c36c60155c Use a different "unicoder" for db strings
It seems that running encoder.encode() on a latin1/latin9 string results
in, yes a bloody UnicodeDecodeError. Decode error on .encode()...
Really. This way the modification from non-unicode string to real
unicode appears to work better.
2010-01-24 13:35:10 +01:00
Mika Bostrom cc3811b8aa Add missing import
GuiPlayerStats.py didn't import the new Charset module but tried to use
the functions.
2010-01-24 13:24:26 +01:00
Mika Bostrom 3a03bc51a2 Some character set improvements
The strings (names) as stored in database should always be UTF-8;
whatever the display locale is, we then need to convert from the storage
encoding to session encoding. When making database queries with players
names in them, the names must be reconverted to UTF-8.
2010-01-23 16:34:24 +01:00
Mika Bostrom 8b012a3af3 Update debian/changelog for snapshot 2010-01-22 09:27:09 +02:00
Mika Bostrom 9aa52ce6a8 Merge branch 'master' of git://git.assembla.com/fpdboz
Conflicts:
	pyfpdb/Card.py

Resolve by removing stray empty lines
2010-01-22 09:24:19 +02:00
Mika Bostrom 91cd2d2599 Remove erroneous encoding
This string should not be encoded, it seems.
2010-01-21 22:05:24 +02:00
Mika Bostrom 29d5204bee Add missing import
GuiPlayerStats.py didn't import the new Charset module but tried to use
the functions.
2010-01-21 21:52:22 +02:00
Mika Bostrom 04c345ae1f Use a different "unicoder" for db strings
It seems that running encoder.encode() on a latin1/latin9 string results
in, yes a bloody UnicodeDecodeError. Decode error on .encode()...
Really. This way the modification from non-unicode string to real
unicode appears to work better.
2010-01-21 21:46:14 +02:00
Mika Bostrom dd12da302d Merge branch 'good'
Conflicts:
	pyfpdb/test_PokerStars.py

Resolve by copying sorrow's version on top-
2010-01-21 21:34:54 +02:00
Mika Bostrom dda00b6b10 Catch character encoding errors 2010-01-21 21:31:19 +02:00
Mika Bostrom a841603460 Some character set improvements
The strings (names) as stored in database should always be UTF-8;
whatever the display locale is, we then need to convert from the storage
encoding to session encoding. When making database queries with players
names in them, the names must be reconverted to UTF-8.
2010-01-21 21:24:55 +02:00
Mika Bostrom e915b0b62c Allow to bypass codec
If the system (display) locale is UTF-8, there is no need to encode to
either direction. In fact, running the .encode() routine appears to
mangle a valid UTF-8 string to a worse condition, effectively breaking
it.
2010-01-21 21:23:13 +02:00
Mika Bostrom 34bf2bd8e9 Use better function name 2010-01-21 18:12:45 +02:00
Mika Bostrom cd71778975 Fix name display in HUD popup
The names are stored in UTF-8, so simply converting the name from UTF-8
to Configuration.LOCALE_ENCODING before putting the string in tooltip is
enough. Neat.
2010-01-21 13:56:50 +08:00
Mika Bostrom 7ec58ad5c2 Fix name display in HUD popup
The names are stored in UTF-8, so simply converting the name from UTF-8
to Configuration.LOCALE_ENCODING before putting the string in tooltip is
enough. Neat.
2010-01-19 19:26:31 +02:00
Mika Bostrom cb172e15ae Fix name display in HUD popup
The names are stored in UTF-8, so simply converting the name from UTF-8
to Configuration.LOCALE_ENCODING before putting the string in tooltip is
enough. Neat.
2010-01-19 19:25:36 +02:00
Mika Bostrom 7f568a52b9 Merge branch 'newstats' into good 2010-01-16 13:56:20 +02:00
Mika Bostrom 1f43d8db48 Merge branch 'stats' of git://git.assembla.com/fpdboz into newstats 2010-01-16 13:35:53 +02:00
Mika Bostrom cdd7e6dce2 Merge branch 'stats' of git://git.assembla.com/fpdboz into newstats 2010-01-16 06:37:21 +02:00
Mika Bostrom 478b82587d Store names as UTF-8
The names should be always in UTF-8 encoding. At least for PostgreSQL
the encdoding of the database comes from the time of running 'initdb'
(which is different from 'createdb') and if the encoding was selected or
set to something else at that time, the following error will occur:

  File ".../pyfpdb/Database.py", line 1630, in <lambda>
    self.pcache = LambdaDict(lambda  key:self.insertPlayer(key, siteid))
  File ".../pyfpdb/Database.py", line 1661, in insertPlayer
    c.execute (q, (site_id, _name))
  File "/usr/lib/python2.5/encodings/iso8859_15.py", line 12, in encode
    return codecs.charmap_encode(input,errors,encoding_table)
UnicodeEncodeError: 'charmap' codec can't encode character u'\u2122' in
position 10: character maps to <undefined>

This happens because 'name' is a regular string as opposed to a valid
unicode object. By forcing the string to unicode and encoding it in
UTF-8 the error goes away. In my case the database encoding was
ISO-8859-15 (latin9) but any other "wrong" encoding would trigger the
same problem.

This is a relatively common problem in python.
2009-12-29 13:05:03 +08:00
Mika Bostrom 3b1e67e78b Store names as UTF-8
The names should be always in UTF-8 encoding. At least for PostgreSQL
the encdoding of the database comes from the time of running 'initdb'
(which is different from 'createdb') and if the encoding was selected or
set to something else at that time, the following error will occur:

  File ".../pyfpdb/Database.py", line 1630, in <lambda>
    self.pcache = LambdaDict(lambda  key:self.insertPlayer(key, siteid))
  File ".../pyfpdb/Database.py", line 1661, in insertPlayer
    c.execute (q, (site_id, _name))
  File "/usr/lib/python2.5/encodings/iso8859_15.py", line 12, in encode
    return codecs.charmap_encode(input,errors,encoding_table)
UnicodeEncodeError: 'charmap' codec can't encode character u'\u2122' in
position 10: character maps to <undefined>

This happens because 'name' is a regular string as opposed to a valid
unicode object. By forcing the string to unicode and encoding it in
UTF-8 the error goes away. In my case the database encoding was
ISO-8859-15 (latin9) but any other "wrong" encoding would trigger the
same problem.

This is a relatively common problem in python.
2009-12-24 09:52:47 +02:00
Mika Bostrom 17aae75f01 Merge branch 'stats' of git://git.assembla.com/fpdboz into newstats 2009-12-23 19:25:06 +02:00
Mika Bostrom 00305e34b6 Merge branch 'stats' of git://git.assembla.com/fpdboz into newstats 2009-12-23 17:30:54 +02:00
Mika Bostrom 6f084e73da Merge branch 'stats' of git://git.assembla.com/fpdboz into newstats 2009-12-22 22:19:35 +02:00
Mika Bostrom 1a4de58e33 Merge branch 'master' into good 2009-12-19 10:23:23 +02:00
Mika Bostrom da03de49dd Merge branch 'master' into good 2009-12-18 09:53:40 +02:00
Mika Bostrom 8189c5c7c3 Merge branch 'master' into good 2009-12-16 22:16:01 +02:00
Mika Bostrom 30e9bdb06d Merge branch 'master' into good 2009-12-16 14:25:44 +02:00
Mika Bostrom 8abdc6597d Merge branch 'master' into good 2009-12-16 09:25:29 +02:00
Mika Bostrom 0bf06122f4 Merge branch 'master' into good 2009-12-14 17:50:42 +02:00
Mika Bostrom 20de6fe730 Clean up about window
Remove duplicates
2009-12-13 16:12:29 +02:00
Mika Bostrom 6fa366bab6 Merge branch 'master' into good 2009-12-13 16:08:46 +02:00
Mika Bostrom fcf14f9100 Merge own master 2009-12-10 06:47:13 +02:00
Mika Bostrom 835fc98f6f Cosmetic fix
About -> Credits takes a list of strings in .set_authors() as opposed to
a single string. Now the credit popup looks about right.
2009-12-10 06:41:15 +02:00
Mika Bostrom e62ae6c31f Enclose dict key lookup in try-except block
Some recent changes moved the dictionary access outside try-except block
again. Widen the block enough again.
2009-12-06 19:27:13 +02:00
Mika Bostrom 128fa2f356 Enclose dict key lookup in try-except block
Some recent changes moved the dictionary access outside try-except block
again. Widen the block enough again.
2009-12-06 14:08:27 +02:00
Mika Bostrom 12e225c771 Merge branch 'master' into good 2009-12-02 19:00:32 +02:00
Mika Bostrom 87a8d57669 Revert "Do not minimize window when workspace changes"
This reverts commit 3e76033cd5.
2009-12-02 18:39:58 +02:00
Mika Bostrom 3e9353e3b9 Revert "Revert "Use wider try-except block""
This reverts commit 761d53f2f4.
2009-12-02 18:39:06 +02:00
Mika Bostrom 761d53f2f4 Revert "Use wider try-except block"
This reverts commit 2f742e371b.
2009-12-02 18:38:58 +02:00
Mika Bostrom a0a6207810 Fix profit graph query
At least postgresql requires to have grouping by hp.sawShowdown as well
2009-12-02 12:29:48 +02:00
Mika Bostrom 3e76033cd5 Do not minimize window when workspace changes
When we have the systray icon enabled, any window visibility event seems
to have WINDOW_STATE_ICONIFIED bit on. By checking both _ICONIFIED and
_WITHDRAWN the behaviour appears nicer.
2009-11-29 11:21:11 +02:00
Mika Bostrom 2f742e371b Use wider try-except block
The 'temp_key' table name in hud_dict can vanish between DB roundtrips.
Enclose all three lines within try-block.
2009-11-28 10:59:44 +02:00
Mika Bostrom 81e77ebfcf Merge branch 'master' into hudfix 2009-11-28 10:58:23 +02:00
Mika Bostrom 6dec7f38f3 Fix a stupid syntax error
Use python's format-string syntax.
2009-11-27 22:21:45 +02:00
Mika Bostrom df6d9a0a56 Fix missing checks before .set_active()
Some validity tests were still missing. Also, typofix:
self.cbFl -> self.cbFL
2009-11-26 23:07:58 +02:00
Mika Bostrom cb9e2cb6e7 Try to fix two HUD main hangs
The main HUD process can hang due to unhandled exceptions, which
occurred in two separate situations:

1. Table window is closed and HUD instance killed before auto-importer
knows about it
2. Sometimes the threading can jam

These changes attempt to counter the effect of race-conditions. The
dictionary key (table name) is properly tested at the beginning of
update/create block, *but* there are two short round-trips to database
before the key is used. While these occur, the HUD instance can vanish
and thus get its key removed from the dictionary.

Also, when Tables.Table() is created, it will be populated on-demand,
and have child attributes only when such are found from the system. The
new table code pulls in data from actual windows. Again, there is a
query involved and while it runs, the table may have vanished. This
ended up as an error in this call:

foo = gtk.gdk.window_foreign_new(table.number)

The object 'table' is valid (not None) but it has been populated only
after actual table window was killed. Therefore it may not have .number
attribute, which raised an AttributeError. Now the presence of
table.number attribute is tested before the object can be sent to
create_HUD().
2009-11-25 20:31:02 +02:00
Mika Bostrom c7342e4b0f Test the correct attribute
When testing for Tables.Table validity, we actually care about the
'number' attribute, because that gets passed around on create_HUD()
2009-11-25 15:31:45 +02:00
Mika Bostrom a7163f5f8c Move return value outside try-finally block
The return value is for Glib/GTK event loop, so it should be after
try-finally sequence. The value needs to be returned every time and we
really like to have threads_enter()/threads_leave() to be invoked in
pairs.
2009-11-25 14:42:17 +02:00
Mika Bostrom 9e23346e5b Merge branch 'master' into hudfix 2009-11-25 14:41:01 +02:00
Mika Bostrom 5435c164f9 Merge branch 'master' of git://git.assembla.com/fpdboz 2009-11-25 14:40:50 +02:00
Mika Bostrom 9c591da893 Saner exit for thread-unsafe code
It can't be right that we return from threads_enter() before releasing
the global lock. Exit works properly for failure (try-finally).
2009-11-25 11:10:34 +02:00
Mika Bostrom df8e0a5899 Merge branch 'master' into hudfix 2009-11-25 08:50:30 +02:00
Mika Bostrom 8d64a720c4 Merge branch 'master' of git://git.assembla.com/fpdboz 2009-11-25 08:50:08 +02:00
Mika Bostrom 752e50ad4c Better test
Built-in function hasattr() deals with and hides the exception
2009-11-25 07:26:26 +02:00
Mika Bostrom 92918df8c5 Attempt to catch the final race
Table attributes are pulled from database but the table window itself
may have disappeared. The search parameters no longer match because
there is no window title to match against, so some attributes are not
set at all.
2009-11-25 00:12:07 +02:00
Mika Bostrom 4db9ec7e79 Merge branch 'master' into hudfix 2009-11-24 19:42:48 +02:00
Mika Bostrom 48930e1679 Merge branch 'master' of git://git.assembla.com/fpdboz 2009-11-24 19:42:39 +02:00
Mika Bostrom 52d8578841 Try to fix HUD hangs 2009-11-24 10:57:03 +02:00
Mika Bostrom 175366934b Merge branch 'good' into hudfix 2009-11-24 10:56:07 +02:00
Mika Bostrom d2c25b6d28 Fix simple error in filter code
Other parts test that the object is valid before calling
.set_active(); follow convention to eliminate needless errors
2009-11-21 23:51:18 +02:00
Mika Bostrom 615d1ea8a6 Add default style keys
It seems there is some weird way for stylekeys to remain unset. Catch
the special case and have a way to see why this happens.
2009-11-20 08:48:49 +02:00
Mika Bostrom 8ddbe15087 Merge branch 'master' of git://git.assembla.com/fpdboz 2009-11-20 08:29:43 +02:00
Mika Bostrom 9823221def Merge branch 'master' of git://git.assembla.com/fpdboz 2009-11-19 12:40:49 +02:00
Mika Bostrom ea3edb6f18 Merge branch 'master' of git://git.assembla.com/free_poker_tools 2009-11-16 20:05:22 +02:00
Mika Bostrom 2a8eaa676a Merge branch 'master' of git://git.assembla.com/free_poker_tools 2009-11-16 18:19:31 +02:00
Mika Bostrom df26fb5fc0 Merge branch 'master' of git://git.assembla.com/fpdboz 2009-11-16 14:08:39 +02:00
Mika Bostrom 6a44f1d5e2 Merge branch 'master' of git://git.assembla.com/free_poker_tools 2009-11-15 00:40:38 +02:00
Mika Bostrom e6f834e617 Catch missing table (key) in hud_dict
This may be the cause of hud and/or main app hanging when import is
stopped
2009-11-14 10:56:02 +02:00
Mika Bostrom 7f31b844ca Merge branch 'master' of git://git.assembla.com/free_poker_tools 2009-11-12 09:59:40 +02:00
Mika Bostrom 824a102691 Merge branch 'master' of git://git.assembla.com/free_poker_tools 2009-11-10 09:00:17 +02:00
Mika Bostrom 33357447be Merge branch 'master' of git://git.assembla.com/free_poker_tools 2009-11-07 08:11:01 +02:00
Mika Bostrom 17a1151954 Update debian packaging
The new table code is saner, cleaner and altogether nicer than the old
one. On linux, the routines finally use Xlib directly. Depend on
python-xlib bindings so we can use them.
2009-11-06 09:56:45 +02:00
Mika Bostrom 62a624a25a Merge branch 'master' of git://git.assembla.com/free_poker_tools 2009-11-05 20:05:44 +02:00
Mika Bostrom 0533c2f19a Merge branch 'master' of git://git.assembla.com/fpdb-eric 2009-11-04 20:24:48 +02:00
Mika Bostrom 344074d26a Merge branch 'master' of git://git.assembla.com/free_poker_tools 2009-11-04 10:54:26 +02:00
Mika Bostrom 6682edb4c0 Merge branch 'master' of git://git.assembla.com/fpdb-eric 2009-11-04 10:54:21 +02:00
Mika Bostrom 39fdcd6be3 Merge branch 'master' of git://git.assembla.com/fpdb-eric 2009-11-03 22:17:27 +02:00
Mika Bostrom 27d5ea6e6a Merge branch 'master' of git://git.assembla.com/fpdboz 2009-11-02 19:07:10 +02:00
Mika Bostrom a4c605bb92 Merge branch 'master' of git://git.assembla.com/free_poker_tools 2009-11-01 21:41:06 +02:00
Mika Bostrom 8bb5d53d7e Merge branch 'master' of git://git.assembla.com/fpdb-eric 2009-11-01 14:20:03 +02:00
Mika Bostrom 2b0d360c44 Merge branch 'master' of git://git.assembla.com/free_poker_tools 2009-11-01 14:19:54 +02:00
Mika Bostrom 0615efcf4a Merge branch 'master' of git://git.assembla.com/fpdboz 2009-10-31 08:02:49 +02:00
Mika Bostrom 485180779f Merge branch 'master' of git://git.assembla.com/fpdboz 2009-10-30 23:13:54 +02:00
Mika Bostrom ca5fea5cc5 Fix HUD start from debianized install 2009-10-30 01:51:57 +02:00
Mika Bostrom 677ec5551c Merge branch 'master' into good 2009-10-27 19:48:00 +02:00
Mika Bostrom 9886b61840 Tray icon click toggles window visibility
Many of the tools that place an icon in systray allow to toggle the
application visibility by left-clicking on the icon. Why not follow
suit?
2009-10-27 19:45:52 +02:00
Mika Bostrom fe53e8c8a7 Merge branch 'master' into good 2009-10-27 15:28:40 +02:00
Mika Bostrom 15980877dd Typofix in status icon load 2009-10-27 15:28:11 +02:00
Mika Bostrom e25e4cf9b3 Use custom tray icon instead of GTK stock
Use the "Anonymous Cards" image from openclipart.org
(http://openclipart.org/media/files/Anonymous/12230)

This same image is used in other new FPDB icons, but the combinations
with looking-glass don't look good in systray. This icon is plain enough
to work properly even when scaled really small.
2009-10-27 15:24:49 +02:00
Mika Bostrom 879506cee4 Merge branch 'master' into good 2009-10-27 06:26:25 +02:00