From: <lu...@us...> - 2010-06-09 11:47:57
|
Revision: 457 http://pyscard.svn.sourceforge.net/pyscard/?rev=457&view=rev Author: ludov Date: 2010-06-09 11:47:51 +0000 (Wed, 09 Jun 2010) Log Message: ----------- make pep8 happy Modified Paths: -------------- trunk/pyscard/src/smartcard/ExclusiveConnectCardConnection.py Modified: trunk/pyscard/src/smartcard/ExclusiveConnectCardConnection.py =================================================================== --- trunk/pyscard/src/smartcard/ExclusiveConnectCardConnection.py 2010-06-09 11:46:00 UTC (rev 456) +++ trunk/pyscard/src/smartcard/ExclusiveConnectCardConnection.py 2010-06-09 11:47:51 UTC (rev 457) @@ -29,33 +29,37 @@ from smartcard.pcsc import PCSCCardConnection import smartcard.pcsc -class ExclusiveConnectCardConnection( CardConnectionDecorator ): - '''This decorator uses exclusive access to the card during connection to prevent other - processes to connect to this card.''' - def __init__( self, cardconnection ): - CardConnectionDecorator.__init__( self, cardconnection ) - def connect( self, protocol=None, mode=None, disposition=None ): +class ExclusiveConnectCardConnection(CardConnectionDecorator): + '''This decorator uses exclusive access to the card during + connection to prevent other processes to connect to this card.''' + + def __init__(self, cardconnection): + CardConnectionDecorator.__init__(self, cardconnection) + + def connect(self, protocol=None, mode=None, disposition=None): '''Disconnect and reconnect in exclusive mode PCSCCardconnections.''' - CardConnectionDecorator.connect( self, protocol, mode, disposition ) - component=self.component + CardConnectionDecorator.connect(self, protocol, mode, disposition) + component = self.component while True: - if isinstance( component, smartcard.pcsc.PCSCCardConnection.PCSCCardConnection ): - pcscprotocol = PCSCCardConnection.translateprotocolmask( protocol ) - if 0==pcscprotocol: + if isinstance(component, smartcard.pcsc.PCSCCardConnection.PCSCCardConnection): + pcscprotocol = PCSCCardConnection.translateprotocolmask(protocol) + if 0 == pcscprotocol: pcscprotocol = component.getProtocol() - if None!=component.hcard: - hresult = SCardDisconnect( component.hcard, SCARD_LEAVE_CARD ) - if hresult!=0: - raise CardConnectionException( 'Failed to disconnect: ' + SCardGetErrorMessage(hresult) ) + if None != component.hcard: + hresult = SCardDisconnect(component.hcard, SCARD_LEAVE_CARD) + if hresult != 0: + raise CardConnectionException('Failed to disconnect: ' + + SCardGetErrorMessage(hresult)) hresult, component.hcard, dwActiveProtocol = SCardConnect( - component.hcontext, str(component.reader), SCARD_SHARE_EXCLUSIVE, pcscprotocol ) - if hresult!=0: - raise CardConnectionException( 'Failed to connect with SCARD_SHARE_EXCLUSIVE' + SCardGetErrorMessage(hresult) ) + component.hcontext, str(component.reader), + SCARD_SHARE_EXCLUSIVE, pcscprotocol) + if hresult != 0: + raise CardConnectionException('Failed to connect with SCARD_SHARE_EXCLUSIVE' + SCardGetErrorMessage(hresult)) # print 'reconnected exclusive' break - if hasattr( component, 'component' ): - component=component.component + if hasattr(component, 'component'): + component = component.component else: break This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |