From 9b2c1bdef64274804a69e65fbb50f668730ca401 Mon Sep 17 00:00:00 2001 From: Daniel Pavel Date: Tue, 9 Oct 2012 12:31:46 +0300 Subject: [PATCH] fixes for python3 --- lib/cli/ur_scanner.py | 22 ++++++++++----------- lib/logitech/unifying_receiver/base.py | 6 +++--- lib/logitech/unifying_receiver/constants.py | 2 +- 3 files changed, 15 insertions(+), 15 deletions(-) diff --git a/lib/cli/ur_scanner.py b/lib/cli/ur_scanner.py index b77f6d78..100e4b16 100644 --- a/lib/cli/ur_scanner.py +++ b/lib/cli/ur_scanner.py @@ -13,34 +13,34 @@ from logitech.unifying_receiver.constants import * def scan_devices(receiver): devices = api.list_devices(receiver) if not devices: - print "!! No attached devices found." + print ("!! No attached devices found.") return for devinfo in devices: - print "Device [%d] %s (%s)" % (devinfo.number, devinfo.name, devinfo.type) - print " Protocol %s" % devinfo.protocol + print ("Device [%d] %s (%s)" % (devinfo.number, devinfo.name, devinfo.type)) + # print " Protocol %s" % devinfo.protocol for fw in devinfo.firmware: - print " %s firmware: %s version %s build %d" % (fw.type, fw.name, fw.version, fw.build) + print (" %s firmware: %s version %s build %d" % (fw.type, fw.name, fw.version, fw.build)) for index in range(0, len(devinfo.features)): feature = devinfo.features[index] if feature: - print " ~ Feature %s (%s) at index %d" % (FEATURE_NAME[feature], hexlify(feature), index) + print (" ~ Feature %s (%s) at index %d" % (FEATURE_NAME[feature], hexlify(feature), index)) if FEATURE.BATTERY in devinfo.features: discharge, dischargeNext, status = api.get_device_battery_level(receiver, devinfo.number, features_array=devinfo.features) - print " Battery %d charged (next level %d%), status %s" % (discharge, dischargeNext, status) + print (" Battery %d charged (next level %d%), status %s" % (discharge, dischargeNext, status)) if FEATURE.REPROGRAMMABLE_KEYS in devinfo.features: keys = api.get_device_keys(receiver, devinfo.number, features_array=devinfo.features) if keys is not None and keys: - print " %d reprogrammable keys found" % len(keys) + print (" %d reprogrammable keys found" % len(keys)) for k in keys: flags = ','.join(KEY_FLAG_NAME[f] for f in KEY_FLAG_NAME if k.flags & f) - print " %2d: %-12s => %-12s :%s" % (k.index, KEY_NAME[k.id], KEY_NAME[k.task], flags) + print (" %2d: %-12s => %-12s :%s" % (k.index, KEY_NAME[k.id], KEY_NAME[k.task], flags)) - print "--------" + print ("--------") if __name__ == '__main__': @@ -56,9 +56,9 @@ if __name__ == '__main__': for rawdevice in api._base.list_receiver_devices(): receiver = api._base.try_open(rawdevice.path) if receiver: - print "!! Logitech Unifying Receiver found (%s)." % rawdevice.path + print ("!! Logitech Unifying Receiver found (%s)." % rawdevice.path) scan_devices(receiver) api.close(receiver) break else: - print "!! Logitech Unifying Receiver not found." + print ("!! Logitech Unifying Receiver not found.") diff --git a/lib/logitech/unifying_receiver/base.py b/lib/logitech/unifying_receiver/base.py index 9dc0915e..4b7272b3 100644 --- a/lib/logitech/unifying_receiver/base.py +++ b/lib/logitech/unifying_receiver/base.py @@ -7,8 +7,8 @@ import logging from struct import pack as _pack from binascii import hexlify as _hexlify -import constants as C -import exceptions as E +from . import constants as C +from . import exceptions as E from . import unhandled as _unhandled import hidapi as _hid @@ -86,7 +86,7 @@ def try_open(path): return receiver_handle # any other replies are ignored, and will assume this is the wrong Linux device - if _l.isEnabledFod(_LOG_LEVEL): + if _l.isEnabledFor(_LOG_LEVEL): if reply == b'\x01\x00\x00\x00\x00\x00\x00\x00': # no idea what this is, but it comes up occasionally _l.log(_LOG_LEVEL, "[%s] (%d,) mistery reply [%s]", path, receiver_handle, _hexlify(reply)) diff --git a/lib/logitech/unifying_receiver/constants.py b/lib/logitech/unifying_receiver/constants.py index f7c6c9dd..c452ad1e 100644 --- a/lib/logitech/unifying_receiver/constants.py +++ b/lib/logitech/unifying_receiver/constants.py @@ -30,7 +30,7 @@ def _feature_name(key): return None if type(key) == int: return FEATURE_NAME[_pack('!H', key)] - return 'UNKNOWN_' + _hexlify(key) + return 'UNKNOWN_' + str(_hexlify(key)) """Feature names indexed by feature id."""