forked from platypush/platypush
Pass also ATR and reader to SmartCardRemovedEvent
This commit is contained in:
parent
9801fe26fc
commit
b04a355cc0
2 changed files with 6 additions and 4 deletions
|
@ -53,6 +53,8 @@ class ScardBackend(Backend):
|
||||||
format(self.ATRs))
|
format(self.ATRs))
|
||||||
|
|
||||||
prev_atr = None
|
prev_atr = None
|
||||||
|
reader = None
|
||||||
|
|
||||||
while not self.should_stop():
|
while not self.should_stop():
|
||||||
try:
|
try:
|
||||||
cardrequest = CardRequest(timeout=None, cardType=self.cardtype)
|
cardrequest = CardRequest(timeout=None, cardType=self.cardtype)
|
||||||
|
@ -69,13 +71,13 @@ class ScardBackend(Backend):
|
||||||
self.bus.post(SmartCardDetectedEvent(atr=atr, reader=reader))
|
self.bus.post(SmartCardDetectedEvent(atr=atr, reader=reader))
|
||||||
prev_atr = atr
|
prev_atr = atr
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
prev_atr = None
|
|
||||||
|
|
||||||
if isinstance(e, NoCardException):
|
if isinstance(e, NoCardException):
|
||||||
self.bus.post(SmartCardRemovedEvent())
|
self.bus.post(SmartCardRemovedEvent(atr=prev_atr, reader=reader))
|
||||||
else:
|
else:
|
||||||
logging.exception(e)
|
logging.exception(e)
|
||||||
|
|
||||||
|
prev_atr = None
|
||||||
|
|
||||||
|
|
||||||
# vim:sw=4:ts=4:et:
|
# vim:sw=4:ts=4:et:
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,7 @@ class SmartCardDetectedEvent(Event):
|
||||||
|
|
||||||
|
|
||||||
class SmartCardRemovedEvent(Event):
|
class SmartCardRemovedEvent(Event):
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, atr=None, reader=None, *args, **kwargs):
|
||||||
super().__init__(*args, **kwargs)
|
super().__init__(*args, **kwargs)
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue