Generating SmartCardRemoveEvent as well when a scard is removed
This commit is contained in:
parent
8a6dcdbf5f
commit
9801fe26fc
1 changed files with 5 additions and 3 deletions
|
@ -7,7 +7,7 @@ from smartcard.Exceptions import NoCardException
|
||||||
from smartcard.util import toHexString
|
from smartcard.util import toHexString
|
||||||
|
|
||||||
from platypush.backend import Backend
|
from platypush.backend import Backend
|
||||||
from platypush.message.event.scard import SmartCardDetectedEvent
|
from platypush.message.event.scard import SmartCardDetectedEvent, SmartCardRemovedEvent
|
||||||
|
|
||||||
|
|
||||||
class ScardBackend(Backend):
|
class ScardBackend(Backend):
|
||||||
|
@ -69,9 +69,11 @@ 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:
|
||||||
if isinstance(e, NoCardException):
|
|
||||||
prev_atr = None
|
prev_atr = None
|
||||||
|
|
||||||
|
if isinstance(e, NoCardException):
|
||||||
self.bus.post(SmartCardRemovedEvent())
|
self.bus.post(SmartCardRemovedEvent())
|
||||||
|
else:
|
||||||
logging.exception(e)
|
logging.exception(e)
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue