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-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  from __future__ import print_function 
28  import smartcard.reader.ReaderFactory 
29  import smartcard.pcsc.PCSCReaderGroups 
30   
31   
32 -def readers(groups=[]):
33 """Returns the list of smartcard readers in groups. 34 35 If group is not specified, returns the list of all smartcard readers. 36 37 import smartcard 38 r=smartcard.readers() 39 r=smartcard.readers(['SCard$DefaultReaders', 'MyReaderGroup']) 40 """ 41 42 return smartcard.reader.ReaderFactory.ReaderFactory.readers(groups)
43 44
45 -def readergroups():
46 """Returns the list of reader groups.""" 47 48 return smartcard.pcsc.PCSCReaderGroups.PCSCReaderGroups().instance
49 50 51 # for legacy only
52 -def listReaders():
53 """Returns the list of smartcard readers. 54 55 Deprecated - Use smartcard.System.readers() instead. 56 """ 57 zreaders = [] 58 for reader in readers(): 59 zreaders.append(str(reader)) 60 return zreaders
61 62 63 if __name__ == '__main__': 64 print(readers()) 65 print(readers(['SCard$DefaultReaders'])) 66 print(readergroups()) 67