Add event names and fix exception display

master
informatic 2016-06-13 23:32:13 +02:00
parent 5e9372d394
commit 95e4e59e3d
2 changed files with 6 additions and 3 deletions

View File

@ -13,6 +13,8 @@ from collections import namedtuple
class Event(namedtuple('Event', ['code', 'args'])):
def __repr__(self):
return '<%s: %s>' % (super(Event, self).__repr__(), self)
def __str__(self):
return constants.poll_codes[self.code] \
if self.code in constants.poll_codes \

View File

@ -9,7 +9,8 @@ class InvalidChecksumException(eSSPException): pass
class DeviceError(eSSPException):
def __str__(self):
if self.msg in self.error_codes:
return constants.error_codes[self.msg]
msg = self.args[0]
if msg in constants.error_codes:
return constants.error_codes[msg]
else:
return 'Unknown error (0x%02X)' % self.msg
return 'Unknown error (0x%02X)' % msg