| Home | Trees | Indices | Help |
|
|---|
|
|
1 """PCSCReaderGroups organizes smartcard readers as groups. 2 3 __author__ = "gemalto http://www.gemalto.com" 4 5 Copyright 2001-2011 gemalto 6 Author: Jean-Daniel Aussel, mailto:jean-daniel.aussel@gemalto.com 7 8 This file is part of pyscard. 9 10 pyscard is free software; you can redistribute it and/or modify 11 it under the terms of the GNU Lesser General Public License as published by 12 the Free Software Foundation; either version 2.1 of the License, or 13 (at your option) any later version. 14 15 pyscard is distributed in the hope that it will be useful, 16 but WITHOUT ANY WARRANTY; without even the implied warranty of 17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 GNU Lesser General Public License for more details. 19 20 You should have received a copy of the GNU Lesser General Public License 21 along with pyscard; if not, write to the Free Software 22 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 23 """ 24 25 from smartcard.scard import * 26 from smartcard.reader.ReaderGroups import readergroups, innerreadergroups 27 from smartcard.pcsc.PCSCExceptions import * 28 2931 """Smartcard PCSC readers groups inner class. 32 33 The PCSCReaderGroups singleton manages the creation of the unique 34 instance of this class. 35 """ 3694 9538 """Constructor.""" 39 innerreadergroups.__init__(self, initlist) 40 self.unremovablegroups = ['SCard$DefaultReaders']4143 """ Returns the list of smartcard reader groups. 44 45 import smartcard 46 print smartcard.reader_groups() 47 """ 48 innerreadergroups.getreadergroups(self) 49 50 hresult, hcontext = SCardEstablishContext(SCARD_SCOPE_USER) 51 if hresult != 0: 52 raise EstablishContextException(hresult) 53 hresult, readers = SCardListReaderGroups(hcontext) 54 if hresult != 0: 55 raise ListReadersException(hresult) 56 hresult = SCardReleaseContext(hcontext) 57 if hresult != 0: 58 raise ReleaseContextException(hresult) 59 return readers6062 """Add a reader group""" 63 64 innerreadergroups.addreadergroup(self, newgroup) 65 66 hresult, hcontext = SCardEstablishContext(SCARD_SCOPE_USER) 67 if 0 != hresult: 68 raise error, 'Failed to establish context: ' + SCardGetErrorMessage(hresult) 69 try: 70 hresult = SCardIntroduceReaderGroup(hcontext, newgroup) 71 if 0 != hresult: 72 raise error, 'Unable to introduce reader group: ' + SCardGetErrorMessage(hresult) 73 finally: 74 hresult = SCardReleaseContext(hcontext) 75 if 0 != hresult: 76 raise error, 'Failed to release context: ' + SCardGetErrorMessage(hresult)7779 """Remove a reader group""" 80 81 innerreadergroups.removereadergroup(self, group) 82 83 hresult, hcontext = SCardEstablishContext(SCARD_SCOPE_USER) 84 if 0 != hresult: 85 raise error, 'Failed to establish context: ' + SCardGetErrorMessage(hresult) 86 try: 87 hresult = SCardForgetReaderGroup(hcontext, group) 88 if hresult != 0: 89 raise error, 'Unable to forget reader group: ' + SCardGetErrorMessage(hresult) 90 finally: 91 hresult = SCardReleaseContext(hcontext) 92 if 0 != hresult: 93 raise error, 'Failed to release context: ' + SCardGetErrorMessage(hresult)97 """PCSC readers groups.""" 98 99 """The single instance of __readergroups""" 100 instance = None 101 102 """Constructor: create a single instance of __readergroups on first call""" 103112 113 114 if __name__ == '__main__': 115 print PCSCReaderGroups() 116105 if None == PCSCReaderGroups.instance: 106 PCSCReaderGroups.instance = pcscinnerreadergroups(initlist)107 108 """All operators redirected to inner class.""" 109111 return getattr(self.instance, name)
| Home | Trees | Indices | Help |
|
|---|
| Generated by Epydoc 3.0.1 on Sat Nov 22 15:23:55 2014 | http://epydoc.sourceforge.net |