daleathan / key-mon

A screencast utility that displays your keyboard and mouse status | Automatically exported from
https://code.google.com/archive/p/key-mon/
Apache License 2.0
0 stars 0 forks source link

1.10 not run on Turkish locale #115

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
Hi,

When i try to run key-mon on console I get followings:

$ key-mon 
Traceback (most recent call last):
  File "/usr/bin/key-mon", line 3, in <module>
    km.main()
  File "/usr/lib/python2.7/site-packages/keymon/key_mon.py", line 1021, in main
    keymon = KeyMon(opts)
  File "/usr/lib/python2.7/site-packages/keymon/key_mon.py", line 113, in __init__
    self.enabled = dict((img, self.get_option(img.lower())) for img in self.IMAGES)
  File "/usr/lib/python2.7/site-packages/keymon/key_mon.py", line 113, in <genexpr>
    self.enabled = dict((img, self.get_option(img.lower())) for img in self.IMAGES)
  File "/usr/lib/python2.7/site-packages/keymon/key_mon.py", line 129, in get_option
    return getattr(self.options, attr)
  File "/usr/lib/python2.7/site-packages/keymon/options.py", line 248, in __getattr__
    raise AttributeError('Invalid attribute name: %r' % name)
AttributeError: Invalid attribute name: 'sh\xc4\xb1ft'

After running following command everything works fine:

$ LC_ALL=C

I'm using Pardus 2011.2 64-bit.
https://svn.pardus.org.tr/pardus/playground/maidis/2011/accessibility/key-mon

Original issue reported on code.google.com by ozbekanil on 13 May 2012 at 5:13

GoogleCodeExporter commented 8 years ago
This definitely is a bug when charmap != UTF8, strangely, with iso8859-9, I got 
a different error message:

$ LC_ALL=tr_TR.iso88599 ./key-mon
Traceback (most recent call last):
  File "./key-mon", line 3, in <module>
    km.main()
  File "/home/livibetter/p/key-mon/src/keymon/key_mon.py", line 1021, in main
    keymon = KeyMon(opts)
  File "/home/livibetter/p/key-mon/src/keymon/key_mon.py", line 119, in __init__
    self.devices = xlib.XEvents()
  File "/home/livibetter/p/key-mon/src/keymon/xlib.py", line 79, in __init__
    self.record_display = display.Display()
  File "/usr/lib64/python2.7/site-packages/Xlib/display.py", line 90, in __init__
    - self.display.info.min_keycode + 1))
  File "/usr/lib64/python2.7/site-packages/Xlib/display.py", line 387, in _update_keymap
    keysyms = self.get_keyboard_mapping(first_keycode, count)
  File "/usr/lib64/python2.7/site-packages/Xlib/display.py", line 693, in get_keyboard_mapping
    count = count)
  File "/usr/lib64/python2.7/site-packages/Xlib/protocol/rq.py", line 1428, in __init__
    self.reply()
  File "/usr/lib64/python2.7/site-packages/Xlib/protocol/rq.py", line 1440, in reply
    self._display.send_and_recv(request = self._serial)
  File "/usr/lib64/python2.7/site-packages/Xlib/protocol/display.py", line 547, in send_and_recv
    gotreq = self.parse_response(request)
  File "/usr/lib64/python2.7/site-packages/Xlib/protocol/display.py", line 634, in parse_response
    gotreq = self.parse_request_response(request) or gotreq
  File "/usr/lib64/python2.7/site-packages/Xlib/protocol/display.py", line 720, in parse_request_response
    req._parse_response(self.data_recv[:self.request_length])
  File "/usr/lib64/python2.7/site-packages/Xlib/protocol/rq.py", line 1452, in _parse_response
    self._data, d = self._reply.parse_binary(data, self._display, rawdict = 1)
  File "/usr/lib64/python2.7/site-packages/Xlib/protocol/rq.py", line 1280, in parse_binary
    return self.parse_binary(data, display, rawdict)
  File "<string>", line 6, in parse_binary
  File "/usr/lib64/python2.7/site-packages/Xlib/protocol/rq.py", line 750, in parse_binary_value
    a = array(array_unsigned_codes[4], str(data[:dlen]))
