diff --git a/platypush/backend/scard/__init__.py b/platypush/backend/scard/__init__.py index 626c7790ad..0d9f9a28a5 100644 --- a/platypush/backend/scard/__init__.py +++ b/platypush/backend/scard/__init__.py @@ -3,7 +3,7 @@ import json from smartcard.CardType import AnyCardType, ATRCardType from smartcard.CardRequest import CardRequest -from smartcard.Exceptions import NoCardException +from smartcard.Exceptions import NoCardException, CardConnectionException from smartcard.util import toHexString from platypush.backend import Backend @@ -71,7 +71,7 @@ class ScardBackend(Backend): self.bus.post(SmartCardDetectedEvent(atr=atr, reader=reader)) prev_atr = atr except Exception as e: - if isinstance(e, NoCardException): + if isinstance(e, NoCardException) or isinstance(e, CardConnectionException): self.bus.post(SmartCardRemovedEvent(atr=prev_atr, reader=reader)) else: logging.exception(e) diff --git a/platypush/message/event/scard.py b/platypush/message/event/scard.py index 252d2800c3..29bbb5ee2a 100644 --- a/platypush/message/event/scard.py +++ b/platypush/message/event/scard.py @@ -8,7 +8,7 @@ class SmartCardDetectedEvent(Event): class SmartCardRemovedEvent(Event): def __init__(self, atr=None, reader=None, *args, **kwargs): - super().__init__(*args, **kwargs) + super().__init__(atr=atr, reader=reader, *args, **kwargs) # vim:sw=4:ts=4:et: