[Pcsclite-cvs-commit] r7096 - trunk/PCSC/UnitaryTests
ludovic.rousseau at free.fr
ludovic.rousseau at free.fr
Tue Feb 24 15:12:10 UTC 2015
Author: rousseau
Date: 2015-02-24 15:12:10 +0000 (Tue, 24 Feb 2015)
New Revision: 7096
Modified:
trunk/PCSC/UnitaryTests/control_get_firmware.py
Log:
Check PCSCv2_PART10_PROPERTY_wIdVendor is returned
Some drivers do not return a value for PCSCv2_PART10_PROPERTY_wIdVendor.
We must check the value exist before using it.
Use "key in dict" instead of try/except to know a key is defined.
Modified: trunk/PCSC/UnitaryTests/control_get_firmware.py
===================================================================
--- trunk/PCSC/UnitaryTests/control_get_firmware.py 2015-02-20 17:35:53 UTC (rev 7095)
+++ trunk/PCSC/UnitaryTests/control_get_firmware.py 2015-02-24 15:12:10 UTC (rev 7096)
@@ -33,16 +33,21 @@
properties = getTlvProperties(cardConnection)
# Gemalto devices supports a control code to get firmware
- if properties['PCSCv2_PART10_PROPERTY_wIdVendor'] == 0x08E6:
- get_firmware = [0x02]
- IOCTL_SMARTCARD_VENDOR_IFD_EXCHANGE = SCARD_CTL_CODE(1)
- res = cardConnection.control(IOCTL_SMARTCARD_VENDOR_IFD_EXCHANGE,
- get_firmware)
- print " Firmware:", "".join([chr(x) for x in res])
+ key = 'PCSCv2_PART10_PROPERTY_wIdVendor'
+ if key in properties:
+ if properties[key] == 0x08E6:
+ get_firmware = [0x02]
+ IOCTL_SMARTCARD_VENDOR_IFD_EXCHANGE = SCARD_CTL_CODE(1)
+ res = cardConnection.control(IOCTL_SMARTCARD_VENDOR_IFD_EXCHANGE,
+ get_firmware)
+ print " Firmware:", "".join([chr(x) for x in res])
+ else:
+ print " Not a Gemalto reader"
+ key = 'PCSCv2_PART10_PROPERTY_sFirmwareID'
+ if key in properties:
+ firmware = properties[key]
+ print " Firmware:", firmware
+ else:
+ print " %s not supported" % key
else:
- print " Not a Gemalto reader"
- try:
- firmware = properties['PCSCv2_PART10_PROPERTY_sFirmwareID']
- print " Firmware:", firmware
- except KeyError:
- print " PCSCv2_PART10_PROPERTY_sFirmwareID not supported"
+ print " %s not supported" % key
More information about the Pcsclite-cvs-commit
mailing list