ValueError: bad typecode (must be c, b, B, u, h, H, i, I, l, L, f or d)

I am not sure if our errors are caused by the same bug.

Could you give me output of `locale`, so I can know exact locale you are using. 
Also please try other encoding to see if also happens.

Original comment by livibet...@gmail.com on 14 May 2012 at 12:46

GoogleCodeExporter commented 8 years ago
Output of locale command on my system:

LANG=tr_TR.UTF-8
LANGUAGE=
LC_CTYPE="tr_TR.UTF-8"
LC_NUMERIC="tr_TR.UTF-8"
LC_TIME="tr_TR.UTF-8"
LC_COLLATE="tr_TR.UTF-8"
LC_MONETARY="tr_TR.UTF-8"
LC_MESSAGES="tr_TR.UTF-8"
LC_PAPER="tr_TR.UTF-8"
LC_NAME="tr_TR.UTF-8"
LC_ADDRESS="tr_TR.UTF-8"
LC_TELEPHONE="tr_TR.UTF-8"
LC_MEASUREMENT="tr_TR.UTF-8"
LC_IDENTIFICATION="tr_TR.UTF-8"
LC_ALL=tr_TR.UTF-8

After running LC_ALL=tr_TR.iso88599 still I get same error:

Traceback (most recent call last):
  File "/usr/bin/key-mon", line 3, in <module>
    km.main()
  File "/usr/lib/python2.7/site-packages/keymon/key_mon.py", line 1021, in main
    keymon = KeyMon(opts)
  File "/usr/lib/python2.7/site-packages/keymon/key_mon.py", line 113, in __init__
    self.enabled = dict((img, self.get_option(img.lower())) for img in self.IMAGES)
  File "/usr/lib/python2.7/site-packages/keymon/key_mon.py", line 113, in <genexpr>
    self.enabled = dict((img, self.get_option(img.lower())) for img in self.IMAGES)
  File "/usr/lib/python2.7/site-packages/keymon/key_mon.py", line 129, in get_option
    return getattr(self.options, attr)
  File "/usr/lib/python2.7/site-packages/keymon/options.py", line 248, in __getattr__
    raise AttributeError('Invalid attribute name: %r' % name)
AttributeError: Invalid attribute name: 'sh\xc4\xb1ft'

I can't change to other locales so I can't test key-mon on them:

