dexter has uploaded this change for review. ( 
https://gerrit.osmocom.org/c/pysim/+/34697?usp=email )


Change subject: transport: do not catch exceptions in init_reader
......................................................................

transport: do not catch exceptions in init_reader

We currently catch any exceptions that may occur when the card reader is
initialized. Then we print the exception string or the exception type
when no string is available. However, a failure during the reader
initialization is usually a severe problem, so a traceback would provde
a lot of helpful information to debug the issue. So lets not catch any
exceptions at this level so that we get the full backtrace.

Related: OS#6210
Change-Id: I4c4807576fe63cf71a7d33b243a3f8fea0b7ff23
---
M pySim/transport/__init__.py
1 file changed, 36 insertions(+), 27 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/pysim refs/changes/97/34697/1

diff --git a/pySim/transport/__init__.py b/pySim/transport/__init__.py
index 0b50a4f..3e62668 100644
--- a/pySim/transport/__init__.py
+++ b/pySim/transport/__init__.py
@@ -297,30 +297,22 @@
     Init card reader driver
     """
     sl = None  # type : :Optional[LinkBase]
-    try:
-        if opts.pcsc_dev is not None:
-            print("Using PC/SC reader interface")
-            from pySim.transport.pcsc import PcscSimLink
-            sl = PcscSimLink(opts.pcsc_dev, **kwargs)
-        elif opts.osmocon_sock is not None:
-            print("Using Calypso-based (OsmocomBB) reader interface")
-            from pySim.transport.calypso import CalypsoSimLink
-            sl = CalypsoSimLink(sock_path=opts.osmocon_sock, **kwargs)
-        elif opts.modem_dev is not None:
-            print("Using modem for Generic SIM Access (3GPP TS 27.007)")
-            from pySim.transport.modem_atcmd import ModemATCommandLink
-            sl = ModemATCommandLink(
-                device=opts.modem_dev, baudrate=opts.modem_baud, **kwargs)
-        else:  # Serial reader is default
-            print("Using serial reader interface")
-            from pySim.transport.serial import SerialSimLink
-            sl = SerialSimLink(device=opts.device,
-                               baudrate=opts.baudrate, **kwargs)
-        return sl
-    except Exception as e:
-        if str(e):
-            print("Card reader initialization failed with exception:\n" + 
str(e))
-        else:
-            print(
-                "Card reader initialization failed with an exception of 
type:\n" + str(type(e)))
-        return None
+    if opts.pcsc_dev is not None:
+        print("Using PC/SC reader interface")
+        from pySim.transport.pcsc import PcscSimLink
+        sl = PcscSimLink(opts.pcsc_dev, **kwargs)
+    elif opts.osmocon_sock is not None:
+        print("Using Calypso-based (OsmocomBB) reader interface")
+        from pySim.transport.calypso import CalypsoSimLink
+        sl = CalypsoSimLink(sock_path=opts.osmocon_sock, **kwargs)
+    elif opts.modem_dev is not None:
+        print("Using modem for Generic SIM Access (3GPP TS 27.007)")
+        from pySim.transport.modem_atcmd import ModemATCommandLink
+        sl = ModemATCommandLink(
+             device=opts.modem_dev, baudrate=opts.modem_baud, **kwargs)
+    else:  # Serial reader is default
+        print("Using serial reader interface")
+        from pySim.transport.serial import SerialSimLink
+        sl = SerialSimLink(device=opts.device,
+                           baudrate=opts.baudrate, **kwargs)
+    return sl

--
To view, visit https://gerrit.osmocom.org/c/pysim/+/34697?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: I4c4807576fe63cf71a7d33b243a3f8fea0b7ff23
Gerrit-Change-Number: 34697
Gerrit-PatchSet: 1
Gerrit-Owner: dexter <pma...@sysmocom.de>
Gerrit-MessageType: newchange

Reply via email to