davidlarizap / key-mon

Automatically exported from code.google.com/p/key-mon
Apache License 2.0
0 stars 0 forks source link

Incorrect kbd directory when running key-mon inside PuDB #98

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Case #1 - works correctly:
$ cd src
$ ./key-mon

Case #2 - fails:
$ cd src
$ python -m pudb.run ./key-mon

IOError: [Errno 2] No such file or directory: './keymon/./keymon/us.kbd'

This exception raises from mod_mapper.read_kdb():
  return parse_kdb(codecs.open(os.path.join(os.path.dirname(__file__), fname), 'r', 'utf-8').read())

Replacing fname with os.path.basename(fname) solves this issue, but I don't 
know if it breaks anything else. (I've done that as a quick-and-dirty fix just 
for debugging inside PuDB)

Reproduced with hg revision 299:0bb208c4c367

PuDB is available at:
http://pypi.python.org/pypi/pudb

Original issue reported on code.google.com by denilsonsa on 11 Oct 2011 at 11:56

GoogleCodeExporter commented 9 years ago
Okay, I did a bit more of debugging... I found this bug does not happen if you 
have an empty config file.

I've tracked down the bug to keymon.settings.get_config_dirs() function. It 
uses __file__ to find out what is the directory. When running standalone, 
__file__ contains the absolute file path. However, for some reason that I don't 
know yet, when running inside PuDB it contains './keymon/settings.pyc'.

The fix should be easy: os.path.abspath(__file__)

Original comment by denilsonsa on 12 Oct 2011 at 8:17

GoogleCodeExporter commented 9 years ago
According to this mail thread:
http://mail.python.org/pipermail/python-dev/2010-February/097461.html
__file__ will be absolute or relative depending on the values of sys.path

(okay, this comment doesn't help fixing this issue, it's just nice to 
understand how things work)

Original comment by denilsonsa on 12 Oct 2011 at 9:54

GoogleCodeExporter commented 9 years ago
Fixed, thanks

Original comment by scottaki...@gmail.com on 13 Oct 2011 at 2:25