You can subscribe to this list here.
2007 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
(1) |
Oct
|
Nov
|
Dec
|
---|---|---|---|---|---|---|---|---|---|---|---|---|
2008 |
Jan
(10) |
Feb
(10) |
Mar
|
Apr
(1) |
May
|
Jun
|
Jul
|
Aug
(17) |
Sep
(9) |
Oct
(10) |
Nov
(2) |
Dec
(5) |
2009 |
Jan
(17) |
Feb
(8) |
Mar
(10) |
Apr
(1) |
May
|
Jun
(11) |
Jul
(18) |
Aug
|
Sep
|
Oct
(10) |
Nov
(40) |
Dec
(4) |
2010 |
Jan
(2) |
Feb
(5) |
Mar
(13) |
Apr
(14) |
May
(27) |
Jun
(86) |
Jul
(1) |
Aug
(12) |
Sep
|
Oct
(2) |
Nov
(3) |
Dec
(5) |
2011 |
Jan
|
Feb
(2) |
Mar
|
Apr
(3) |
May
|
Jun
|
Jul
(11) |
Aug
(1) |
Sep
(3) |
Oct
(65) |
Nov
|
Dec
(1) |
2012 |
Jan
(1) |
Feb
(4) |
Mar
(6) |
Apr
(6) |
May
|
Jun
(4) |
Jul
|
Aug
|
Sep
(12) |
Oct
(3) |
Nov
(1) |
Dec
|
2013 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
(3) |
Nov
|
Dec
(1) |
2014 |
Jan
(2) |
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
(1) |
Sep
(4) |
Oct
(1) |
Nov
(24) |
Dec
(10) |
2015 |
Jan
(1) |
Feb
(10) |
Mar
|
Apr
|
May
(1) |
Jun
(15) |
Jul
(4) |
Aug
(2) |
Sep
(1) |
Oct
|
Nov
|
Dec
|
From: <lu...@us...> - 2010-07-28 09:41:38
|
Revision: 502 http://pyscard.svn.sourceforge.net/pyscard/?rev=502&view=rev Author: ludov Date: 2010-07-28 09:41:32 +0000 (Wed, 28 Jul 2010) Log Message: ----------- Add value for Di=7 (7816-3:2006 page 19) Modified Paths: -------------- trunk/contrib/parseATR/parseATR.py Modified: trunk/contrib/parseATR/parseATR.py =================================================================== --- trunk/contrib/parseATR/parseATR.py 2010-06-23 17:05:38 UTC (rev 501) +++ trunk/contrib/parseATR/parseATR.py 2010-07-28 09:41:32 UTC (rev 502) @@ -138,7 +138,7 @@ def TA1(v): Fi = (372, 372, 558, 744, 1116, 1488, 1860, "RFU", "RFU", 512, 768, 1024, 1536, 2048, "RFU", "RFU") - Di = ("RFU", 1, 2, 4, 8, 16, 32, "RFU", 12, 20, "RFU", "RFU", "RFU", "RFU", "RFU", "RFU") + Di = ("RFU", 1, 2, 4, 8, 16, 32, 64, 12, 20, "RFU", "RFU", "RFU", "RFU", "RFU", "RFU") FMax = (4, 5, 6, 8, 12, 16, 20, "RFU", "RFU", 5, 7.5, 10, 15, 20, "RFU", "RFU") F = v >> 4 D = v & 0xF This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jda...@us...> - 2010-06-23 17:05:44
|
Revision: 501 http://pyscard.svn.sourceforge.net/pyscard/?rev=501&view=rev Author: jdaussel Date: 2010-06-23 17:05:38 +0000 (Wed, 23 Jun 2010) Log Message: ----------- Reader list is now created by ReaderFactory static method Modified Paths: -------------- trunk/pyscard/src/smartcard/System.py trunk/pyscard/src/smartcard/pcsc/PCSCReader.py trunk/pyscard/src/smartcard/reader/ReaderFactory.py Modified: trunk/pyscard/src/smartcard/System.py =================================================================== --- trunk/pyscard/src/smartcard/System.py 2010-06-23 16:39:34 UTC (rev 500) +++ trunk/pyscard/src/smartcard/System.py 2010-06-23 17:05:38 UTC (rev 501) @@ -24,7 +24,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA """ -import smartcard.pcsc.PCSCReader +import smartcard.reader.ReaderFactory import smartcard.pcsc.PCSCReaderGroups @@ -38,7 +38,7 @@ r=smartcard.readers(['SCard$DefaultReaders', 'MyReaderGroup']) """ - return smartcard.pcsc.PCSCReader.PCSCReader.readers(groups) + return smartcard.reader.ReaderFactory.ReaderFactory.readers(groups) def readergroups(): Modified: trunk/pyscard/src/smartcard/pcsc/PCSCReader.py =================================================================== --- trunk/pyscard/src/smartcard/pcsc/PCSCReader.py 2010-06-23 16:39:34 UTC (rev 500) +++ trunk/pyscard/src/smartcard/pcsc/PCSCReader.py 2010-06-23 17:05:38 UTC (rev 501) @@ -23,7 +23,6 @@ """ from smartcard.CardConnectionDecorator import CardConnectionDecorator -from smartcard.reader.ReaderFactory import ReaderFactory from smartcard.reader.Reader import Reader from smartcard.pcsc.PCSCContext import PCSCContext from smartcard.pcsc.PCSCCardConnection import PCSCCardConnection @@ -99,16 +98,16 @@ class Factory: - def create(self, readername): + def create(readername): return PCSCReader(readername) + create = staticmethod(create) def readers(groups=[]): creaders = [] hcontext = PCSCContext().getContext() for reader in __PCSCreaders__(hcontext, groups): - creaders.append(ReaderFactory.createReader( - 'smartcard.pcsc.PCSCReader.PCSCReader', reader)) + creaders.append(PCSCReader.Factory.create(reader)) return creaders readers = staticmethod(readers) Modified: trunk/pyscard/src/smartcard/reader/ReaderFactory.py =================================================================== --- trunk/pyscard/src/smartcard/reader/ReaderFactory.py 2010-06-23 16:39:34 UTC (rev 500) +++ trunk/pyscard/src/smartcard/reader/ReaderFactory.py 2010-06-23 17:05:38 UTC (rev 501) @@ -31,18 +31,15 @@ """ from smartcard.ClassLoader import get_class +from smartcard.pcsc.PCSCReader import PCSCReader class ReaderFactory: """Class to create readers from reader type id.""" factories = {} + factorymethods = [PCSCReader.readers] - def addFactory(id, ReaderFactory): - """Static method to add a ReaderFactory associated to a reader id.""" - ReaderFactory.factories.put[id] = ReaderFactory - addFactory = staticmethod(addFactory) - # A Template Method: def createReader(clazz, readername): """Static method to create a reader from a reader clazz. @@ -55,3 +52,10 @@ ReaderFactory.factories[clazz] = get_class(clazz).Factory() return ReaderFactory.factories[clazz].create(readername) createReader = staticmethod(createReader) + + def readers(groups=[]): + zreaders = [] + for fm in ReaderFactory.factorymethods: + zreaders += fm(groups) + return zreaders + readers = staticmethod(readers) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jda...@us...> - 2010-06-23 16:39:40
|
Revision: 500 http://pyscard.svn.sourceforge.net/pyscard/?rev=500&view=rev Author: jdaussel Date: 2010-06-23 16:39:34 +0000 (Wed, 23 Jun 2010) Log Message: ----------- readers() method is now a staticmethod of the PCSCReader class Modified Paths: -------------- trunk/pyscard/src/smartcard/System.py trunk/pyscard/src/smartcard/pcsc/PCSCReader.py Modified: trunk/pyscard/src/smartcard/System.py =================================================================== --- trunk/pyscard/src/smartcard/System.py 2010-06-23 12:27:32 UTC (rev 499) +++ trunk/pyscard/src/smartcard/System.py 2010-06-23 16:39:34 UTC (rev 500) @@ -38,7 +38,7 @@ r=smartcard.readers(['SCard$DefaultReaders', 'MyReaderGroup']) """ - return smartcard.pcsc.PCSCReader.readers(groups) + return smartcard.pcsc.PCSCReader.PCSCReader.readers(groups) def readergroups(): Modified: trunk/pyscard/src/smartcard/pcsc/PCSCReader.py =================================================================== --- trunk/pyscard/src/smartcard/pcsc/PCSCReader.py 2010-06-23 12:27:32 UTC (rev 499) +++ trunk/pyscard/src/smartcard/pcsc/PCSCReader.py 2010-06-23 16:39:34 UTC (rev 500) @@ -83,9 +83,11 @@ if 0 != hresult: raise EstablishContextException(hresult) try: - hresult = SCardRemoveReaderFromGroup(hcontext, self.name, groupname) + hresult = SCardRemoveReaderFromGroup(hcontext, self.name, + groupname) if 0 != hresult: - raise RemoveReaderFromGroupException(hresult, self.name, groupname) + raise RemoveReaderFromGroupException(hresult, self.name, + groupname) finally: hresult = SCardReleaseContext(hcontext) if 0 != hresult: @@ -100,21 +102,29 @@ def create(self, readername): return PCSCReader(readername) + def readers(groups=[]): + creaders = [] + hcontext = PCSCContext().getContext() -def readers(groups=[]): - creaders = [] - hcontext = PCSCContext().getContext() + for reader in __PCSCreaders__(hcontext, groups): + creaders.append(ReaderFactory.createReader( + 'smartcard.pcsc.PCSCReader.PCSCReader', reader)) + return creaders + readers = staticmethod(readers) - for reader in __PCSCreaders__(hcontext, groups): - creaders.append(ReaderFactory.createReader('smartcard.pcsc.PCSCReader.PCSCReader', reader)) - return creaders - if __name__ == '__main__': + from smartcard.util import * SELECT = [0xA0, 0xA4, 0x00, 0x00, 0x02] DF_TELECOM = [0x7F, 0x10] - creaders = readers() - cc = creaders[0].createConnection() - cc.connect() - data, sw1, sw2 = cc.transmit(SELECT + DF_TELECOM) - print "%X %X" % (sw1, sw2) + creaders = PCSCReader.readers() + for reader in creaders: + try: + print reader.name + connection = reader.createConnection() + connection.connect() + print toHexString(connection.getATR()) + data, sw1, sw2 = connection.transmit(SELECT + DF_TELECOM) + print "%X %X" % (sw1, sw2) + except NoCardException, x: + print 'no card in reader' This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <lu...@us...> - 2010-06-23 12:27:38
|
Revision: 499 http://pyscard.svn.sourceforge.net/pyscard/?rev=499&view=rev Author: ludov Date: 2010-06-23 12:27:32 +0000 (Wed, 23 Jun 2010) Log Message: ----------- make pep8 happy Modified Paths: -------------- trunk/pyscard/src/smartcard/pcsc/PCSCExceptions.py Modified: trunk/pyscard/src/smartcard/pcsc/PCSCExceptions.py =================================================================== --- trunk/pyscard/src/smartcard/pcsc/PCSCExceptions.py 2010-06-23 12:26:49 UTC (rev 498) +++ trunk/pyscard/src/smartcard/pcsc/PCSCExceptions.py 2010-06-23 12:27:32 UTC (rev 499) @@ -113,5 +113,5 @@ if __name__ == "__main__": try: raise EstablishContextException(smartcard.scard.SCARD_E_NO_MEMORY) - except BaseSCardException,exc: + except BaseSCardException, exc: print exc This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <lu...@us...> - 2010-06-23 12:26:55
|
Revision: 498 http://pyscard.svn.sourceforge.net/pyscard/?rev=498&view=rev Author: ludov Date: 2010-06-23 12:26:49 +0000 (Wed, 23 Jun 2010) Log Message: ----------- make pep8 happy Modified Paths: -------------- trunk/pyscard/src/smartcard/Exceptions.py Modified: trunk/pyscard/src/smartcard/Exceptions.py =================================================================== --- trunk/pyscard/src/smartcard/Exceptions.py 2010-06-23 11:52:22 UTC (rev 497) +++ trunk/pyscard/src/smartcard/Exceptions.py 2010-06-23 12:26:49 UTC (rev 498) @@ -34,45 +34,59 @@ """ pass + class CardConnectionException(SmartcardException): """Raised when a CardConnection class method fails.""" pass + class CardRequestException(SmartcardException): """Raised when a CardRequest wait fails.""" pass + class CardRequestTimeoutException(SmartcardException): """Raised when a CardRequest times out.""" + def __init__(self, *args): SmartcardException.__init__(self, "Time-out during card request", *args) + class CardServiceException(SmartcardException): """Raised when a CardService class method fails.""" pass + class InvalidATRMaskLengthException(SmartcardException): """Raised when an ATR mask does not match an ATR length.""" + def __init__(self, *args): SmartcardException.__init__(self, 'Invalid ATR mask length: ', *args) + class InvalidReaderException(SmartcardException): """Raised when trying to acces an invalid smartcard reader.""" + def __init__(self, *args): SmartcardException.__init__(self, 'Invalid reader: ', *args) + class ListReadersException(SmartcardException): """Raised when smartcard readers cannot be listed.""" + def __init__(self, *args): SmartcardException.__init__(self, 'Failed to list readers', *args) + class NoCardException(SmartcardException): """Raised when no card in is present in reader.""" + def __init__(self, *args): SmartcardException.__init__(self, 'Unable to connect to card or no card in reader', *args) + class NoReadersException(SmartcardException): """Raised when the system has no smartcard reader.""" + def __init__(self, *args): SmartcardException.__init__(self, 'No reader found', *args) - This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jda...@us...> - 2010-06-23 11:52:28
|
Revision: 497 http://pyscard.svn.sourceforge.net/pyscard/?rev=497&view=rev Author: jdaussel Date: 2010-06-23 11:52:22 +0000 (Wed, 23 Jun 2010) Log Message: ----------- Updated version number to release 1.6.12 Modified Paths: -------------- trunk/pyscard/src/PKG-INFO trunk/pyscard/src/README trunk/pyscard/src/setup.py trunk/pyscard/src/smartcard/ChangeLog trunk/pyscard/src/smartcard/README trunk/pyscard/src/smartcard/__init__.py trunk/pyscard/src/smartcard/doc/framework-samples.html trunk/pyscard/src/smartcard/doc/index.html trunk/pyscard/src/smartcard/doc/scard-samples.html trunk/pyscard/src/smartcard/scard/gemalto.ver Modified: trunk/pyscard/src/PKG-INFO =================================================================== --- trunk/pyscard/src/PKG-INFO 2010-06-23 11:31:22 UTC (rev 496) +++ trunk/pyscard/src/PKG-INFO 2010-06-23 11:52:22 UTC (rev 497) @@ -1,6 +1,6 @@ Metadata-Version: 1.0 Name: pyscard -Version: 1.6.10 +Version: 1.6.12 Summary: Smartcard module for Python. Home-page: http://pyscard.sourceforge.net/ Author: Jean-Daniel Aussel @@ -11,7 +11,7 @@ Platform: linux Platform: win32 Platform: Mac OSX -Classifier: Development Status :: 1.6.10 - Release +Classifier: Development Status :: 1.6.12 - Release Classifier: License :: GNU LESSER GENERAL PUBLIC LICENSE Classifier: Intended Audience :: Developers Classifier: Operating System :: Unix Modified: trunk/pyscard/src/README =================================================================== --- trunk/pyscard/src/README 2010-06-23 11:31:22 UTC (rev 496) +++ trunk/pyscard/src/README 2010-06-23 11:52:22 UTC (rev 497) @@ -23,14 +23,14 @@ Franklin St, Fifth Floor, Boston, MA 02110-1301 USA ------------------------------------------------------------------------------- -Last update : pyscard 1.6.10 (May 2010) +Last update : pyscard 1.6.12 (July 2010) ------------------------------------------------------------------------------- pyscard is a python module adding smart cards support to python. It consists of the smartcard.scard module, an extension module wrapping Windows smart card base components (also known as PCSC) on Windows, and PCSC lite on -linux and Mac OS X Tiger, and of the smartcard module, a python framework with +linux and Mac OS X Tiger, and of the smartcard module, a python framework with objects wrapping PCSC API. @@ -99,7 +99,7 @@ 1. download the binary distribution The binary distribution is either an archive file or a rpm file, with -names similar to pyscard-1.6.10-1.i386.rpm for the rpm distribution, +names similar to pyscard-1.6.12-1.i386.rpm for the rpm distribution, or pyscard-1.6.10.linux-i686.tar.gz for the archive distribution. 2. untar the binary distribution @@ -140,14 +140,14 @@ 1. download the binary distribution The binary distribution is an archive file, with a name similar to -pyscard-1.6.10-py-2.3-macosx10.4.mpkg or pyscard-1.6.10-py-2.5-macosx10.4.mpkg. +pyscard-1.6.12-py-2.3-macosx10.4.mpkg or pyscard-1.6.12-py-2.5-macosx10.4.mpkg. 2. Open the package and proceed with installation. -Python 2.3 is pre-installed, so install pyscard-1.6.10-py-2.3-macosx10.4.mpkg if +Python 2.3 is pre-installed, so install pyscard-1.6.12-py-2.3-macosx10.4.mpkg if you did not install another release of python. -Install pyscard-1.6.10-py-2.5-macosx10.4.mpkg if you installed python 2.5. +Install pyscard-1.6.12-py-2.5-macosx10.4.mpkg if you installed python 2.5. Installing on Mac OS X Tiger from the source distribution ---------------------------------------------------------- @@ -183,7 +183,7 @@ 1. download the binary distribution The binary distribution is an archive file, with a name similar to -pyscard-1.6.10-py-2.5-macosx10.5.mpkg. +pyscard-1.6.12-py-2.5-macosx10.5.mpkg. 2. Open the package and proceed with installation. @@ -274,7 +274,7 @@ echo "%_unpackaged_files_terminate_build 0" >> /etc/rpm/macros This will build in the dist directory a binary distribution with a name -similar to pyscard-1.6.10-1.i386.rpm. +similar to pyscard-1.6.12-1.i386.rpm. Building a binary distribution for Mac OS X Tiger ------------------------------------------------- @@ -284,22 +284,22 @@ and bdist_mpkg 0.4.3 (http://cheeseshop.python.org/pypi/bdist_mpkg/). -If you are using the pre-installed python 2.3 distribution, in the root directory -of the source distribution, i.e. in the src directory, execute the following commands +If you are using the pre-installed python 2.3 distribution, in the root directory +of the source distribution, i.e. in the src directory, execute the following commands in a terminal: python setup.py build_ext /System/Library/Frameworks/Python.Framework/Versions/2.3/bin/bdist_mpkg setup.py -This will build package pyscard-1.6.10-py-2.3-macosx10.4.mpkg. +This will build package pyscard-1.6.12-py-2.3-macosx10.4.mpkg. -If you are using python 2.5, in the root directory of the source distribution, +If you are using python 2.5, in the root directory of the source distribution, i.e. in the src directory, execute the following commands in a terminal: python setup.py build_ext /Library/Frameworks/Python.Framework/Versions/2.5/bin/bdist_mpkg setup.py -This will build package pyscard-1.6.10-py-2.6-macosx10.4.mpkg. +This will build package pyscard-1.6.12-py-2.6-macosx10.4.mpkg. Building a binary distribution for Mac OS X Leopard @@ -339,24 +339,24 @@ This patch is required since Mac OS X Leopard does not have the nidump command any more. Install bdist_mpkg by executing the bdist_mpkg setup.py script with build and -install as arguments, i.e. from the root directory of the bdist_mpkg +install as arguments, i.e. from the root directory of the bdist_mpkg source distribution enter: python setup.py build install. -For python 2.5, from the root directory of the pyscard source distribution, +For python 2.5, from the root directory of the pyscard source distribution, i.e. in the src directory, execute the following commands in a terminal: python setup.py build_ext /Library/Frameworks/Python.Framework/Versions/2.5/Extras/bin/bdist_mpkg setup.py -This will build package pyscard-1.6.10-py-2.5-macosx10.5.mpkg. +This will build package pyscard-1.6.12-py-2.5-macosx10.5.mpkg. -For python 2.6, from the root directory of the pyscard source distribution, +For python 2.6, from the root directory of the pyscard source distribution, i.e. in the src directory, execute the following commands in a terminal: python setup.py build_ext /Library/Frameworks/Python.framework/Versions/2.6/bin/bdist_mpkg setup.py -This will build package pyscard-1.6.10-py-2.6-macosx10.5.mpkg. +This will build package pyscard-1.6.12-py-2.6-macosx10.5.mpkg. ------------------------------------------------------------------------------- Issue Tracking Modified: trunk/pyscard/src/setup.py =================================================================== --- trunk/pyscard/src/setup.py 2010-06-23 11:31:22 UTC (rev 496) +++ trunk/pyscard/src/setup.py 2010-06-23 11:52:22 UTC (rev 497) @@ -152,7 +152,7 @@ build_ext.swig_sources = swig_sources kw = {'name': "pyscard", - 'version': "1.6.10", + 'version': "1.6.12", 'description': "Smartcard module for Python.", 'author': "Jean-Daniel Aussel", 'author_email': "aus...@ge...", @@ -198,7 +198,7 @@ if hasattr(core, 'setup_keywords'): if 'classifiers' in core.setup_keywords: kw['classifiers'] = [ - 'Development Status :: 1.6.10 - Release', + 'Development Status :: 1.6.12 - Release', 'License :: GNU LESSER GENERAL PUBLIC LICENSE', 'Intended Audience :: Developers', 'Operating System :: Unix', Modified: trunk/pyscard/src/smartcard/ChangeLog =================================================================== --- trunk/pyscard/src/smartcard/ChangeLog 2010-06-23 11:31:22 UTC (rev 496) +++ trunk/pyscard/src/smartcard/ChangeLog 2010-06-23 11:52:22 UTC (rev 497) @@ -1,3 +1,8 @@ +1.6.12 (July 2010) +=================== + * comply with PEP 8 (Ludovic Rousseau) + * comply with PEP 352 (Jean-Daniel Aussel) + 1.6.10 (May 2010) =================== * connect() has a new disposition parameter that is passed to SCardDisconnect (Ludovic Rousseau) @@ -40,7 +45,7 @@ ===== * better thread support and clean-up in ReaderMonitoringThread (Frank Aune) * fixed issue on Mac OS X Leopard with dlsym loading of bad SCardControl function (Mattias Br\xE4ndstr\xF6m) - * supported build of documentation files on linux and removed unresolved doc links (Ludovic Rousseau) + * supported build of documentation files on linux and removed unresolved doc links (Ludovic Rousseau) 1.6.6 ===== Modified: trunk/pyscard/src/smartcard/README =================================================================== --- trunk/pyscard/src/smartcard/README 2010-06-23 11:31:22 UTC (rev 496) +++ trunk/pyscard/src/smartcard/README 2010-06-23 11:52:22 UTC (rev 497) @@ -23,14 +23,14 @@ Franklin St, Fifth Floor, Boston, MA 02110-1301 USA ------------------------------------------------------------------------------- -Last update : pyscard 1.6.10 (May 2010) +Last update : pyscard 1.6.12 (July 2010) ------------------------------------------------------------------------------- pyscard is a python module adding smart cards support to python. It consists of the smartcard.scard module, an extension module wrapping Windows smart card base components (also known as PCSC) on Windows, and PCSC lite on -linux and Mac OS X Tiger, and of the smartcard module, a python framework with +linux and Mac OS X Tiger, and of the smartcard module, a python framework with objects wrapping PCSC API. @@ -99,7 +99,7 @@ 1. download the binary distribution The binary distribution is either an archive file or a rpm file, with -names similar to pyscard-1.6.10-1.i386.rpm for the rpm distribution, +names similar to pyscard-1.6.12-1.i386.rpm for the rpm distribution, or pyscard-1.6.10.linux-i686.tar.gz for the archive distribution. 2. untar the binary distribution @@ -140,14 +140,14 @@ 1. download the binary distribution The binary distribution is an archive file, with a name similar to -pyscard-1.6.10-py-2.3-macosx10.4.mpkg or pyscard-1.6.10-py-2.5-macosx10.4.mpkg. +pyscard-1.6.12-py-2.3-macosx10.4.mpkg or pyscard-1.6.12-py-2.5-macosx10.4.mpkg. 2. Open the package and proceed with installation. -Python 2.3 is pre-installed, so install pyscard-1.6.10-py-2.3-macosx10.4.mpkg if +Python 2.3 is pre-installed, so install pyscard-1.6.12-py-2.3-macosx10.4.mpkg if you did not install another release of python. -Install pyscard-1.6.10-py-2.5-macosx10.4.mpkg if you installed python 2.5. +Install pyscard-1.6.12-py-2.5-macosx10.4.mpkg if you installed python 2.5. Installing on Mac OS X Tiger from the source distribution ---------------------------------------------------------- @@ -183,7 +183,7 @@ 1. download the binary distribution The binary distribution is an archive file, with a name similar to -pyscard-1.6.10-py-2.5-macosx10.5.mpkg. +pyscard-1.6.12-py-2.5-macosx10.5.mpkg. 2. Open the package and proceed with installation. @@ -274,7 +274,7 @@ echo "%_unpackaged_files_terminate_build 0" >> /etc/rpm/macros This will build in the dist directory a binary distribution with a name -similar to pyscard-1.6.10-1.i386.rpm. +similar to pyscard-1.6.12-1.i386.rpm. Building a binary distribution for Mac OS X Tiger ------------------------------------------------- @@ -284,22 +284,22 @@ and bdist_mpkg 0.4.3 (http://cheeseshop.python.org/pypi/bdist_mpkg/). -If you are using the pre-installed python 2.3 distribution, in the root directory -of the source distribution, i.e. in the src directory, execute the following commands +If you are using the pre-installed python 2.3 distribution, in the root directory +of the source distribution, i.e. in the src directory, execute the following commands in a terminal: python setup.py build_ext /System/Library/Frameworks/Python.Framework/Versions/2.3/bin/bdist_mpkg setup.py -This will build package pyscard-1.6.10-py-2.3-macosx10.4.mpkg. +This will build package pyscard-1.6.12-py-2.3-macosx10.4.mpkg. -If you are using python 2.5, in the root directory of the source distribution, +If you are using python 2.5, in the root directory of the source distribution, i.e. in the src directory, execute the following commands in a terminal: python setup.py build_ext /Library/Frameworks/Python.Framework/Versions/2.5/bin/bdist_mpkg setup.py -This will build package pyscard-1.6.10-py-2.6-macosx10.4.mpkg. +This will build package pyscard-1.6.12-py-2.6-macosx10.4.mpkg. Building a binary distribution for Mac OS X Leopard @@ -339,24 +339,24 @@ This patch is required since Mac OS X Leopard does not have the nidump command any more. Install bdist_mpkg by executing the bdist_mpkg setup.py script with build and -install as arguments, i.e. from the root directory of the bdist_mpkg +install as arguments, i.e. from the root directory of the bdist_mpkg source distribution enter: python setup.py build install. -For python 2.5, from the root directory of the pyscard source distribution, +For python 2.5, from the root directory of the pyscard source distribution, i.e. in the src directory, execute the following commands in a terminal: python setup.py build_ext /Library/Frameworks/Python.Framework/Versions/2.5/Extras/bin/bdist_mpkg setup.py -This will build package pyscard-1.6.10-py-2.5-macosx10.5.mpkg. +This will build package pyscard-1.6.12-py-2.5-macosx10.5.mpkg. -For python 2.6, from the root directory of the pyscard source distribution, +For python 2.6, from the root directory of the pyscard source distribution, i.e. in the src directory, execute the following commands in a terminal: python setup.py build_ext /Library/Frameworks/Python.framework/Versions/2.6/bin/bdist_mpkg setup.py -This will build package pyscard-1.6.10-py-2.6-macosx10.5.mpkg. +This will build package pyscard-1.6.12-py-2.6-macosx10.5.mpkg. ------------------------------------------------------------------------------- Issue Tracking Modified: trunk/pyscard/src/smartcard/__init__.py =================================================================== --- trunk/pyscard/src/smartcard/__init__.py 2010-06-23 11:31:22 UTC (rev 496) +++ trunk/pyscard/src/smartcard/__init__.py 2010-06-23 11:52:22 UTC (rev 497) @@ -5,7 +5,7 @@ __author__ = "gemalto http://www.gemalto.com" __date__ = "May 2010" -__version__ = "1.6.10" +__version__ = "1.6.12" Copyright 2001-2010 gemalto Author: Jean-Daniel Aussel, mailto:jea...@ge... Modified: trunk/pyscard/src/smartcard/doc/framework-samples.html =================================================================== --- trunk/pyscard/src/smartcard/doc/framework-samples.html 2010-06-23 11:31:22 UTC (rev 496) +++ trunk/pyscard/src/smartcard/doc/framework-samples.html 2010-06-23 11:52:22 UTC (rev 497) @@ -6,21 +6,21 @@ </head> <body bgcolor="#ffffff"> <H1 align="center">pyscard library samples</h1> -<a href="http://sourceforge.net/projects/pyscard"><img -src="http://sflogo.sourceforge.net/sflogo.php?group_id=196342&type=11" +<a href="http://sourceforge.net/projects/pyscard"><img +src="http://sflogo.sourceforge.net/sflogo.php?group_id=196342&type=11" width="120" height="30" align="right" alt="Get pyscard at SourceForge.net. Fast, -secure and Free Open +secure and Free Open Source software downloads" /></a> <hr> <H1 align="center"> </h1> -Last update : pyscard 1.6.10 (May 2010) +Last update : pyscard 1.6.12 (May 2010) <p> <a href="pyscard-usersguide.html">pyscard</a> is a python module adding smart cards support to <a href="http://www.python.org">python</a>. -<p>It consists of <a - href="epydoc/smartcard.scard.scard-module.html">smartcard.scard</a>, an - extension module wrapping Windows smart card base components (also known as - PCSC), and <a href="epydoc/index.html">smartcard</a>, a python framework +<p>It consists of <a + href="epydoc/smartcard.scard.scard-module.html">smartcard.scard</a>, an + extension module wrapping Windows smart card base components (also known as + PCSC), and <a href="epydoc/index.html">smartcard</a>, a python framework library hiding PCSC complexity. -<p align="center"><img src="images/pyscard.jpg" width="396" height="540" +<p align="center"><img src="images/pyscard.jpg" width="396" height="540" align="middle"> <h2> </h2> <H2>Smartcard python framework samples</H2> Modified: trunk/pyscard/src/smartcard/doc/index.html =================================================================== --- trunk/pyscard/src/smartcard/doc/index.html 2010-06-23 11:31:22 UTC (rev 496) +++ trunk/pyscard/src/smartcard/doc/index.html 2010-06-23 11:52:22 UTC (rev 497) @@ -8,27 +8,27 @@ <body bgcolor="#ffffff"> <H1 align="center">pyscard<a href="http://sourceforge.net/projects/pyscard"></a> <a href="http://sourceforge.net/projects/pyscard"> - <img - src="http://sflogo.sourceforge.net/sflogo.php?group_id=196342&type=11" + <img + src="http://sflogo.sourceforge.net/sflogo.php?group_id=196342&type=11" width="120" height="30" align="right" - alt="Get pyscard at SourceForge.net. Fast, secure and Free Open Source software downloads" /></a> + alt="Get pyscard at SourceForge.net. Fast, secure and Free Open Source software downloads" /></a> </h1> <hr> - Last update : pyscard 1.6.10 (May 2010) + Last update : pyscard 1.6.12 (May 2010) <p> <a href="pyscard-usersguide.html">pyscard - python smart card library</a> is a python module adding smart cards support to <a href="http://www.python.org">python.</a> <p><a href="http://sourceforge.net/projects/pyscard/">download</a> pyscard from sourceforge.net. <p>Report bugs, patches and feature requests using the sourceforge <a - href="http://sourceforge.net/tracker/?group_id=196342">pyscard bug tracking - system</a>.</p> + href="http://sourceforge.net/tracker/?group_id=196342">pyscard bug tracking + system</a>.</p> <p>Pyscard consists of <a href="epydoc/smartcard.scard.scard-module.html">smartcard.scard</a>, an extension module wrapping Windows smart card base components (also known - as PCSC) on Windows and PCSC lite on linux and Mac OS X Tiger and Leopard, and - <a href="epydoc/index.html">smartcard</a>, a higher level python framework + as PCSC) on Windows and PCSC lite on linux and Mac OS X Tiger and Leopard, and + <a href="epydoc/index.html">smartcard</a>, a higher level python framework built on top of the raw PCSC API. -<p align="center"><img src="images/pyscard.jpg" width="396" height="540" +<p align="center"><img src="images/pyscard.jpg" width="396" height="540" align="middle"> <h2>Documentation Index</h2> <UL> Modified: trunk/pyscard/src/smartcard/doc/scard-samples.html =================================================================== --- trunk/pyscard/src/smartcard/doc/scard-samples.html 2010-06-23 11:31:22 UTC (rev 496) +++ trunk/pyscard/src/smartcard/doc/scard-samples.html 2010-06-23 11:52:22 UTC (rev 497) @@ -6,13 +6,13 @@ </head> <body bgcolor="#ffffff"> <H1 align="center">smartcard.scard PCSC wrapper samples</h1> -<a href="http://sourceforge.net/projects/pyscard"><img -src="http://sflogo.sourceforge.net/sflogo.php?group_id=196342&type=11" +<a href="http://sourceforge.net/projects/pyscard"><img +src="http://sflogo.sourceforge.net/sflogo.php?group_id=196342&type=11" width="120" height="30" align="right" alt="Get pyscard at SourceForge.net. Fast, -secure and Free Open +secure and Free Open Source software downloads" /></a> <hr> <H1 align="center"> </h1> -Last update : pyscard 1.6.10 (May 2010) +Last update : pyscard 1.6.12 (May 2010) <p>Using the <a href="epydoc/index.html">smartcard framework</a> is the preferred way to write python smart card application. You can however use the <a href="epydoc/smartcard.scard.scard-module.html">smartcard.scard</a> library to write your python smart card application if you want to write your @@ -20,10 +20,10 @@ C API not available in the smartcard framework. <p>The <a href="epydoc/smartcard.scard.scard-module.html">smartcard.scard</a> module is a native extension module wrapping Windows smart card base components - (also known as PCSC) on Windows, and pcsc-lite on linux and Mac OS X, whereas - the <a href="epydoc/index.html">smartcard framework</a> is a pure python + (also known as PCSC) on Windows, and pcsc-lite on linux and Mac OS X, whereas + the <a href="epydoc/index.html">smartcard framework</a> is a pure python framework hiding scard complexity and PCSC. -<p align="center"><img src="images/pyscard.jpg" width="396" height="540" +<p align="center"><img src="images/pyscard.jpg" width="396" height="540" align="middle"> <h2>smartcard.scard samples</h2> <table border> @@ -49,7 +49,7 @@ <td><a href="Examples/scard-api/sample_listCards.py">view source</a></td> </tr> <td>list the interfaces supported by a card</td> - <td><a href="Examples/scard-api/sample_listInterfaces.py">view + <td><a href="Examples/scard-api/sample_listInterfaces.py">view source</a></td> </tr> <tr> @@ -88,7 +88,7 @@ <p>You should have received a copy of the GNU Lesser General Public License along with pyscard; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA</p> -</body> +</body> <!-- Piwik --> <script type="text/javascript"> var pkBaseURL = (("https:" == document.location.protocol) ? "https://sourceforge.net/apps/piwik/pyscard/" : "http://sourceforge.net/apps/piwik/pyscard/"); @@ -100,6 +100,6 @@ piwik_log(piwik_action_name, piwik_idsite, piwik_url); </script> <object><noscript><p><img src="http://sourceforge.net/apps/piwik/pyscard/piwik.php?idsite=1" alt="piwik"/></p></noscript></object> -<!-- End Piwik Tag --> +<!-- End Piwik Tag --> </html> Modified: trunk/pyscard/src/smartcard/scard/gemalto.ver =================================================================== --- trunk/pyscard/src/smartcard/scard/gemalto.ver 2010-06-23 11:31:22 UTC (rev 496) +++ trunk/pyscard/src/smartcard/scard/gemalto.ver 2010-06-23 11:52:22 UTC (rev 497) @@ -16,7 +16,7 @@ #endif #ifndef VER_PRODUCTVERSION -#define VER_PRODUCTVERSION 1,06,10,0010 +#define VER_PRODUCTVERSION 1,06,12,0010 #endif #ifndef VER_FILEVERSION @@ -24,7 +24,7 @@ #endif #ifndef VER_PRODUCTVERSION_STR -#define VER_PRODUCTVERSION_STR "1.6.10" +#define VER_PRODUCTVERSION_STR "1.6.12" #endif #ifndef VER_FILEFLAGSMASK This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jda...@us...> - 2010-06-23 11:31:31
|
Revision: 496 http://pyscard.svn.sourceforge.net/pyscard/?rev=496&view=rev Author: jdaussel Date: 2010-06-23 11:31:22 +0000 (Wed, 23 Jun 2010) Log Message: ----------- fixed typo on 0x86 status word Modified Paths: -------------- trunk/pyscard/src/smartcard/sw/ISO7816_8ErrorChecker.py Modified: trunk/pyscard/src/smartcard/sw/ISO7816_8ErrorChecker.py =================================================================== --- trunk/pyscard/src/smartcard/sw/ISO7816_8ErrorChecker.py 2010-06-23 11:24:22 UTC (rev 495) +++ trunk/pyscard/src/smartcard/sw/ISO7816_8ErrorChecker.py 2010-06-23 11:31:22 UTC (rev 496) @@ -69,7 +69,7 @@ 0x6A: (smartcard.sw.SWExceptions.CheckingErrorException, {0x81: "Function not supported", 0x82: "File not found", - x86: "Incorrect parameters P1-P2", + 0x86: "Incorrect parameters P1-P2", 0x88: "Referenced data not found"}), } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jda...@us...> - 2010-06-23 11:24:28
|
Revision: 495 http://pyscard.svn.sourceforge.net/pyscard/?rev=495&view=rev Author: jdaussel Date: 2010-06-23 11:24:22 +0000 (Wed, 23 Jun 2010) Log Message: ----------- BaseSCardException now derives from Exception to comply with PEP 352 Modified Paths: -------------- trunk/pyscard/src/smartcard/pcsc/PCSCExceptions.py Modified: trunk/pyscard/src/smartcard/pcsc/PCSCExceptions.py =================================================================== --- trunk/pyscard/src/smartcard/pcsc/PCSCExceptions.py 2010-06-23 11:15:16 UTC (rev 494) +++ trunk/pyscard/src/smartcard/pcsc/PCSCExceptions.py 2010-06-23 11:24:22 UTC (rev 495) @@ -28,7 +28,7 @@ import smartcard.scard -class BaseSCardException: +class BaseSCardException(Exception): """Base class for scard (aka PCSC) exceptions. scard exceptions are raised by the scard module, i.e. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jda...@us...> - 2010-06-23 11:15:23
|
Revision: 494 http://pyscard.svn.sourceforge.net/pyscard/?rev=494&view=rev Author: jdaussel Date: 2010-06-23 11:15:16 +0000 (Wed, 23 Jun 2010) Log Message: ----------- SmartCardException now derives from base Exception class; message attribute removed to comply with PEP 352 Modified Paths: -------------- trunk/pyscard/src/smartcard/Exceptions.py Modified: trunk/pyscard/src/smartcard/Exceptions.py =================================================================== --- trunk/pyscard/src/smartcard/Exceptions.py 2010-06-23 11:00:16 UTC (rev 493) +++ trunk/pyscard/src/smartcard/Exceptions.py 2010-06-23 11:15:16 UTC (rev 494) @@ -25,80 +25,54 @@ """ -class SmartcardException: +class SmartcardException(Exception): """Base class for smartcard exceptions. smartcard exceptions are generated by the smartcard module and shield scard (i.e. PCSC) exceptions raised by the scard module. """ + pass - def __init__(self, message=""): - self.message = message - - def __str__(self): - return repr('Smartcard Exception: ' + self.message + '!') - - class CardConnectionException(SmartcardException): """Raised when a CardConnection class method fails.""" + pass - def __init__(self, message=""): - SmartcardException.__init__(self, message) - - class CardRequestException(SmartcardException): """Raised when a CardRequest wait fails.""" + pass - def __init__(self, message=""): - SmartcardException.__init__(self, message) - - class CardRequestTimeoutException(SmartcardException): """Raised when a CardRequest times out.""" + def __init__(self, *args): + SmartcardException.__init__(self, "Time-out during card request", *args) - def __init__(self, message=""): - SmartcardException.__init__(self, "Time-out during card request") - - class CardServiceException(SmartcardException): """Raised when a CardService class method fails.""" + pass - def __init__(self, message=""): - SmartcardException.__init__(self, message) - - class InvalidATRMaskLengthException(SmartcardException): """Raised when an ATR mask does not match an ATR length.""" + def __init__(self, *args): + SmartcardException.__init__(self, 'Invalid ATR mask length: ', *args) - def __init__(self, mask=""): - SmartcardException.__init__(self, 'Invalid ATR mask length: ' + mask) - - class InvalidReaderException(SmartcardException): """Raised when trying to acces an invalid smartcard reader.""" + def __init__(self, *args): + SmartcardException.__init__(self, 'Invalid reader: ', *args) - def __init__(self, readername=""): - SmartcardException.__init__(self, 'Invalid reader: ' + readername) - - class ListReadersException(SmartcardException): """Raised when smartcard readers cannot be listed.""" + def __init__(self, *args): + SmartcardException.__init__(self, 'Failed to list readers', *args) - def __init__(self, message=""): - SmartcardException.__init__(self, 'failed to list readers') - - class NoCardException(SmartcardException): """Raised when no card in is present in reader.""" + def __init__(self, *args): + SmartcardException.__init__(self, 'Unable to connect to card or no card in reader', *args) - def __init__(self, message=""): - SmartcardException.__init__(self, - 'Unable to connect to card or no card in reader') - - class NoReadersException(SmartcardException): """Raised when the system has no smartcard reader.""" + def __init__(self, *args): + SmartcardException.__init__(self, 'No reader found', *args) - def __init__(self, message=""): - SmartcardException.__init__(self, 'no readers found') This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jda...@us...> - 2010-06-23 11:00:22
|
Revision: 493 http://pyscard.svn.sourceforge.net/pyscard/?rev=493&view=rev Author: jdaussel Date: 2010-06-23 11:00:16 +0000 (Wed, 23 Jun 2010) Log Message: ----------- Fixed exception handling syntax for python 2.4 Modified Paths: -------------- trunk/pyscard/src/smartcard/pcsc/PCSCExceptions.py Modified: trunk/pyscard/src/smartcard/pcsc/PCSCExceptions.py =================================================================== --- trunk/pyscard/src/smartcard/pcsc/PCSCExceptions.py 2010-06-13 18:54:29 UTC (rev 492) +++ trunk/pyscard/src/smartcard/pcsc/PCSCExceptions.py 2010-06-23 11:00:16 UTC (rev 493) @@ -113,5 +113,5 @@ if __name__ == "__main__": try: raise EstablishContextException(smartcard.scard.SCARD_E_NO_MEMORY) - except BaseSCardException as exc: + except BaseSCardException,exc: print exc This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <lu...@us...> - 2010-06-13 18:54:36
|
Revision: 492 http://pyscard.svn.sourceforge.net/pyscard/?rev=492&view=rev Author: ludov Date: 2010-06-13 18:54:29 +0000 (Sun, 13 Jun 2010) Log Message: ----------- just print the exception instead of print sys.exc_info()[0], ':', sys.exc_info()[1] Modified Paths: -------------- trunk/pyscard/src/smartcard/Examples/scard-api/sample_control.py trunk/pyscard/src/smartcard/Examples/scard-api/sample_getATR.py trunk/pyscard/src/smartcard/Examples/scard-api/sample_getAttrib.py trunk/pyscard/src/smartcard/Examples/scard-api/sample_getStatusChange.py trunk/pyscard/src/smartcard/Examples/scard-api/sample_listCards.py trunk/pyscard/src/smartcard/Examples/scard-api/sample_locateCards.py trunk/pyscard/src/smartcard/Examples/scard-api/sample_pinpad.py trunk/pyscard/src/smartcard/Examples/scard-api/sample_readerGroups.py trunk/pyscard/src/smartcard/Examples/scard-api/sample_readers.py trunk/pyscard/src/smartcard/Examples/scard-api/sample_selectDFTelecom.py trunk/pyscard/src/smartcard/Examples/scard-api/sample_transaction.py Modified: trunk/pyscard/src/smartcard/Examples/scard-api/sample_control.py =================================================================== --- trunk/pyscard/src/smartcard/Examples/scard-api/sample_control.py 2010-06-13 18:33:38 UTC (rev 491) +++ trunk/pyscard/src/smartcard/Examples/scard-api/sample_control.py 2010-06-13 18:54:29 UTC (rev 492) @@ -88,9 +88,8 @@ raise error, 'Failed to release context: ' + SCardGetErrorMessage(hresult) print 'Released context.' -except: - import sys - print sys.exc_info()[0], ':', sys.exc_info()[1] +except error, e: + print e import sys if 'win32' == sys.platform: Modified: trunk/pyscard/src/smartcard/Examples/scard-api/sample_getATR.py =================================================================== --- trunk/pyscard/src/smartcard/Examples/scard-api/sample_getATR.py 2010-06-13 18:33:38 UTC (rev 491) +++ trunk/pyscard/src/smartcard/Examples/scard-api/sample_getATR.py 2010-06-13 18:54:29 UTC (rev 492) @@ -76,9 +76,8 @@ raise error, 'Failed to release context: ' + SCardGetErrorMessage(hresult) print 'Released context.' -except: - import sys - print sys.exc_info()[0], ':', sys.exc_info()[1] +except Exception, e: + print e import sys if 'win32' == sys.platform: Modified: trunk/pyscard/src/smartcard/Examples/scard-api/sample_getAttrib.py =================================================================== --- trunk/pyscard/src/smartcard/Examples/scard-api/sample_getAttrib.py 2010-06-13 18:33:38 UTC (rev 491) +++ trunk/pyscard/src/smartcard/Examples/scard-api/sample_getAttrib.py 2010-06-13 18:54:29 UTC (rev 492) @@ -136,9 +136,8 @@ raise error, 'Failed to release context: ' + SCardGetErrorMessage(hresult) print 'Released context.' -except error: - import sys - print sys.exc_info()[0], ':', sys.exc_info()[1] +except Exception, e: + print e import sys if 'win32' == sys.platform: Modified: trunk/pyscard/src/smartcard/Examples/scard-api/sample_getStatusChange.py =================================================================== --- trunk/pyscard/src/smartcard/Examples/scard-api/sample_getStatusChange.py 2010-06-13 18:33:38 UTC (rev 491) +++ trunk/pyscard/src/smartcard/Examples/scard-api/sample_getStatusChange.py 2010-06-13 18:54:29 UTC (rev 492) @@ -100,6 +100,5 @@ print 'press Enter to continue' sys.stdin.read(1) -except error: - import sys - print sys.exc_info()[0], ':', sys.exc_info()[1] +except error, e: + print e Modified: trunk/pyscard/src/smartcard/Examples/scard-api/sample_listCards.py =================================================================== --- trunk/pyscard/src/smartcard/Examples/scard-api/sample_listCards.py 2010-06-13 18:33:38 UTC (rev 491) +++ trunk/pyscard/src/smartcard/Examples/scard-api/sample_listCards.py 2010-06-13 18:54:29 UTC (rev 492) @@ -64,9 +64,8 @@ raise error, 'Failed to release context: ' + SCardGetErrorMessage(hresult) print 'Released context.' - except error: - import sys - print sys.exc_info()[0], ':', sys.exc_info()[1] + except error, e: + print e elif 'pcsclite' == resourceManager: print 'SCardListCards not supported by pcsc lite' Modified: trunk/pyscard/src/smartcard/Examples/scard-api/sample_locateCards.py =================================================================== --- trunk/pyscard/src/smartcard/Examples/scard-api/sample_locateCards.py 2010-06-13 18:33:38 UTC (rev 491) +++ trunk/pyscard/src/smartcard/Examples/scard-api/sample_locateCards.py 2010-06-13 18:54:29 UTC (rev 492) @@ -105,9 +105,8 @@ raise error, 'Failed to release context: ' + SCardGetErrorMessage(hresult) print 'Released context.' - except error: - import sys - print sys.exc_info()[0], ':', sys.exc_info()[1] + except error, e: + print e elif 'pcsclite' == resourceManager: print 'SCardLocateCards not supported by pcsc lite' Modified: trunk/pyscard/src/smartcard/Examples/scard-api/sample_pinpad.py =================================================================== --- trunk/pyscard/src/smartcard/Examples/scard-api/sample_pinpad.py 2010-06-13 18:33:38 UTC (rev 491) +++ trunk/pyscard/src/smartcard/Examples/scard-api/sample_pinpad.py 2010-06-13 18:54:29 UTC (rev 492) @@ -118,9 +118,8 @@ raise error, 'Failed to release context: ' + SCardGetErrorMessage(hresult) print 'Released context.' -except: - import sys - print sys.exc_info()[0], ':', sys.exc_info()[1] +except error, e: + print e import sys if 'win32' == sys.platform: Modified: trunk/pyscard/src/smartcard/Examples/scard-api/sample_readerGroups.py =================================================================== --- trunk/pyscard/src/smartcard/Examples/scard-api/sample_readerGroups.py 2010-06-13 18:33:38 UTC (rev 491) +++ trunk/pyscard/src/smartcard/Examples/scard-api/sample_readerGroups.py 2010-06-13 18:54:29 UTC (rev 492) @@ -117,6 +117,5 @@ print 'press Enter to continue' sys.stdin.read(1) -except error: - import sys - print sys.exc_info()[0], ':', sys.exc_info()[1] +except error, e: + print e Modified: trunk/pyscard/src/smartcard/Examples/scard-api/sample_readers.py =================================================================== --- trunk/pyscard/src/smartcard/Examples/scard-api/sample_readers.py 2010-06-13 18:33:38 UTC (rev 491) +++ trunk/pyscard/src/smartcard/Examples/scard-api/sample_readers.py 2010-06-13 18:54:29 UTC (rev 492) @@ -56,6 +56,5 @@ print 'press Enter to continue' sys.stdin.read(1) -except error: - import sys - print sys.exc_info()[0], ':', sys.exc_info()[1] +except error, e: + print e Modified: trunk/pyscard/src/smartcard/Examples/scard-api/sample_selectDFTelecom.py =================================================================== --- trunk/pyscard/src/smartcard/Examples/scard-api/sample_selectDFTelecom.py 2010-06-13 18:33:38 UTC (rev 491) +++ trunk/pyscard/src/smartcard/Examples/scard-api/sample_selectDFTelecom.py 2010-06-13 18:54:29 UTC (rev 492) @@ -83,9 +83,8 @@ raise error, 'Failed to release context: ' + SCardGetErrorMessage(hresult) print 'Released context.' -except error: - import sys - print sys.exc_info()[0], ':', sys.exc_info()[1] +except error, e: + print e import sys if 'win32' == sys.platform: Modified: trunk/pyscard/src/smartcard/Examples/scard-api/sample_transaction.py =================================================================== --- trunk/pyscard/src/smartcard/Examples/scard-api/sample_transaction.py 2010-06-13 18:33:38 UTC (rev 491) +++ trunk/pyscard/src/smartcard/Examples/scard-api/sample_transaction.py 2010-06-13 18:54:29 UTC (rev 492) @@ -86,9 +86,8 @@ raise error, 'failed to release context: ' + SCardGetErrorMessage(hresult) print 'Released context.' -except error: - import sys - print sys.exc_info()[0], ':', sys.exc_info()[1] +except error, e: + print e import sys if 'win32' == sys.platform: This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <lu...@us...> - 2010-06-13 18:33:44
|
Revision: 491 http://pyscard.svn.sourceforge.net/pyscard/?rev=491&view=rev Author: ludov Date: 2010-06-13 18:33:38 +0000 (Sun, 13 Jun 2010) Log Message: ----------- do not import sys anymore Modified Paths: -------------- trunk/pyscard/src/smartcard/pcsc/PCSCExceptions.py Modified: trunk/pyscard/src/smartcard/pcsc/PCSCExceptions.py =================================================================== --- trunk/pyscard/src/smartcard/pcsc/PCSCExceptions.py 2010-06-12 23:06:52 UTC (rev 490) +++ trunk/pyscard/src/smartcard/pcsc/PCSCExceptions.py 2010-06-13 18:33:38 UTC (rev 491) @@ -111,7 +111,6 @@ smartcard.scard.SCardGetErrorMessage(self.hresult)) if __name__ == "__main__": - import sys try: raise EstablishContextException(smartcard.scard.SCARD_E_NO_MEMORY) except BaseSCardException as exc: This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <lu...@us...> - 2010-06-12 23:06:59
|
Revision: 490 http://pyscard.svn.sourceforge.net/pyscard/?rev=490&view=rev Author: ludov Date: 2010-06-12 23:06:52 +0000 (Sat, 12 Jun 2010) Log Message: ----------- improve epydoc Modified Paths: -------------- trunk/pyscard/src/smartcard/sw/ErrorChecker.py trunk/pyscard/src/smartcard/sw/ErrorCheckingChain.py trunk/pyscard/src/smartcard/sw/ISO7816_4ErrorChecker.py trunk/pyscard/src/smartcard/sw/ISO7816_4_SW1ErrorChecker.py trunk/pyscard/src/smartcard/sw/ISO7816_8ErrorChecker.py trunk/pyscard/src/smartcard/sw/ISO7816_9ErrorChecker.py trunk/pyscard/src/smartcard/sw/op21_ErrorChecker.py Modified: trunk/pyscard/src/smartcard/sw/ErrorChecker.py =================================================================== --- trunk/pyscard/src/smartcard/sw/ErrorChecker.py 2010-06-12 22:50:52 UTC (rev 489) +++ trunk/pyscard/src/smartcard/sw/ErrorChecker.py 2010-06-12 23:06:52 UTC (rev 490) @@ -26,21 +26,21 @@ class ErrorChecker: """Base class for status word error checking strategies. - Error checking strategies are chained into an ErrorCheckingChain to + Error checking strategies are chained into an L{ErrorCheckingChain} to implement a Chain of Responsibility. Each strategy in the chain is called until an error is detected. The strategy raises a - smartcard.sw.SWException exception when an error is detected. + L{smartcard.sw.SWException} exception when an error is detected. Implementation derived from Bruce Eckel, Thinking in Python. The - ErrorCheckingChain implements the Chain Of Responsibility design + L{ErrorCheckingChain} implements the Chain Of Responsibility design pattern. """ def __call__(data, sw1, sw2): """Called to test data, sw1 and sw2 for error. - data: apdu response data - sw1, sw2: apdu data status words + @param data: apdu response data + @param sw1, sw2: apdu data status words - Derived classes must raise a smartcard.sw.SWException upon error.""" + Derived classes must raise a L{smartcard.sw.SWException} upon error.""" pass Modified: trunk/pyscard/src/smartcard/sw/ErrorCheckingChain.py =================================================================== --- trunk/pyscard/src/smartcard/sw/ErrorCheckingChain.py 2010-06-12 22:50:52 UTC (rev 489) +++ trunk/pyscard/src/smartcard/sw/ErrorCheckingChain.py 2010-06-12 23:06:52 UTC (rev 490) @@ -28,17 +28,18 @@ class ErrorCheckingChain: """The error checking chain is a list of response apdu status word (sw1, sw2) error check strategies. Each strategy in the chain is - called until an error is detected. A smartcard.sw.SWException + called until an error is detected. A L{smartcard.sw.SWException} exception is raised when an error is detected. No exception is raised if no error is detected. Implementation derived from Bruce Eckel, Thinking in Python. The - ErrorCheckingChain implements the Chain Of Responsibility design + L{ErrorCheckingChain} implements the Chain Of Responsibility design pattern. """ def __init__(self, chain, strategy): - """constructor. Appends a strategy to the ErrorCheckingChain chain.""" + """constructor. Appends a strategy to the L{ErrorCheckingChain} + chain.""" self.strategy = strategy self.chain = chain self.chain.append(self) @@ -54,8 +55,8 @@ def addFilterException(self, exClass): """Add an exception filter to the error checking chain. - exClass: the exception to exclude, e.g. - smartcard.sw.SWExceptions.WarningProcessingException A filtered + @param exClass: the exception to exclude, e.g. + L{smartcard.sw.SWExceptions.WarningProcessingException} A filtered exception will not be raised when the sw1,sw2 conditions that would raise the excption are met. """ @@ -66,7 +67,8 @@ self.next().addFilterException(exClass) def end(self): - """Returns True if this is the end of the error checking strategy chain.""" + """Returns True if this is the end of the error checking + strategy chain.""" return (self.chain.index(self) + 1 >= len(self.chain)) def __call__(self, data, sw1, sw2): Modified: trunk/pyscard/src/smartcard/sw/ISO7816_4ErrorChecker.py =================================================================== --- trunk/pyscard/src/smartcard/sw/ISO7816_4ErrorChecker.py 2010-06-12 22:50:52 UTC (rev 489) +++ trunk/pyscard/src/smartcard/sw/ISO7816_4ErrorChecker.py 2010-06-12 23:06:52 UTC (rev 490) @@ -103,33 +103,31 @@ """ISO7816-4 error checking strategy. This strategy raises the following exceptions: - sw1 sw2 - 62 00 81 82 83 84 FF WarningProcessingException - 63 00 81 C0->CF WarningProcessingException - 64 00 ExecutionErrorException - 67 00 CheckingErrorException - 68 81 82 CheckingErrorException - 69 81->88 99? c1? CheckingErrorException - 6a 80->88 CheckingErrorException - 6b 00 CheckingErrorException - 6d 00 CheckingErrorException - 6e 00 CheckingErrorException - 6f 00 CheckingErrorException + - sw1 sw2 + - 62 00 81 82 83 84 FF WarningProcessingException + - 63 00 81 C0->CF WarningProcessingException + - 64 00 ExecutionErrorException + - 67 00 CheckingErrorException + - 68 81 82 CheckingErrorException + - 69 81->88 99? c1? CheckingErrorException + - 6a 80->88 CheckingErrorException + - 6b 00 CheckingErrorException + - 6d 00 CheckingErrorException + - 6e 00 CheckingErrorException + - 6f 00 CheckingErrorException This checker does not raise exceptions on undefined sw1 values, e.g.: + - sw1 sw2 + - 65 any + - 66 any + - 6c any - sw1 sw2 - 65 any - 66 any - 6c any - and on undefined sw2 values, e.g.: + - sw1 sw2 + - 62 80 85 + - 6b any except 00 - sw1 sw2 - 62 80 85 - 6b any except 00 - Use another checker in the error checking chain, e.g., the ISO7816_4SW1ErrorChecker, to raise exceptions on these undefined values. @@ -138,10 +136,10 @@ def __call__(self, data, sw1, sw2): """Called to test data, sw1 and sw2 for error. - data: apdu response data - sw1, sw2: apdu data status words + @param data: apdu response data + @param sw1, sw2: apdu data status words - Derived classes must raise a smartcard.sw.SWException upon error.""" + Derived classes must raise a L{smartcard.sw.SWException} upon error.""" if iso7816_4SW.has_key(sw1): exception, sw2dir = iso7816_4SW[sw1] if type(sw2dir) == type({}): Modified: trunk/pyscard/src/smartcard/sw/ISO7816_4_SW1ErrorChecker.py =================================================================== --- trunk/pyscard/src/smartcard/sw/ISO7816_4_SW1ErrorChecker.py 2010-06-12 22:50:52 UTC (rev 489) +++ trunk/pyscard/src/smartcard/sw/ISO7816_4_SW1ErrorChecker.py 2010-06-12 23:06:52 UTC (rev 490) @@ -47,28 +47,28 @@ """ISO7816-4 error checker based on status word sw1 only. This error checker raises the following exceptions: - sw1 sw2 - 62 any WarningProcessingException - 63 any WarningProcessingException - 64 any ExecutionErrorException - 65 any ExecutionErrorException - 66 any SecurityRelatedException - 67 any CheckingErrorException - 68 any CheckingErrorException - 69 any CheckingErrorException - 6a any CheckingErrorException - 6b any CheckingErrorException - 6c any CheckingErrorException - 6d any CheckingErrorException - 6e any CheckingErrorException - 6f any CheckingErrorException + - sw1 sw2 + - 62 any WarningProcessingException + - 63 any WarningProcessingException + - 64 any ExecutionErrorException + - 65 any ExecutionErrorException + - 66 any SecurityRelatedException + - 67 any CheckingErrorException + - 68 any CheckingErrorException + - 69 any CheckingErrorException + - 6a any CheckingErrorException + - 6b any CheckingErrorException + - 6c any CheckingErrorException + - 6d any CheckingErrorException + - 6e any CheckingErrorException + - 6f any CheckingErrorException """ def __call__(self, data, sw1, sw2): """Called to test data, sw1 and sw2 for error. - data: apdu response data - sw1, sw2: apdu data status words + @param data: apdu response data + @param sw1, sw2: apdu data status words """ if iso7816_4SW1.has_key(sw1): exception = iso7816_4SW1[sw1] Modified: trunk/pyscard/src/smartcard/sw/ISO7816_8ErrorChecker.py =================================================================== --- trunk/pyscard/src/smartcard/sw/ISO7816_8ErrorChecker.py 2010-06-12 22:50:52 UTC (rev 489) +++ trunk/pyscard/src/smartcard/sw/ISO7816_8ErrorChecker.py 2010-06-12 23:06:52 UTC (rev 490) @@ -78,29 +78,26 @@ """ISO7816-8 error checker. This error checker raises the following exceptions: + - sw1 sw2 + - 63 00,c0-cf WarningProcessingException + - 65 81 ExecutionErrorException + - 66 00,87,88 SecurityRelatedException + - 67 00 CheckingErrorException + - 68 82,84 CheckingErrorException + - 69 82,83,84,85 CheckingErrorException + - 6A 81,82,86,88 CheckingErrorException - sw1 sw2 - 63 00,c0-cf WarningProcessingException - 65 81 ExecutionErrorException - 66 00,87,88 SecurityRelatedException - 67 00 CheckingErrorException - 68 82,84 CheckingErrorException - 69 82,83,84,85 CheckingErrorException - 6A 81,82,86,88 CheckingErrorException - This checker does not raise exceptions on undefined sw1 values, e.g.: + - sw1 sw2 + - 62 any + - 6f any - sw1 sw2 - 62 any - 6f any - and on undefined sw2 values, e.g.: + - sw1 sw2 + - 66 81 82 + - 67 any except 00 - sw1 sw2 - 66 81 82 - 67 any except 00 - Use another checker in the error checking chain, e.g., the ISO7816_4SW1ErrorChecker or ISO7816_4ErrorChecker, to raise exceptions on these undefined values. @@ -109,10 +106,10 @@ def __call__(self, data, sw1, sw2): """Called to test data, sw1 and sw2 for error. - data: apdu response data - sw1, sw2: apdu data status words + @param data: apdu response data + @param sw1, sw2: apdu data status words - Derived classes must raise a smartcard.sw.SWException upon error.""" + Derived classes must raise a L{smartcard.sw.SWException} upon error.""" if iso7816_8SW.has_key(sw1): exception, sw2dir = iso7816_8SW[sw1] if type(sw2dir) == type({}): Modified: trunk/pyscard/src/smartcard/sw/ISO7816_9ErrorChecker.py =================================================================== --- trunk/pyscard/src/smartcard/sw/ISO7816_9ErrorChecker.py 2010-06-12 22:50:52 UTC (rev 489) +++ trunk/pyscard/src/smartcard/sw/ISO7816_9ErrorChecker.py 2010-06-12 23:06:52 UTC (rev 490) @@ -47,26 +47,23 @@ """ISO7816-8 error checker. This error checker raises the following exceptions: + - sw1 sw2 + - 62 82 WarningProcessingException + - 64 00 ExecutionErrorException + - 69 82 CheckingErrorException + - 6A 80,84,89,8A CheckingErrorException - sw1 sw2 - 62 82 WarningProcessingException - 64 00 ExecutionErrorException - 69 82 CheckingErrorException - 6A 80,84,89,8A CheckingErrorException - This checker does not raise exceptions on undefined sw1 values, e.g.: + - sw1 sw2 + - 63 any + - 6F any - sw1 sw2 - 63 any - 6F any - and on undefined sw2 values, e.g.: + - sw1 sw2 + - 62 81 83 + - 64 any except 00 - sw1 sw2 - 62 81 83 - 64 any except 00 - Use another checker in the error checking chain, e.g., the ISO7816_4SW1ErrorChecker or ISO7816_4ErrorChecker, to raise exceptions on these undefined values. @@ -75,10 +72,10 @@ def __call__(self, data, sw1, sw2): """Called to test data, sw1 and sw2 for error. - data: apdu response data - sw1, sw2: apdu data status words + @param data: apdu response data + @param sw1, sw2: apdu data status words - Derived classes must raise a smartcard.sw.SWException upon error.""" + Derived classes must raise a L{smartcard.sw.SWException} upon error.""" if iso7816_9SW.has_key(sw1): exception, sw2dir = iso7816_9SW[sw1] if type(sw2dir) == type({}): Modified: trunk/pyscard/src/smartcard/sw/op21_ErrorChecker.py =================================================================== --- trunk/pyscard/src/smartcard/sw/op21_ErrorChecker.py 2010-06-12 22:50:52 UTC (rev 489) +++ trunk/pyscard/src/smartcard/sw/op21_ErrorChecker.py 2010-06-12 23:06:52 UTC (rev 490) @@ -70,32 +70,29 @@ """Open platform 2.1 error checker. This error checker raises the following exceptions: + - sw1 sw2 + - 62 83 WarningProcessingException + - 63 00 WarningProcessingException + - 64 00 ExecutionErrorException + - 65 81 ExecutionErrorException + - 67 00 CheckingErrorException + - 69 82 85 CheckingErrorException + - 6A 80 81 82 84 86 88 CheckingErrorException + - 6D 00 CheckingErrorException + - 6E 00 CheckingErrorException + - 94 84 85 CheckingErrorException - sw1 sw2 - 62 83 WarningProcessingException - 63 00 WarningProcessingException - 64 00 ExecutionErrorException - 65 81 ExecutionErrorException - 67 00 CheckingErrorException - 69 82 85 CheckingErrorException - 6A 80 81 82 84 86 88 CheckingErrorException - 6D 00 CheckingErrorException - 6E 00 CheckingErrorException - 94 84 85 CheckingErrorException - This checker does not raise exceptions on undefined sw1 values, e.g.: + - sw1 sw2 + - 63 any + - 6F any - sw1 sw2 - 63 any - 6F any - and on undefined sw2 values, e.g.: + - sw1 sw2 + - 62 81 83 + - 64 any except 00 - sw1 sw2 - 62 81 83 - 64 any except 00 - Use another checker in the error checking chain to raise exceptions on these undefined values. """ @@ -103,10 +100,10 @@ def __call__(self, data, sw1, sw2): """Called to test data, sw1 and sw2 for error. - data: apdu response data - sw1, sw2: apdu data status words + @param data: apdu response data + @param sw1, sw2: apdu data status words - Derived classes must raise a smartcard.sw.SWException upon error.""" + Derived classes must raise a L{smartcard.sw.SWException} upon error.""" if op21_SW.has_key(sw1): exception, sw2dir = op21_SW[sw1] if type(sw2dir) == type({}): This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <lu...@us...> - 2010-06-12 22:50:58
|
Revision: 489 http://pyscard.svn.sourceforge.net/pyscard/?rev=489&view=rev Author: ludov Date: 2010-06-12 22:50:52 +0000 (Sat, 12 Jun 2010) Log Message: ----------- improve epydoc Modified Paths: -------------- trunk/pyscard/src/smartcard/reader/ReaderFactory.py Modified: trunk/pyscard/src/smartcard/reader/ReaderFactory.py =================================================================== --- trunk/pyscard/src/smartcard/reader/ReaderFactory.py 2010-06-12 22:48:25 UTC (rev 488) +++ trunk/pyscard/src/smartcard/reader/ReaderFactory.py 2010-06-12 22:50:52 UTC (rev 489) @@ -47,9 +47,9 @@ def createReader(clazz, readername): """Static method to create a reader from a reader clazz. - module: the python module that contains the reader class - clazz: the reader class name - readername: the reader name + @param module: the python module that contains the reader class + @param clazz: the reader class name + @param readername: the reader name """ if not ReaderFactory.factories.has_key(clazz): ReaderFactory.factories[clazz] = get_class(clazz).Factory() This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <lu...@us...> - 2010-06-12 22:48:31
|
Revision: 488 http://pyscard.svn.sourceforge.net/pyscard/?rev=488&view=rev Author: ludov Date: 2010-06-12 22:48:25 +0000 (Sat, 12 Jun 2010) Log Message: ----------- improve epydoc and make sample code more pep8 compliant Modified Paths: -------------- trunk/pyscard/src/smartcard/scard/scard.i Modified: trunk/pyscard/src/smartcard/scard/scard.i =================================================================== --- trunk/pyscard/src/smartcard/scard/scard.i 2010-06-12 22:14:03 UTC (rev 487) +++ trunk/pyscard/src/smartcard/scard/scard.i 2010-06-12 22:48:25 UTC (rev 488) @@ -1,6 +1,7 @@ /*============================================================================== Copyright 2001-2010 gemalto Author: Jean-Daniel Aussel, mailto:jea...@ge... +Author: Ludovic Rousseau, mailto:lud...@fr... This file is part of pyscard. @@ -29,12 +30,12 @@ You should avoid using the smartcard.scard package directly, and use the pyscard directly because: -. smartcard.scard being a C wrapper, the code tends to look like C code -written in python syntax + - smartcard.scard being a C wrapper, the code tends to look like C code + written in python syntax -. the smartcard package provides higher level abstractions (e.g. CardType, -CardConnection), and makes programming easier since it is totally written -in Python + - the smartcard package provides higher level abstractions (e.g. + CardType, CardConnection), and makes programming easier since it is + totally written in Python You can still use the smartcard.scard package if you want to write your own framework, or if you want to perform quick-and-dirty port of C @@ -53,87 +54,91 @@ On Windows using the smart card base components, the smartcard.scard module provides mapping for the following API functions: -SCardAddReaderToGroup -SCardBeginTransaction -SCardCancel -SCardConnect -SCardControl -SCardDisconnect -SCardEndTransaction -SCardEstablishContext -SCardForgetCardType -SCardForgetReader -SCardForgetReaderGroup -SCardGetAttrib -SCardGetCardTypeProviderName -SCardGetErrorMessage -SCardGetStatusChange -SCardIntroduceCardType -SCardIntroduceReader -SCardIntroduceReaderGroup -SCardIsValidContext -SCardListInterfaces -SCardListCards -SCardListReaders -SCardListReaderGroups -SCardLocateCards -SCardReconnect -SCardReleaseContext -SCardRemoveReaderFromGroup -SCardSetAttrib -SCardStatus -SCardTransmit + - SCardAddReaderToGroup + - SCardBeginTransaction + - SCardCancel + - SCardConnect + - SCardControl + - SCardDisconnect + - SCardEndTransaction + - SCardEstablishContext + - SCardForgetCardType + - SCardForgetReader + - SCardForgetReaderGroup + - SCardGetAttrib + - SCardGetCardTypeProviderName + - SCardGetErrorMessage + - SCardGetStatusChange + - SCardIntroduceCardType + - SCardIntroduceReader + - SCardIntroduceReaderGroup + - SCardIsValidContext + - SCardListInterfaces + - SCardListCards + - SCardListReaders + - SCardListReaderGroups + - SCardLocateCards + - SCardReconnect + - SCardReleaseContext + - SCardRemoveReaderFromGroup + - SCardSetAttrib + - SCardStatus + - SCardTransmit -On linux or Mac OS X Leopard with PCSC lite, the smartcard.scard module provides mapping for the following API functions: +On linux or Mac OS X Leopard with PCSC lite, the smartcard.scard module +provides mapping for the following API functions: -SCardBeginTransaction -SCardCancel -SCardConnect -SCardControl -SCardDisconnect -SCardEndTransaction -SCardEstablishContext -SCardGetAttrib -SCardGetStatusChange -SCardIsValidContext -SCardListReaders -SCardListReaderGroups -SCardReconnect -SCardReleaseContext -SCardSetAttrib -SCardStatus -SCardTransmit + - SCardBeginTransaction + - SCardCancel + - SCardConnect + - SCardControl + - SCardDisconnect + - SCardEndTransaction + - SCardEstablishContext + - SCardGetAttrib + - SCardGetStatusChange + - SCardIsValidContext + - SCardListReaders + - SCardListReaderGroups + - SCardReconnect + - SCardReleaseContext + - SCardSetAttrib + - SCardStatus + - SCardTransmit -On Mac OS X Tiger with PCSC lite, the smartcard.scard module provides mapping for the following API functions: +On Mac OS X Tiger with PCSC lite, the smartcard.scard module provides +mapping for the following API functions: -SCardBeginTransaction -SCardCancel -SCardConnect -SCardControl -SCardDisconnect -SCardEndTransaction -SCardEstablishContext -SCardGetStatusChange -SCardListReaders -SCardListReaderGroups -SCardReconnect -SCardReleaseContext -SCardStatus -SCardTransmit + - SCardBeginTransaction + - SCardCancel + - SCardConnect + - SCardControl + - SCardDisconnect + - SCardEndTransaction + - SCardEstablishContext + - SCardGetStatusChange + - SCardListReaders + - SCardListReaderGroups + - SCardReconnect + - SCardReleaseContext + - SCardStatus + - SCardTransmit -The following PCSC smart card functions are not wrapped by the scard module on any platform: +The following PCSC smart card functions are not wrapped by the scard +module on any platform: -GetOpenCardName -SCardFreeMemory -SCardGetProviderId -SCardSetCartTypeProviderName -SCardUIDlgSelectCard + - GetOpenCardName + - SCardFreeMemory + - SCardGetProviderId + - SCardSetCartTypeProviderName + - SCardUIDlgSelectCard -Comments, bugs, improvements welcome. +Comments, bug reports, improvements welcome. ------------------------------------------------------------------------------- Copyright 2001-2010 gemalto -Author: Jean-Daniel Aussel, mailto:jea...@ge... +@Author: Jean-Daniel Aussel, mailto:jea...@ge... +@Author: Ludovic Rousseau, mailto:lud...@fr... This file is part of pyscard. @@ -154,9 +159,9 @@ " %enddef -%module( docstring=DOCSTRING, package="smartcard.scard") scard +%module(docstring=DOCSTRING, package="smartcard.scard") scard -%feature("autodoc", "3" ); +%feature("autodoc", "3"); %{ #ifdef WIN32 @@ -212,30 +217,30 @@ SCARDRETCODE _AddReaderToGroup( SCARDCONTEXT hcontext, char* szReaderName, - char* szGroupName ) + char* szGroupName) { return (mySCardAddReaderToGroupA)( hcontext, szReaderName, - szGroupName ); + szGroupName); } /////////////////////////////////////////////////////////////////////////////// -SCARDRETCODE _ForgetCardType( SCARDCONTEXT hcontext, char* pszCardName ) +SCARDRETCODE _ForgetCardType(SCARDCONTEXT hcontext, char* pszCardName) { - return (mySCardForgetCardTypeA)( hcontext, pszCardName ); + return (mySCardForgetCardTypeA)(hcontext, pszCardName); } /////////////////////////////////////////////////////////////////////////////// -SCARDRETCODE _ForgetReader( SCARDCONTEXT hcontext, char* szReaderName ) +SCARDRETCODE _ForgetReader(SCARDCONTEXT hcontext, char* szReaderName) { - return (mySCardForgetReaderA)( hcontext, szReaderName ); + return (mySCardForgetReaderA)(hcontext, szReaderName); } /////////////////////////////////////////////////////////////////////////////// -SCARDRETCODE _ForgetReaderGroup( SCARDCONTEXT hcontext, char* szGroupName ) +SCARDRETCODE _ForgetReaderGroup(SCARDCONTEXT hcontext, char* szGroupName) { - return (mySCardForgetReaderGroupA)( hcontext, szGroupName ); + return (mySCardForgetReaderGroupA)(hcontext, szGroupName); } /////////////////////////////////////////////////////////////////////////////// @@ -243,7 +248,7 @@ SCARDCONTEXT hcontext, char* pszCardName, SCARDDWORDARG dwProviderId, - PROVIDERNAME_t* psl ) + PROVIDERNAME_t* psl) { long lRetCode; unsigned long cchProviderName=SCARD_AUTOALLOCATE; @@ -255,7 +260,7 @@ lRetCode=(mySCardGetCardTypeProviderNameA)( hcontext, pszCardName, dwProviderId, - (LPTSTR)&psl->sz, &cchProviderName ); + (LPTSTR)&psl->sz, &cchProviderName); return lRetCode; }; @@ -278,23 +283,23 @@ rgguidInterfaces ? rgguidInterfaces->cGuids : 0, pbAtr->ab, pbAtrMask->ab, - pbAtr->cBytes ); + pbAtr->cBytes); } /////////////////////////////////////////////////////////////////////////////// -SCARDRETCODE _IntroduceReader( SCARDCONTEXT hcontext, char* szReaderName, char* szDeviceName ) +SCARDRETCODE _IntroduceReader(SCARDCONTEXT hcontext, char* szReaderName, char* szDeviceName) { - return (mySCardIntroduceReaderA)( hcontext, szReaderName, szDeviceName ); + return (mySCardIntroduceReaderA)(hcontext, szReaderName, szDeviceName); } /////////////////////////////////////////////////////////////////////////////// -SCARDRETCODE _IntroduceReaderGroup( SCARDCONTEXT hcontext, char* szGroupName ) +SCARDRETCODE _IntroduceReaderGroup(SCARDCONTEXT hcontext, char* szGroupName) { - return (mySCardIntroduceReaderGroupA)( hcontext, szGroupName ); + return (mySCardIntroduceReaderGroupA)(hcontext, szGroupName); } /////////////////////////////////////////////////////////////////////////////// -SCARDRETCODE _ListCards( SCARDCONTEXT hcontext, BYTELIST* pbl, GUIDLIST* guidlist, STRINGLIST* pmszCards ) +SCARDRETCODE _ListCards(SCARDCONTEXT hcontext, BYTELIST* pbl, GUIDLIST* guidlist, STRINGLIST* pmszCards) { // autoallocate memory; will be freed on output typemap unsigned long cchCards=SCARD_AUTOALLOCATE; @@ -302,14 +307,14 @@ pmszCards->ac=NULL; pmszCards->hcontext=hcontext; - //SCardHelper_PrintByteList( pbl ); + //SCardHelper_PrintByteList(pbl); return (mySCardListCardsA)( hcontext, pbl->ab, (NULL==guidlist) ? NULL : guidlist->aguid, (NULL==guidlist) ? 0 : guidlist->cGuids, (LPTSTR)&pmszCards->ac, - &cchCards ); + &cchCards); }; @@ -327,8 +332,8 @@ pgl->aguid = NULL; lRetCode = (mySCardListInterfacesA)(hcontext, pszCard, (LPGUID)&pgl->aguid, - &pgl->cGuids ); - if( lRetCode!=SCARD_S_SUCCESS ) + &pgl->cGuids); + if (lRetCode!=SCARD_S_SUCCESS) { pgl->cGuids=0; } @@ -348,19 +353,19 @@ hcontext, pcstr, prl->ars, - prl->cRStates ); + prl->cRStates); } /////////////////////////////////////////////////////////////////////////////// SCARDRETCODE _RemoveReaderFromGroup( SCARDCONTEXT hcontext, char* szReaderName, - char* szGroupName ) + char* szGroupName) { return (mySCardRemoveReaderFromGroupA)( hcontext, szReaderName, - szGroupName ); + szGroupName); } #endif // WIN32 @@ -371,21 +376,21 @@ // #ifndef __TIGER__ /////////////////////////////////////////////////////////////////////////////// -static SCARDRETCODE _IsValidContext( SCARDCONTEXT hcontext ) +static SCARDRETCODE _IsValidContext(SCARDCONTEXT hcontext) { - return (mySCardIsValidContext)( hcontext ); + return (mySCardIsValidContext)(hcontext); } /////////////////////////////////////////////////////////////////////////////// -static SCARDRETCODE _GetAttrib( SCARDHANDLE hcard, SCARDDWORDARG dwAttrId, BYTELIST* pbl ) +static SCARDRETCODE _GetAttrib(SCARDHANDLE hcard, SCARDDWORDARG dwAttrId, BYTELIST* pbl) { long lRetCode; pbl->cBytes = 0; pbl->ab = NULL; - lRetCode = (mySCardGetAttrib)( hcard, dwAttrId, pbl->ab, &pbl->cBytes ); - if( (lRetCode!=SCARD_S_SUCCESS) || (pbl->cBytes<1) ) + lRetCode = (mySCardGetAttrib)(hcard, dwAttrId, pbl->ab, &pbl->cBytes); + if ((lRetCode!=SCARD_S_SUCCESS) || (pbl->cBytes<1)) { return lRetCode; } @@ -396,16 +401,16 @@ return SCARD_E_NO_MEMORY; } - lRetCode = (mySCardGetAttrib)( hcard, dwAttrId, pbl->ab, &pbl->cBytes ); + lRetCode = (mySCardGetAttrib)(hcard, dwAttrId, pbl->ab, &pbl->cBytes); return lRetCode; } /////////////////////////////////////////////////////////////////////////////// -static SCARDRETCODE _SetAttrib( SCARDHANDLE hcard, SCARDDWORDARG dwAttrId, BYTELIST* pbl ) +static SCARDRETCODE _SetAttrib(SCARDHANDLE hcard, SCARDDWORDARG dwAttrId, BYTELIST* pbl) { long lRetCode; - lRetCode = (mySCardSetAttrib)( hcard, dwAttrId, pbl->ab, pbl->cBytes ); + lRetCode = (mySCardSetAttrib)(hcard, dwAttrId, pbl->ab, pbl->cBytes); return lRetCode; } #endif // !__TIGER__ @@ -421,7 +426,7 @@ SCARDHANDLE hcard, BYTELIST* pblSendBuffer, BYTELIST* pblRecvBuffer - ) + ) { SCARDRETCODE lRet; @@ -433,7 +438,7 @@ pblSendBuffer->ab, pblSendBuffer->cBytes, pblRecvBuffer->ab, - &pblRecvBuffer->cBytes ); + &pblRecvBuffer->cBytes); return lRet; } #else // !__TIGER__ @@ -443,7 +448,7 @@ SCARDDWORDARG controlCode, BYTELIST* pblSendBuffer, BYTELIST* pblRecvBuffer - ) + ) { SCARDRETCODE lRet; @@ -457,21 +462,21 @@ pblSendBuffer->cBytes, pblRecvBuffer->ab, pblRecvBuffer->cBytes, - &pblRecvBuffer->cBytes ); + &pblRecvBuffer->cBytes); return lRet; } #endif // __TIGER__ /////////////////////////////////////////////////////////////////////////////// -static SCARDRETCODE _BeginTransaction( SCARDHANDLE hcard ) +static SCARDRETCODE _BeginTransaction(SCARDHANDLE hcard) { - return (mySCardBeginTransaction)( hcard ); + return (mySCardBeginTransaction)(hcard); } /////////////////////////////////////////////////////////////////////////////// -static SCARDRETCODE _Cancel( SCARDCONTEXT hcontext ) +static SCARDRETCODE _Cancel(SCARDCONTEXT hcontext) { - return (mySCardCancel)( hcontext ); + return (mySCardCancel)(hcontext); } /////////////////////////////////////////////////////////////////////////////// @@ -492,38 +497,38 @@ dwShareMode, dwPreferredProtocols, phCard, - pdwActiveProtocol ); + pdwActiveProtocol); return lRet; } /////////////////////////////////////////////////////////////////////////////// -static SCARDRETCODE _Disconnect( SCARDHANDLE hcard, SCARDDWORDARG dwDisposition ) +static SCARDRETCODE _Disconnect(SCARDHANDLE hcard, SCARDDWORDARG dwDisposition) { - return (mySCardDisconnect)( hcard, dwDisposition ); + return (mySCardDisconnect)(hcard, dwDisposition); } /////////////////////////////////////////////////////////////////////////////// -static SCARDRETCODE _EndTransaction( SCARDHANDLE hcard, SCARDDWORDARG dwDisposition ) +static SCARDRETCODE _EndTransaction(SCARDHANDLE hcard, SCARDDWORDARG dwDisposition) { - return (mySCardEndTransaction)( hcard, dwDisposition ); + return (mySCardEndTransaction)(hcard, dwDisposition); } /////////////////////////////////////////////////////////////////////////////// -static SCARDRETCODE _EstablishContext( SCARDDWORDARG dwScope, SCARDCONTEXT* phContext ) +static SCARDRETCODE _EstablishContext(SCARDDWORDARG dwScope, SCARDCONTEXT* phContext) { long lRet; - lRet = (mySCardEstablishContext)( dwScope, NULL, NULL, phContext ); + lRet = (mySCardEstablishContext)(dwScope, NULL, NULL, phContext); #ifdef __TIGER__ // SCardReleaseContext on Mac OS X Tiger fails if SCardConnect is not called with an established // context, even on a dummy reader - if( SCARD_S_SUCCESS==lRet ) + if (SCARD_S_SUCCESS==lRet) { SCARDHANDLE hcard; SCARDDWORDARG dwarg; - (mySCardConnectA)( *phContext, "dummy-reader", SCARD_SHARE_SHARED, - SCARD_PROTOCOL_ANY, &hcard, &dwarg ); + (mySCardConnectA)(*phContext, "dummy-reader", SCARD_SHARE_SHARED, + SCARD_PROTOCOL_ANY, &hcard, &dwarg); } #endif // __TIGER__ @@ -534,32 +539,32 @@ static SCARDRETCODE _GetStatusChange( SCARDCONTEXT hcontext, SCARDDWORDARG dwTimeout, - READERSTATELIST* prsl ) + READERSTATELIST* prsl) { SCARDRETCODE hresult; int i; // bad reader state list - if( NULL==prsl ) + if (NULL==prsl) { return SCARD_E_INVALID_PARAMETER; } // remove changed bit - for( i=0; i<prsl->cRStates; i++ ) + for(i=0; i<prsl->cRStates; i++) { // remove changed bit prsl->ars[i].dwCurrentState = prsl->ars[i].dwCurrentState & (0xFFFFFFFF ^ SCARD_STATE_CHANGED); } - hresult = (mySCardGetStatusChangeA)( hcontext, dwTimeout, prsl->ars, - prsl->cRStates ); + hresult = (mySCardGetStatusChangeA)(hcontext, dwTimeout, prsl->ars, + prsl->cRStates); - //printf( "\n%.8lx ", hresult ); - //for( i=0; i<prsl->cRStates; i++ ) + //printf("\n%.8lx ", hresult); + //for(i=0; i<prsl->cRStates; i++) //{ - // printf( "%.8lx %.8lx ", prsl->ars[i].dwCurrentState, prsl->ars[i].dwEventState ); + // printf("%.8lx %.8lx ", prsl->ars[i].dwCurrentState, prsl->ars[i].dwEventState); //} return hresult; @@ -569,7 +574,7 @@ static SCARDRETCODE _ListReaders( SCARDCONTEXT hcontext, STRINGLIST* pmszGroups, - STRINGLIST* pmszReaders ) + STRINGLIST* pmszReaders) { LPCTSTR mszGroups; SCARDDWORDARG cchReaders; @@ -591,8 +596,8 @@ pmszReaders->ac=NULL; pmszReaders->hcontext=hcontext; - return (mySCardListReadersA)( hcontext, mszGroups, - (LPTSTR)&pmszReaders->ac, &cchReaders ); + return (mySCardListReadersA)(hcontext, mszGroups, + (LPTSTR)&pmszReaders->ac, &cchReaders); #endif //AUTOALLOCATE // no autoallocate on pcsc-lite; do a first call to get length @@ -604,31 +609,31 @@ pmszReaders->ac=NULL; cchReaders=0; - lRetCode = (mySCardListReadersA)( hcontext, mszGroups, NULL, - &cchReaders ); + lRetCode = (mySCardListReadersA)(hcontext, mszGroups, NULL, + &cchReaders); - if ( SCARD_S_SUCCESS!=lRetCode ) + if (SCARD_S_SUCCESS!=lRetCode) { return lRetCode; } - if( 0==cchReaders ) + if (0==cchReaders) { return SCARD_S_SUCCESS; } - pmszReaders->ac=mem_Malloc( cchReaders*sizeof( char ) ); - if ( NULL==pmszReaders->ac ) + pmszReaders->ac=mem_Malloc(cchReaders*sizeof(char)); + if (NULL==pmszReaders->ac) { return SCARD_E_NO_MEMORY; } - return (mySCardListReadersA)( hcontext, mszGroups, (LPTSTR)pmszReaders->ac, &cchReaders ); + return (mySCardListReadersA)(hcontext, mszGroups, (LPTSTR)pmszReaders->ac, &cchReaders); #endif // !NOAUTOALLOCATE } /////////////////////////////////////////////////////////////////////////////// -static SCARDRETCODE _ListReaderGroups( SCARDCONTEXT hcontext, STRINGLIST* pmszReaderGroups ) +static SCARDRETCODE _ListReaderGroups(SCARDCONTEXT hcontext, STRINGLIST* pmszReaderGroups) { DWORD cchReaderGroups; LONG lRetCode; @@ -638,8 +643,8 @@ pmszReaderGroups->ac=NULL; pmszReaderGroups->hcontext=hcontext; - return (mySCardListReaderGroupsA)( hcontext, - (LPTSTR)&pmszReaderGroups->ac, &cchReaderGroups ); + return (mySCardListReaderGroupsA)(hcontext, + (LPTSTR)&pmszReaderGroups->ac, &cchReaderGroups); #endif // NOAUTOALLOCATE // no autoallocate on pcsc-lite; do a first call to get length @@ -651,25 +656,25 @@ pmszReaderGroups->hcontext=0; cchReaderGroups = 0; pmszReaderGroups->ac=NULL; - lRetCode = (mySCardListReaderGroupsA)( hcontext, - (LPTSTR)pmszReaderGroups->ac, &cchReaderGroups ); - if ( SCARD_S_SUCCESS!=lRetCode ) + lRetCode = (mySCardListReaderGroupsA)(hcontext, + (LPTSTR)pmszReaderGroups->ac, &cchReaderGroups); + if (SCARD_S_SUCCESS!=lRetCode) { return lRetCode; } - if( 0==cchReaderGroups ) + if (0==cchReaderGroups) { return SCARD_S_SUCCESS; } - pmszReaderGroups->ac=mem_Malloc( cchReaderGroups*sizeof( char ) ); - if ( NULL==pmszReaderGroups->ac ) + pmszReaderGroups->ac=mem_Malloc(cchReaderGroups*sizeof(char)); + if (NULL==pmszReaderGroups->ac) { return SCARD_E_NO_MEMORY; } - return (mySCardListReaderGroupsA)( hcontext, (LPTSTR)pmszReaderGroups->ac, &cchReaderGroups ); + return (mySCardListReaderGroupsA)(hcontext, (LPTSTR)pmszReaderGroups->ac, &cchReaderGroups); #endif // !NOAUTOALLOCATE }; @@ -688,14 +693,14 @@ dwShareMode, dwPreferredProtocols, dwInitialization, - pdwActiveProtocol ); + pdwActiveProtocol); } /////////////////////////////////////////////////////////////////////////////// -static SCARDRETCODE _ReleaseContext( SCARDCONTEXT hcontext ) +static SCARDRETCODE _ReleaseContext(SCARDCONTEXT hcontext) { SCARDRETCODE lRet; - lRet = (mySCardReleaseContext)( hcontext ); + lRet = (mySCardReleaseContext)(hcontext); return lRet; } @@ -715,7 +720,7 @@ for(;;) { pbl->ab = (unsigned char*)mem_Malloc(dwAtrLen*sizeof(unsigned char)); - if( pbl->ab == NULL ) + if (pbl->ab == NULL) { lRetCode=SCARD_E_NO_MEMORY; break; @@ -723,7 +728,7 @@ pbl->cBytes = dwAtrLen; pszReaderName->sz = mem_Malloc(dwReaderLen*sizeof(char)); pszReaderName->hcontext = 0; - if( NULL == pszReaderName->sz ) + if (NULL == pszReaderName->sz) { lRetCode=SCARD_E_NO_MEMORY; break; @@ -735,7 +740,7 @@ pdwState, pdwProtocol, pbl->ab, - &pbl->cBytes ); + &pbl->cBytes); break; } @@ -782,19 +787,19 @@ pblSendBuffer->cBytes, NULL, pblRecvBuffer->ab, - &pblRecvBuffer->cBytes ); + &pblRecvBuffer->cBytes); return ret; } /////////////////////////////////////////////////////////////////////////////// -static long _SCARD_CTL_CODE( long code ) +static long _SCARD_CTL_CODE(long code) { return SCARD_CTL_CODE(code); } /////////////////////////////////////////////////////////////////////////////// -static ERRORSTRING* _GetErrorMessage( long lErrCode ) +static ERRORSTRING* _GetErrorMessage(long lErrCode) { #ifdef WIN32 #define _NO_SERVICE_MSG "The Smart card resource manager is not running." @@ -806,20 +811,20 @@ FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_MAX_WIDTH_MASK, NULL, lErrCode, - MAKELANGID( LANG_NEUTRAL, SUBLANG_DEFAULT ), + MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPTSTR)&ppszError, 0, - NULL ); + NULL); - if( 0L==dwRetCode ) + if (0L==dwRetCode) { ppszError=NULL; - if( SCARD_E_NO_SERVICE==lErrCode ) + if (SCARD_E_NO_SERVICE==lErrCode) { - ppszError=(LPVOID)LocalAlloc( LPTR, sizeof( _NO_SERVICE_MSG )+1 ); - if(NULL!=ppszError) + ppszError=(LPVOID)LocalAlloc(LPTR, sizeof(_NO_SERVICE_MSG)+1); + if (NULL!=ppszError) { - strncpy( ppszError, _NO_SERVICE_MSG, sizeof( _NO_SERVICE_MSG )+1 ); + strncpy(ppszError, _NO_SERVICE_MSG, sizeof(_NO_SERVICE_MSG)+1); } } } @@ -827,7 +832,7 @@ return ppszError; #endif // WIN32 #ifdef PCSCLITE - return (ERRORSTRING*)myPcscStringifyError( lErrCode ); + return (ERRORSTRING*)myPcscStringifyError(lErrCode); #endif // PCSCLITE } @@ -907,11 +912,11 @@ newgroup = 'SCard$MyOwnGroup' reader = 'SchlumbergerSema Reflex USB v.2 0' readeralias = 'SchlumbergerSema Reflex USB v.2 0 alias' - hresult = SCardIntroduceReader( hcontext, readeralias, reader] ) - if hresult!=0: + hresult = SCardIntroduceReader(hcontext, readeralias, reader]) + if hresult != SCARD_S_SUCCESS: raise error, 'Unable to introduce reader: ' + SCardGetErrorMessage(hresult) - hresult = SCardAddReaderToGroup( hcontext, readeralias, newgroup ) + hresult = SCardAddReaderToGroup(hcontext, readeralias, newgroup) if hresult!=0: raise error, 'Unable to add reader to group: ' + SCardGetErrorMessage(hresult) @@ -922,11 +927,11 @@ %rename(SCardAddReaderToGroup) _AddReaderToGroup( SCARDCONTEXT hcontext, char* szReaderName, - char* szGroupName ); + char* szGroupName); SCARDRETCODE _AddReaderToGroup( SCARDCONTEXT hcontext, char* szReaderName, - char* szGroupName ); + char* szGroupName); /////////////////////////////////////////////////////////////////////////////// %define DOCSTRING_FORGETCARDTYPE @@ -937,16 +942,16 @@ from smartcard.scard import * ... establish context ... -hresult = SCardForgetCardType( hcontext, 'myCardName' ) -if hresult!=SCARD_S_SUCCESS: +hresult = SCardForgetCardType(hcontext, 'myCardName') +if hresult != SCARD_S_SUCCESS: raise error, 'Failed to remove card type: ' + SCardGetErrorMessage(hresult) ... " %enddef %feature("docstring") DOCSTRING_FORGETCARDTYPE; -%rename(SCardForgetCardType) _ForgetCardType( SCARDCONTEXT hcontext, char* szCardName ); -SCARDRETCODE _ForgetCardType( SCARDCONTEXT hcontext, char* szCardName ); +%rename(SCardForgetCardType) _ForgetCardType(SCARDCONTEXT hcontext, char* szCardName); +SCARDRETCODE _ForgetCardType(SCARDCONTEXT hcontext, char* szCardName); /////////////////////////////////////////////////////////////////////////////// %define DOCSTRING_FORGETREADER @@ -959,15 +964,15 @@ from smartcard.scard import * ... establish context ... ... -hresult = SCardForgetReader( hcontext, dummyreader ) -if hresult!=0: +hresult = SCardForgetReader(hcontext, dummyreader) +if hresult != SCARD_S_SUCCESS: raise error, 'Failed to forget readers ' + SCardGetErrorMessage(hresult) ... " %enddef %feature("docstring") DOCSTRING_FORGETREADER; -%rename(SCardForgetReader) _ForgetReader( SCARDCONTEXT hcontext, char* szReaderName ); -SCARDRETCODE _ForgetReader( SCARDCONTEXT hcontext, char* szReaderName ); +%rename(SCardForgetReader) _ForgetReader(SCARDCONTEXT hcontext, char* szReaderName); +SCARDRETCODE _ForgetReader(SCARDCONTEXT hcontext, char* szReaderName); /////////////////////////////////////////////////////////////////////////////// %define DOCSTRING_FORGETREADERGROUP @@ -982,35 +987,35 @@ from smartcard.scard import * ... establish context ... ... -hresult = SCardForgetReaderGroup( hcontext, newgroup ) -if hresult!=0: +hresult = SCardForgetReaderGroup(hcontext, newgroup) +if hresult != SCARD_S_SUCCESS: raise error, 'Unable to forget reader group: ' + SCardGetErrorMessage(hresult) ... " %enddef %feature("docstring") DOCSTRING_FORGETREADERGROUP; -%rename(SCardForgetReaderGroup) _ForgetReaderGroup( SCARDCONTEXT hcontext, char* szGroupName ); -SCARDRETCODE _ForgetReaderGroup( SCARDCONTEXT hcontext, char* szGroupName ); +%rename(SCardForgetReaderGroup) _ForgetReaderGroup(SCARDCONTEXT hcontext, char* szGroupName); +SCARDRETCODE _ForgetReaderGroup(SCARDCONTEXT hcontext, char* szGroupName); /////////////////////////////////////////////////////////////////////////////// %define DOCSTRING_GETCARDTYPEPROVIDERNAME " -Returns the name of the module (dynamic link library) containing the provider for a -given card name and provider type. +Returns the name of the module (dynamic link library) containing the +provider for a given card name and provider type. Windows only, not supported by PCSC lite wrapper. from smartcard.scard import * ... establish context ... -hresult, cards = SCardListCards( hcontext, [], [] ) -if hresult!=SCARD_S_SUCCESS: +hresult, cards = SCardListCards(hcontext, [], []) +if hresult != SCARD_S_SUCCESS: raise error, 'Failure to list cards: ' + SCardGetErrorMessage(hresult) for i in cards: - hresult, providername = SCardGetCardTypeProviderName( hcontext, i, SCARD_PROVIDER_PRIMARY ) - if hresult==0: + hresult, providername = SCardGetCardTypeProviderName(hcontext, i, SCARD_PROVIDER_PRIMARY) + if hresult == SCARD_S_SUCCESS: print providername - hresult, providername = SCardGetCardTypeProviderName( hcontext, i, SCARD_PROVIDER_CSP ) - if hresult==0: + hresult, providername = SCardGetCardTypeProviderName(hcontext, i, SCARD_PROVIDER_CSP) + if hresult == SCARD_S_SUCCESS: print providername ... " @@ -1041,15 +1046,15 @@ ... znewcardName = 'dummy-card' znewcardATR = [0x3B, 0x77, 0x94, 0x00, 0x00, 0x82, 0x30, 0x00, 0x13, 0x6C, 0x9F, 0x22] -znewcardMask= [0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF] +znewcardMask = [0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF] znewcardPrimGuid = smartcard.guid.strToGUID('{128F3806-4F70-4ccf-977A-60C390664840}') znewcardSecGuid = smartcard.guid.strToGUID('{EB7F69EA-BA20-47d0-8C50-11CFDEB63BBE}') ... - hresult = SCardIntroduceCardType( hcontext, znewcardName, znewcardPrimGuid, - znewcardPrimGuid + znewcardSecGuid, znewcardATR, znewcardMask ) - if hresult!=0: - raise error, 'Failed to introduce card type: ' + SCardGetErrorMessage(hresult) -if hresult!=SCARD_S_SUCCESS: +hresult = SCardIntroduceCardType(hcontext, znewcardName, + znewcardPrimGuid, znewcardPrimGuid + znewcardSecGuid, + znewcardATR, znewcardMask) + +if hresult != SCARD_S_SUCCESS: raise error, 'Failed to introduce card type: ' + SCardGetErrorMessage(hresult) ... " @@ -1082,15 +1087,15 @@ from smartcard.scard import * ... dummyreader = readers[0] + ' dummy' -hresult = SCardIntroduceReader( hcontext, dummyreader, readers[0] ) -if hresult!=0: +hresult = SCardIntroduceReader(hcontext, dummyreader, readers[0]) +if hresult != SCARD_S_SUCCESS: raise error, 'Unable to introduce reader: ' + dummyreader + ' : ' + SCardGetErrorMessage(hresult) ... " %enddef %feature("docstring") DOCSTRING_INTRODUCEREADER; -%rename(SCardIntroduceReader) _IntroduceReader( SCARDCONTEXT hcontext, char* szReaderName, char* szDeviceName ); -SCARDRETCODE _IntroduceReader( SCARDCONTEXT hcontext, char* szReaderName, char* szDeviceName ); +%rename(SCardIntroduceReader) _IntroduceReader(SCARDCONTEXT hcontext, char* szReaderName, char* szDeviceName); +SCARDRETCODE _IntroduceReader(SCARDCONTEXT hcontext, char* szReaderName, char* szDeviceName); /////////////////////////////////////////////////////////////////////////////// %define DOCSTRING_INTRODUCEREADERGROUP @@ -1102,18 +1107,18 @@ Windows only, not supported by PCSC lite wrapper. from smartcard.scard import * -hresult, hcontext = SCardEstablishContext( SCARD_SCOPE_USER ) -hresult = SCardIntroduceReaderGroup( hcontext, 'SCard$MyOwnGroup' ) -if hresult!=SCARD_S_SUCCESS: +hresult, hcontext = SCardEstablishContext(SCARD_SCOPE_USER) +hresult = SCardIntroduceReaderGroup(hcontext, 'SCard$MyOwnGroup') +if hresult != SCARD_S_SUCCESS: raise error, 'Unable to introduce reader group: ' + SCardGetErrorMessage(hresult) -hresult = SCardAddReaderToGroup( hcontext, 'SchlumbergerSema Reflex USB v.2 0', 'SCard$MyOwnGroup' ) -if hresult!=SCARD_S_SUCCESS: +hresult = SCardAddReaderToGroup(hcontext, 'SchlumbergerSema Reflex USB v.2 0', 'SCard$MyOwnGroup') +if hresult != SCARD_S_SUCCESS: raise error, 'Unable to add reader to group: ' + SCardGetErrorMessage(hresult) " %enddef %feature("docstring") DOCSTRING_INTRODUCEREADERGROUP; -%rename(SCardIntroduceReaderGroup) _IntroduceReaderGroup( SCARDCONTEXT hcontext, char* szGroupName ); -SCARDRETCODE _IntroduceReaderGroup( SCARDCONTEXT hcontext, char* szGroupName ); +%rename(SCardIntroduceReaderGroup) _IntroduceReaderGroup(SCARDCONTEXT hcontext, char* szGroupName); +SCARDRETCODE _IntroduceReaderGroup(SCARDCONTEXT hcontext, char* szGroupName); /////////////////////////////////////////////////////////////////////////////// %define DOCSTRING_LISTINTERFACES @@ -1125,16 +1130,16 @@ Windows only, not supported by PCSC lite wrapper. from smartcard.scard import * -hresult, hcontext = SCardEstablishContext( SCARD_SCOPE_USER ) -hresult, interfaces = SCardListInterfaces( hcontext, 'Schlumberger Cryptoflex 8k v2' ) -if hresult!=SCARD_S_SUCCESS: +hresult, hcontext = SCardEstablishContext(SCARD_SCOPE_USER) +hresult, interfaces = SCardListInterfaces(hcontext, 'Schlumberger Cryptoflex 8k v2') +if hresult != SCARD_S_SUCCESS: raise error, 'Failed to list interfaces: ' + SCardGetErrorMessage(hresult) ... " %enddef %feature("docstring") DOCSTRING_LISTINTERFACES; -%rename(SCardListInterfaces) _ListInterfaces( SCARDCONTEXT hcontext, char* szCardName, GUIDLIST* GUIDINTERFACES ); -SCARDRETCODE _ListInterfaces( SCARDCONTEXT hcontext, char* szCardName, GUIDLIST* GUIDINTERFACES ); +%rename(SCardListInterfaces) _ListInterfaces(SCARDCONTEXT hcontext, char* szCardName, GUIDLIST* GUIDINTERFACES); +SCARDRETCODE _ListInterfaces(SCARDCONTEXT hcontext, char* szCardName, GUIDLIST* GUIDINTERFACES); /////////////////////////////////////////////////////////////////////////////// %define DOCSTRING_LISTCARDS @@ -1150,11 +1155,11 @@ from smartcard.scard import * ... slbCryptoFlex8kv2ATR = [ 0x3B, 0x95, 0x15, 0x40, 0x00, 0x68, 0x01, 0x02, 0x00, 0x00 ] -hresult, card = SCardListCards( hcontext, slbCryptoFlex8kv2ATR, [] ) -if hresult!=SCARD_S_SUCCESS: +hresult, card = SCardListCards(hcontext, slbCryptoFlex8kv2ATR, []) +if hresult ! =SCARD_S_SUCCESS: raise error, 'Failure to locate Schlumberger Cryptoflex 8k v2 card: ' + SCardGetErrorMessage(hresult) -hresult, cards = SCardListCards( hcontext, [], [] ) -if hresult!=SCARD_S_SUCCESS: +hresult, cards = SCardListCards(hcontext, [], []) +if hresult != SCARD_S_SUCCESS: raise error, 'Failure to list cards: ' + SCardGetErrorMessage(hresult) print 'Cards: ', cards ... @@ -1165,12 +1170,12 @@ SCARDCONTEXT hcontext, BYTELIST* ATR, GUIDLIST* PROVIDERLIST, - STRINGLIST* MATCHINGCARDS ); + STRINGLIST* MATCHINGCARDS); SCARDRETCODE _ListCards( SCARDCONTEXT hcontext, BYTELIST* ATR, GUIDLIST* PROVIDERLIST, - STRINGLIST* MATCHINGCARDS ); + STRINGLIST* MATCHINGCARDS); /////////////////////////////////////////////////////////////////////////////// %define DOCSTRING_LOCATECARDS @@ -1182,13 +1187,13 @@ Windows only, not supported by PCSC lite wrapper. from smartcard.scard import * -hresult, hcontext = SCardEstablishContext( SCARD_SCOPE_USER ) -hresult, readers = SCardListReaders( hcontext, [] ) +hresult, hcontext = SCardEstablishContext(SCARD_SCOPE_USER) +hresult, readers = SCardListReaders(hcontext, []) readerstates = [] -cards = [ 'Schlumberger Cryptoflex 4k', 'Schlumberger Cryptoflex 8k', 'Schlumberger Cryptoflex 8k v2' ] +cards = ['Schlumberger Cryptoflex 4k', 'Schlumberger Cryptoflex 8k', 'Schlumberger Cryptoflex 8k v2'] for i in xrange(len(readers)): - readerstates += [ (readers[i], SCARD_STATE_UNAWARE ) ] -hresult, newstates = SCardLocateCards( hcontext, cards, readerstates ) + readerstates += [(readers[i], SCARD_STATE_UNAWARE)] +hresult, newstates = SCardLocateCards(hcontext, cards, readerstates) for i in newstates: reader, eventstate, atr = i print reader, @@ -1208,11 +1213,11 @@ %rename(SCardLocateCards) _LocateCards( SCARDCONTEXT hcontext, STRINGLIST* CARDSTOLOCATE, - READERSTATELIST *prsl ); + READERSTATELIST *prsl); SCARDRETCODE _LocateCards( SCARDCONTEXT hcontext, STRINGLIST* CARDSTOLOCATE, - READERSTATELIST *prsl ); + READERSTATELIST *prsl); /////////////////////////////////////////////////////////////////////////////// %define DOCSTRING_REMOVEREADERFROMGROUP @@ -1224,9 +1229,9 @@ Windows only, not supported by PCSC lite wrapper. from smartcard.scard import * -hresult, hcontext = SCardEstablishContext( SCARD_SCOPE_USER ) -hresult = SCardRemoveReaderFromGroup( hcontext, 'SchlumbergerSema Reflex USB v.2 0', 'SCard$MyOwnGroup' ) -if hresult!=SCARD_S_SUCCESS: +hresult, hcontext = SCardEstablishContext(SCARD_SCOPE_USER) +hresult = SCardRemoveReaderFromGroup(hcontext, 'SchlumbergerSema Reflex USB v.2 0', 'SCard$MyOwnGroup') +if hresult != SCARD_S_SUCCESS: raise error, 'Unable to remove reader from group: ' + SCardGetErrorMessage(hresult) ... " @@ -1235,11 +1240,11 @@ %rename(SCardRemoveReaderFromGroup) _RemoveReaderFromGroup( SCARDCONTEXT hcontext, char* szReaderName, - char* szGroupName ); + char* szGroupName); SCARDRETCODE _RemoveReaderFromGroup( SCARDCONTEXT hcontext, char* szReaderName, - char* szGroupName ); + char* szGroupName); #endif // WIN32 @@ -1259,16 +1264,16 @@ service has been shut down. from smartcard.scard import * - hresult, hcontext = SCardEstablishContext( SCARD_SCOPE_USER ) - hresult = SCardIsValidContext( hcontext ) - if hresult!=SCARD_S_SUCCESS: + hresult, hcontext = SCardEstablishContext(SCARD_SCOPE_USER) + hresult = SCardIsValidContext(hcontext) + if hresult != SCARD_S_SUCCESS: raise error, 'Invalid context: ' + SCardGetErrorMessage(hresult) ... " %enddef %feature("docstring") DOCSTRING_ISVALIDCONTEXT; - %rename(SCardIsValidContext) _IsValidContext( SCARDCONTEXT hcontext ); - SCARDRETCODE _IsValidContext( SCARDCONTEXT hcontext ); + %rename(SCardIsValidContext) _IsValidContext(SCARDCONTEXT hcontext); + SCARDRETCODE _IsValidContext(SCARDCONTEXT hcontext); /////////////////////////////////////////////////////////////////////////////// %define DOCSTRING_GETATTRIB @@ -1375,23 +1380,24 @@ from smartcard.scard import * ... establish context and connect to card ... - hresult, attrib = SCardGetAttrib( hcard, SCARD_ATTR_ATR_STRING ) - if hresult==SCARD_S_SUCCESS: + hresult, attrib = SCardGetAttrib(hcard, SCARD_ATTR_ATR_STRING) + if hresult == SCARD_S_SUCCESS: for j in attrib: print '0x%.2X' % attrib, ... " %enddef %feature("docstring") DOCSTRING_GETATTRIB; - %rename(SCardGetAttrib) _GetAttrib( SCARDHANDLE hcard, SCARDDWORDARG dwAttrId, BYTELIST* ATTRIBUTES ); - SCARDRETCODE _GetAttrib( SCARDHANDLE hcard, SCARDDWORDARG dwAttrId, BYTELIST* ATTRIBUTES ); + %rename(SCardGetAttrib) _GetAttrib(SCARDHANDLE hcard, SCARDDWORDARG dwAttrId, BYTELIST* ATTRIBUTES); + SCARDRETCODE _GetAttrib(SCARDHANDLE hcard, SCARDDWORDARG dwAttrId, BYTELIST* ATTRIBUTES); /////////////////////////////////////////////////////////////////////////////// %define DOCSTRING_SETATTRIB " - This function sets an attribute from the IFD Handler. Not all attributes are supported by all readers nor can - they be set at all times. + This function sets an attribute from the IFD Handler. Not all + attributes are supported by all readers nor can they be set at all + times. For PCSC lite, the list of possible attributes is: @@ -1492,15 +1498,15 @@ from smartcard.scard import * ... establish context and connect to card ... - hresult, attrib = SCardSetAttrib( hcard, SCARD_ATTR_VENDOR_NAME, ['G', 'e', 'm', 'a', 'l', 't', 'o'] ) - if hresult!=SCARD_S_SUCCESS: + hresult, attrib = SCardSetAttrib(hcard, SCARD_ATTR_VENDOR_NAME, ['G', 'e', 'm', 'a', 'l', 't', 'o']) + if hresult != SCARD_S_SUCCESS: print 'Failed to set attribute' ... " %enddef %feature("docstring") DOCSTRING_SETATTRIB; - %rename(SCardSetAttrib) _SetAttrib( SCARDHANDLE hcard, SCARDDWORDARG dwAttrId, BYTELIST* ATTRIBUTESIN ); - SCARDRETCODE _SetAttrib( SCARDHANDLE hcard, SCARDDWORDARG dwAttrId, BYTELIST* ATTRIBUTESIN ); + %rename(SCardSetAttrib) _SetAttrib(SCARDHANDLE hcard, SCARDDWORDARG dwAttrId, BYTELIST* ATTRIBUTESIN); + SCARDRETCODE _SetAttrib(SCARDHANDLE hcard, SCARDDWORDARG dwAttrId, BYTELIST* ATTRIBUTESIN); #endif // !__TIGER__ @@ -1512,16 +1518,16 @@ /////////////////////////////////////////////////////////////////////////////// %define DOCSTRING_CONTROL " - This function sends a control command to the reader connected to by SCardConnect(). - It returns a result and the control response. + This function sends a control command to the reader connected to by + SCardConnect(). It returns a result and the control response. from smartcard.scard import * - hresult, hcontext = SCardEstablishContext( SCARD_SCOPE_USER ) + hresult, hcontext = SCardEstablishContext(SCARD_SCOPE_USER) hresult, hcard, dwActiveProtocol = SCardConnect( - hcontext, 'SchlumbergerSema Reflex USB v.2 0', SCARD_SHARE_SHARED, SCARD_PROTOCOL_T0 ) + hcontext, 'SchlumbergerSema Reflex USB v.2 0', SCARD_SHARE_SHARED, SCARD_PROTOCOL_T0) CMD = [ 42, 0x12, 0x34] - hresult, response = SCardControl( hcard, CMD ) - if hresult!=SCARD_S_SUCCESS: + hresult, response = SCardControl(hcard, CMD) + if hresult != SCARD_S_SUCCESS: raise error, 'Failed to control: ' + SCardGetErrorMessage(hresult) " %enddef @@ -1530,27 +1536,27 @@ SCARDHANDLE hcard, BYTELIST* INBUFFER, BYTELIST* OUTBUFFER - ); + ); SCARDRETCODE _Control( SCARDHANDLE hcard, BYTELIST* INBUFFER, BYTELIST* OUTBUFFER - ); + ); #else // !__TIGER__ /////////////////////////////////////////////////////////////////////////////// %define DOCSTRING_CONTROL " - This function sends a control command to the reader connected to by SCardConnect(). - It returns a result and the control response. + This function sends a control command to the reader connected to by + SCardConnect(). It returns a result and the control response. from smartcard.scard import * - hresult, hcontext = SCardEstablishContext( SCARD_SCOPE_USER ) + hresult, hcontext = SCardEstablishContext(SCARD_SCOPE_USER) hresult, hcard, dwActiveProtocol = SCardConnect( - hcontext, 'SchlumbergerSema Reflex USB v.2 0', SCARD_SHARE_SHARED, SCARD_PROTOCOL_T0 ) + hcontext, 'SchlumbergerSema Reflex USB v.2 0', SCARD_SHARE_SHARED, SCARD_PROTOCOL_T0) CMD = [0x12, 0x34] - hresult, response = SCardControl( hcard, 42, CMD ) - if hresult!=SCARD_S_SUCCESS: + hresult, response = SCardControl(hcard, 42, CMD) + if hresult != SCARD_S_SUCCESS: raise error, 'Failed to control: ' + SCardGetErrorMessage(hresult) " %enddef @@ -1560,13 +1566,13 @@ SCARDDWORDARG dwControlCode, BYTELIST* INBUFFER, BYTELIST* OUTBUFFER - ); + ); SCARDRETCODE _Control( SCARDHANDLE hcard, SCARDDWORDARG dwControlCode, BYTELIST* INBUFFER, BYTELIST* OUTBUFFER - ); + ); #endif // __TIGER__ @@ -1583,34 +1589,35 @@ from smartcard.scard import * ... establish context ... hresult, hcard, dwActiveProtocol = SCardConnect( - hcontext, 'SchlumbergerSema Reflex USB v.2 0', SCARD_SHARE_SHARED, SCARD_PROTOCOL_T0 ) + hcontext, 'SchlumbergerSema Reflex USB v.2 0', SCARD_SHARE_SHARED, SCARD_PROTOCOL_T0) if hresult!=SCARD_S_SUCCESS: raise error, 'unable to connect: ' + SCardGetErrorMessage(hresult) -hresult = SCardBeginTransaction( hcard ) -if hresult!=SCARD_S_SUCCESS: +hresult = SCardBeginTransaction(hcard) +if hresult != SCARD_S_SUCCESS: raise error, 'failed to begin transaction: ' + SCardGetErrorMessage(hresult) ... " %enddef %feature("docstring") DOCSTRING_BEGINTRANSACTION; -%rename(SCardBeginTransaction) _BeginTransaction( SCARDHANDLE hcard ); -SCARDRETCODE _BeginTransaction( SCARDHANDLE hcard ); +%rename(SCardBeginTransaction) _BeginTransaction(SCARDHANDLE hcard); +SCARDRETCODE _BeginTransaction(SCARDHANDLE hcard); /////////////////////////////////////////////////////////////////////////////// %define DOCSTRING_CANCEL " -This function cancels all pending blocking requests on the ScardGetStatusChange() function. +This function cancels all pending blocking requests on the +ScardGetStatusChange() function. from smartcard.scard import * ... establish context ... -hresult = SCardCancel( hcard ) -if hresult!=SCARD_S_SUCCESS: +hresult = SCardCancel(hcard) +if hresult != SCARD_S_SUCCESS: raise error, 'failed to cancel pending actions: ' + SCardGetErrorMessage(hresult) ..." %enddef %feature("docstring") DOCSTRING_CANCEL; -%rename(SCardCancel) _Cancel( SCARDCONTEXT hcontext ); -SCARDRETCODE _Cancel( SCARDCONTEXT hcontext ); +%rename(SCardCancel) _Cancel(SCARDCONTEXT hcontext); +SCARDRETCODE _Cancel(SCARDCONTEXT hcontext); /////////////////////////////////////////////////////////////////////////////// %define DOCSTRING_CONNECT @@ -1634,12 +1641,12 @@ from smartcard.scard import * ... establish context ... -hresult, readers = SCardListReaders( hcontext, 'NULL' ) -if hresult!=SCARD_S_SUCCESS: +hresult, readers = SCardListReaders(hcontext, 'NULL') +if hresult != SCARD_S_SUCCESS: raise error, 'Failed to list readers:: ' + SCardGetErrorMessage(hresult) hresult, hcard, dwActiveProtocol = SCardConnect( - hcontext, readers[0], SCARD_SHARE_SHARED, SCARD_PROTOCOL_T0 ) -if hresult!=SCARD_S_SUCCESS: + hcontext, readers[0], SCARD_SHARE_SHARED, SCARD_PROTOCOL_T0) +if hresult != SCARD_S_SUCCESS: raise error, 'unable to connect: ' + SCardGetErrorMessage(hresult) ... " @@ -1676,15 +1683,15 @@ from smartcard.scard import * ... establish context and connect to card ... -hresult = SCardDisconnect( hcard, SCARD_UNPOWER_CARD ) -if hresult!=SCARD_S_SUCCESS: +hresult = SCardDisconnect(hcard, SCARD_UNPOWER_CARD) +if hresult != SCARD_S_SUCCESS: raise error, 'failed to disconnect: ' + SCardGetErrorMessage(hresult) ... " %enddef %feature("docstring") DOCSTRING_DISCONNECT; -%rename(SCardDisconnect) _Disconnect( SCARDHANDLE hcard, SCARDDWORDARG dwDisposition ); -SCARDRETCODE _Disconnect( SCARDHANDLE hcard, SCARDDWORDARG dwDisposition ); +%rename(SCardDisconnect) _Disconnect(SCARDHANDLE hcard, SCARDDWORDARG dwDisposition); +SCARDRETCODE _Disconnect(SCARDHANDLE hcard, SCARDDWORDARG dwDisposition); /////////////////////////////////////////////////////////////////////////////// %define DOCSTRING_ENDTRANSACTION @@ -1703,14 +1710,14 @@ from smartcard.scard import * ... establish context, connect to card, begin transaction ... -hresult = SCardEndTransaction( hcard, SCARD_LEAVE_CARD ) -if hresult!=SCARD_S_SUCCESS: +hresult = SCardEndTransaction(hcard, SCARD_LEAVE_CARD) +if hresult != SCARD_S_SUCCESS: raise error, 'failed to end transaction: ' + SCardGetErrorMessage(hresult) " %enddef %feature("docstring") DOCSTRING_ENDTRANSACTION; -%rename(SCardEndTransaction) _EndTransaction( SCARDHANDLE hcard, SCARDDWORDARG dwDisposition ); -SCARDRETCODE _EndTransaction( SCARDHANDLE hcard, SCARDDWORDARG dwDisposition ); +%rename(SCardEndTransaction) _EndTransaction(SCARDHANDLE hcard, SCARDDWORDARG dwDisposition); +SCARDRETCODE _EndTransaction(SCARDHANDLE hcard, SCARDDWORDARG dwDisposition); /////////////////////////////////////////////////////////////////////////////// %define DOCSTRING_ESTABLISHCONTEXT @@ -1726,14 +1733,14 @@ from smartcard.scard import * -hresult, hcontext = SCardEstablishContext( SCARD_SCOPE_USER ) -if hresult!=SCARD_S_SUCCESS: +hresult, hcontext = SCardEstablishContext(SCARD_SCOPE_USER) +if hresult != SCARD_S_SUCCESS: raise error, 'Failed to establish context: ' + SCardGetErrorMessage(hresult) " %enddef %feature("docstring") DOCSTRING_ESTABLISHCONTEXT; -%rename(SCardEstablishContext) _EstablishContext( SCARDDWORDARG dwScope, SCARDCONTEXT* phcontext ); -SCARDRETCODE _EstablishContext( SCARDDWORDARG dwScope, SCARDCONTEXT* phcontext ); +%rename(SCardEstablishContext) _EstablishContext(SCARDDWORDARG dwScope, SCARDCONTEXT* phcontext); +SCARDRETCODE _EstablishContext(SCARDDWORDARG dwScope, SCARDCONTEXT* phcontext); /////////////////////////////////////////////////////////////////////////////// @@ -1741,7 +1748,7 @@ " This function receives a structure or list of tuples containing reader -states. A READERSTATE hast three fields ( readername, state, atr ). +states. A READERSTATE hast three fields (readername, state, atr). It then blocks for a change in state to occur on any of the OR'd values contained in the current state for a maximum blocking time of dwTimeout or forever if INFINITE is used. The new event state will be @@ -1763,15 +1770,15 @@ from smartcard.scard import * -hresult, hcontext = SCardEstablishContext( SCARD_SCOPE_USER ) -hresult, readers = SCardListReaders( hcontext, [] ) +hresult, hcontext = SCardEstablishContext(SCARD_SCOPE_USER) +hresult, readers = SCardListReaders(hcontext, []) readerstates = [] cards = [ 'Schlumberger Cryptoflex 4k', 'Schlumberger Cryptoflex 8k', 'Schlumberger Cryptoflex 8k v2' ] for i in xrange(len(readers)): - readerstates += [ (readers[i], SCARD_STATE_UNAWARE ) ] -hresult, newstates = SCardLocateCards( hcontext, cards, readerstates ) + readerstates += [ (readers[i], SCARD_STATE_UNAWARE) ] +hresult, newstates = SCardLocateCards(hcontext, cards, readerstates) print '----- Please insert or remove a card ------------' -hresult, newstates = SCardGetStatusChange( hcontext, INFINITE, newstates ) +hresult, newstates = SCardGetStatusChange(hcontext, INFINITE, newstates) for i in newstates reader, eventstate, atr = i if eventstate & SCARD_STATE_ATRMATCH: @@ -1794,15 +1801,16 @@ %define DOCSTRING_LISTREADERS " This function returns a list of currently available readers on the system. -A list of group can be provided in input to list readers in a given group only. +A list of group can be provided in input to list readers in a given +group only. from smartcard.scard import * -hresult, hcontext = SCardEstablishContext( SCARD_SCOPE_USER ) -hresult, readers = SCardListReaders( hcontext, [] ) -if hresult!=SCARD_S_SUCCESS: +hresult, hcontext = SCardEstablishContext(SCARD_SCOPE_USER) +hresult, readers = SCardListReaders(hcontext, []) +if hresult != SCARD_S_SUCCESS: raise error, 'Failed to list readers: ' + SCardGetErrorMessage(hresult) print 'PCSC Readers: ', readers -hresult, readers = SCardListReaders( hcontext, ['SCard$T1ProtocolReaders', 'SCard$MyOwnGroup'] +hresult, readers = SCardListReaders(hcontext, ['SCard$T1ProtocolReaders', 'SCard$MyOwnGroup'] ... " %enddef @@ -1810,29 +1818,30 @@ %rename(SCardListReaders) _ListReaders( SCARDCONTEXT hcontext, STRINGLIST* READERGROUPSIN, - STRINGLIST* READERSFOUND ); + STRINGLIST* READERSFOUND); SCARDRETCODE _ListReaders( SCARDCONTEXT hcontext, STRINGLIST* READERGROUPSIN, - STRINGLIST* READERSFOUND ); + STRINGLIST* READERSFOUND); /////////////////////////////////////////////////////////////////////////////// %define DOCSTRING_LISTREADERGROUPS " -This function returns a list of currently available reader groups on the system. +This function returns a list of currently available reader groups on the +system. from smartcard.scard import * -hresult, hcontext = SCardEstablishContext( SCARD_SCOPE_USER ) -hresult, readerGroups = SCardListReaderGroups( hcontext ) -if hresult!=SCARD_S_SUCCESS: +hresult, hcontext = SCardEstablishContext(SCARD_SCOPE_USER) +hresult, readerGroups = SCardListReaderGroups(hcontext) +if hresult != SCARD_S_SUCCESS: raise error, 'Unable to list reader groups: ' + SCardGetErrorMessage(hresult) print 'PCSC Reader groups: ', readerGroups " %enddef %feature("docstring") DOCSTRING_LISTREADERGROUPS; -%rename(SCardListReaderGroups) _ListReaderGroups( SCARDCONTEXT hcontext, STRINGLIST* READERGROUPSOUT ); -SCARDRETCODE _ListReaderGroups( SCARDCONTEXT hcontext, STRINGLIST* READERGROUPSOUT ); +%rename(SCardListReaderGroups) _ListReaderGroups(SCARDCONTEXT hcontext, STRINGLIST* READERGROUPSOUT); +SCARDRETCODE _ListReaderGroups(SCARDCONTEXT hcontext, STRINGLIST* READERGROUPSOUT); /////////////////////////////////////////////////////////////////////////////// %define DOCSTRING_RECONNECT @@ -1865,11 +1874,11 @@ from smartcard.scard import * -hresult, hcontext = SCardEstablishContext( SCARD_SCOPE_USER ) +hresult, hcontext = SCardEstablishContext(SCARD_SCOPE_USER) hresult, hcard, dwActiveProtocol = SCardConnect( - hcontext, 'SchlumbergerSema Reflex USB v.2 0', SCARD_SHARE_SHARED, SCARD_PROTOCOL_T0 ) -hresult, activeProtocol = SCardReconnect( hcard, SCARD_SHARE_EXCLUSIVE, - SCARD_PROTOCOL_T0, SCARD_RESET_CARD ) + hcontext, 'SchlumbergerSema Reflex USB v.2 0', SCARD_SHARE_SHARED, SCARD_PROTOCOL_T0) +hresult, activeProtocol = SCardReconnect(hcard, SCARD_SHARE_EXCLUSIVE, + SCARD_PROTOCOL_T0, SCARD_RESET_CARD) ... " %enddef @@ -1895,8 +1904,8 @@ " %enddef %feature("docstring") DOCSTRING_RELEASECONTEXT; -%rename(SCardReleaseContext) _ReleaseContext( SCARDCONTEXT hcontext ); -SCARDRETCODE _ReleaseContext( SCARDCONTEXT hcontext ); +%rename(SCardReleaseContext) _ReleaseContext(SCARDCONTEXT hcontext); +SCARDRETCODE _ReleaseContext(SCARDCONTEXT hcontext); /////////////////////////////////////////////////////////////////////////////// %define DOCSTRING_STATUS @@ -1920,11 +1929,11 @@ from smartcard.scard import * -hresult, hcontext = SCardEstablishContext( SCARD_SCOPE_USER ) +hresult, hcontext = SCardEstablishContext(SCARD_SCOPE_USER) hresult, hcard, dwActiveProtocol = SCardConnect( - hcontext, 'SchlumbergerSema Reflex USB v.2 0', SCARD_SHARE_SHARED, SCARD_PROTOCOL_T0 ) -hresult, reader, state, protocol, atr = SCardStatus( hcard ) -if hresult!=SCARD_S_SUCCESS: + hcontext, 'SchlumbergerSema Reflex USB v.2 0', SCARD_SHARE_SHARED, SCARD_PROTOCOL_T0) +hresult, reader, state, protocol, atr = SCardStatus(hcard) +if hresult != SCARD_S_SUCCESS: raise error, 'failed to get status: ' + SCardGetErrorMessage(hresult) print 'Reader: ', reader print 'State: ', state @@ -1955,7 +1964,8 @@ /////////////////////////////////////////////////////////////////////////////// %define DOCSTRING_TRANSMIT " -This function sends an APDU to the smart card contained in the reader connected to by SCardConnect(). +This function sends an APDU to the smart card contained in the reader +connected to by SCardConnect(). It returns a result and the card APDU response. Value of pioSendPci Meaning @@ -1964,13 +1974,13 @@ from smartcard.scard import * -hresult, hcontext = SCardEstablishContext( SCARD_SCOPE_USER ) +hresult, hcontext = SCardEstablishContext(SCARD_SCOPE_USER) hresult, hcard, dwActiveProtocol = SCardConnect( - hcontext, 'SchlumbergerSema Reflex USB v.2 0', SCARD_SHARE_SHARED, SCARD_PROTOCOL_T0 ) + hcontext, 'SchlumbergerSema Reflex USB v.2 0', SCARD_SHARE_SHARED, SCARD_PROTOCOL_T0) SELECT = [0xA0, 0xA4, 0x00, 0x00, 0x02] DF_TELECOM = [0x7F, 0x10] -hresult, response = SCardTransmit( hcard, SCARD_PCI_T0, SELECT + DF_TELECOM ) -if hresult!=SCARD_S_SUCCESS: +hresult, response = SCardTransmit(hcard, SCARD_PCI_T0, SELECT + DF_TELECOM) +if hresult != SCARD_S_SUCCESS: raise error, 'Failed to transmit: ' + SCardGetErrorMessage(hresult) " %enddef @@ -2000,8 +2010,8 @@ " %enddef %feature("docstring") DOCSTRING_SCARD_CTL_CODE; -%rename(SCARD_CTL_CODE) _SCARD_CTL_CODE( long code ); -long _SCARD_CTL_CODE( long code ); +%rename(SCARD_CTL_CODE) _SCARD_CTL_CODE(long code); +long _SCARD_CTL_CODE(long code); /////////////////////////////////////////////////////////////////////////////// %define DOCSTRING_GETERRORMESSAGE @@ -2010,15 +2020,15 @@ from smartcard.scard import * ... -hresult, response = SCardTransmit( hcard, SCARD_PCI_T0, SELECT + DF_TELECOM ) -if hresult!=SCARD_S_SUCCESS: +hresult, response = SCardTransmit(hcard, SCARD_PCI_T0, SELECT + DF_TELECOM) +if hresult != SCARD_S_SUCCESS: raise error, 'Failed to transmit: ' + SCardGetErrorMessage(hresult) ... " %enddef %feature("docstring") DOCSTRING_GETERRORMESSAGE; -%rename(SCardGetErrorMessage) _GetErrorMessage( long lErrCode ); -ERRORSTRING* _GetErrorMessage( long lErrCode ); +%rename(SCardGetErrorMessage) _GetErrorMessage(long lErrCode); +ERRORSTRING* _GetErrorMessage(long lErrCode); %inline @@ -2055,15 +2065,15 @@ #ifdef PCSCLITEyy %pythoncode %{ -def SCardListCards( hcontext, atr, guidlist ): - return ( SCARD_S_SUCCESS, [] ) +def SCardListCards(hcontext, atr, guidlist): + return (SCARD_S_SUCCESS, []) -def SCardLocateCards( hcontext, cardnames, readerstates ): +def SCardLocateCards(hcontext, cardnames, readerstates): newreaderstates=[] for state in readerstates: - newreaderstates.append( (state[0], state[1], [] ) ) + newreaderstates.append((state[0], state[1], [])) - return ( SCARD_S_SUCCESS, newreaderstates ) + return (SCARD_S_SUCCESS, newreaderstates) %} #endif This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <lu...@us...> - 2010-06-12 22:14:09
|
Revision: 487 http://pyscard.svn.sourceforge.net/pyscard/?rev=487&view=rev Author: ludov Date: 2010-06-12 22:14:03 +0000 (Sat, 12 Jun 2010) Log Message: ----------- better epydoc Modified Paths: -------------- trunk/pyscard/src/smartcard/pcsc/PCSCCardRequest.py trunk/pyscard/src/smartcard/pcsc/PCSCPart10.py Modified: trunk/pyscard/src/smartcard/pcsc/PCSCCardRequest.py =================================================================== --- trunk/pyscard/src/smartcard/pcsc/PCSCCardRequest.py 2010-06-12 22:02:30 UTC (rev 486) +++ trunk/pyscard/src/smartcard/pcsc/PCSCCardRequest.py 2010-06-12 22:14:03 UTC (rev 487) @@ -45,25 +45,23 @@ def __init__(self, newcardonly=False, readers=None, cardType=None, cardServiceClass=None, timeout=1): """Construct new PCSCCardRequest. - newcardonly: if True, request a new card - default is False, i.e. accepts cards already - inserted + @param newcardonly: if True, request a new card default is + False, i.e. accepts cards already inserted - readers: the list of readers to consider for requesting - a card default is to consider all readers + @param readers: the list of readers to consider for requesting a + card default is to consider all readers - cardTypeClass: the CardType class to wait for; default is - AnyCardType, i.e. the request will returns - with new or already inserted cards + @param cardTypeClass: the CardType class to wait for; default is + AnyCardType, i.e. the request will returns with new or already + inserted cards - cardServiceClass: the specific card service class to create and - bind to the card default is to create and - bind a PassThruCardService + @param cardServiceClass: the specific card service class to + create and bind to the card default is to create and bind a + PassThruCardService - timeout: the time in seconds we are ready to wait for - connecting to the requested card. default - is to wait one second to wait forever, set - timeout to None + @param timeout: the time in seconds we are ready to wait for + connecting to the requested card. default is to wait one second + to wait forever, set timeout to None """ AbstractCardRequest.__init__(self, newcardonly, readers, cardType, cardServiceClass, timeout) Modified: trunk/pyscard/src/smartcard/pcsc/PCSCPart10.py =================================================================== --- trunk/pyscard/src/smartcard/pcsc/PCSCPart10.py 2010-06-12 22:02:30 UTC (rev 486) +++ trunk/pyscard/src/smartcard/pcsc/PCSCPart10.py 2010-06-12 22:14:03 UTC (rev 487) @@ -101,9 +101,10 @@ def getFeatureRequest(cardConnection): """ Get the list of Part10 features supported by the reader. - cardConnection: CardConnection object + @param cardConnection: L{CardConnection} object - return: a list of list [[tag1, value1], [tag2, value2]] + @rtype: list + @return: a list of list [[tag1, value1], [tag2, value2]] """ response = cardConnection.control(CM_IOCTL_GET_FEATURE_REQUEST, []) features = [] @@ -121,10 +122,10 @@ def hasFeature(featureList, feature): """ return the controlCode for a feature or None - feature: feature to look for - featureList: feature list as returned by getFeatureRequest() + @param feature: feature to look for + @param featureList: feature list as returned by L{getFeatureRequest()} - return: feature value or None + @return: feature value or None """ for f in featureList: if f[0] == feature or Features[f[0]] == feature: @@ -134,11 +135,12 @@ def getPinProperties(cardConnection, featureList=None, controlCode=None): """ return the PIN_PROPERTIES structure - cardConnection: CardConnection object - featureList: feature list as returned by getFeatureRequest() - controlCode: control code for FEATURE_IFD_PIN_PROPERTIES + @param cardConnection: L{CardConnection} object + @param featureList: feature list as returned by L{getFeatureRequest()} + @param controlCode: control code for L{FEATURE_IFD_PIN_PROPERTIES} - return: a dict """ + @rtype: dict + @return: a dict """ if controlCode is None: if featureList is None: featureList = getFeatureRequest(cardConnection) @@ -161,11 +163,12 @@ def getTlvProperties(cardConnection, featureList=None, controlCode=None): """ return the GET_TLV_PROPERTIES structure - cardConnection: CardConnection object - featureList: feature list as returned by getFeatureRequest() - controlCode: control code for FEATURE_GET_TLV_PROPERTIES + @param cardConnection: L{CardConnection} object + @param featureList: feature list as returned by L{getFeatureRequest()} + @param controlCode: control code for L{FEATURE_GET_TLV_PROPERTIES} - return: a dict """ + @rtype: dict + @return: a dict """ if controlCode is None: if featureList is None: featureList = getFeatureRequest(cardConnection) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <lu...@us...> - 2010-06-12 22:02:36
|
Revision: 486 http://pyscard.svn.sourceforge.net/pyscard/?rev=486&view=rev Author: ludov Date: 2010-06-12 22:02:30 +0000 (Sat, 12 Jun 2010) Log Message: ----------- make pep8 happy Modified Paths: -------------- trunk/pyscard/tools/commands/build-doc.py trunk/pyscard/tools/commands/uninstall.py Modified: trunk/pyscard/tools/commands/build-doc.py =================================================================== --- trunk/pyscard/tools/commands/build-doc.py 2010-06-11 16:33:21 UTC (rev 485) +++ trunk/pyscard/tools/commands/build-doc.py 2010-06-12 22:02:30 UTC (rev 486) @@ -38,82 +38,83 @@ from distutils import dir_util # where the source doc files are located, as well as epydoc configuration file -sourcedocdir = os.path.join( '..', '..', 'src', 'smartcard', 'doc' ) -sourceexampledir = os.path.join( '..', '..', 'src', 'smartcard', 'Examples' ) -configfile = os.path.join( '..', '..', 'src', 'smartcard', 'doc', 'epydoc.cfg' ) +sourcedocdir = os.path.join('..', '..', 'src', 'smartcard', 'doc') +sourceexampledir = os.path.join('..', '..', 'src', 'smartcard', 'Examples') +configfile = os.path.join('..', '..', 'src', 'smartcard', 'doc', 'epydoc.cfg') # this is where the doc is copied and generated with epydoc -targetgenerateddir = os.path.join( '..', '..', 'generated' ) -targetdocdir = os.path.join( targetgenerateddir, 'doc' ) -targetepydocdir = os.path.join( targetdocdir, 'epydoc' ) +targetgenerateddir = os.path.join('..', '..', 'generated') +targetdocdir = os.path.join(targetgenerateddir, 'doc') +targetepydocdir = os.path.join(targetdocdir, 'epydoc') # the smartcard module must be installed to run epydoc -smartcardpackagedir = os.path.join( get_python_lib(), 'smartcard' ) +smartcardpackagedir = os.path.join(get_python_lib(), 'smartcard') # check that we are in the correct directory -assert os.path.exists( sourcedocdir ), "Can't find directory: " + sourcedocdir +assert os.path.exists(sourcedocdir), "Can't find directory: " + sourcedocdir # remove an already existing 'generated' directory -if os.path.isdir( targetgenerateddir ): - shutil.rmtree( targetgenerateddir ) -os.makedirs( targetgenerateddir ) +if os.path.isdir(targetgenerateddir): + shutil.rmtree(targetgenerateddir) +os.makedirs(targetgenerateddir) -# this pattern is searched in html files to include sourceforge logo for pyscard +# this pattern is searched in html files to include sourceforge logo for +# pyscard searchterm = '>pyscard</th>' -placeholder = re.compile( searchterm ) +placeholder = re.compile(searchterm) sourceforgelogo = '<a href="http://sourceforge.net/projects/pyscard"><img src="http://sflogo.sourceforge.net/sflogo.php?group_id=196342&type=11" width="120" height="30" alt="Get pyscard at SourceForge.net. Fast, secure and Free Open Source software downloads" /></a>' # looks for placeholder and insert sourceforge logo if found -def insertSourceForgeLogo( file ): +def insertSourceForgeLogo(file): try: - fileToSearch = open( file, 'r' ) + fileToSearch = open(file, 'r') data = fileToSearch.read() data = data.split('\n') for line in data: - bFound = placeholder.search( line ) - if ( bFound ): + bFound = placeholder.search(line) + if (bFound): break fileToSearch.close() except IOError: print "No such file:", file return if bFound: - fileToReplace = open( file, 'w' ) + fileToReplace = open(file, 'w') for line in data: - fileToReplace.write( line + '\n' ) - if placeholder.search( line ): - fileToReplace.write( sourceforgelogo ) + fileToReplace.write(line + '\n') + if placeholder.search(line): + fileToReplace.write(sourceforgelogo) fileToReplace.close() # build documentation package for pyscard -if os.path.exists( smartcardpackagedir ): - os.makedirs( targetepydocdir ) - sys.argv = [ '--html', '--output', targetepydocdir, '--config=' + configfile ] +if os.path.exists(smartcardpackagedir): + os.makedirs(targetepydocdir) + sys.argv = ['--html', '--output', targetepydocdir, '--config=' + configfile] cli() - dir_util.copy_tree( sourcedocdir, targetdocdir, preserve_mode=0, verbose=1 ) - dir_util.copy_tree( sourceexampledir, os.path.join( targetdocdir, 'Examples' ), preserve_mode=0, verbose=1 ) + dir_util.copy_tree(sourcedocdir, targetdocdir, preserve_mode=0, verbose=1) + dir_util.copy_tree(sourceexampledir, os.path.join(targetdocdir, 'Examples'), preserve_mode=0, verbose=1) # remove subversion directories (*//.svn) - files = os.walk( os.path.join( targetdocdir ) ) + files = os.walk(os.path.join(targetdocdir)) dirstodelete = [] for dirpath, dn, fn in files: - if '.svn' in dirpath[-4:] and dirpath not in dirstodelete: dirstodelete.append( dirpath ) + if '.svn' in dirpath[-4:] and dirpath not in dirstodelete: dirstodelete.append(dirpath) for dir in dirstodelete: - dir_util.remove_tree( dir ) + dir_util.remove_tree(dir) # insert sourceforge pyscard logo in html pages - files = os.walk( os.path.join( targetdocdir ) ) + files = os.walk(os.path.join(targetdocdir)) htmlfiles = [] for dirpath, dn, filenames in files: for filename in filenames: - root, ext = os.path.splitext( filename ) + root, ext = os.path.splitext(filename) if '.html' == ext: - htmlfiles.append( os.path.join( dirpath, filename ) ) + htmlfiles.append(os.path.join(dirpath, filename)) for file in htmlfiles: - insertSourceForgeLogo( file ) + insertSourceForgeLogo(file) else: print "Can't find " + smartcardpackagedir # zip documentation -make_archive( os.path.join( targetgenerateddir, 'pyscard-doc'), 'zip', root_dir=targetgenerateddir, base_dir='doc' ) +make_archive(os.path.join(targetgenerateddir, 'pyscard-doc'), 'zip', root_dir=targetgenerateddir, base_dir='doc') Modified: trunk/pyscard/tools/commands/uninstall.py =================================================================== --- trunk/pyscard/tools/commands/uninstall.py 2010-06-11 16:33:21 UTC (rev 485) +++ trunk/pyscard/tools/commands/uninstall.py 2010-06-12 22:02:30 UTC (rev 486) @@ -29,18 +29,19 @@ from distutils.sysconfig import get_python_lib -def _rmdir( path ): - for file in os.listdir( path ): - item = os.path.join( path, file ) - if os.path.isdir( item ) and not os.path.islink( item ): + +def _rmdir(path): + for file in os.listdir(path): + item = os.path.join(path, file) + if os.path.isdir(item) and not os.path.islink(item): print 'deleting ', item - _rmdir( item ) + _rmdir(item) else: print 'deleting ', item - os.remove( item ) + os.remove(item) print 'deleting ', path - os.rmdir( path ) + os.rmdir(path) -smartcardpackagedir = os.path.join( get_python_lib(), 'smartcard' ) -if os.path.exists( smartcardpackagedir ): - _rmdir( smartcardpackagedir ) +smartcardpackagedir = os.path.join(get_python_lib(), 'smartcard') +if os.path.exists(smartcardpackagedir): + _rmdir(smartcardpackagedir) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: Ludovic R. <lud...@gm...> - 2010-06-11 16:35:50
|
2010/6/11 jean daniel aussel <jda...@gm...>: > Hi Ludovic, > > just committed the following: > > def __checksyncbyte__(self): > """Check validity of TS.""" > if not 0x3b == self.bytes[0] and not 0x03f == self.bytes[0]: > raise SmartcardException( 'invalid TS' + " 0x%-0.2x" % > self.bytes[0] ) Great. I just changed the code to make it more PEP8 compliant :-) I guess a new version of pyscard will not be available before some months. I will backport the patch and release a new version of the Debian package. Bye -- Dr. Ludovic Rousseau |
From: <lu...@us...> - 2010-06-11 16:33:30
|
Revision: 485 http://pyscard.svn.sourceforge.net/pyscard/?rev=485&view=rev Author: ludov Date: 2010-06-11 16:33:21 +0000 (Fri, 11 Jun 2010) Log Message: ----------- make pep8 happy Modified Paths: -------------- trunk/pyscard/src/smartcard/ATR.py Modified: trunk/pyscard/src/smartcard/ATR.py =================================================================== --- trunk/pyscard/src/smartcard/ATR.py 2010-06-11 14:34:04 UTC (rev 484) +++ trunk/pyscard/src/smartcard/ATR.py 2010-06-11 16:33:21 UTC (rev 485) @@ -24,11 +24,14 @@ from smartcard.Exceptions import SmartcardException + class ATR: """ATR class.""" - clockrateconversion = [372, 372, 558, 744, 1116, 1488, 1860, 'RFU', 'RFU', 512, 768, 1024, 1536, 2048, 'RFU', 'RFU', 'RFU'] - bitratefactor = ['RFU', 1, 2, 4, 8, 16, 32, 'RFU', 12, 20, 'RFU', 'RFU', 'RFU', 'RFU', 'RFU', 'RFU'] + clockrateconversion = [372, 372, 558, 744, 1116, 1488, 1860, 'RFU', + 'RFU', 512, 768, 1024, 1536, 2048, 'RFU', 'RFU', 'RFU'] + bitratefactor = ['RFU', 1, 2, 4, 8, 16, 32, 'RFU', 12, 20, 'RFU', + 'RFU', 'RFU', 'RFU', 'RFU', 'RFU'] currenttable = [25, 50, 100, 'RFU'] def __init__(self, bytes): @@ -39,14 +42,16 @@ def __checksyncbyte__(self): """Check validity of TS.""" if not 0x3b == self.bytes[0] and not 0x03f == self.bytes[0]: - raise SmartcardException( 'invalid TS' + " 0x%-0.2x" % self.bytes[0] ) + raise SmartcardException("invalid TS 0x%-0.2x" % self.bytes[0]) def __initInstance__(self): """Parse ATR and initialize members: TS: initial character T0: format character TA[n], TB[n], TC[n], TD[n], for n=0,1,...: protocol parameters - note: protocol parameters indices start at 0, e.g. TA[0], TA[1] correspond to the ISO standard TA1, TA2 parameters + note: protocol parameters indices start at 0, e.g. + TA[0], TA[1] correspond to the ISO standard TA1, TA2 + parameters historicalBytes: the ATR T1, T2, ..., TK historical bytes TCK: checksum byte (only for protocols different from T=0) FI: clock rate conversion factor @@ -152,7 +157,8 @@ self.N = self.TC[0] def getChecksum(self): - """Return the checksum of the ATR. Checksum is mandatory only for T=1.""" + """Return the checksum of the ATR. Checksum is mandatory only + for T=1.""" return self.TCK def getHistoricalBytes(self): @@ -283,8 +289,10 @@ [0x3F, 0x65, 0x25, 0x08, 0x93, 0x04, 0x6C, 0x90, 0x00], [0x3B, 0x16, 0x94, 0x7C, 0x03, 0x01, 0x00, 0x00, 0x0D], [0x3B, 0x65, 0x00, 0x00, 0x9C, 0x11, 0x01, 0x01, 0x03], - [0x3B, 0xE3, 0x00, 0xFF, 0x81, 0x31, 0x52, 0x45, 0xA1, 0xA2, 0xA3, 0x1B], - [0x3B, 0xE5, 0x00, 0x00, 0x81, 0x21, 0x45, 0x9C, 0x10, 0x01, 0x00, 0x80, 0x0D]] + [0x3B, 0xE3, 0x00, 0xFF, 0x81, 0x31, 0x52, 0x45, 0xA1, + 0xA2, 0xA3, 0x1B], + [0x3B, 0xE5, 0x00, 0x00, 0x81, 0x21, 0x45, 0x9C, 0x10, + 0x01, 0x00, 0x80, 0x0D]] for atr in atrs: a = ATR(atr) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: jean d. a. <jda...@gm...> - 2010-06-11 14:37:24
|
Hi Ludovic, just committed the following: def __checksyncbyte__(self): """Check validity of TS.""" if not 0x3b == self.bytes[0] and not 0x03f == self.bytes[0]: raise SmartcardException( 'invalid TS' + " 0x%-0.2x" % self.bytes[0] ) cheers, -jda On Fri, Jun 11, 2010 at 4:12 PM, Ludovic Rousseau < lud...@gm...> wrote: > 2010/6/7 Ludovic Rousseau <lud...@gm...>: > > 2010/6/7 jean daniel aussel <jda...@gm...>: > >> I have added three such classes, for AddReaderToGroupException, > >> RemoveReaderFromGroupException and IntroduceReaderException. Seen that > you > >> run pep8.py, guess I have to do it systematically for further commits. > > > > Yes, that would be nice to commit code that is PEP8 compliant. > > > > We still have a lot of "W602 deprecated form of raising exception" > > Many of the "raise" are in samples or test codes. > > Debian reported [1] only one exception: > python-pyscard_1.6.10-1 E string-literal-exception > /usr/share/pyshared/smartcard/ATR.py:41 > > The code is: > def __checksyncbyte__(self): > """Check validity of TS.""" > if not 0x3b == self.bytes[0] and not 0x03f == self.bytes[0]: > raise 'invalid TS', "0x%-0.2x" % self.bytes[0] > > What exception do you want to raise in that case? > Maybe add a new class in Exceptions.py and use it? > > Bye, > > [1] http://people.debian.org/~morph/strexp/string-exceptions.lintian<http://people.debian.org/%7Emorph/strexp/string-exceptions.lintian> > > -- > Dr. Ludovic Rousseau > |
From: <jda...@us...> - 2010-06-11 14:34:11
|
Revision: 484 http://pyscard.svn.sourceforge.net/pyscard/?rev=484&view=rev Author: jdaussel Date: 2010-06-11 14:34:04 +0000 (Fri, 11 Jun 2010) Log Message: ----------- Replaced deprecated string exception Modified Paths: -------------- trunk/pyscard/src/smartcard/ATR.py Modified: trunk/pyscard/src/smartcard/ATR.py =================================================================== --- trunk/pyscard/src/smartcard/ATR.py 2010-06-09 16:39:44 UTC (rev 483) +++ trunk/pyscard/src/smartcard/ATR.py 2010-06-11 14:34:04 UTC (rev 484) @@ -22,6 +22,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA """ +from smartcard.Exceptions import SmartcardException class ATR: """ATR class.""" @@ -38,7 +39,7 @@ def __checksyncbyte__(self): """Check validity of TS.""" if not 0x3b == self.bytes[0] and not 0x03f == self.bytes[0]: - raise 'invalid TS', "0x%-0.2x" % self.bytes[0] + raise SmartcardException( 'invalid TS' + " 0x%-0.2x" % self.bytes[0] ) def __initInstance__(self): """Parse ATR and initialize members: This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: Ludovic R. <lud...@gm...> - 2010-06-11 14:12:48
|
2010/6/7 Ludovic Rousseau <lud...@gm...>: > 2010/6/7 jean daniel aussel <jda...@gm...>: >> I have added three such classes, for AddReaderToGroupException, >> RemoveReaderFromGroupException and IntroduceReaderException. Seen that you >> run pep8.py, guess I have to do it systematically for further commits. > > Yes, that would be nice to commit code that is PEP8 compliant. > > We still have a lot of "W602 deprecated form of raising exception" Many of the "raise" are in samples or test codes. Debian reported [1] only one exception: python-pyscard_1.6.10-1 E string-literal-exception /usr/share/pyshared/smartcard/ATR.py:41 The code is: def __checksyncbyte__(self): """Check validity of TS.""" if not 0x3b == self.bytes[0] and not 0x03f == self.bytes[0]: raise 'invalid TS', "0x%-0.2x" % self.bytes[0] What exception do you want to raise in that case? Maybe add a new class in Exceptions.py and use it? Bye, [1] http://people.debian.org/~morph/strexp/string-exceptions.lintian -- Dr. Ludovic Rousseau |
From: <lu...@us...> - 2010-06-09 16:39:50
|
Revision: 483 http://pyscard.svn.sourceforge.net/pyscard/?rev=483&view=rev Author: ludov Date: 2010-06-09 16:39:44 +0000 (Wed, 09 Jun 2010) Log Message: ----------- make pep8 happy Modified Paths: -------------- trunk/pyscard/src/smartcard/test/scard/testcase_getatr.py trunk/pyscard/src/smartcard/test/scard/testcase_getattrib.py Modified: trunk/pyscard/src/smartcard/test/scard/testcase_getatr.py =================================================================== --- trunk/pyscard/src/smartcard/test/scard/testcase_getatr.py 2010-06-09 16:35:51 UTC (rev 482) +++ trunk/pyscard/src/smartcard/test/scard/testcase_getatr.py 2010-06-09 16:39:44 UTC (rev 483) @@ -45,45 +45,44 @@ class testcase_getATR(unittest.TestCase): """Test scard API for ATR retrieval""" + def setUp(self): - hresult, self.hcontext = SCardEstablishContext( SCARD_SCOPE_USER ) + hresult, self.hcontext = SCardEstablishContext(SCARD_SCOPE_USER) self.assertEquals(hresult, 0) - hresult, self.readers = SCardListReaders( self.hcontext, [] ) + hresult, self.readers = SCardListReaders(self.hcontext, []) self.assertEquals(hresult, 0) def tearDown(self): - hresult = SCardReleaseContext( self.hcontext ) + hresult = SCardReleaseContext(self.hcontext) self.assertEquals(hresult, 0) - def _getATR(self, r): - if r<len(expectedATRs) and []!=expectedATRs[r]: + if r < len(expectedATRs) and [] != expectedATRs[r]: hresult, hcard, dwActiveProtocol = SCardConnect( self.hcontext, self.readers[r], SCARD_SHARE_SHARED, SCARD_PROTOCOL_T0 | SCARD_PROTOCOL_T1) self.assertEquals(hresult, 0) try: - hresult, reader, state, protocol, atr = SCardStatus( hcard ) + hresult, reader, state, protocol, atr = SCardStatus(hcard) self.assertEquals(hresult, 0) - self.assertEquals( reader, expectedReaders[r] ) - self.assertEquals( atr, expectedATRs[r] ) + self.assertEquals(reader, expectedReaders[r]) + self.assertEquals(atr, expectedATRs[r]) finally: - hresult = SCardDisconnect( hcard, SCARD_UNPOWER_CARD ) + hresult = SCardDisconnect(hcard, SCARD_UNPOWER_CARD) self.assertEquals(hresult, 0) - def test_getATR0(self): - testcase_getATR._getATR(self,0) + testcase_getATR._getATR(self, 0) def test_getATR1(self): - testcase_getATR._getATR(self,1) + testcase_getATR._getATR(self, 1) def test_getATR2(self): - testcase_getATR._getATR(self,2) + testcase_getATR._getATR(self, 2) def test_getATR3(self): - testcase_getATR._getATR(self,3) + testcase_getATR._getATR(self, 3) def suite(): Modified: trunk/pyscard/src/smartcard/test/scard/testcase_getattrib.py =================================================================== --- trunk/pyscard/src/smartcard/test/scard/testcase_getattrib.py 2010-06-09 16:35:51 UTC (rev 482) +++ trunk/pyscard/src/smartcard/test/scard/testcase_getattrib.py 2010-06-09 16:39:44 UTC (rev 483) @@ -46,55 +46,55 @@ class testcase_getAttrib(unittest.TestCase): """Test scard API for SCardGetAttrib""" + def setUp(self): - hresult, self.hcontext = SCardEstablishContext( SCARD_SCOPE_USER ) + hresult, self.hcontext = SCardEstablishContext(SCARD_SCOPE_USER) self.assertEquals(hresult, 0) - hresult, self.readers = SCardListReaders( self.hcontext, [] ) + hresult, self.readers = SCardListReaders(self.hcontext, []) self.assertEquals(hresult, 0) def tearDown(self): - hresult = SCardReleaseContext( self.hcontext ) + hresult = SCardReleaseContext(self.hcontext) self.assertEquals(hresult, 0) - def _getAttrib(self, r): - if r<len(expectedATRs) and []!=expectedATRs[r]: + if r < len(expectedATRs) and [] != expectedATRs[r]: hresult, hcard, dwActiveProtocol = SCardConnect( self.hcontext, self.readers[r], SCARD_SHARE_SHARED, SCARD_PROTOCOL_T0 | SCARD_PROTOCOL_T1) self.assertEquals(hresult, 0) try: - hresult, reader, state, protocol, atr = SCardStatus( hcard ) + hresult, reader, state, protocol, atr = SCardStatus(hcard) self.assertEquals(hresult, 0) - self.assertEquals( reader, expectedReaders[r] ) - self.assertEquals( atr, expectedATRs[r] ) + self.assertEquals(reader, expectedReaders[r]) + self.assertEquals(atr, expectedATRs[r]) - if scard.__dict__.has_key( 'SCARD_ATTR_ATR_STRING' ): - hresult, attrib = SCardGetAttrib( hcard, SCARD_ATTR_ATR_STRING ) + if scard.__dict__.has_key('SCARD_ATTR_ATR_STRING'): + hresult, attrib = SCardGetAttrib(hcard, SCARD_ATTR_ATR_STRING) self.assertEquals(hresult, 0) - self.assertEquals( expectedATRs[r], attrib ) + self.assertEquals(expectedATRs[r], attrib) - if 'winscard'==resourceManager: - hresult, attrib = SCardGetAttrib( hcard, SCARD_ATTR_DEVICE_SYSTEM_NAME_A ) + if 'winscard' == resourceManager: + hresult, attrib = SCardGetAttrib(hcard, SCARD_ATTR_DEVICE_SYSTEM_NAME_A) self.assertEquals(hresult, 0) - trimmedAttrib=attrib[:-1] - self.assertEquals( expectedReaders[r], apply( struct.pack, [ '<' + 'B' * len(trimmedAttrib)] + trimmedAttrib ) ) + trimmedAttrib = attrib[:-1] + self.assertEquals(expectedReaders[r], apply(struct.pack, ['<' + 'B' * len(trimmedAttrib)] + trimmedAttrib)) finally: - hresult = SCardDisconnect( hcard, SCARD_UNPOWER_CARD ) + hresult = SCardDisconnect(hcard, SCARD_UNPOWER_CARD) self.assertEquals(hresult, 0) def test_getATR0(self): - testcase_getAttrib._getAttrib(self,0) + testcase_getAttrib._getAttrib(self, 0) def test_getATR1(self): - testcase_getAttrib._getAttrib(self,1) + testcase_getAttrib._getAttrib(self, 1) def test_getATR3(self): - testcase_getAttrib._getAttrib(self,2) + testcase_getAttrib._getAttrib(self, 2) def test_getATR4(self): - testcase_getAttrib._getAttrib(self,3) + testcase_getAttrib._getAttrib(self, 3) def suite(): This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <lu...@us...> - 2010-06-09 16:35:57
|
Revision: 482 http://pyscard.svn.sourceforge.net/pyscard/?rev=482&view=rev Author: ludov Date: 2010-06-09 16:35:51 +0000 (Wed, 09 Jun 2010) Log Message: ----------- make pep8 happy Modified Paths: -------------- trunk/pyscard/src/smartcard/test/scard/testcase_geterrormessage.py trunk/pyscard/src/smartcard/test/scard/testcase_listcards.py Modified: trunk/pyscard/src/smartcard/test/scard/testcase_geterrormessage.py =================================================================== --- trunk/pyscard/src/smartcard/test/scard/testcase_geterrormessage.py 2010-06-09 16:21:13 UTC (rev 481) +++ trunk/pyscard/src/smartcard/test/scard/testcase_geterrormessage.py 2010-06-09 16:35:51 UTC (rev 482) @@ -34,26 +34,28 @@ class testcase_geterrormessage(unittest.TestCase): """Test scard API for ATR retrieval with SCardLocateCards""" + def setUp(self): - hresult, self.hcontext = SCardEstablishContext( SCARD_SCOPE_USER ) + hresult, self.hcontext = SCardEstablishContext(SCARD_SCOPE_USER) self.assertEquals(hresult, 0) def tearDown(self): - hresult = SCardReleaseContext( self.hcontext ) + hresult = SCardReleaseContext(self.hcontext) self.assertEquals(hresult, 0) def test_getErrorMessage(self): - hresult, readers = SCardListReaders( self.hcontext, [] ) + hresult, readers = SCardListReaders(self.hcontext, []) self.assertEquals(hresult, 0) - hresult = SCardReleaseContext( 123L ) - if 'win32'==sys.platform: - self.assertEquals( (SCARD_E_INVALID_HANDLE==hresult or ERROR_INVALID_HANDLE==hresult), True ) + hresult = SCardReleaseContext(123L) + if 'win32' == sys.platform: + self.assertEquals((SCARD_E_INVALID_HANDLE == hresult or ERROR_INVALID_HANDLE == hresult), True) else: - self.assertEquals( (SCARD_E_INVALID_HANDLE==hresult), True ) - self.assertEquals( ( SCardGetErrorMessage(hresult).rstrip()=='Invalid handle.'.rstrip() or - SCardGetErrorMessage(hresult).rstrip()=='The handle is invalid.'.rstrip() ), True ) + self.assertEquals((SCARD_E_INVALID_HANDLE == hresult), True) + self.assertEquals((SCardGetErrorMessage(hresult).rstrip() == 'Invalid handle.'.rstrip() or + SCardGetErrorMessage(hresult).rstrip() == 'The handle is invalid.'.rstrip()), True) + def suite(): suite1 = unittest.makeSuite(testcase_geterrormessage) return unittest.TestSuite((suite1)) Modified: trunk/pyscard/src/smartcard/test/scard/testcase_listcards.py =================================================================== --- trunk/pyscard/src/smartcard/test/scard/testcase_listcards.py 2010-06-09 16:21:13 UTC (rev 481) +++ trunk/pyscard/src/smartcard/test/scard/testcase_listcards.py 2010-06-09 16:35:51 UTC (rev 482) @@ -31,18 +31,19 @@ from smartcard.scard import * import smartcard.guid -if 'winscard'==resourceManager: +if 'winscard' == resourceManager: + class testcase_listcards(unittest.TestCase): """Test scard API for ATR retrieval""" # setup for all unit tests: establish context and introduce # a dummy card interface def setUp(self): - hresult, self.hcontext = SCardEstablishContext( SCARD_SCOPE_USER ) + hresult, self.hcontext = SCardEstablishContext(SCARD_SCOPE_USER) self.assertEquals(hresult, 0) self.dummycardname = 'dummycard' - self.dummycardATR = [ 0x3B, 0x75, 0x94, 0x00, 0x00, 0x62, 0x02, 0x02, 0x01, 0x01 ] - self.dummycardMask = [ 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF ] + self.dummycardATR = [0x3B, 0x75, 0x94, 0x00, 0x00, 0x62, 0x02, 0x02, 0x01, 0x01] + self.dummycardMask = [0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF] self.dummycardguid1 = smartcard.guid.strToGUID('{AD4F1667-EA75-4124-84D4-641B3B197C65}') self.dummycardguid2 = smartcard.guid.strToGUID('{382AE95A-7C2C-449c-A179-56C6DE6FF3BC}') testcase_listcards.__introduceinterface(self) @@ -51,14 +52,13 @@ # dummy card interface def tearDown(self): testcase_listcards.__forgetinterface(self) - hresult = SCardReleaseContext( self.hcontext ) + hresult = SCardReleaseContext(self.hcontext) self.assertEquals(hresult, 0) - # introduce a dummy card interface # card ATR same as e-gate def __introduceinterface(self): - hresult = SCardForgetCardType( self.hcontext, self.dummycardname ) + hresult = SCardForgetCardType(self.hcontext, self.dummycardname) dummycardPrimaryGUID = self.dummycardguid1 dummycardGUIDS = self.dummycardguid1 + self.dummycardguid2 hresult = SCardIntroduceCardType( @@ -67,85 +67,83 @@ dummycardPrimaryGUID, dummycardGUIDS, self.dummycardATR, - self.dummycardMask ) + self.dummycardMask) self.assertEquals(hresult, 0) # forget dummy card interface def __forgetinterface(self): - hresult = SCardForgetCardType( self.hcontext, self.dummycardname ) + hresult = SCardForgetCardType(self.hcontext, self.dummycardname) self.assertEquals(hresult, 0) - # locate Cryptoflex 8k v2 # Cryptoflex 8k v2 is present in standard Windows 2000 def test_listcryptoflexbyatr(self): - slbCryptoFlex8kv2ATR = [ 0x3B, 0x95, 0x15, 0x40, 0x00, 0x68, 0x01, 0x02, 0x00, 0x00 ] + slbCryptoFlex8kv2ATR = [0x3B, 0x95, 0x15, 0x40, 0x00, 0x68, 0x01, 0x02, 0x00, 0x00] slbCryptoFlex8kv2Name = ['Schlumberger Cryptoflex 8K v2'] - hresult, card = SCardListCards( self.hcontext, slbCryptoFlex8kv2ATR, [] ) + hresult, card = SCardListCards(self.hcontext, slbCryptoFlex8kv2ATR, []) self.assertEquals(hresult, 0) - self.assertEquals( card, slbCryptoFlex8kv2Name ) + self.assertEquals(card, slbCryptoFlex8kv2Name) # locate dummy card by interface def test_listdummycardbyguid(self): guidstolocate = self.dummycardguid2 + self.dummycardguid1 locatedcardnames = [self.dummycardname] - hresult, card = SCardListCards( self.hcontext, [], guidstolocate ) + hresult, card = SCardListCards(self.hcontext, [], guidstolocate) self.assertEquals(hresult, 0) - self.assertEquals( card, locatedcardnames ) + self.assertEquals(card, locatedcardnames) - # list our dummy card interfaces and check # that they match the introduced interfaces def test_listdummycardinterfaces(self): - hresult, interfaces = SCardListInterfaces( self.hcontext, self.dummycardname ) + hresult, interfaces = SCardListInterfaces(self.hcontext, self.dummycardname) self.assertEquals(hresult, 0) - self.assertEquals( 2, len(interfaces) ) - self.assertEquals( self.dummycardguid1, interfaces[0] ) - self.assertEquals( self.dummycardguid2, interfaces[1] ) + self.assertEquals(2, len(interfaces)) + self.assertEquals(self.dummycardguid1, interfaces[0]) + self.assertEquals(self.dummycardguid2, interfaces[1]) # locate all cards and interfaces in the system def test_listallcards(self): - # dummycard has been introduced in the test setup and # will be removed in the test teardown. Other cards are # the cards present by default on Windows 2000 - expectedCards = [ 'dummycard', 'GemSAFE Smart Card (8K)', 'Schlumberger Cryptoflex 4K', - 'Schlumberger Cryptoflex 8K', 'Schlumberger Cryptoflex 8K v2' ] - hresult, cards = SCardListCards( self.hcontext, [], [] ) + expectedCards = ['dummycard', 'GemSAFE Smart Card (8K)', + 'Schlumberger Cryptoflex 4K', + 'Schlumberger Cryptoflex 8K', 'Schlumberger Cryptoflex 8K v2'] + hresult, cards = SCardListCards(self.hcontext, [], []) self.assertEquals(hresult, 0) foundCards = {} for i in xrange(len(cards)): - foundCards[cards[i]]=1 + foundCards[cards[i]] = 1 for i in expectedCards: - self.assert_( foundCards.has_key( i ) ) + self.assert_(foundCards.has_key(i)) # dummycard has a primary provider, other cards have no primary provider expectedPrimaryProviderResult = { - 'dummycard':[0,self.dummycardguid1], - 'GemSAFE':[2,None], - 'Schlumberger Cryptoflex 4k':[2,None], - 'Schlumberger Cryptoflex 8k':[2,None], - 'Schlumberger Cryptoflex 8k v2':[2,None] } + 'dummycard': [0, self.dummycardguid1], + 'GemSAFE': [2, None], + 'Schlumberger Cryptoflex 4k': [2, None], + 'Schlumberger Cryptoflex 8k': [2, None], + 'Schlumberger Cryptoflex 8k v2': [2, None]} for i in xrange(len(cards)): hresult, providername = SCardGetCardTypeProviderName( - self.hcontext, cards[i], SCARD_PROVIDER_PRIMARY ) + self.hcontext, cards[i], SCARD_PROVIDER_PRIMARY) if expectedPrimaryProviderResult.has_key(cards[i]): self.assertEquals(hresult, expectedPrimaryProviderResult[cards[i]][0]) - if hresult==0: + if hresult == 0: self.assertEquals(providername, smartcard.guid.GUIDToStr(expectedPrimaryProviderResult[cards[i]][1])) # dummycard has no CSP, other cards have a CSP - #expectedProviderCSP = [ 2, 0, 0, 0, 0 ] + #expectedProviderCSP = [2, 0, 0, 0, 0] expectedProviderCSPResult = { - 'dummycard':[2,None], - 'GemSAFE':[0,'Gemplus GemSAFE Card CSP v1.0'], - 'Schlumberger Cryptoflex 4k':[0,'Schlumberger Cryptographic Service Provider'], - 'Schlumberger Cryptoflex 8k':[0,'Schlumberger Cryptographic Service Provider'], - 'Schlumberger Cryptoflex 8k v2':[0,'Schlumberger Cryptographic Service Provider'] } + 'dummycard': [2, None], + 'GemSAFE': [0, 'Gemplus GemSAFE Card CSP v1.0'], + 'Schlumberger Cryptoflex 4k': [0, 'Schlumberger Cryptographic Service Provider'], + 'Schlumberger Cryptoflex 8k': [0, 'Schlumberger Cryptographic Service Provider'], + 'Schlumberger Cryptoflex 8k v2': [0, 'Schlumberger Cryptographic Service Provider']} for i in xrange(len(cards)): hresult, providername = SCardGetCardTypeProviderName( - self.hcontext, cards[i], SCARD_PROVIDER_CSP ) + self.hcontext, cards[i], SCARD_PROVIDER_CSP) if expectedProviderCSPResult.has_key(cards[i]): self.assertEquals(hresult, expectedProviderCSPResult[cards[i]][0]) self.assertEquals(providername, expectedProviderCSPResult[cards[i]][1]) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <lu...@us...> - 2010-06-09 16:21:19
|
Revision: 481 http://pyscard.svn.sourceforge.net/pyscard/?rev=481&view=rev Author: ludov Date: 2010-06-09 16:21:13 +0000 (Wed, 09 Jun 2010) Log Message: ----------- make pep8 happy Modified Paths: -------------- trunk/pyscard/src/smartcard/test/scard/testcase_locatecards.py trunk/pyscard/src/smartcard/test/scard/testcase_readergroups.py trunk/pyscard/src/smartcard/test/scard/testcase_returncodes.py trunk/pyscard/src/smartcard/test/scard/testcase_transaction.py trunk/pyscard/src/smartcard/test/scard/testsuite_scard.py Modified: trunk/pyscard/src/smartcard/test/scard/testcase_locatecards.py =================================================================== --- trunk/pyscard/src/smartcard/test/scard/testcase_locatecards.py 2010-06-09 16:16:10 UTC (rev 480) +++ trunk/pyscard/src/smartcard/test/scard/testcase_locatecards.py 2010-06-09 16:21:13 UTC (rev 481) @@ -45,65 +45,66 @@ class testcase_locatecards(unittest.TestCase): """Test scard API for ATR retrieval with SCardLocateCards""" + def setUp(self): - hresult, self.hcontext = SCardEstablishContext( SCARD_SCOPE_USER ) + hresult, self.hcontext = SCardEstablishContext(SCARD_SCOPE_USER) self.assertEquals(hresult, 0) def tearDown(self): - hresult = SCardReleaseContext( self.hcontext ) + hresult = SCardReleaseContext(self.hcontext) self.assertEquals(hresult, 0) def test_locateCards(self): - hresult, readers = SCardListReaders( self.hcontext, [] ) + hresult, readers = SCardListReaders(self.hcontext, []) self.assertEquals(hresult, 0) - foundReaders={} + foundReaders = {} for reader in readers: - foundReaders[reader]=1 + foundReaders[reader] = 1 for reader in expectedReaders: - self.assert_( foundReaders.has_key( reader ) ) + self.assert_(foundReaders.has_key(reader)) - if 'winscard'==resourceManager: - hresult, cards = SCardListCards( self.hcontext, [], [] ) + if 'winscard' == resourceManager: + hresult, cards = SCardListCards(self.hcontext, [], []) self.assertEquals(hresult, 0) readerstates = [] for i in xrange(len(readers)): - readerstates += [ (readers[i], SCARD_STATE_UNAWARE ) ] + readerstates += [(readers[i], SCARD_STATE_UNAWARE)] - hresult, newstates = SCardLocateCards( self.hcontext, cards, readerstates ) + hresult, newstates = SCardLocateCards(self.hcontext, cards, readerstates) self.assertEquals(hresult, 0) - dictexpectedreaders={} + dictexpectedreaders = {} for reader in expectedReaders: - dictexpectedreaders[reader]=1 + dictexpectedreaders[reader] = 1 for reader, eventstate, atr in newstates: - if dictexpectedreaders.has_key( reader ) and []!=expectedATRinReader[reader]: - self.assertEquals( expectedATRinReader[reader], atr ) - self.assert_( eventstate & SCARD_STATE_PRESENT ) - self.assert_( eventstate & SCARD_STATE_CHANGED ) + if dictexpectedreaders.has_key(reader) and [] != expectedATRinReader[reader]: + self.assertEquals(expectedATRinReader[reader], atr) + self.assert_(eventstate & SCARD_STATE_PRESENT) + self.assert_(eventstate & SCARD_STATE_CHANGED) # 10ms delay, so that time-out always occurs - hresult, newstates = SCardGetStatusChange( self.hcontext, 10, newstates ) - self.assertEquals( hresult, SCARD_E_TIMEOUT ) - self.assertEquals( SCardGetErrorMessage(hresult), 'The user-specified timeout value has expired. ' ) + hresult, newstates = SCardGetStatusChange(self.hcontext, 10, newstates) + self.assertEquals(hresult, SCARD_E_TIMEOUT) + self.assertEquals(SCardGetErrorMessage(hresult), 'The user-specified timeout value has expired. ') - elif 'pcsclite'==resourceManager: + elif 'pcsclite' == resourceManager: readerstates = [] for i in xrange(len(readers)): - readerstates += [ (readers[i], SCARD_STATE_UNAWARE ) ] + readerstates += [(readers[i], SCARD_STATE_UNAWARE)] - hresult, newstates = SCardGetStatusChange( self.hcontext, 0, readerstates ) + hresult, newstates = SCardGetStatusChange(self.hcontext, 0, readerstates) self.assertEquals(hresult, 0) - dictexpectedreaders={} + dictexpectedreaders = {} for reader in expectedReaders: - dictexpectedreaders[reader]=1 + dictexpectedreaders[reader] = 1 for reader, eventstate, atr in newstates: - if dictexpectedreaders.has_key( reader ) and []!=expectedATRinReader[reader]: - self.assertEquals( expectedATRinReader[reader], atr ) - self.assert_( eventstate & SCARD_STATE_PRESENT ) - self.assert_( eventstate & SCARD_STATE_CHANGED ) + if dictexpectedreaders.has_key(reader) and [] != expectedATRinReader[reader]: + self.assertEquals(expectedATRinReader[reader], atr) + self.assert_(eventstate & SCARD_STATE_PRESENT) + self.assert_(eventstate & SCARD_STATE_CHANGED) def suite(): Modified: trunk/pyscard/src/smartcard/test/scard/testcase_readergroups.py =================================================================== --- trunk/pyscard/src/smartcard/test/scard/testcase_readergroups.py 2010-06-09 16:16:10 UTC (rev 480) +++ trunk/pyscard/src/smartcard/test/scard/testcase_readergroups.py 2010-06-09 16:21:13 UTC (rev 481) @@ -45,78 +45,77 @@ expectedGroups = ['SCard$DefaultReaders'] + class testcase_readergroups(unittest.TestCase): """Test scard reader groups API""" + def setUp(self): - hresult, self.hcontext = SCardEstablishContext( SCARD_SCOPE_USER ) + hresult, self.hcontext = SCardEstablishContext(SCARD_SCOPE_USER) self.assertEquals(hresult, 0) def tearDown(self): - hresult = SCardReleaseContext( self.hcontext ) + hresult = SCardReleaseContext(self.hcontext) self.assertEquals(hresult, 0) - def test_listReaders(self): # list current readers and compare with expected list - hresult, readers = SCardListReaders( self.hcontext, [] ) + hresult, readers = SCardListReaders(self.hcontext, []) self.assertEquals(hresult, 0) for i in xrange(len(expectedReaders)): - self.assertEquals( readers[i], expectedReaders[i] ) + self.assertEquals(readers[i], expectedReaders[i]) - # list current reader groups and compare with expected list - hresult, readerGroups = SCardListReaderGroups( self.hcontext ) + hresult, readerGroups = SCardListReaderGroups(self.hcontext) self.assertEquals(hresult, 0) for i in xrange(len(expectedGroups)): - self.assertEquals( readerGroups[i], expectedGroups[i] ) + self.assertEquals(readerGroups[i], expectedGroups[i]) - if 'winscard'==resourceManager: + if 'winscard' == resourceManager: # add a new group newgroup = 'SCard$MyOwnGroup' expectedGroups.append(newgroup) - hresult = SCardIntroduceReaderGroup( self.hcontext, newgroup ) + hresult = SCardIntroduceReaderGroup(self.hcontext, newgroup) self.assertEquals(hresult, 0) dummyreader = readers[0] + ' alias' - hresult = SCardIntroduceReader( self.hcontext, dummyreader, readers[0] ) + hresult = SCardIntroduceReader(self.hcontext, dummyreader, readers[0]) self.assertEquals(hresult, 0) - hresult = SCardAddReaderToGroup( self.hcontext, dummyreader, newgroup ) + hresult = SCardAddReaderToGroup(self.hcontext, dummyreader, newgroup) self.assertEquals(hresult, 0) - hresult, readerGroups = SCardListReaderGroups( self.hcontext ) + hresult, readerGroups = SCardListReaderGroups(self.hcontext) self.assertEquals(hresult, 0) for i in xrange(len(expectedGroups)): - self.assertEquals( readerGroups[i], expectedGroups[i] ) + self.assertEquals(readerGroups[i], expectedGroups[i]) - # list readers in new group - hresult, newreaders = SCardListReaders( self.hcontext, [newgroup] ) + hresult, newreaders = SCardListReaders(self.hcontext, [newgroup]) self.assertEquals(hresult, 0) - self.assertEquals( newreaders[0], dummyreader ) + self.assertEquals(newreaders[0], dummyreader) # remove reader from new group - hresult = SCardRemoveReaderFromGroup( self.hcontext, dummyreader, newgroup ) + hresult = SCardRemoveReaderFromGroup(self.hcontext, dummyreader, newgroup) self.assertEquals(hresult, 0) - hresult, readerGroups = SCardListReaderGroups( self.hcontext ) + hresult, readerGroups = SCardListReaderGroups(self.hcontext) self.assertEquals(hresult, 0) expectedGroups.remove(newgroup) for i in xrange(len(expectedGroups)): - self.assertEquals( readerGroups[i], expectedGroups[i] ) + self.assertEquals(readerGroups[i], expectedGroups[i]) - hresult = SCardForgetReaderGroup( self.hcontext, newgroup ) + hresult = SCardForgetReaderGroup(self.hcontext, newgroup) self.assertEquals(hresult, 0) - hresult, readerGroups = SCardListReaderGroups( self.hcontext ) + hresult, readerGroups = SCardListReaderGroups(self.hcontext) self.assertEquals(hresult, 0) for i in xrange(len(expectedGroups)): - self.assertEquals( readerGroups[i], expectedGroups[i] ) + self.assertEquals(readerGroups[i], expectedGroups[i]) - hresult = SCardForgetReader( self.hcontext, dummyreader) + hresult = SCardForgetReader(self.hcontext, dummyreader) self.assertEquals(hresult, 0) Modified: trunk/pyscard/src/smartcard/test/scard/testcase_returncodes.py =================================================================== --- trunk/pyscard/src/smartcard/test/scard/testcase_returncodes.py 2010-06-09 16:16:10 UTC (rev 480) +++ trunk/pyscard/src/smartcard/test/scard/testcase_returncodes.py 2010-06-09 16:21:13 UTC (rev 481) @@ -34,8 +34,9 @@ class testcase_returncodes(unittest.TestCase): """Test scard API for return codes """ + def test_getReturnCodes(self): - errors = ( + errors = ( SCARD_S_SUCCESS, SCARD_F_INTERNAL_ERROR, SCARD_E_CANCELLED, @@ -100,6 +101,7 @@ #for e in errors: # print hex((e+0x100000000) & 0xFFFFFFFF) + def suite(): suite1 = unittest.makeSuite(testcase_returncodes) return unittest.TestSuite((suite1)) Modified: trunk/pyscard/src/smartcard/test/scard/testcase_transaction.py =================================================================== --- trunk/pyscard/src/smartcard/test/scard/testcase_transaction.py 2010-06-09 16:16:10 UTC (rev 480) +++ trunk/pyscard/src/smartcard/test/scard/testcase_transaction.py 2010-06-09 16:21:13 UTC (rev 481) @@ -43,54 +43,52 @@ sys.exit() - class testcase_transaction(unittest.TestCase): """Test scard API for SCardBegin/EndTransaction""" + def setUp(self): - hresult, self.hcontext = SCardEstablishContext( SCARD_SCOPE_USER ) + hresult, self.hcontext = SCardEstablishContext(SCARD_SCOPE_USER) self.assertEquals(hresult, 0) - hresult, self.readers = SCardListReaders( self.hcontext, [] ) + hresult, self.readers = SCardListReaders(self.hcontext, []) self.assertEquals(hresult, 0) def tearDown(self): - hresult = SCardReleaseContext( self.hcontext ) + hresult = SCardReleaseContext(self.hcontext) self.assertEquals(hresult, 0) - def _transaction(self, r): - if r<len(expectedATRs) and []!=expectedATRs[r]: + if r < len(expectedATRs) and [] != expectedATRs[r]: hresult, hcard, dwActiveProtocol = SCardConnect( self.hcontext, self.readers[r], SCARD_SHARE_SHARED, SCARD_PROTOCOL_T0 | SCARD_PROTOCOL_T1) self.assertEquals(hresult, 0) try: - hresult = SCardBeginTransaction( hcard ) + hresult = SCardBeginTransaction(hcard) self.assertEquals(hresult, 0) - hresult, reader, state, protocol, atr = SCardStatus( hcard ) + hresult, reader, state, protocol, atr = SCardStatus(hcard) self.assertEquals(hresult, 0) - self.assertEquals( reader, expectedReaders[r] ) - self.assertEquals( atr, expectedATRs[r] ) + self.assertEquals(reader, expectedReaders[r]) + self.assertEquals(atr, expectedATRs[r]) - hresult = SCardEndTransaction( hcard, SCARD_LEAVE_CARD ) + hresult = SCardEndTransaction(hcard, SCARD_LEAVE_CARD) self.assertEquals(hresult, 0) finally: - hresult = SCardDisconnect( hcard, SCARD_UNPOWER_CARD ) + hresult = SCardDisconnect(hcard, SCARD_UNPOWER_CARD) self.assertEquals(hresult, 0) - def test_transaction_reader0(self): - testcase_transaction._transaction(self,0) + testcase_transaction._transaction(self, 0) def test_transaction_reader1(self): - testcase_transaction._transaction(self,1) + testcase_transaction._transaction(self, 1) def test_transaction_reader2(self): - testcase_transaction._transaction(self,2) + testcase_transaction._transaction(self, 2) def test_transaction_reader3(self): - testcase_transaction._transaction(self,3) + testcase_transaction._transaction(self, 3) def suite(): Modified: trunk/pyscard/src/smartcard/test/scard/testsuite_scard.py =================================================================== --- trunk/pyscard/src/smartcard/test/scard/testsuite_scard.py 2010-06-09 16:16:10 UTC (rev 480) +++ trunk/pyscard/src/smartcard/test/scard/testsuite_scard.py 2010-06-09 16:21:13 UTC (rev 481) @@ -31,6 +31,7 @@ sys.path += ['..'] import configcheck + def suite(): modules_to_test = ( 'testcase_getatr', @@ -40,7 +41,7 @@ 'testcase_locatecards', 'testcase_readergroups', 'testcase_returncodes', - 'testcase_transaction' ) + 'testcase_transaction') testsuite_scard = unittest.TestSuite() for module in map(__import__, modules_to_test): testsuite_scard.addTest(unittest.findTestCases(module)) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |