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

Source Code for Module smartcard.System

 1  """Smartcard system utility functions and classes. 
 2   
 3  Manages smartcard readers and reader groups. 
 4   
 5  __author__ = "gemalto http://www.gemalto.com" 
 6   
 7  Copyright 2001-2011 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  import smartcard.reader.ReaderFactory 
28  import smartcard.pcsc.PCSCReaderGroups 
29   
30   
31 -def readers(groups=[]):
32 """Returns the list of smartcard readers in groups. 33 34 If group is not specified, returns the list of all smartcard readers. 35 36 import smartcard 37 r=smartcard.readers() 38 r=smartcard.readers(['SCard$DefaultReaders', 'MyReaderGroup']) 39 """ 40 41 return smartcard.reader.ReaderFactory.ReaderFactory.readers(groups)
42 43
44 -def readergroups():
45 """Returns the list of reader groups.""" 46 47 return smartcard.pcsc.PCSCReaderGroups.PCSCReaderGroups()
48 49 50 # for legacy only
51 -def listReaders():
52 """Returns the list of smartcard readers. 53 54 Deprecated - Use smartcard.System.readers() instead. 55 """ 56 zreaders = [] 57 for reader in readers(): 58 zreaders.append(str(reader)) 59 return zreaders
60 61 62 if __name__ == '__main__': 63 try: 64 print readers() 65 print readers(['SCard$DefaultReaders']) 66 print readergroups() 67 except: 68 import sys 69 print sys.exc_info()[1] 70