Package smartcard :: Module Exceptions
[hide private]
[frames] | no frames]

Source Code for Module smartcard.Exceptions

 1  """Smartcard module exceptions. 
 2   
 3  This module defines the exceptions raised by the smartcard module. 
 4   
 5  __author__ = "http://www.gemalto.com" 
 6   
 7  Copyright 2001-2012 gemalto 
 8  Author: Jean-Daniel Aussel, mailto:jean-daniel.aussel@gemalto.com 
 9   
10  This file is part of pyscard. 
11   
12  pyscard is free software; you can redistribute it and/or modify 
13  it under the terms of the GNU Lesser General Public License as published by 
14  the Free Software Foundation; either version 2.1 of the License, or 
15  (at your option) any later version. 
16   
17  pyscard is distributed in the hope that it will be useful, 
18  but WITHOUT ANY WARRANTY; without even the implied warranty of 
19  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
20  GNU Lesser General Public License for more details. 
21   
22  You should have received a copy of the GNU Lesser General Public License 
23  along with pyscard; if not, write to the Free Software 
24  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA 
25  """ 
26   
27   
28 -class SmartcardException(Exception):
29 """Base class for smartcard exceptions. 30 31 smartcard exceptions are generated by the smartcard module and 32 shield scard (i.e. PCSC) exceptions raised by the scard module. 33 34 """ 35 pass
36 37
38 -class CardConnectionException(SmartcardException):
39 """Raised when a CardConnection class method fails.""" 40 pass
41 42
43 -class CardRequestException(SmartcardException):
44 """Raised when a CardRequest wait fails.""" 45 pass
46 47
48 -class CardRequestTimeoutException(SmartcardException):
49 """Raised when a CardRequest times out.""" 50
51 - def __init__(self, *args):
52 SmartcardException.__init__(self, 53 "Time-out during card request", *args)
54 55
56 -class CardServiceException(SmartcardException):
57 """Raised when a CardService class method fails.""" 58 pass
59 60
61 -class InvalidATRMaskLengthException(SmartcardException):
62 """Raised when an ATR mask does not match an ATR length.""" 63
64 - def __init__(self, *args):
65 SmartcardException.__init__(self, 66 'Invalid ATR mask length: ', *args)
67 68
69 -class InvalidReaderException(SmartcardException):
70 """Raised when trying to acces an invalid smartcard reader.""" 71
72 - def __init__(self, *args):
73 SmartcardException.__init__(self, 'Invalid reader: ', *args)
74 75
76 -class ListReadersException(SmartcardException):
77 """Raised when smartcard readers cannot be listed.""" 78
79 - def __init__(self, *args):
80 SmartcardException.__init__(self, 'Failed to list readers', *args)
81 82
83 -class NoCardException(SmartcardException):
84 """Raised when no card in is present in reader.""" 85
86 - def __init__(self, *args):
87 SmartcardException.__init__( 88 self, 89 'Unable to connect to card or no card in reader', 90 *args)
91 92
93 -class NoReadersException(SmartcardException):
94 """Raised when the system has no smartcard reader.""" 95
96 - def __init__(self, *args):
97 SmartcardException.__init__(self, 'No reader found', *args)
98