Pass also ATR and reader to SmartCardRemovedEvent

This commit is contained in:
Fabio Manganiello 2018-05-27 11:25:29 +02:00
parent 9801fe26fc
commit b04a355cc0
2 changed files with 6 additions and 4 deletions

View file

@ -53,6 +53,8 @@ class ScardBackend(Backend):
format(self.ATRs))
prev_atr = None
reader = None
while not self.should_stop():
try:
cardrequest = CardRequest(timeout=None, cardType=self.cardtype)
@ -69,13 +71,13 @@ class ScardBackend(Backend):
self.bus.post(SmartCardDetectedEvent(atr=atr, reader=reader))
prev_atr = atr
except Exception as e:
prev_atr = None
if isinstance(e, NoCardException):
self.bus.post(SmartCardRemovedEvent())
self.bus.post(SmartCardRemovedEvent(atr=prev_atr, reader=reader))
else:
logging.exception(e)
prev_atr = None
# vim:sw=4:ts=4:et:

View file

@ -7,7 +7,7 @@ class SmartCardDetectedEvent(Event):
class SmartCardRemovedEvent(Event):
def __init__(self, *args, **kwargs):
def __init__(self, atr=None, reader=None, *args, **kwargs):
super().__init__(*args, **kwargs)