Change in pysim[master]: pySim-read: put try/catch block around select_adf_by_aid()

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

dexter gerrit-no-reply at lists.osmocom.org
Mon Nov 15 16:30:17 UTC 2021


dexter has uploaded this change for review. ( https://gerrit.osmocom.org/c/pysim/+/26253 )


Change subject: pySim-read: put try/catch block around select_adf_by_aid()
......................................................................

pySim-read: put try/catch block around select_adf_by_aid()

Selecting an application may fail, especially when the application does
not exist on the card.

Change-Id: Ia904a74d672cf9551fb4ee062dd606b350b64cef
---
M pySim-read.py
1 file changed, 10 insertions(+), 6 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/pysim refs/changes/53/26253/1

diff --git a/pySim-read.py b/pySim-read.py
index 00194b4..0c09dac 100755
--- a/pySim-read.py
+++ b/pySim-read.py
@@ -219,7 +219,11 @@
 
 	# Check whether we have th AID of USIM, if so select it by its AID
 	# EF.UST - File Id in ADF USIM : 6f38
-	data, sw = card.select_adf_by_aid(adf="usim")
+	try:
+		sw = 0
+		data, sw = card.select_adf_by_aid(adf="usim")
+	except Exception as e:
+		print("ADF.USIM: Can't select application -- " + str(e))
 	if sw == '9000':
 		# Select USIM profile
 		usim_card = UsimCard(scc)
@@ -269,7 +273,11 @@
 			print("ePDGSelection: Can't read file -- " + str(e))
 
 	# Select ISIM application by its AID
-	data, sw = card.select_adf_by_aid(adf="isim")
+	try:
+		sw = 0
+		data, sw = card.select_adf_by_aid(adf="isim")
+	except Exception as e:
+		print("ADF.ISIM: Can't select application -- " + str(e))
 	if sw == '9000':
 		# Select USIM profile
 		isim_card = IsimCard(scc)
@@ -320,10 +328,6 @@
 		except Exception as e:
 			print("UICC IARI: Can't read file -- " + str(e))
 
-	# Check whether we have th AID of ISIM, if so select it by its AID
-	# EF.IST - File Id in ADF ISIM : 6f07
-	data, sw = card.select_adf_by_aid(adf="isim")
-	if sw == '9000':
 		# EF.IST
 		(res, sw) = card.read_binary('6f07')
 		if sw == '9000':

-- 
To view, visit https://gerrit.osmocom.org/c/pysim/+/26253
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: pysim
Gerrit-Branch: master
Gerrit-Change-Id: Ia904a74d672cf9551fb4ee062dd606b350b64cef
Gerrit-Change-Number: 26253
Gerrit-PatchSet: 1
Gerrit-Owner: dexter <pmaier at sysmocom.de>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20211115/d8492c0d/attachment.htm>


More information about the gerrit-log mailing list