From 9801fe26fc3d3ecd7c5ba3ab8d54758146f3b32c Mon Sep 17 00:00:00 2001 From: Fabio Manganiello Date: Sun, 27 May 2018 11:21:47 +0200 Subject: [PATCH] Generating SmartCardRemoveEvent as well when a scard is removed --- platypush/backend/scard/__init__.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/platypush/backend/scard/__init__.py b/platypush/backend/scard/__init__.py index f5b944a9f..1ac34d702 100644 --- a/platypush/backend/scard/__init__.py +++ b/platypush/backend/scard/__init__.py @@ -7,7 +7,7 @@ from smartcard.Exceptions import NoCardException from smartcard.util import toHexString from platypush.backend import Backend -from platypush.message.event.scard import SmartCardDetectedEvent +from platypush.message.event.scard import SmartCardDetectedEvent, SmartCardRemovedEvent class ScardBackend(Backend): @@ -69,10 +69,12 @@ 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): - prev_atr = None self.bus.post(SmartCardRemovedEvent()) - logging.exception(e) + else: + logging.exception(e) # vim:sw=4:ts=4:et: