From 41e84e55f10873ee0a9fdfb598af3cc911a08f7e Mon Sep 17 00:00:00 2001 From: Daniel Pavel Date: Fri, 4 Jan 2013 08:33:59 +0200 Subject: [PATCH] fix hidconsole input --- src/hidapi/hidconsole.py | 2 +- tools/hidconsole | 20 ++++++++------------ 2 files changed, 9 insertions(+), 13 deletions(-) diff --git a/src/hidapi/hidconsole.py b/src/hidapi/hidconsole.py index 5f71b9a5..98f18aed 100644 --- a/src/hidapi/hidconsole.py +++ b/src/hidapi/hidconsole.py @@ -14,7 +14,7 @@ import hidapi # # no Python 3 support :( -read_packet = input +read_packet = raw_input interactive = os.isatty(0) prompt = '?? Input: ' if interactive else '' diff --git a/tools/hidconsole b/tools/hidconsole index aed2ce5b..8ea39720 100755 --- a/tools/hidconsole +++ b/tools/hidconsole @@ -7,25 +7,21 @@ from __future__ import absolute_import import sys -def solaar_init(): +def init_paths(): + """Make the app work in the source tree.""" + import sys import os.path as _path - prefix = _path.dirname(_path.dirname(_path.realpath(_path.abspath(__file__)))) - - dist_lib = _path.join(prefix, 'share', 'solaar', 'lib') - src_lib = _path.join(prefix, 'src') - - for location in (dist_lib, src_lib): - init_py = _path.join(location, 'hidapi', '__init__.py') - if _path.exists(init_py): - sys.path.insert(1, location) - break + src_lib = _path.normpath(_path.join(_path.realpath(sys.path[0]), '..', 'src')) + init_py = _path.join(src_lib, 'hidapi', '__init__.py') + if _path.exists(init_py): + sys.path[0] = src_lib if __name__ == '__main__': if sys.version_info >= (2, 8): sys.exit("Python 3 is not supported by hidconsole.") - solaar_init() + init_paths() from hidapi import hidconsole hidconsole.main()