[S] Change in pysim[master]: app: do not catch exceptions in init_card
laforge has submitted this change. ( https://gerrit.osmocom.org/c/pysim/+/35101?usp=email ) Change subject: app: do not catch exceptions in init_card ...................................................................... app: do not catch exceptions in init_card The function init_card catches all exceptions and then returns None objects for card or rs in case of an error. This does not fit in the style we pursue in pySim. This is in particular true for library functions. We want those functions to raise exceptions when something is wrong, so that we can catch the exception at top level. Let's fix this for init_card now. Related: OS#6271 Change-Id: I581125d8273ef024f6dbf3a5db6116be15c5c95d --- M pySim/app.py 1 file changed, 22 insertions(+), 8 deletions(-) Approvals: Jenkins Builder: Verified laforge: Looks good to me, approved pespin: Looks good to me, but someone else must approve fixeria: Looks good to me, but someone else must approve diff --git a/pySim/app.py b/pySim/app.py index 1711a1c..b0df85f 100644 --- a/pySim/app.py +++ b/pySim/app.py @@ -55,14 +55,7 @@ # Wait up to three seconds for a card in reader and try to detect # the card type. print("Waiting for card...") - try: - sl.wait_for_card(3) - except NoCardError: - print("No card detected!") - return None, None - except: - print("Card not readable!") - return None, None + sl.wait_for_card(3) generic_card = False card = card_detect(scc) @@ -73,6 +66,10 @@ profile = CardProfile.pick(scc) if profile is None: + # It is not an unrecoverable error in case profile detection fails. It + # just means that pySim was unable to recognize the card profile. This + # may happen in particular with unprovisioned cards that do not have + # any files on them yet. print("Unsupported card type!") return None, card -- To view, visit https://gerrit.osmocom.org/c/pysim/+/35101?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: pysim Gerrit-Branch: master Gerrit-Change-Id: I581125d8273ef024f6dbf3a5db6116be15c5c95d Gerrit-Change-Number: 35101 Gerrit-PatchSet: 2 Gerrit-Owner: dexter <pmaier@sysmocom.de> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: fixeria <vyanitskiy@sysmocom.de> Gerrit-Reviewer: laforge <laforge@osmocom.org> Gerrit-Reviewer: pespin <pespin@sysmocom.de> Gerrit-MessageType: merged
participants (1)
-
laforge