From b04a355cc0f72cbe591d472d40645ac7da98a201 Mon Sep 17 00:00:00 2001 From: Fabio Manganiello Date: Sun, 27 May 2018 11:25:29 +0200 Subject: [PATCH] Pass also ATR and reader to SmartCardRemovedEvent --- platypush/backend/scard/__init__.py | 8 +++++--- platypush/message/event/scard.py | 2 +- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/platypush/backend/scard/__init__.py b/platypush/backend/scard/__init__.py index 1ac34d702..626c7790a 100644 --- a/platypush/backend/scard/__init__.py +++ b/platypush/backend/scard/__init__.py @@ -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: diff --git a/platypush/message/event/scard.py b/platypush/message/event/scard.py index 9b887b72e..252d2800c 100644 --- a/platypush/message/event/scard.py +++ b/platypush/message/event/scard.py @@ -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)