LC_ALL=es_ES.ISO-8859-1
bash: warning: setlocale: LC_ALL: cannot change locale (es_ES.ISO-8859-1): 
B�yle bir dosya ya da dizin yok (there isn't such a file or directory)
maidis@pardus2011 ~ $ LC_ALL=ru_RU.KOI8-R    
bash: warning: setlocale: LC_ALL: cannot change locale (ru_RU.KOI8-R): B�yle 
bir dosya ya da dizin yok (there isn't such a file or directory)

Original comment by ozbekanil on 14 May 2012 at 9:00

GoogleCodeExporter commented 8 years ago
There isn't any problems with following locales:

en_GB.iso885915
en_US
en_US.iso885915
en_US.utf8

key-mon runs without any errors with these.

Original comment by ozbekanil on 14 May 2012 at 9:05

GoogleCodeExporter commented 8 years ago
The error you got might be caused by the revert in r6fb8c5938b36, because of 
that, changes of r955f64ed4240 are gone.

Could you pull out r955f64ed4240 (one commit before r6fb8c5938b36) and see if 
the error is gone. If so, I will put that part of code back.

I still don't know why I have different error for charmap=iso88599 and no error 
for utf8.

Original comment by livibet...@gmail.com on 14 May 2012 at 1:03

GoogleCodeExporter commented 8 years ago
Could you also give me your python-xlib version (I am using 0.15rc1)?

You can run:

  python -c 'import Xlib; print(Xlib.__version_string__)'

to get it. This might be why we have different error messages, mine stopped 
before going further into key-mon's code.

Original comment by livibet...@gmail.com on 14 May 2012 at 1:14

GoogleCodeExporter commented 8 years ago
r955f64ed4240 works fine on my system.

I'm using too 0.15rc1 version of python-xlib.

Original comment by ozbekanil on 14 May 2012 at 1:46

GoogleCodeExporter commented 8 years ago
I made a mistake, it's not r6fb8c5938b36 but r96856394c71d, which I didn't 
update correctly for lower().

Please pull and update, and see it gets fixed.

Original comment by livibet...@gmail.com on 14 May 2012 at 2:31

GoogleCodeExporter commented 8 years ago
I hope I understood correctly:

$ hg clone https://code.google.com/p/key-mon/
$ cd key-mon
$ hg update 96856394c71d

This version gives followings:

$ key-mon                                                                       

Traceback (most recent call last):
  File "/usr/bin/key-mon", line 3, in <module>
    km.main()
  File "/usr/lib/python2.7/site-packages/keymon/key_mon.py", line 957, in main
    keymon = KeyMon(opts)
  File "/usr/lib/python2.7/site-packages/keymon/key_mon.py", line 114, in __init__
    self.enabled = dict((img, self.get_option(img.lower())) for img in self.IMAGES)
  File "/usr/lib/python2.7/site-packages/keymon/key_mon.py", line 114, in <genexpr>
    self.enabled = dict((img, self.get_option(img.lower())) for img in self.IMAGES)
  File "/usr/lib/python2.7/site-packages/keymon/key_mon.py", line 130, in get_option
    return getattr(self.options, attr)
  File "/usr/lib/python2.7/site-packages/keymon/options.py", line 242, in __getattr__
    raise AttributeError('Invalid attribute name: %r' % name)
AttributeError: Invalid attribute name: 'sh\xc4\xb1ft'

Or pull and update means get latest code? Because latest commit is about this 
issue. I'm sorry for the confusion, I never used Mercurial repository and not 
familiar with its expressions.

Original comment by ozbekanil on 14 May 2012 at 2:57

GoogleCodeExporter commented 8 years ago
Sorry for not being clear. I meant pulling the latest code, rf2894eeff5d5.

Original comment by livibet...@gmail.com on 14 May 2012 at 3:33

GoogleCodeExporter commented 8 years ago
Last situation:

$ key-mon                                                                       

Traceback (most recent call last):
  File "/usr/bin/key-mon", line 3, in <module>
    km.main()
  File "/usr/lib/python2.7/site-packages/keymon/key_mon.py", line 1021, in main
    keymon = KeyMon(opts)
  File "/usr/lib/python2.7/site-packages/keymon/key_mon.py", line 113, in __init__
    self.enabled = dict((img, self.get_option(str(unicode(img).lower()))) for img in self.IMAGES)
  File "/usr/lib/python2.7/site-packages/keymon/key_mon.py", line 113, in <genexpr>
    self.enabled = dict((img, self.get_option(str(unicode(img).lower()))) for img in self.IMAGES)
  File "/usr/lib/python2.7/site-packages/keymon/key_mon.py", line 129, in get_option
    return getattr(self.options, attr)
  File "/usr/lib/python2.7/site-packages/keymon/options.py", line 248, in __getattr__
    raise AttributeError('Invalid attribute name: %r' % name)
AttributeError: Invalid attribute name: 'sh\xc4\xb1ft'

Original comment by ozbekanil on 14 May 2012 at 4:06

GoogleCodeExporter commented 8 years ago
now I read again, shouldn't need my last commit.

What is the output of

/usr/bin/python -c 'print("I".lower());print(str(unicode("I").lower()));import 
locale;l=locale.getlocale(locale.LC_CTYPE);print(l);locale.setlocale(locale.LC_C
TYPE, "C");print("I".lower())'

and /usr/bin/python --version

Original comment by livibet...@gmail.com on 14 May 2012 at 4:57

GoogleCodeExporter commented 8 years ago
long command:

i
i
(None, None)
i

short command:

Python 2.7.2

Original comment by ozbekanil on 14 May 2012 at 5:19

GoogleCodeExporter commented 8 years ago
I am so confused by the result, was expecting "I".

Anyway, a patch for bringing back cstrf()

  $ cd /path/to/repo-root
  $ hg update
  $ patch -p1 < /path/to/cstrf.patch

I think this will work, but I don't like cstrf. Since I don't have any clue 
what cause this, if this does work, I will push with this comeback code.

Original comment by livibet...@gmail.com on 15 May 2012 at 4:38

Attachments:

GoogleCodeExporter commented 8 years ago
This patch makes key-mon works again. But now there is some errors at settings. 
When I change options I get:

$ key-mon 
Xlib.protocol.request.QueryExtension
Xlib.protocol.request.QueryExtension
Traceback (most recent call last):
  File "/usr/lib/python2.7/site-packages/keymon/key_mon.py", line 758, in settings_changed
    self._toggle_a_key(self.images[img], img, self.get_option(img.lower()))
  File "/usr/lib/python2.7/site-packages/keymon/key_mon.py", line 140, in get_option
    return getattr(self.options, attr)
  File "/usr/lib/python2.7/site-packages/keymon/options.py", line 248, in __getattr__
    raise AttributeError('Invalid attribute name: %r' % name)
AttributeError: Invalid attribute name: 'shIft'
Traceback (most recent call last):
  File "/usr/lib/python2.7/site-packages/keymon/key_mon.py", line 758, in settings_changed
    self._toggle_a_key(self.images[img], img, self.get_option(img.lower()))
  File "/usr/lib/python2.7/site-packages/keymon/key_mon.py", line 140, in get_option
    return getattr(self.options, attr)
  File "/usr/lib/python2.7/site-packages/keymon/options.py", line 248, in __getattr__
    raise AttributeError('Invalid attribute name: %r' % name)
AttributeError: Invalid attribute name: 'shIft'
Traceback (most recent call last):
  File "/usr/lib/python2.7/site-packages/keymon/key_mon.py", line 758, in settings_changed
    self._toggle_a_key(self.images[img], img, self.get_option(img.lower()))
  File "/usr/lib/python2.7/site-packages/keymon/key_mon.py", line 140, in get_option
    return getattr(self.options, attr)
  File "/usr/lib/python2.7/site-packages/keymon/options.py", line 248, in __getattr__
    raise AttributeError('Invalid attribute name: %r' % name)
AttributeError: Invalid attribute name: 'shIft'
Unable to fade the window
Traceback (most recent call last):
  File "/usr/lib/python2.7/site-packages/keymon/key_mon.py", line 758, in settings_changed
    self._toggle_a_key(self.images[img], img, self.get_option(img.lower()))
  File "/usr/lib/python2.7/site-packages/keymon/key_mon.py", line 140, in get_option
    return getattr(self.options, attr)
  File "/usr/lib/python2.7/site-packages/keymon/options.py", line 248, in __getattr__
    raise AttributeError('Invalid attribute name: %r' % name)
AttributeError: Invalid attribute name: 'shIft'
Traceback (most recent call last):
  File "/usr/lib/python2.7/site-packages/keymon/key_mon.py", line 758, in settings_changed
    self._toggle_a_key(self.images[img], img, self.get_option(img.lower()))
  File "/usr/lib/python2.7/site-packages/keymon/key_mon.py", line 140, in get_option
    return getattr(self.options, attr)
  File "/usr/lib/python2.7/site-packages/keymon/options.py", line 248, in __getattr__
    raise AttributeError('Invalid attribute name: %r' % name)
AttributeError: Invalid attribute name: 'shIft'

Original comment by ozbekanil on 15 May 2012 at 10:05

GoogleCodeExporter commented 8 years ago
oopsie, I missed that one. Patch updated.

Original comment by livibet...@gmail.com on 15 May 2012 at 11:32

Attachments:

GoogleCodeExporter commented 8 years ago
Thanks :) This time everything works. No local related errors on console aymore.

Original comment by ozbekanil on 15 May 2012 at 12:08

GoogleCodeExporter commented 8 years ago
This issue was closed by revision 5ddf6195e9c5.

Original comment by livibet...@gmail.com on 15 May 2012 at 12:45