dexter has uploaded this change for review.

View Change

transport: show full traceback on failed reader init

When the reader initialization failes with an exception we may have a
major hardware problem and it may not be enough to print only the
exception message. Also in some rare cases an exception message may not
be available. To make it easier to debug problems lets print the full
traceback like we already do it in pySim-shell.py.

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

git pull ssh://gerrit.osmocom.org:29418/pysim refs/changes/87/34687/1
diff --git a/pySim/transport/__init__.py b/pySim/transport/__init__.py
index 79f82c2..6bce674 100644
--- a/pySim/transport/__init__.py
+++ b/pySim/transport/__init__.py
@@ -5,6 +5,7 @@

import abc
import argparse
+import traceback
from typing import Optional, Tuple
from construct import Construct

@@ -293,6 +294,7 @@
Init card reader driver
"""
sl = None # type : :Optional[LinkBase]
+
try:
if opts.pcsc_dev is not None:
print("Using PC/SC reader number %u" % opts.pcsc_dev)
@@ -314,9 +316,8 @@
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)))
+ print("Card reader initialization failed with an exception:")
+ print("---------------------8<---------------------")
+ traceback.print_exc()
+ print("---------------------8<---------------------")
return None

To view, visit change 34687. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: pysim
Gerrit-Branch: master
Gerrit-Change-Id: I46e913a516dbc13f7610512484f515ab25d3fbae
Gerrit-Change-Number: 34687
Gerrit-PatchSet: 1
Gerrit-Owner: dexter <pmaier@sysmocom.de>
Gerrit-MessageType: newchange