From: <lu...@us...> - 2010-06-06 15:52:19
|
Revision: 436 http://pyscard.svn.sourceforge.net/pyscard/?rev=436&view=rev Author: ludov Date: 2010-06-06 15:52:13 +0000 (Sun, 06 Jun 2010) Log Message: ----------- make pep8 happy Modified Paths: -------------- trunk/pyscard/src/smartcard/pcsc/PCSCReaderGroups.py trunk/pyscard/src/smartcard/pcsc/__init__.py Modified: trunk/pyscard/src/smartcard/pcsc/PCSCReaderGroups.py =================================================================== --- trunk/pyscard/src/smartcard/pcsc/PCSCReaderGroups.py 2010-06-06 15:49:58 UTC (rev 435) +++ trunk/pyscard/src/smartcard/pcsc/PCSCReaderGroups.py 2010-06-06 15:52:13 UTC (rev 436) @@ -48,13 +48,13 @@ innerreadergroups.getreadergroups(self) hresult, hcontext = SCardEstablishContext(SCARD_SCOPE_USER) - if hresult!=0: + if hresult != 0: raise EstablishContextException(hresult) hresult, readers = SCardListReaderGroups(hcontext) - if hresult!=0: + if hresult != 0: raise ListReadersException(hresult) hresult = SCardReleaseContext(hcontext) - if hresult!=0: + if hresult != 0: raise ReleaseContextException(hresult) return readers Modified: trunk/pyscard/src/smartcard/pcsc/__init__.py =================================================================== --- trunk/pyscard/src/smartcard/pcsc/__init__.py 2010-06-06 15:49:58 UTC (rev 435) +++ trunk/pyscard/src/smartcard/pcsc/__init__.py 2010-06-06 15:52:13 UTC (rev 436) @@ -1 +0,0 @@ - This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jda...@us...> - 2010-06-07 17:04:28
|
Revision: 445 http://pyscard.svn.sourceforge.net/pyscard/?rev=445&view=rev Author: jdaussel Date: 2010-06-07 17:04:20 +0000 (Mon, 07 Jun 2010) Log Message: ----------- Added three new exceptions Modified Paths: -------------- trunk/pyscard/src/smartcard/pcsc/PCSCExceptions.py trunk/pyscard/src/smartcard/pcsc/PCSCReader.py Modified: trunk/pyscard/src/smartcard/pcsc/PCSCExceptions.py =================================================================== --- trunk/pyscard/src/smartcard/pcsc/PCSCExceptions.py 2010-06-06 18:53:08 UTC (rev 444) +++ trunk/pyscard/src/smartcard/pcsc/PCSCExceptions.py 2010-06-07 17:04:20 UTC (rev 445) @@ -46,6 +46,18 @@ smartcard.scard.SCardGetErrorMessage(self.hresult)) +class AddReaderToGroupException(BaseSCardException): + """Raised when scard fails to add a new reader to a PCSC reader group.""" + + def __init__( self, hresult, readername="", groupname="" ): + BaseSCardException.__init__( self, hresult ) + self.readername = readername + self.groupname = groupname + + def __str__(self): + return repr('Failure to add reader: ' + self.readername + ' to group: ' + self.groupname + ' ' + + smartcard.scard.SCardGetErrorMessage(self.hresult)) + class EstablishContextException(BaseSCardException): """Raised when scard failed to establish context with PCSC.""" @@ -63,11 +75,15 @@ smartcard.scard.SCardGetErrorMessage(self.hresult)) -class EstablishContextException(BaseSCardException): - """Raised when scard failed to establish a PCSC context.""" +class IntroduceReaderException(BaseSCardException): + """Raised when scard fails to introduce a new reader to PCSC.""" + def __init__( self, hresult, readername="" ): + BaseSCardException.__init__( self, hresult ) + self.readername = readername + def __str__(self): - return repr('Failure to establish context: ' + + return repr('Failure to introduce a new reader: ' + self.readername + ' ' + smartcard.scard.SCardGetErrorMessage(self.hresult)) @@ -78,6 +94,18 @@ return repr('Failure to release context: ' + smartcard.scard.SCardGetErrorMessage(self.hresult)) +class RemoveReaderFromGroupException(BaseSCardException): + """Raised when scard fails to remove a reader from a PCSC reader group.""" + + def __init__( self, hresult, readername="", groupname="" ): + BaseSCardException.__init__( self, hresult ) + self.readername = readername + self.groupname = groupname + + def __str__(self): + return repr('Failure to remove reader: ' + self.readername + ' from group: ' + self.groupname + ' ' + + smartcard.scard.SCardGetErrorMessage(self.hresult)) + if __name__ == "__main__": import sys try: Modified: trunk/pyscard/src/smartcard/pcsc/PCSCReader.py =================================================================== --- trunk/pyscard/src/smartcard/pcsc/PCSCReader.py 2010-06-06 18:53:08 UTC (rev 444) +++ trunk/pyscard/src/smartcard/pcsc/PCSCReader.py 2010-06-07 17:04:20 UTC (rev 445) @@ -67,10 +67,10 @@ try: hresult = SCardIntroduceReader(hcontext, self.name, self.name) if 0 != hresult and SCARD_E_DUPLICATE_READER != hresult: - raise error, 'Unable to introduce reader: ' + self.name + ' : ' + SCardGetErrorMessage(hresult) + raise IntroduceReaderException(hresult,self.name) hresult = SCardAddReaderToGroup(hcontext, self.name, groupname) if 0 != hresult: - raise error, 'Unable to add reader to group: ' + SCardGetErrorMessage(hresult) + raise AddReaderToGroupException(hresult,self.name,groupname) finally: hresult = SCardReleaseContext(hcontext) if 0 != hresult: @@ -85,7 +85,7 @@ try: hresult = SCardRemoveReaderFromGroup(hcontext, self.name, groupname) if 0 != hresult: - raise error, 'Unable to add reader to group: ' + SCardGetErrorMessage(hresult) + raise RemoveReaderFromGroupException(hresult,self.name,groupname) finally: hresult = SCardReleaseContext(hcontext) if 0 != hresult: This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <lu...@us...> - 2010-06-07 17:10:01
|
Revision: 446 http://pyscard.svn.sourceforge.net/pyscard/?rev=446&view=rev Author: ludov Date: 2010-06-07 17:09:55 +0000 (Mon, 07 Jun 2010) Log Message: ----------- make pep8 happy Modified Paths: -------------- trunk/pyscard/src/smartcard/pcsc/PCSCExceptions.py trunk/pyscard/src/smartcard/pcsc/PCSCReader.py Modified: trunk/pyscard/src/smartcard/pcsc/PCSCExceptions.py =================================================================== --- trunk/pyscard/src/smartcard/pcsc/PCSCExceptions.py 2010-06-07 17:04:20 UTC (rev 445) +++ trunk/pyscard/src/smartcard/pcsc/PCSCExceptions.py 2010-06-07 17:09:55 UTC (rev 446) @@ -49,8 +49,8 @@ class AddReaderToGroupException(BaseSCardException): """Raised when scard fails to add a new reader to a PCSC reader group.""" - def __init__( self, hresult, readername="", groupname="" ): - BaseSCardException.__init__( self, hresult ) + def __init__(self, hresult, readername="", groupname=""): + BaseSCardException.__init__(self, hresult) self.readername = readername self.groupname = groupname @@ -58,6 +58,7 @@ return repr('Failure to add reader: ' + self.readername + ' to group: ' + self.groupname + ' ' + smartcard.scard.SCardGetErrorMessage(self.hresult)) + class EstablishContextException(BaseSCardException): """Raised when scard failed to establish context with PCSC.""" @@ -78,8 +79,8 @@ class IntroduceReaderException(BaseSCardException): """Raised when scard fails to introduce a new reader to PCSC.""" - def __init__( self, hresult, readername="" ): - BaseSCardException.__init__( self, hresult ) + def __init__(self, hresult, readername=""): + BaseSCardException.__init__(self, hresult) self.readername = readername def __str__(self): @@ -94,11 +95,12 @@ return repr('Failure to release context: ' + smartcard.scard.SCardGetErrorMessage(self.hresult)) + class RemoveReaderFromGroupException(BaseSCardException): """Raised when scard fails to remove a reader from a PCSC reader group.""" - def __init__( self, hresult, readername="", groupname="" ): - BaseSCardException.__init__( self, hresult ) + def __init__(self, hresult, readername="", groupname=""): + BaseSCardException.__init__(self, hresult) self.readername = readername self.groupname = groupname Modified: trunk/pyscard/src/smartcard/pcsc/PCSCReader.py =================================================================== --- trunk/pyscard/src/smartcard/pcsc/PCSCReader.py 2010-06-07 17:04:20 UTC (rev 445) +++ trunk/pyscard/src/smartcard/pcsc/PCSCReader.py 2010-06-07 17:09:55 UTC (rev 446) @@ -67,10 +67,10 @@ try: hresult = SCardIntroduceReader(hcontext, self.name, self.name) if 0 != hresult and SCARD_E_DUPLICATE_READER != hresult: - raise IntroduceReaderException(hresult,self.name) + raise IntroduceReaderException(hresult, self.name) hresult = SCardAddReaderToGroup(hcontext, self.name, groupname) if 0 != hresult: - raise AddReaderToGroupException(hresult,self.name,groupname) + raise AddReaderToGroupException(hresult, self.name, groupname) finally: hresult = SCardReleaseContext(hcontext) if 0 != hresult: @@ -85,7 +85,7 @@ try: 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: 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. |