small logging fixes for repr()
This commit is contained in:
parent
345bab3a99
commit
216928f904
|
@ -121,11 +121,11 @@ def _open(device, hidpp):
|
|||
if not handle:
|
||||
sys.exit("!! Failed to open %s, aborting." % device)
|
||||
|
||||
print (".. Opened handle %s, vendor %s product %s serial %s." % (
|
||||
repr(handle),
|
||||
repr(hidapi.get_manufacturer(handle)),
|
||||
repr(hidapi.get_product(handle)),
|
||||
repr(hidapi.get_serial(handle))))
|
||||
print (".. Opened handle %r, vendor %r product %r serial %r." % (
|
||||
handle,
|
||||
hidapi.get_manufacturer(handle),
|
||||
hidapi.get_product(handle),
|
||||
hidapi.get_serial(handle)))
|
||||
if hidpp:
|
||||
if hidapi.get_manufacturer(handle) != b'Logitech':
|
||||
sys.exit("!! Only Logitech devices support the HID++ protocol.")
|
||||
|
@ -208,7 +208,7 @@ def main():
|
|||
except Exception as e:
|
||||
print ('%s: %s' % (type(e).__name__, e))
|
||||
|
||||
print (".. Closing handle", repr(handle))
|
||||
print (".. Closing handle %r" % handle)
|
||||
hidapi.close(handle)
|
||||
if interactive:
|
||||
readline.write_history_file(args.history)
|
||||
|
|
|
@ -108,10 +108,10 @@ def close(handle):
|
|||
_hid.close(handle)
|
||||
else:
|
||||
handle.close()
|
||||
# _log.info("closed receiver handle %s", repr(handle))
|
||||
# _log.info("closed receiver handle %r", handle)
|
||||
return True
|
||||
except:
|
||||
# _log.exception("closing receiver handle %s", repr(handle))
|
||||
# _log.exception("closing receiver handle %r", handle)
|
||||
pass
|
||||
|
||||
return False
|
||||
|
@ -141,7 +141,7 @@ def write(handle, devnumber, data):
|
|||
try:
|
||||
_hid.write(int(handle), wdata)
|
||||
except Exception as reason:
|
||||
_log.error("write failed, assuming handle %s no longer available", repr(handle))
|
||||
_log.error("write failed, assuming handle %r no longer available", handle)
|
||||
close(handle)
|
||||
raise NoReceiver(reason=reason)
|
||||
|
||||
|
@ -173,7 +173,7 @@ def _read(handle, timeout):
|
|||
try:
|
||||
data = _hid.read(int(handle), _MAX_READ_SIZE, timeout)
|
||||
except Exception as reason:
|
||||
_log.error("read failed, assuming handle %s no longer available", repr(handle))
|
||||
_log.error("read failed, assuming handle %r no longer available", handle)
|
||||
close(handle)
|
||||
raise NoReceiver(reason=reason)
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@ class NamedInt(int):
|
|||
def __new__(cls, value, name):
|
||||
assert isinstance(name, str) or isinstance(name, unicode)
|
||||
obj = int.__new__(cls, value)
|
||||
obj.name = name
|
||||
obj.name = unicode(name)
|
||||
return obj
|
||||
|
||||
def bytes(self, count=2):
|
||||
|
@ -40,12 +40,11 @@ class NamedInt(int):
|
|||
return int(self)
|
||||
|
||||
def __str__(self):
|
||||
return str(self.name)
|
||||
def __unicode__(self):
|
||||
return unicode(self.name)
|
||||
return self.name
|
||||
__unicode__ = __str__
|
||||
|
||||
def __repr__(self):
|
||||
return 'NamedInt(%d, %s)' % (int(self), repr(self.name))
|
||||
return 'NamedInt(%d, %r)' % (int(self), self.name)
|
||||
|
||||
|
||||
class NamedInts(object):
|
||||
|
|
|
@ -34,7 +34,7 @@ class ThreadedHandle(object):
|
|||
def __init__(self, initial_handle, path):
|
||||
assert initial_handle
|
||||
if type(initial_handle) != int:
|
||||
raise TypeError('expected int as initial handle, got %s' % repr(initial_handle))
|
||||
raise TypeError('expected int as initial handle, got %r' % initial_handle)
|
||||
|
||||
assert path
|
||||
self.path = path
|
||||
|
|
|
@ -125,7 +125,7 @@ class ReceiverListener(_listener.EventsListener):
|
|||
dev = self.receiver[n.devnumber]
|
||||
|
||||
if not dev:
|
||||
_log.warn("received %s for invalid device %d: %s", n, n.devnumber, repr(dev))
|
||||
_log.warn("received %s for invalid device %d: %r", n, n.devnumber, dev)
|
||||
return
|
||||
|
||||
if not already_known:
|
||||
|
|
Loading…
Reference in New Issue