• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

LudovicRousseau / pyscard / 16621389771

30 Jul 2025 11:33AM UTC coverage: 66.181% (+0.1%) from 66.048%
16621389771

push

github

LudovicRousseau
Release 2.3.0

Signed-off-by: Ludovic Rousseau <ludovic.rousseau@free.fr>

108 of 485 branches covered (22.27%)

4452 of 6727 relevant lines covered (66.18%)

4.77 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/src/smartcard/CardConnectionObserver.py
1
"""CardConnectionObserver interface.
2

3
CardConnectionObserver is a base class for objects that are to be notified
4
upon CardConnection events.
5

6
__author__ = "https://www.gemalto.com/"
7

8
Copyright 2001-2012 gemalto
9
Author: Jean-Daniel Aussel, mailto:jean-daniel.aussel@gemalto.com
10

11
This file is part of pyscard.
12

13
pyscard is free software; you can redistribute it and/or modify
14
it under the terms of the GNU Lesser General Public License as published by
15
the Free Software Foundation; either version 2.1 of the License, or
16
(at your option) any later version.
17

18
pyscard is distributed in the hope that it will be useful,
19
but WITHOUT ANY WARRANTY; without even the implied warranty of
20
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
21
GNU Lesser General Public License for more details.
22

23
You should have received a copy of the GNU Lesser General Public License
24
along with pyscard; if not, write to the Free Software
25
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
26
"""
27

28
from smartcard.Observer import Observer
×
29
from smartcard.util import toHexString
×
30

31
# pylint: disable=too-few-public-methods
32

33

34
# ReaderObserver interface
35
class CardConnectionObserver(Observer):
×
36
    """
37
    CardConnectionObserver is a base class for objects that are to be notified
38
    upon L{CardConnection} events.
39
    """
40

41
    def update(self, observable, handlers):
×
42
        """Called upon CardConnection event.
43

44
        @param observable:         the observed card connection object
45
        @param handlers:    the CardConnectionEvent sent by the connection
46
        """
47

48

49
class ConsoleCardConnectionObserver(CardConnectionObserver):
×
50
    """CardConnectionObserver output to the console"""
51

52
    def update(self, observable, handlers):
×
53

54
        if "connect" == handlers.type:
×
55
            print("connecting to " + observable.getReader())
×
56

57
        elif "reconnect" == handlers.type:
×
58
            print("reconnecting to " + observable.getReader())
×
59

60
        elif "disconnect" == handlers.type:
×
61
            print("disconnecting from " + observable.getReader())
×
62

63
        elif "release" == handlers.type:
×
64
            print("release from " + observable.getReader())
×
65

66
        elif "command" == handlers.type:
×
67
            print("> " + toHexString(handlers.args[0]))
×
68

69
        elif "response" == handlers.type:
×
70
            sw1, sw2 = handlers.args[-2:]
×
71
            SW = f" {sw1:2X} {sw2:02X}"
×
72
            if [] == handlers.args[0]:
×
73
                print("<  []" + SW)
×
74
            else:
75
                print("< " + toHexString(handlers.args[0]) + SW)
×
76
        else:
77
            print("unknown event:", handlers.type)
×
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc