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


Change subject: _match_applications: catch SwMatchError e.g. if permission 
denied
......................................................................

_match_applications: catch SwMatchError e.g. if permission denied

There are some SIM cards (e.g. those of sipgate), which return
an undefined error status word if one tries to select some of the
applications the card itself lists in EF.DIR.  Let's handle this
situation gracefully rather than printing python exceptions.

Change-Id: Id03a44c84cc8939908bc15f9fe42a9955d58c643
Closes: OS#5409
---
M pySim/filesystem.py
1 file changed, 7 insertions(+), 4 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/pysim refs/changes/61/26961/1

diff --git a/pySim/filesystem.py b/pySim/filesystem.py
index dfe1677..785108c 100644
--- a/pySim/filesystem.py
+++ b/pySim/filesystem.py
@@ -1113,10 +1113,13 @@
         # Some card applications may not be registered in EF.DIR, we will 
actively
         # probe for those applications
         for f in set(apps_profile) - set(apps_taken):
-            data, sw = self.card.select_adf_by_aid(f.aid)
-            if sw == "9000":
-                print(" %s: %s" % (f.name, f.aid))
-                apps_taken.append(f)
+            try:
+                data, sw = self.card.select_adf_by_aid(f.aid)
+                if sw == "9000":
+                    print(" %s: %s" % (f.name, f.aid))
+                    apps_taken.append(f)
+            except SwMatchError as e:
+                print(" ERROR: %s: %s: Unable to select: %s" % (f.name, f.aid, 
e))
 
         return apps_taken


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

Gerrit-Project: pysim
Gerrit-Branch: master
Gerrit-Change-Id: Id03a44c84cc8939908bc15f9fe42a9955d58c643
Gerrit-Change-Number: 26961
Gerrit-PatchSet: 1
Gerrit-Owner: laforge <[email protected]>
Gerrit-MessageType: newchange

Reply via email to