|
From: <jda...@us...> - 2011-10-16 15:00:42
|
Revision: 562
http://pyscard.svn.sourceforge.net/pyscard/?rev=562&view=rev
Author: jdaussel
Date: 2011-10-16 15:00:33 +0000 (Sun, 16 Oct 2011)
Log Message:
-----------
Fixed E501 pep8 line too long
Modified Paths:
--------------
trunk/pyscard/src/setup.py
trunk/pyscard/src/smartcard/ATR.py
trunk/pyscard/src/smartcard/AbstractCardRequest.py
trunk/pyscard/src/smartcard/Card.py
trunk/pyscard/src/smartcard/CardConnection.py
trunk/pyscard/src/smartcard/CardConnectionObserver.py
trunk/pyscard/src/smartcard/CardMonitoring.py
trunk/pyscard/src/smartcard/Examples/framework/sample_CardConnectionDecorator.py
trunk/pyscard/src/smartcard/Examples/framework/sample_ExclusiveCardConnection.py
trunk/pyscard/src/smartcard/Examples/framework/sample_TransmitCardObserver.py
trunk/pyscard/src/smartcard/Examples/framework/sample_apduTracerInterpreter.py
trunk/pyscard/src/smartcard/Examples/framework/sample_toHexString.py
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_listInterfaces.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
trunk/pyscard/src/smartcard/Examples/wx/apdumanager/SampleAPDUManagerPanel.py
trunk/pyscard/src/smartcard/Examples/wx/apdumanager/apdumanager.py
trunk/pyscard/src/smartcard/Examples/wx/apdumanager/setup.py
trunk/pyscard/src/smartcard/Examples/wx/cardmonitor/cardmonitor.py
trunk/pyscard/src/smartcard/Examples/wx/cardmonitor/setup.py
trunk/pyscard/src/smartcard/Examples/wx/pcscdiag/pcscdiag.py
trunk/pyscard/src/smartcard/Examples/wx/readerviewer/readerviewer.py
trunk/pyscard/src/smartcard/Examples/wx/readerviewer/setup.py
trunk/pyscard/src/smartcard/Exceptions.py
trunk/pyscard/src/smartcard/ExclusiveConnectCardConnection.py
trunk/pyscard/src/smartcard/ExclusiveTransmitCardConnection.py
trunk/pyscard/src/smartcard/pcsc/PCSCCardConnection.py
trunk/pyscard/src/smartcard/pcsc/PCSCCardRequest.py
trunk/pyscard/src/smartcard/pcsc/PCSCPart10.py
trunk/pyscard/src/smartcard/pcsc/PCSCReaderGroups.py
trunk/pyscard/src/smartcard/pyro/server/PyroEventServer.py
trunk/pyscard/src/smartcard/pyro/server/PyroNameServer.py
trunk/pyscard/src/smartcard/pyro/server/RemoteReaderServer.py
trunk/pyscard/src/smartcard/reader/ReaderGroups.py
trunk/pyscard/src/smartcard/sw/ErrorCheckingChain.py
trunk/pyscard/src/smartcard/sw/ISO7816_4ErrorChecker.py
trunk/pyscard/src/smartcard/sw/ISO7816_8ErrorChecker.py
trunk/pyscard/src/smartcard/sw/SWExceptions.py
trunk/pyscard/src/smartcard/test/configcheck.py
trunk/pyscard/src/smartcard/test/framework/testcase_ATR.py
trunk/pyscard/src/smartcard/test/framework/testcase_Card.py
trunk/pyscard/src/smartcard/test/framework/testcase_CardConnection.py
trunk/pyscard/src/smartcard/test/framework/testcase_CardMonitor.py
trunk/pyscard/src/smartcard/test/framework/testcase_CardRequest.py
trunk/pyscard/src/smartcard/test/framework/testcase_CardService.py
trunk/pyscard/src/smartcard/test/framework/testcase_CardType.py
trunk/pyscard/src/smartcard/test/framework/testcase_ErrorChecking.py
trunk/pyscard/src/smartcard/test/framework/testcase_ExclusiveCardConnection.py
trunk/pyscard/src/smartcard/test/framework/testcase_readergroups.py
trunk/pyscard/src/smartcard/test/framework/testcase_readermonitor.py
trunk/pyscard/src/smartcard/test/framework/testcase_readermonitorstress.py
trunk/pyscard/src/smartcard/test/framework/testcase_readers.py
trunk/pyscard/src/smartcard/test/framework/testcase_utils.py
trunk/pyscard/src/smartcard/test/frameworkpcsc/testcase_pcscreadergroups.py
trunk/pyscard/src/smartcard/test/manual/testcase_manualCardRequest.py
trunk/pyscard/src/smartcard/test/scard/testcase_getatr.py
trunk/pyscard/src/smartcard/test/scard/testcase_getattrib.py
trunk/pyscard/src/smartcard/test/scard/testcase_geterrormessage.py
trunk/pyscard/src/smartcard/test/scard/testcase_listcards.py
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_transaction.py
trunk/pyscard/src/smartcard/util/__init__.py
trunk/pyscard/src/smartcard/wx/APDUTracerPanel.py
trunk/pyscard/src/smartcard/wx/CardAndReaderTreePanel.py
trunk/pyscard/src/smartcard/wx/ReaderToolbar.py
trunk/pyscard/src/smartcard/wx/SimpleSCardAppEventObserver.py
trunk/pyscard/src/smartcard/wx/SimpleSCardAppFrame.py
trunk/pyscard/src/smartcard/wx/__init__.py
trunk/pyscard/tools/commands/build-doc.py
Modified: trunk/pyscard/src/setup.py
===================================================================
--- trunk/pyscard/src/setup.py 2011-10-16 13:19:22 UTC (rev 561)
+++ trunk/pyscard/src/setup.py 2011-10-16 15:00:33 UTC (rev 562)
@@ -58,14 +58,20 @@
# python 2.3
# if python 2.5 is installed, get_platform() returns a string similar to
# 'macosx-10.3-fat'
-elif 'darwin' in get_platform() or 'macosx-10.3' in get_platform() or 'macosx-10.4' in get_platform():
- platform__cc_defines = [('PCSCLITE', '1'), ('__APPLE__', '1'), ('__TIGER__', '1')]
- platform_swig_opts = ['-DPCSCLITE', '-D__APPLE__', '-D__TIGER__']
- platform_sources = []
- platform_libraries = []
- platform_include_dirs = []
- platform_extra_compile_args = ['-v', '-framework', 'PCSC', '-arch', 'i386', '-arch', 'ppc', '-ggdb', '-O0']
- platform_extra_link_args = ['-arch', 'i386', '-arch', 'ppc', '-ggdb']
+elif 'darwin' in get_platform() \
+ or 'macosx-10.3' in get_platform() \
+ or 'macosx-10.4' in get_platform():
+ platform__cc_defines = [('PCSCLITE', '1'),
+ ('__APPLE__', '1'),
+ ('__TIGER__', '1')]
+ platform_swig_opts = ['-DPCSCLITE', '-D__APPLE__', '-D__TIGER__']
+ platform_sources = []
+ platform_libraries = []
+ platform_include_dirs = []
+ platform_extra_compile_args = ['-v', '-framework', 'PCSC',
+ '-arch', 'i386', '-arch',
+ 'ppc', '-ggdb', '-O0']
+ platform_extra_link_args = ['-arch', 'i386', '-arch', 'ppc', '-ggdb']
#
# Mac OS X Snow Leopard, python 2.6
@@ -75,12 +81,15 @@
# x86_64 and i386
#
elif 'macosx-10.6' in get_platform() or 'macosx-10.7' in get_platform():
- platform__cc_defines = [('PCSCLITE', '1'), ('__APPLE__', '1'), ('__LEOPARD__', '1')]
+ platform__cc_defines = [('PCSCLITE', '1'),
+ ('__APPLE__', '1'),
+ ('__LEOPARD__', '1')]
platform_swig_opts = ['-DPCSCLITE', '-D__APPLE__', '-D__LEOPARD__']
platform_sources = []
platform_libraries = []
platform_include_dirs = []
- platform_extra_compile_args = ['-v', '-arch', 'i386', '-arch', 'x86_64', '-ggdb']
+ platform_extra_compile_args = ['-v', '-arch', 'i386',
+ '-arch', 'x86_64', '-ggdb']
platform_extra_link_args = ['-arch', 'i386', '-arch', 'x86_64', '-ggdb']
#
@@ -88,12 +97,16 @@
# get_platform() returns a string similar to 'macosx-10.5-i386'
#
elif 'macosx-10.' in get_platform():
- platform__cc_defines = [('PCSCLITE', '1'), ('__APPLE__', '1'), ('__LEOPARD__', '1')]
+ platform__cc_defines = [('PCSCLITE', '1'),
+ ('__APPLE__', '1'),
+ ('__LEOPARD__', '1')]
platform_swig_opts = ['-DPCSCLITE', '-D__APPLE__', '-D__LEOPARD__']
platform_sources = []
platform_libraries = []
platform_include_dirs = []
- platform_extra_compile_args = ['-v', '-framework', 'PCSC', '-arch', 'i386', '-arch', 'ppc', '-ggdb', '-O0']
+ platform_extra_compile_args = ['-v', '-framework', 'PCSC',
+ '-arch', 'i386',
+ '-arch', 'ppc', '-ggdb', '-O0']
platform_extra_link_args = ['-arch', 'i386', '-arch', 'ppc', '-ggdb']
else:
platform__cc_defines = [('PCSCLITE', '1')]
@@ -106,7 +119,8 @@
class _pyscardBuildExt(build_ext):
- '''Specialization of build_ext to enable swig_opts for python 2.3 distutils'''
+ '''Specialization of build_ext to enable swig_opts
+ for python 2.3 distutils'''
if sys.version_info < (2, 4):
# This copy of swig_sources is from Python 2.3.
@@ -195,14 +209,18 @@
# the _scard.pyd extension to build
'ext_modules': [Extension("smartcard.scard._scard",
define_macros=platform__cc_defines,
- include_dirs=['smartcard/scard/'] + platform_include_dirs,
+ include_dirs=['smartcard/scard/'] \
+ + platform_include_dirs,
sources=["smartcard/scard/helpers.c",
"smartcard/scard/winscarddll.c",
- "smartcard/scard/scard.i"] + platform_sources,
+ "smartcard/scard/scard.i"] \
+ + platform_sources,
libraries=platform_libraries,
extra_compile_args=platform_extra_compile_args,
extra_link_args=platform_extra_link_args,
- swig_opts=['-outdir', 'smartcard/scard'] + platform_swig_opts)],
+ swig_opts=['-outdir',
+ 'smartcard/scard'] \
+ + platform_swig_opts)],
'cmdclass': {'build_ext': _pyscardBuildExt},
}
Modified: trunk/pyscard/src/smartcard/ATR.py
===================================================================
--- trunk/pyscard/src/smartcard/ATR.py 2011-10-16 13:19:22 UTC (rev 561)
+++ trunk/pyscard/src/smartcard/ATR.py 2011-10-16 15:00:33 UTC (rev 562)
@@ -105,14 +105,25 @@
if self.hasTB[n]:
self.TB[n] = self.bytes[offset + self.hasTA[n] + self.hasTB[n]]
if self.hasTC[n]:
- self.TC[n] = self.bytes[offset + self.hasTA[n] + self.hasTB[n] + self.hasTC[n]]
+ self.TC[n] = self.bytes[offset +\
+ self.hasTA[n] +\
+ self.hasTB[n] +\
+ self.hasTC[n]]
if self.hasTD[n]:
- self.TD[n] = self.bytes[offset + self.hasTA[n] + self.hasTB[n] + self.hasTC[n] + self.hasTD[n]]
+ self.TD[n] = self.bytes[offset +\
+ self.hasTA[n] +\
+ self.hasTB[n] +\
+ self.hasTC[n] +\
+ self.hasTD[n]]
- self.interfaceBytesCount += self.hasTA[n] + self.hasTB[n] + self.hasTC[n] + self.hasTD[n]
+ self.interfaceBytesCount += self.hasTA[n] +\
+ self.hasTB[n] +\
+ self.hasTC[n] +\
+ self.hasTD[n]
TD = self.TD[n]
hasTD = self.hasTD[n]
- offset = offset + self.hasTA[n] + self.hasTB[n] + self.hasTC[n] + self.hasTD[n]
+ offset = offset + self.hasTA[n] + self.hasTB[n] +\
+ self.hasTC[n] + self.hasTD[n]
n = n + 1
# historical bytes
@@ -279,7 +290,8 @@
def __str__(self):
"""Returns a string representation of the ATR as a strem of bytes."""
- return reduce(lambda a, b: a + "%-0.2X " % ((b + 256) % 256), self.bytes, '')
+ return reduce(lambda a, b: a + \
+ "%-0.2X " % ((b + 256) % 256), self.bytes, '')
if __name__ == '__main__':
@@ -299,4 +311,5 @@
print 80 * '-'
print a
a.dump()
- print reduce(lambda a, b: a + "%-0.2X " % ((b + 256) % 256), a.getHistoricalBytes(), '')
+ print reduce(lambda a, b: a + \
+ "%-0.2X " % ((b + 256) % 256), a.getHistoricalBytes(), '')
Modified: trunk/pyscard/src/smartcard/AbstractCardRequest.py
===================================================================
--- trunk/pyscard/src/smartcard/AbstractCardRequest.py 2011-10-16 13:19:22 UTC (rev 561)
+++ trunk/pyscard/src/smartcard/AbstractCardRequest.py 2011-10-16 15:00:33 UTC (rev 562)
@@ -35,7 +35,8 @@
Known subclasses: smartcard.pcsc.PCSCCardRequest"""
- def __init__(self, newcardonly=False, readers=None, cardType=None, cardServiceClass=None, timeout=1):
+ def __init__(self, newcardonly=False, readers=None,
+ cardType=None, cardServiceClass=None, timeout=1):
"""Construct new CardRequest.
newcardonly: if True, request a new card; default is
Modified: trunk/pyscard/src/smartcard/Card.py
===================================================================
--- trunk/pyscard/src/smartcard/Card.py 2011-10-16 13:19:22 UTC (rev 561)
+++ trunk/pyscard/src/smartcard/Card.py 2011-10-16 15:00:33 UTC (rev 562)
@@ -46,7 +46,8 @@
"""Return True if self==other (same reader and same atr).
Return False otherwise."""
if isinstance(other, Card):
- return (self.atr == other.atr and repr(self.reader) == repr(other.reader))
+ return (self.atr == other.atr and
+ repr(self.reader) == repr(other.reader))
else:
return False
@@ -68,5 +69,6 @@
if readerobj:
return readerobj.createConnection()
else:
- #raise CardConnectionException('not a valid reader: ' + str(self.reader))
+ #raise CardConnectionException(
+ # 'not a valid reader: ' + str(self.reader))
return None
Modified: trunk/pyscard/src/smartcard/CardConnection.py
===================================================================
--- trunk/pyscard/src/smartcard/CardConnection.py 2011-10-16 13:19:22 UTC (rev 561)
+++ trunk/pyscard/src/smartcard/CardConnection.py 2011-10-16 15:00:33 UTC (rev 562)
@@ -48,7 +48,8 @@
Observable.__init__(self)
self.reader = reader
self.errorcheckingchain = None
- self.defaultprotocol = CardConnection.T0_protocol | CardConnection.T1_protocol
+ self.defaultprotocol = CardConnection.T0_protocol |\
+ CardConnection.T1_protocol
def __del__(self):
"""Connect to card."""
@@ -136,10 +137,16 @@
CardConnection.RAW_protocol
"""
Observable.setChanged(self)
- Observable.notifyObservers(self, CardConnectionEvent('command', [bytes, protocol]))
+ Observable.notifyObservers(self,
+ CardConnectionEvent(
+ 'command',
+ [bytes, protocol]))
data, sw1, sw2 = self.doTransmit(bytes, protocol)
Observable.setChanged(self)
- Observable.notifyObservers(self, CardConnectionEvent('response', [data, sw1, sw2]))
+ Observable.notifyObservers(self,
+ CardConnectionEvent(
+ 'response',
+ [data, sw1, sw2]))
if None != self.errorcheckingchain:
self.errorcheckingchain[0](data, sw1, sw2)
return data, sw1, sw2
@@ -161,10 +168,16 @@
bytes: list of bytes to transmit
"""
Observable.setChanged(self)
- Observable.notifyObservers(self, CardConnectionEvent('command', [controlCode, bytes]))
+ Observable.notifyObservers(self,
+ CardConnectionEvent(
+ 'command',
+ [controlCode, bytes]))
data = self.doControl(controlCode, bytes)
Observable.setChanged(self)
- Observable.notifyObservers(self, CardConnectionEvent('response', data))
+ Observable.notifyObservers(self,
+ CardConnectionEvent(
+ 'response',
+ data))
if None != self.errorcheckingchain:
self.errorcheckingchain[0](data)
return data
@@ -181,7 +194,10 @@
attribId: attribute id like SCARD_ATTR_VENDOR_NAME
"""
Observable.setChanged(self)
- Observable.notifyObservers(self, CardConnectionEvent('attrib', [attribId]))
+ Observable.notifyObservers(self,
+ CardConnectionEvent(
+ 'attrib',
+ [attribId]))
data = self.doGetAttrib(attribId)
if None != self.errorcheckingchain:
self.errorcheckingchain[0](data)
Modified: trunk/pyscard/src/smartcard/CardConnectionObserver.py
===================================================================
--- trunk/pyscard/src/smartcard/CardConnectionObserver.py 2011-10-16 13:19:22 UTC (rev 561)
+++ trunk/pyscard/src/smartcard/CardConnectionObserver.py 2011-10-16 15:00:33 UTC (rev 562)
@@ -62,4 +62,6 @@
if [] == ccevent.args[0]:
print '< [] ', "%-2X %-2X" % tuple(ccevent.args[-2:])
else:
- print '< ', toHexString(ccevent.args[0]), "%-2X %-2X" % tuple(ccevent.args[-2:])
+ print '< ', \
+ toHexString(ccevent.args[0]), \
+ "%-2X %-2X" % tuple(ccevent.args[-2:])
Modified: trunk/pyscard/src/smartcard/CardMonitoring.py
===================================================================
--- trunk/pyscard/src/smartcard/CardMonitoring.py 2011-10-16 13:19:22 UTC (rev 561)
+++ trunk/pyscard/src/smartcard/CardMonitoring.py 2011-10-16 15:00:33 UTC (rev 562)
@@ -173,7 +173,8 @@
if addedcards != [] or removedcards != []:
self.cards = currentcards
self.observable.setChanged()
- self.observable.notifyObservers((addedcards, removedcards))
+ self.observable.notifyObservers(
+ (addedcards, removedcards))
# when CardMonitoringThread.__del__() is invoked in
# response to shutdown, e.g., when execution of the
@@ -204,7 +205,8 @@
def __init__(self, observable):
if not CardMonitoringThread.instance:
- CardMonitoringThread.instance = CardMonitoringThread.__CardMonitoringThreadSingleton(observable)
+ CardMonitoringThread.instance = \
+ CardMonitoringThread.__CardMonitoringThreadSingleton(observable)
CardMonitoringThread.instance.start()
def __getattr__(self, name):
Modified: trunk/pyscard/src/smartcard/Examples/framework/sample_CardConnectionDecorator.py
===================================================================
--- trunk/pyscard/src/smartcard/Examples/framework/sample_CardConnectionDecorator.py 2011-10-16 13:19:22 UTC (rev 561)
+++ trunk/pyscard/src/smartcard/Examples/framework/sample_CardConnectionDecorator.py 2011-10-16 15:00:33 UTC (rev 562)
@@ -49,14 +49,16 @@
return bytes
def uncypher(self, data):
- '''Uncypher mock-up; you would include the secure channel logics here.'''
+ '''Uncypher mock-up;
+ you would include the secure channel logics here.'''
print 'uncyphering', toHexString(data)
return data
def transmit(self, bytes, protocol=None):
"""Cypher/uncypher APDUs before transmission"""
cypheredbytes = self.cypher(bytes)
- data, sw1, sw2 = CardConnectionDecorator.transmit(self, cypheredbytes, protocol)
+ data, sw1, sw2 = CardConnectionDecorator.transmit(
+ self, cypheredbytes, protocol)
if [] != data:
data = self.uncypher(data)
return data, sw1, sw2
@@ -91,7 +93,8 @@
cardservice.connection.addObserver(observer)
# attach our decorator
-cardservice.connection = FakeATRConnection(SecureChannelConnection(cardservice.connection))
+cardservice.connection = FakeATRConnection(
+ SecureChannelConnection(cardservice.connection))
# connect to the card and perform a few transmits
cardservice.connection.connect()
Modified: trunk/pyscard/src/smartcard/Examples/framework/sample_ExclusiveCardConnection.py
===================================================================
--- trunk/pyscard/src/smartcard/Examples/framework/sample_ExclusiveCardConnection.py 2011-10-16 13:19:22 UTC (rev 561)
+++ trunk/pyscard/src/smartcard/Examples/framework/sample_ExclusiveCardConnection.py 2011-10-16 15:00:33 UTC (rev 562)
@@ -29,8 +29,10 @@
from smartcard.CardConnection import CardConnection
from smartcard.util import toHexString
-from smartcard.ExclusiveConnectCardConnection import ExclusiveConnectCardConnection
-from smartcard.ExclusiveTransmitCardConnection import ExclusiveTransmitCardConnection
+from smartcard.ExclusiveConnectCardConnection import \
+ ExclusiveConnectCardConnection
+from smartcard.ExclusiveTransmitCardConnection import \
+ ExclusiveTransmitCardConnection
# define the apdus used in this script
@@ -48,7 +50,8 @@
cardservice.connection.addObserver(observer)
# attach our decorator
-cardservice.connection = ExclusiveTransmitCardConnection(ExclusiveConnectCardConnection(cardservice.connection))
+cardservice.connection = ExclusiveTransmitCardConnection(
+ ExclusiveConnectCardConnection(cardservice.connection))
# connect to the card and perform a few transmits
cardservice.connection.connect()
Modified: trunk/pyscard/src/smartcard/Examples/framework/sample_TransmitCardObserver.py
===================================================================
--- trunk/pyscard/src/smartcard/Examples/framework/sample_TransmitCardObserver.py 2011-10-16 13:19:22 UTC (rev 561)
+++ trunk/pyscard/src/smartcard/Examples/framework/sample_TransmitCardObserver.py 2011-10-16 15:00:33 UTC (rev 562)
@@ -1,6 +1,7 @@
#! /usr/bin/env python
"""
-Sample script that monitors card insertions, connects to cards and transmit an apdu
+Sample script that monitors card insertions,
+connects to cards and transmit an apdu
__author__ = "http://www.gemalto.com"
@@ -47,7 +48,8 @@
print "+Inserted: ", toHexString(card.atr)
card.connection = card.createConnection()
card.connection.connect()
- response, sw1, sw2 = card.connection.transmit(SELECT_DF_TELECOM)
+ response, sw1, sw2 = card.connection.transmit(
+ SELECT_DF_TELECOM)
print "%.2x %.2x" % (sw1, sw2)
for card in removedcards:
Modified: trunk/pyscard/src/smartcard/Examples/framework/sample_apduTracerInterpreter.py
===================================================================
--- trunk/pyscard/src/smartcard/Examples/framework/sample_apduTracerInterpreter.py 2011-10-16 13:19:22 UTC (rev 561)
+++ trunk/pyscard/src/smartcard/Examples/framework/sample_apduTracerInterpreter.py 2011-10-16 15:00:33 UTC (rev 562)
@@ -53,7 +53,9 @@
if [] == ccevent.args[0]:
print '< []', "%-2X %-2X" % tuple(ccevent.args[-2:])
else:
- print '<', toHexString(ccevent.args[0]), "%-2X %-2X" % tuple(ccevent.args[-2:])
+ print '<',
+ toHexString(ccevent.args[0]),
+ "%-2X %-2X" % tuple(ccevent.args[-2:])
# define the apdus used in this script
Modified: trunk/pyscard/src/smartcard/Examples/framework/sample_toHexString.py
===================================================================
--- trunk/pyscard/src/smartcard/Examples/framework/sample_toHexString.py 2011-10-16 13:19:22 UTC (rev 561)
+++ trunk/pyscard/src/smartcard/Examples/framework/sample_toHexString.py 2011-10-16 15:00:33 UTC (rev 562)
@@ -35,8 +35,10 @@
print 'toHexString(bytes, PACK) =', toHexString(bytes, PACK)
print 'toHexString(bytes, HEX) =', toHexString(bytes, HEX)
print 'toHexString(bytes, HEX | COMMA) =', toHexString(bytes, HEX | COMMA)
-print 'toHexString(bytes, HEX | UPPERCASE) =', toHexString(bytes, HEX | UPPERCASE)
-print 'toHexString(bytes, HEX | UPPERCASE | COMMA) =', toHexString(bytes, HEX | UPPERCASE | COMMA)
+print 'toHexString(bytes, HEX | UPPERCASE) =', \
+ toHexString(bytes, HEX | UPPERCASE)
+print 'toHexString(bytes, HEX | UPPERCASE | COMMA) =', \
+ toHexString(bytes, HEX | UPPERCASE | COMMA)
print 40 * '-'
@@ -47,8 +49,10 @@
print 'toHexString(bytes, PACK) =', toHexString(bytes, PACK)
print 'toHexString(bytes, HEX) =', toHexString(bytes, HEX)
print 'toHexString(bytes, HEX | COMMA) =', toHexString(bytes, HEX | COMMA)
-print 'toHexString(bytes, HEX | UPPERCASE) =', toHexString(bytes, HEX | UPPERCASE)
-print 'toHexString(bytes, HEX | UPPERCASE | COMMA) =', toHexString(bytes, HEX | UPPERCASE | COMMA)
+print 'toHexString(bytes, HEX | UPPERCASE) =', \
+ toHexString(bytes, HEX | UPPERCASE)
+print 'toHexString(bytes, HEX | UPPERCASE | COMMA) =', \
+ toHexString(bytes, HEX | UPPERCASE | COMMA)
import sys
Modified: trunk/pyscard/src/smartcard/Examples/scard-api/sample_control.py
===================================================================
--- trunk/pyscard/src/smartcard/Examples/scard-api/sample_control.py 2011-10-16 13:19:22 UTC (rev 561)
+++ trunk/pyscard/src/smartcard/Examples/scard-api/sample_control.py 2011-10-16 15:00:33 UTC (rev 562)
@@ -31,13 +31,15 @@
try:
hresult, hcontext = SCardEstablishContext(SCARD_SCOPE_USER)
if hresult != SCARD_S_SUCCESS:
- raise error('Failed to establish context: ' + SCardGetErrorMessage(hresult))
+ raise error(
+ 'Failed to establish context: ' + SCardGetErrorMessage(hresult))
print 'Context established!'
try:
hresult, readers = SCardListReaders(hcontext, [])
if hresult != SCARD_S_SUCCESS:
- raise error('Failed to list readers: ' + SCardGetErrorMessage(hresult))
+ raise error(
+ 'Failed to list readers: ' + SCardGetErrorMessage(hresult))
print 'PCSC Readers:', readers
if len(readers) < 1:
@@ -51,24 +53,36 @@
hresult, hcard, dwActiveProtocol = SCardConnect(
hcontext, zreader, SCARD_SHARE_DIRECT, SCARD_PROTOCOL_T0)
if hresult != SCARD_S_SUCCESS:
- raise error('Unable to connect: ' + SCardGetErrorMessage(hresult))
+ raise error(
+ 'Unable to connect: ' + SCardGetErrorMessage(hresult))
print 'Connected with active protocol', dwActiveProtocol
try:
if 'winscard' == resourceManager:
# IOCTL_SMARTCARD_GET_ATTRIBUTE = SCARD_CTL_CODE(2)
- hresult, response = SCardControl(hcard, SCARD_CTL_CODE(2), toBytes("%.8lx" % SCARD_ATTR_VENDOR_NAME))
+ hresult, response = SCardControl(
+ hcard,
+ SCARD_CTL_CODE(2),
+ toBytes("%.8lx" % SCARD_ATTR_VENDOR_NAME))
if hresult != SCARD_S_SUCCESS:
- raise error('SCardControl failed: ' + SCardGetErrorMessage(hresult))
+ raise error(
+ 'SCardControl failed: ' +\
+ SCardGetErrorMessage(hresult))
r = ""
for i in xrange(len(response)):
r += "%c" % response[i]
print 'SCARD_ATTR_VENDOR_NAME:', r
- elif 'pcsclite' == resourceManager and not 'pcsclite-tiger' == resourceManagerSubType:
+ elif 'pcsclite' == resourceManager and \
+ not 'pcsclite-tiger' == resourceManagerSubType:
# get firmware on Gemplus readers
- hresult, response = SCardControl(hcard, SCARD_CTL_CODE(1), [0x02])
+ hresult, response = SCardControl(
+ hcard,
+ SCARD_CTL_CODE(1),
+ [0x02])
if hresult != SCARD_S_SUCCESS:
- raise error('SCardControl failed: ' + SCardGetErrorMessage(hresult))
+ raise error(
+ 'SCardControl failed: ' + \
+ SCardGetErrorMessage(hresult))
r = ""
for i in xrange(len(response)):
r += "%c" % response[i]
@@ -76,7 +90,9 @@
finally:
hresult = SCardDisconnect(hcard, SCARD_UNPOWER_CARD)
if hresult != SCARD_S_SUCCESS:
- raise error('Failed to disconnect: ' + SCardGetErrorMessage(hresult))
+ raise error(
+ 'Failed to disconnect: ' + \
+ SCardGetErrorMessage(hresult))
print 'Disconnected'
except error, (message):
@@ -85,7 +101,9 @@
finally:
hresult = SCardReleaseContext(hcontext)
if hresult != SCARD_S_SUCCESS:
- raise error('Failed to release context: ' + SCardGetErrorMessage(hresult))
+ raise error(
+ 'Failed to release context: ' + \
+ SCardGetErrorMessage(hresult))
print 'Released context.'
except error, e:
Modified: trunk/pyscard/src/smartcard/Examples/scard-api/sample_getATR.py
===================================================================
--- trunk/pyscard/src/smartcard/Examples/scard-api/sample_getATR.py 2011-10-16 13:19:22 UTC (rev 561)
+++ trunk/pyscard/src/smartcard/Examples/scard-api/sample_getATR.py 2011-10-16 15:00:33 UTC (rev 562)
@@ -32,13 +32,17 @@
try:
hresult, hcontext = SCardEstablishContext(SCARD_SCOPE_USER)
if hresult != SCARD_S_SUCCESS:
- raise error('Failed to establish context: ' + SCardGetErrorMessage(hresult))
+ raise error(
+ 'Failed to establish context: ' + \
+ SCardGetErrorMessage(hresult))
print 'Context established!'
try:
hresult, readers = SCardListReaders(hcontext, [])
if hresult != SCARD_S_SUCCESS:
- raise error('Failed to list readers: ' + SCardGetErrorMessage(hresult))
+ raise error(
+ 'Failed to list readers: ' + \
+ SCardGetErrorMessage(hresult))
if len(readers) < 1:
raise Exception('No smart card readers')
print 'PCSC Readers:', readers
@@ -47,7 +51,9 @@
print 'Trying to retreive ATR of card in', reader
hresult, hcard, dwActiveProtocol = SCardConnect(
- hcontext, reader, SCARD_SHARE_SHARED, SCARD_PROTOCOL_T0 | SCARD_PROTOCOL_T1)
+ hcontext,
+ reader,
+ SCARD_SHARE_SHARED, SCARD_PROTOCOL_T0 | SCARD_PROTOCOL_T1)
if hresult != SCARD_S_SUCCESS:
print 'Unable to connect: ' + SCardGetErrorMessage(hresult)
else:
@@ -57,22 +63,27 @@
try:
hresult, reader, state, protocol, atr = SCardStatus(hcard)
if hresult != SCARD_S_SUCCESS:
- print 'failed to get status: ' + SCardGetErrorMessage(hresult)
+ print 'failed to get status: ' + \
+ SCardGetErrorMessage(hresult)
print 'Reader:', reader
print 'State:', hex(state)
print 'Protocol:', protocol
- print 'ATR:', smartcard.util.toHexString(atr, smartcard.util.HEX)
+ print 'ATR:', smartcard.util.toHexString(
+ atr,
+ smartcard.util.HEX)
finally:
hresult = SCardDisconnect(hcard, SCARD_UNPOWER_CARD)
if hresult != SCARD_S_SUCCESS:
- print 'Failed to disconnect: ' + SCardGetErrorMessage(hresult)
+ print 'Failed to disconnect: ' + \
+ SCardGetErrorMessage(hresult)
print 'Disconnected'
finally:
hresult = SCardReleaseContext(hcontext)
if hresult != SCARD_S_SUCCESS:
- raise error('Failed to release context: ' + SCardGetErrorMessage(hresult))
+ raise error('Failed to release context: ' + \
+ SCardGetErrorMessage(hresult))
print 'Released context.'
except Exception, e:
Modified: trunk/pyscard/src/smartcard/Examples/scard-api/sample_getAttrib.py
===================================================================
--- trunk/pyscard/src/smartcard/Examples/scard-api/sample_getAttrib.py 2011-10-16 13:19:22 UTC (rev 561)
+++ trunk/pyscard/src/smartcard/Examples/scard-api/sample_getAttrib.py 2011-10-16 15:00:33 UTC (rev 562)
@@ -71,7 +71,8 @@
SCARD_ATTR_POWER_MGMT_SUPPORT: 'SCARD_ATTR_POWER_MGMT_SUPPORT',
SCARD_ATTR_SUPRESS_T1_IFS_REQUEST: 'SCARD_ATTR_SUPRESS_T1_IFS_REQUEST',
SCARD_ATTR_USER_AUTH_INPUT_DEVICE: 'SCARD_ATTR_USER_AUTH_INPUT_DEVICE',
- SCARD_ATTR_USER_TO_CARD_AUTH_DEVICE: 'SCARD_ATTR_USER_TO_CARD_AUTH_DEVICE',
+ SCARD_ATTR_USER_TO_CARD_AUTH_DEVICE: \
+ 'SCARD_ATTR_USER_TO_CARD_AUTH_DEVICE',
SCARD_ATTR_VENDOR_IFD_SERIAL_NO: 'SCARD_ATTR_VENDOR_IFD_SERIAL_NO',
SCARD_ATTR_VENDOR_IFD_TYPE: 'SCARD_ATTR_VENDOR_IFD_TYPE',
SCARD_ATTR_VENDOR_IFD_VERSION: 'SCARD_ATTR_VENDOR_IFD_VERSION',
@@ -93,13 +94,17 @@
try:
hresult, hcontext = SCardEstablishContext(SCARD_SCOPE_USER)
if hresult != SCARD_S_SUCCESS:
- raise error('Failed to establish context: ' + SCardGetErrorMessage(hresult))
+ raise error(
+ 'Failed to establish context: ' + \
+ SCardGetErrorMessage(hresult))
print 'Context established!'
try:
hresult, readers = SCardListReaders(hcontext, [])
if hresult != SCARD_S_SUCCESS:
- raise error('Failed to list readers: ' + SCardGetErrorMessage(hresult))
+ raise error(
+ 'Failed to list readers: ' + \
+ SCardGetErrorMessage(hresult))
print 'PCSC Readers:', readers
if len(readers) < 1:
@@ -108,9 +113,12 @@
for reader in readers:
hresult, hcard, dwActiveProtocol = SCardConnect(
- hcontext, reader, SCARD_SHARE_SHARED, SCARD_PROTOCOL_T0 | SCARD_PROTOCOL_T1)
+ hcontext,
+ reader,
+ SCARD_SHARE_SHARED, SCARD_PROTOCOL_T0 | SCARD_PROTOCOL_T1)
if hresult != SCARD_S_SUCCESS:
- print error, 'Unable to connect: ' + SCardGetErrorMessage(hresult)
+ print error, \
+ 'Unable to connect: ' + SCardGetErrorMessage(hresult)
else:
print 'Connected with active protocol', dwActiveProtocol
@@ -121,19 +129,25 @@
if hresult == SCARD_S_SUCCESS:
printAttribute(i, attrib)
else:
- print '-----------------', attributes[i], '-----------------'
+ print '-----------------', \
+ attributes[i], \
+ '-----------------'
print 'unsupported'
finally:
hresult = SCardDisconnect(hcard, SCARD_UNPOWER_CARD)
if hresult != SCARD_S_SUCCESS:
- raise error('Failed to disconnect: ' + SCardGetErrorMessage(hresult))
+ raise error(
+ 'Failed to disconnect: ' + \
+ SCardGetErrorMessage(hresult))
print 'Disconnected'
finally:
hresult = SCardReleaseContext(hcontext)
if hresult != SCARD_S_SUCCESS:
- raise error('Failed to release context: ' + SCardGetErrorMessage(hresult))
+ raise error(
+ 'Failed to release context: ' + \
+ SCardGetErrorMessage(hresult))
print 'Released context.'
except Exception, e:
Modified: trunk/pyscard/src/smartcard/Examples/scard-api/sample_getStatusChange.py
===================================================================
--- trunk/pyscard/src/smartcard/Examples/scard-api/sample_getStatusChange.py 2011-10-16 13:19:22 UTC (rev 561)
+++ trunk/pyscard/src/smartcard/Examples/scard-api/sample_getStatusChange.py 2011-10-16 15:00:33 UTC (rev 562)
@@ -29,8 +29,10 @@
from smartcard.scard import *
import smartcard.util
-srTreeATR = [0x3B, 0x77, 0x94, 0x00, 0x00, 0x82, 0x30, 0x00, 0x13, 0x6C, 0x9F, 0x22]
-srTreeMask = [0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF]
+srTreeATR = \
+ [0x3B, 0x77, 0x94, 0x00, 0x00, 0x82, 0x30, 0x00, 0x13, 0x6C, 0x9F, 0x22]
+srTreeMask = \
+ [0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF]
def printstate(state):
@@ -63,13 +65,17 @@
try:
hresult, hcontext = SCardEstablishContext(SCARD_SCOPE_USER)
if hresult != SCARD_S_SUCCESS:
- raise error('Failed to establish context: ' + SCardGetErrorMessage(hresult))
+ raise error(
+ 'Failed to establish context: ' + \
+ SCardGetErrorMessage(hresult))
print 'Context established!'
try:
hresult, readers = SCardListReaders(hcontext, [])
if hresult != SCARD_S_SUCCESS:
- raise error('Failed to list readers: ' + SCardGetErrorMessage(hresult))
+ raise error(
+ 'Failed to list readers: ' + \
+ SCardGetErrorMessage(hresult))
print 'PCSC Readers:', readers
readerstates = []
@@ -82,7 +88,10 @@
printstate(i)
print '----- Please insert or remove a card ------------'
- hresult, newstates = SCardGetStatusChange(hcontext, INFINITE, newstates)
+ hresult, newstates = SCardGetStatusChange(
+ hcontext,
+ INFINITE,
+ newstates)
print '----- New reader and card states are: -----------'
for i in newstates:
@@ -91,7 +100,9 @@
finally:
hresult = SCardReleaseContext(hcontext)
if hresult != SCARD_S_SUCCESS:
- raise error('Failed to release context: ' + SCardGetErrorMessage(hresult))
+ raise error(
+ 'Failed to release context: ' + \
+ SCardGetErrorMessage(hresult))
print 'Released context.'
import sys
Modified: trunk/pyscard/src/smartcard/Examples/scard-api/sample_listCards.py
===================================================================
--- trunk/pyscard/src/smartcard/Examples/scard-api/sample_listCards.py 2011-10-16 13:19:22 UTC (rev 561)
+++ trunk/pyscard/src/smartcard/Examples/scard-api/sample_listCards.py 2011-10-16 15:00:33 UTC (rev 562)
@@ -30,22 +30,29 @@
if 'winscard' == resourceManager:
# Cryptoflex 8k v2 is introduced in standard Windows 2000
- slbCryptoFlex8kv2ATR = [0x3B, 0x95, 0x15, 0x40, 0x00, 0x68, 0x01, 0x02, 0x00, 0x00]
+ slbCryptoFlex8kv2ATR = \
+ [0x3B, 0x95, 0x15, 0x40, 0x00, 0x68, 0x01, 0x02, 0x00, 0x00]
try:
hresult, hcontext = SCardEstablishContext(SCARD_SCOPE_USER)
if hresult != SCARD_S_SUCCESS:
- raise error('Failed to establish context: ' + SCardGetErrorMessage(hresult))
+ raise error(
+ 'Failed to establish context: ' + \
+ SCardGetErrorMessage(hresult))
print 'Context established!'
try:
hresult, card = SCardListCards(hcontext, slbCryptoFlex8kv2ATR, [])
if hresult != SCARD_S_SUCCESS:
- raise error('Failure to locate Schlumberger Cryptoflex 8k v2 card: ' + SCardGetErrorMessage(hresult))
+ raise error(
+ 'Failure to locate Schlumberger Cryptoflex 8k v2 card: ' +\
+ SCardGetErrorMessage(hresult))
print 'Located by ATR:', card
hresult, cards = SCardListCards(hcontext, [], [])
if hresult != SCARD_S_SUCCESS:
- raise error('Failure to list cards: ' + SCardGetErrorMessage(hresult))
+ raise error(
+ 'Failure to list cards: ' + \
+ SCardGetErrorMessage(hresult))
print 'Cards:', cards
for i in cards:
@@ -61,7 +68,9 @@
finally:
hresult = SCardReleaseContext(hcontext)
if hresult != SCARD_S_SUCCESS:
- raise error('Failed to release context: ' + SCardGetErrorMessage(hresult))
+ raise error(
+ 'Failed to release context: ' + \
+ SCardGetErrorMessage(hresult))
print 'Released context.'
except error, e:
Modified: trunk/pyscard/src/smartcard/Examples/scard-api/sample_listInterfaces.py
===================================================================
--- trunk/pyscard/src/smartcard/Examples/scard-api/sample_listInterfaces.py 2011-10-16 13:19:22 UTC (rev 561)
+++ trunk/pyscard/src/smartcard/Examples/scard-api/sample_listInterfaces.py 2011-10-16 15:00:33 UTC (rev 562)
@@ -32,49 +32,73 @@
if 'winscard' == resourceManager:
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]
- znewcardPrimGuid = smartcard.guid.strToGUID('{128F3806-4F70-4ccf-977A-60C390664840}')
- znewcardSecGuid = smartcard.guid.strToGUID('{EB7F69EA-BA20-47d0-8C50-11CFDEB63BBE}')
+ 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]
+ znewcardPrimGuid = \
+ smartcard.guid.strToGUID('{128F3806-4F70-4ccf-977A-60C390664840}')
+ znewcardSecGuid = \
+ smartcard.guid.strToGUID('{EB7F69EA-BA20-47d0-8C50-11CFDEB63BBE}')
try:
hresult, hcontext = SCardEstablishContext(SCARD_SCOPE_USER)
if hresult != SCARD_S_SUCCESS:
- raise scard.error, 'Failed to establish context: ' + SCardGetErrorMessage(hresult)
+ raise scard.error(
+ 'Failed to establish context: ' + \
+ SCardGetErrorMessage(hresult))
print 'Context established!'
try:
# list interfaces for a known card
- hresult, interfaces = SCardListInterfaces(hcontext, 'Schlumberger Cryptoflex 8k v2')
+ hresult, interfaces = SCardListInterfaces(
+ hcontext,
+ 'Schlumberger Cryptoflex 8k v2')
if hresult != SCARD_S_SUCCESS:
- raise scard.error, 'Failed to list interfaces: ' + SCardGetErrorMessage(hresult)
+ raise scard.error(
+ 'Failed to list interfaces: ' + \
+ SCardGetErrorMessage(hresult))
print 'Interfaces for Schlumberger Cryptoflex 8k v2:', interfaces
# introduce a card (forget first in case it is already present)
hresult = SCardForgetCardType(hcontext, znewcardName)
print 'Introducing card ' + znewcardName
- hresult = SCardIntroduceCardType(hcontext, znewcardName, znewcardPrimGuid,
- znewcardPrimGuid + znewcardSecGuid, znewcardATR, znewcardMask)
+ hresult = SCardIntroduceCardType(
+ hcontext,
+ znewcardName,
+ znewcardPrimGuid,
+ znewcardPrimGuid + znewcardSecGuid,
+ znewcardATR,
+ znewcardMask)
if hresult != SCARD_S_SUCCESS:
- raise error('Failed to introduce card type: ' + SCardGetErrorMessage(hresult))
+ raise error(
+ 'Failed to introduce card type: ' + \
+ SCardGetErrorMessage(hresult))
# list card interfaces
hresult, interfaces = SCardListInterfaces(hcontext, znewcardName)
if hresult != SCARD_S_SUCCESS:
- raise error('Failed to list interfaces: ' + SCardGetErrorMessage(hresult))
+ raise error(
+ 'Failed to list interfaces: ' + \
+ SCardGetErrorMessage(hresult))
for i in interfaces:
- print 'Interface for ' + znewcardName + ' :', smartcard.guid.GUIDToStr(i)
+ print 'Interface for ' + znewcardName + ' :', \
+ smartcard.guid.GUIDToStr(i)
print 'Forgeting card ' + znewcardName
hresult = SCardForgetCardType(hcontext, znewcardName)
if hresult != SCARD_S_SUCCESS:
- raise error('Failed to remove card type: ' + SCardGetErrorMessage(hresult))
+ raise error(
+ 'Failed to remove card type: ' + \
+ SCardGetErrorMessage(hresult))
finally:
hresult2 = SCardReleaseContext(hcontext)
if hresult2 != SCARD_S_SUCCESS:
- raise error('Failed to release context: ' + SCardGetErrorMessage(hresult))
+ raise error(
+ 'Failed to release context: ' + \
+ SCardGetErrorMessage(hresult))
print 'Released context.'
except error:
Modified: trunk/pyscard/src/smartcard/Examples/scard-api/sample_locateCards.py
===================================================================
--- trunk/pyscard/src/smartcard/Examples/scard-api/sample_locateCards.py 2011-10-16 13:19:22 UTC (rev 561)
+++ trunk/pyscard/src/smartcard/Examples/scard-api/sample_locateCards.py 2011-10-16 15:00:33 UTC (rev 562)
@@ -31,19 +31,25 @@
if 'winscard' == resourceManager:
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]
+ 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]
try:
hresult, hcontext = SCardEstablishContext(SCARD_SCOPE_USER)
if hresult != SCARD_S_SUCCESS:
- raise scard.error, 'Failed to establish context: ' + SCardGetErrorMessage(hresult)
+ raise scard.error(
+ 'Failed to establish context: ' + \
+ SCardGetErrorMessage(hresult))
print 'Context established!'
try:
hresult, readers = SCardListReaders(hcontext, [])
if hresult != SCARD_S_SUCCESS:
- raise scard.error, 'Failed to list readers: ' + SCardGetErrorMessage(hresult)
+ raise scard.error(
+ 'Failed to list readers: ' + \
+ SCardGetErrorMessage(hresult))
print 'PCSC Readers:', readers
# introduce a card (forget first in case it is already present)
@@ -55,7 +61,9 @@
if hresult == ERROR_ALREADY_EXISTS:
print 'Card already exists'
else:
- raise error('Failed to introduce card type: ' + SCardGetErrorMessage(hresult))
+ raise error(
+ 'Failed to introduce card type: ' + \
+ SCardGetErrorMessage(hresult))
hresult, cards = SCardListCards(hcontext, [], [])
if hresult != SCARD_S_SUCCESS:
@@ -67,7 +75,10 @@
readerstates += [(readers[i], SCARD_STATE_UNAWARE)]
print readerstates
- hresult, newstates = SCardLocateCards(hcontext, cards, readerstates)
+ hresult, newstates = SCardLocateCards(
+ hcontext,
+ cards,
+ readerstates)
for i in newstates:
reader, eventstate, atr = i
print reader,
@@ -87,9 +98,9 @@
if eventstate & SCARD_STATE_PRESENT:
print 'Card present in reader'
if eventstate & SCARD_STATE_EXCLUSIVE:
- print 'Card allocated for exclusive use by another application'
+ print 'Card allocated for exclusive use'
if eventstate & SCARD_STATE_INUSE:
- print 'Card in used by another application but can be shared'
+ print 'Card in use but can be shared'
if eventstate & SCARD_STATE_MUTE:
print 'Card is mute'
if eventstate & SCARD_STATE_CHANGED:
@@ -101,7 +112,9 @@
hresult = SCardForgetCardType(hcontext, znewcardName)
hresult = SCardReleaseContext(hcontext)
if hresult != SCARD_S_SUCCESS:
- raise error('Failed to release context: ' + SCardGetErrorMessage(hresult))
+ raise error(
+ 'Failed to release context: ' + \
+ SCardGetErrorMessage(hresult))
print 'Released context.'
except error, e:
Modified: trunk/pyscard/src/smartcard/Examples/scard-api/sample_pinpad.py
===================================================================
--- trunk/pyscard/src/smartcard/Examples/scard-api/sample_pinpad.py 2011-10-16 13:19:22 UTC (rev 561)
+++ trunk/pyscard/src/smartcard/Examples/scard-api/sample_pinpad.py 2011-10-16 15:00:33 UTC (rev 562)
@@ -50,7 +50,10 @@
while len(response) > 0:
tag = response[0]
if feature == tag:
- return (((((response[2] << 8) + response[3]) << 8) + response[4]) << 8) + response[5]
+ return (((((response[2] << 8) + \
+ response[3]) << 8) + \
+ response[4]) << 8) + \
+ response[5]
response = response[6:]
@@ -109,7 +112,10 @@
try:
SELECT = [0x00, 0xA4, 0x04, 0x00, 0x06, 0xA0, 0x00,
0x00, 0x00, 0x18, 0xFF]
- hresult, response = SCardTransmit(hcard, dwActiveProtocol, SELECT)
+ hresult, response = SCardTransmit(
+ hcard,
+ dwActiveProtocol,
+ SELECT)
if hresult != SCARD_S_SUCCESS:
raise BaseSCardException(hresult)
Modified: trunk/pyscard/src/smartcard/Examples/scard-api/sample_readerGroups.py
===================================================================
--- trunk/pyscard/src/smartcard/Examples/scard-api/sample_readerGroups.py 2011-10-16 13:19:22 UTC (rev 561)
+++ trunk/pyscard/src/smartcard/Examples/scard-api/sample_readerGroups.py 2011-10-16 15:00:33 UTC (rev 562)
@@ -33,82 +33,120 @@
try:
hresult, hcontext = SCardEstablishContext(SCARD_SCOPE_USER)
if hresult != SCARD_S_SUCCESS:
- raise error('Failed to establish context: ' + SCardGetErrorMessage(hresult))
+ raise error(
+ 'Failed to establish context: ' + \
+ SCardGetErrorMessage(hresult))
print 'Context established!'
try:
hresult, readers = SCardListReaders(hcontext, [])
if hresult != SCARD_S_SUCCESS:
- raise error('Failed to list readers: ' + SCardGetErrorMessage(hresult))
+ raise error(
+ 'Failed to list readers: ' + \
+ SCardGetErrorMessage(hresult))
print 'PCSC Readers in all groups:', readers
hresult, readerGroups = SCardListReaderGroups(hcontext)
if hresult != SCARD_S_SUCCESS:
- raise error('Unable to list reader groups: ' + SCardGetErrorMessage(hresult))
+ raise error(
+ 'Unable to list reader groups: ' + \
+ SCardGetErrorMessage(hresult))
print 'PCSC Reader groups:', readerGroups
if 'winscard' == resourceManager:
hresult = SCardIntroduceReaderGroup(hcontext, newgroup)
if hresult != SCARD_S_SUCCESS:
- raise error('Unable to introduce reader group: ' + SCardGetErrorMessage(hresult))
+ raise error(
+ 'Unable to introduce reader group: ' + \
+ SCardGetErrorMessage(hresult))
dummyreader = readers[0] + ' dummy'
hresult = SCardIntroduceReader(hcontext, dummyreader, readers[0])
if hresult != SCARD_S_SUCCESS:
- raise error('Unable to introduce reader: ' + dummyreader + ' : ' + SCardGetErrorMessage(hresult))
+ raise error(
+ 'Unable to introduce reader: ' + \
+ dummyreader + ' : ' + \
+ SCardGetErrorMessage(hresult))
hresult, readers = SCardListReaders(hcontext, [])
if hresult != SCARD_S_SUCCESS:
- raise error('Failed to list readers: ' + SCardGetErrorMessage(hresult))
+ raise error(
+ 'Failed to list readers: ' + \
+ SCardGetErrorMessage(hresult))
print 'PCSC Readers in all groups:', readers
hresult = SCardAddReaderToGroup(hcontext, dummyreader, newgroup)
if hresult != SCARD_S_SUCCESS:
- raise error('Unable to add reader to group: ' + SCardGetErrorMessage(hresult))
+ raise error(
+ 'Unable to add reader to group: ' + \
+ SCardGetErrorMessage(hresult))
hresult, readerGroups = SCardListReaderGroups(hcontext)
if hresult != SCARD_S_SUCCESS:
- raise error('Unable to list reader groups: ' + SCardGetErrorMessage(hresult))
+ raise error(
+ 'Unable to list reader groups: ' + \
+ SCardGetErrorMessage(hresult))
print 'PCSC Reader groups:', readerGroups
hresult, readers = SCardListReaders(hcontext, [newgroup])
if hresult != SCARD_S_SUCCESS:
- raise error('Failed to list readers in group ' + newgroup + ' : ' + SCardGetErrorMessage(hresult))
+ raise error(
+ 'Failed to list readers in group ' + \
+ newgroup + ' : ' + \
+ SCardGetErrorMessage(hresult))
print 'PCSC Readers in reader group', newgroup, ':', readers
- hresult = SCardRemoveReaderFromGroup(hcontext, dummyreader, newgroup)
+ hresult = SCardRemoveReaderFromGroup(
+ hcontext,
+ dummyreader,
+ newgroup)
if hresult != SCARD_S_SUCCESS:
- raise error('Unable to remove reader from group: ' + SCardGetErrorMessage(hresult))
+ raise error(
+ 'Unable to remove reader from group: ' + \
+ SCardGetErrorMessage(hresult))
hresult, readerGroups = SCardListReaderGroups(hcontext)
if hresult != SCARD_S_SUCCESS:
- raise error('Unable to list reader groups: ' + SCardGetErrorMessage(hresult))
+ raise error(
+ 'Unable to list reader groups: ' + \
+ SCardGetErrorMessage(hresult))
print 'PCSC Reader groups:', readerGroups
hresult = SCardForgetReaderGroup(hcontext, newgroup)
if hresult != SCARD_S_SUCCESS:
- raise error('Unable to forget reader group: ' + SCardGetErrorMessage(hresult))
+ raise error(
+ 'Unable to forget reader group: ' + \
+ SCardGetErrorMessage(hresult))
hresult = SCardForgetReader(hcontext, dummyreader)
if hresult != SCARD_S_SUCCESS:
- raise error('Failed to forget readers ' + SCardGetErrorMessage(hresult))
+ raise error(
+ 'Failed to forget readers ' + \
+ SCardGetErrorMessage(hresult))
hresult, readers = SCardListReaders(hcontext, [])
if hresult != SCARD_S_SUCCESS:
- raise error('Failed to list readers: ' + SCardGetErrorMessage(hresult))
+ raise error(
+ 'Failed to list readers: ' + \
+ SCardGetErrorMessage(hresult))
print 'PCSC Readers in all groups:', readers
elif 'pcsclite' == resourceManager:
hresult, readers = SCardListReaders(hcontext, readerGroups)
if hresult != SCARD_S_SUCCESS:
- raise error('Failed to list readers in groups ' + repr(readerGroups) + ' : ' + SCardGetErrorMessage(hresult))
+ raise error(
+ 'Failed to list readers in groups ' + \
+ repr(readerGroups) + ' : ' + \
+ SCardGetErrorMessage(hresult))
print 'PCSC Readers in reader group', readerGroups, ':', readers
finally:
hresult = SCardReleaseContext(hcontext)
if hresult != SCARD_S_SUCCESS:
- raise error('Failed to release context: ' + SCardGetErrorMessage(hresult))
+ raise error(
+ 'Failed to release context: ' + \
+ SCardGetErrorMessage(hresult))
print 'Released context.'
import sys
Modified: trunk/pyscard/src/smartcard/Examples/scard-api/sample_readers.py
===================================================================
--- trunk/pyscard/src/smartcard/Examples/scard-api/sample_readers.py 2011-10-16 13:19:22 UTC (rev 561)
+++ trunk/pyscard/src/smartcard/Examples/scard-api/sample_readers.py 2011-10-16 15:00:33 UTC (rev 562)
@@ -31,24 +31,32 @@
try:
hresult, hcontext = SCardEstablishContext(SCARD_SCOPE_USER)
if hresult != SCARD_S_SUCCESS:
- raise error('Failed to establish context: ' + SCardGetErrorMessage(hresult))
+ raise error(
+ 'Failed to establish context: ' + \
+ SCardGetErrorMessage(hresult))
print 'Context established!'
try:
hresult, readers = SCardListReaders(hcontext, [])
if hresult != SCARD_S_SUCCESS:
- raise error('Failed to list readers: ' + SCardGetErrorMessage(hresult))
+ raise error(
+ 'Failed to list readers: ' + \
+ SCardGetErrorMessage(hresult))
print 'PCSC Readers:', readers
hresult, readerGroups = SCardListReaderGroups(hcontext)
if hresult != SCARD_S_SUCCESS:
- raise error('Unable to list reader groups: ' + SCardGetErrorMessage(hresult))
+ raise error(
+ 'Unable to list reader groups: ' + \
+ SCardGetErrorMessage(hresult))
print 'PCSC Reader groups:', readerGroups
finally:
hresult = SCardReleaseContext(hcontext)
if hresult != SCARD_S_SUCCESS:
- raise error('Failed to release context: ' + SCardGetErrorMessage(hresult))
+ raise error(
+ 'Failed to release context: ' + \
+ SCardGetErrorMessage(hresult))
print 'Released context.'
import sys
Modified: trunk/pys...
[truncated message content] |