lists.osmocom.org
Sign In Sign Up
Manage this list Sign In Sign Up

Keyboard Shortcuts

Thread View

  • j: Next unread message
  • k: Previous unread message
  • j a: Jump to all threads
  • j l: Jump to MailingList overview

gerrit-log

Thread Start a new thread
Download
Threads by month
  • ----- 2026 -----
  • November
  • October
  • September
  • August
  • July
  • June
  • May
  • April
  • March
  • February
  • January
  • ----- 2025 -----
  • December
  • November
  • October
  • September
  • August
  • July
  • June
  • May
  • April
  • March
  • February
  • January
  • ----- 2024 -----
  • December
  • November
  • October
  • September
  • August
  • July
  • June
  • May
  • April
  • March
  • February
  • January
  • ----- 2023 -----
  • December
  • November
  • October
  • September
  • August
  • July
  • June
  • May
  • April
  • March
  • February
  • January
  • ----- 2022 -----
  • December
  • November
  • October
  • September
  • August
  • July
  • June
  • May
  • April
  • March
  • February
  • January
gerrit-log@lists.osmocom.org

October 2023

  • 1 participants
  • 1843 discussions
[M] Change in pysim[master]: transport: do not catch exceptions in init_reader
by dexter 10 Oct '23

10 Oct '23
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 <pmaier(a)sysmocom.de> Gerrit-MessageType: newchange
1 0
0 0
[S] Change in pysim[master]: transport: add return type annotation to method __str__
by dexter 10 Oct '23

10 Oct '23
dexter has uploaded this change for review. ( https://gerrit.osmocom.org/c/pysim/+/34696?usp=email ) Change subject: transport: add return type annotation to method __str__ ...................................................................... transport: add return type annotation to method __str__ The abstract class LinkBase has no return type annotation on its __str__ method. Related: OS#6210 Change-Id: I26d3d2714708dbe957704b60d17ba2afa325b2c4 --- M pySim/transport/__init__.py M pySim/transport/calypso.py M pySim/transport/modem_atcmd.py M pySim/transport/pcsc.py M pySim/transport/serial.py 5 files changed, 18 insertions(+), 5 deletions(-) git pull ssh://gerrit.osmocom.org:29418/pysim refs/changes/96/34696/1 diff --git a/pySim/transport/__init__.py b/pySim/transport/__init__.py index 1dd8d18..0b50a4f 100644 --- a/pySim/transport/__init__.py +++ b/pySim/transport/__init__.py @@ -68,7 +68,7 @@ self.proactive_handler = proactive_handler @abc.abstractmethod - def __str__(self): + def __str__(self) -> str: """Implementation specific method for printing an information to identify the device.""" @abc.abstractmethod diff --git a/pySim/transport/calypso.py b/pySim/transport/calypso.py index b827d88..d7d9649 100644 --- a/pySim/transport/calypso.py +++ b/pySim/transport/calypso.py @@ -160,5 +160,5 @@ return b2h(data), b2h(sw) - def __str__(self): + def __str__(self) -> str: return "osmocon:%s" % (self._sock_path) diff --git a/pySim/transport/modem_atcmd.py b/pySim/transport/modem_atcmd.py index 58d6f9d..5e5a3dd 100644 --- a/pySim/transport/modem_atcmd.py +++ b/pySim/transport/modem_atcmd.py @@ -170,5 +170,5 @@ log.debug('Command response: %s, %s', data, sw) return data, sw - def __str__(self): + def __str__(self) -> str: return "modem:%s" % self._device diff --git a/pySim/transport/pcsc.py b/pySim/transport/pcsc.py index 41c4c19..c7b5878 100644 --- a/pySim/transport/pcsc.py +++ b/pySim/transport/pcsc.py @@ -93,5 +93,5 @@ # Return value return i2h(data), i2h(sw) - def __str__(self): + def __str__(self) -> str: return "PCSC:%u[%s]" % (self._reader_number, self._reader) diff --git a/pySim/transport/serial.py b/pySim/transport/serial.py index f4b1621..e5f7bdb 100644 --- a/pySim/transport/serial.py +++ b/pySim/transport/serial.py @@ -237,5 +237,5 @@ # Return value return b2h(data), b2h(sw) - def __str__(self): + def __str__(self) -> str: return "serial:%s" % (self._sl.name) -- To view, visit https://gerrit.osmocom.org/c/pysim/+/34696?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: I26d3d2714708dbe957704b60d17ba2afa325b2c4 Gerrit-Change-Number: 34696 Gerrit-PatchSet: 1 Gerrit-Owner: dexter <pmaier(a)sysmocom.de> Gerrit-MessageType: newchange
1 0
0 0
[S] Change in pysim[master]: transport: print device path/number on initialization failure
by dexter 10 Oct '23

10 Oct '23
Attention is currently required from: fixeria, laforge. dexter has posted comments on this change. ( https://gerrit.osmocom.org/c/pysim/+/34693?usp=email ) Change subject: transport: print device path/number on initialization failure ...................................................................... Patch Set 6: (1 comment) File pySim/transport/__init__.py: https://gerrit.osmocom.org/c/pysim/+/34693/comment/cf2808bc_d753c987 PS4, Line 330: devinfo = "serial:%s" % opts.device > I don't think that common code should contain clauses for each specific backend. […] Ack -- To view, visit https://gerrit.osmocom.org/c/pysim/+/34693?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: I3f5387508ccc2aa349adc7aec3d04d8fc977690b Gerrit-Change-Number: 34693 Gerrit-PatchSet: 6 Gerrit-Owner: dexter <pmaier(a)sysmocom.de> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: laforge <laforge(a)osmocom.org> Gerrit-Reviewer: osmith <osmith(a)sysmocom.de> Gerrit-CC: fixeria <vyanitskiy(a)sysmocom.de> Gerrit-Attention: laforge <laforge(a)osmocom.org> Gerrit-Attention: fixeria <vyanitskiy(a)sysmocom.de> Gerrit-Comment-Date: Tue, 10 Oct 2023 10:06:13 +0000 Gerrit-HasComments: Yes Gerrit-Has-Labels: No Comment-In-Reply-To: laforge <laforge(a)osmocom.org> Gerrit-MessageType: comment
1 0
0 0
[S] Change in pysim[master]: pySim-shell: print device info in case an exception occurs
by dexter 10 Oct '23

10 Oct '23
dexter has submitted this change. ( https://gerrit.osmocom.org/c/pysim/+/34692?usp=email ) ( 4 is the latest approved patch-set. No files were changed between the latest approved patch-set and the submitted one. )Change subject: pySim-shell: print device info in case an exception occurs ...................................................................... pySim-shell: print device info in case an exception occurs When an exception occurs while initializing or handling the card we print a traceback, but we do not print any info that allows us to identify the device that was involved when the exception occurred. Let's include the device path or number in the error message before we print the traceback. In order to make it easier to print the device information, let's add a __str__() method to all of our devices. This method shall return the device number or path. Related: OS#6210 Change-Id: I200463e692245da40ea6d5b609bfc0ca02d15bdb --- M pySim-shell.py M pySim-trace.py M pySim/transport/__init__.py M pySim/transport/calypso.py M pySim/transport/modem_atcmd.py M pySim/transport/pcsc.py M pySim/transport/serial.py 7 files changed, 46 insertions(+), 3 deletions(-) Approvals: osmith: Looks good to me, but someone else must approve laforge: Looks good to me, but someone else must approve Jenkins Builder: Verified fixeria: Looks good to me, approved diff --git a/pySim-shell.py b/pySim-shell.py index 79b4d8b..56655ba 100755 --- a/pySim-shell.py +++ b/pySim-shell.py @@ -374,7 +374,7 @@ rc = self.equip(card, rs) except: self.poutput("") - self.poutput("Card initialization failed with an exception:") + self.poutput("Card initialization (%s) failed with an exception:" % str(self.sl)) self.poutput("---------------------8<---------------------") traceback.print_exc() self.poutput("---------------------8<---------------------") @@ -489,7 +489,7 @@ return except: self.poutput("") - self.poutput("Card handling failed with an exception:") + self.poutput("Card handling (%s) failed with an exception:" % str(self.sl)) self.poutput("---------------------8<---------------------") traceback.print_exc() self.poutput("---------------------8<---------------------") @@ -1031,7 +1031,7 @@ rs, card = init_card(sl) app = PysimApp(card, rs, sl, ch, opts.script) except: - print("Card initialization failed with an exception:") + print("Card initialization (%s) failed with an exception:" % str(sl)) print("---------------------8<---------------------") traceback.print_exc() print("---------------------8<---------------------") diff --git a/pySim-trace.py b/pySim-trace.py index 325fb8c..eb29ed1 100755 --- a/pySim-trace.py +++ b/pySim-trace.py @@ -48,6 +48,9 @@ self._debug = debug self._atr = h2i('3B9F96801F878031E073FE211B674A4C753034054BA9') + def __str__(self): + return "dummy" + def _send_apdu_raw(self, pdu): #print("DummySimLink-apdu: %s" % pdu) return [], '9000' diff --git a/pySim/transport/__init__.py b/pySim/transport/__init__.py index c8079f6..1dd8d18 100644 --- a/pySim/transport/__init__.py +++ b/pySim/transport/__init__.py @@ -68,6 +68,10 @@ self.proactive_handler = proactive_handler @abc.abstractmethod + def __str__(self): + """Implementation specific method for printing an information to identify the device.""" + + @abc.abstractmethod def _send_apdu_raw(self, pdu: Hexstr) -> ResTuple: """Implementation specific method for sending the PDU.""" diff --git a/pySim/transport/calypso.py b/pySim/transport/calypso.py index 34fc646..b827d88 100644 --- a/pySim/transport/calypso.py +++ b/pySim/transport/calypso.py @@ -90,6 +90,9 @@ self.sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) self.sock.connect(sock_path) + # Remember socket path + self._sock_path = sock_path + def __del__(self): self.sock.close() @@ -156,3 +159,6 @@ sw = rsp[-2:] return b2h(data), b2h(sw) + + def __str__(self): + return "osmocon:%s" % (self._sock_path) diff --git a/pySim/transport/modem_atcmd.py b/pySim/transport/modem_atcmd.py index e99762d..58d6f9d 100644 --- a/pySim/transport/modem_atcmd.py +++ b/pySim/transport/modem_atcmd.py @@ -169,3 +169,6 @@ sw = rsp_pdu[-4:].decode().lower() log.debug('Command response: %s, %s', data, sw) return data, sw + + def __str__(self): + return "modem:%s" % self._device diff --git a/pySim/transport/pcsc.py b/pySim/transport/pcsc.py index a01917f..41c4c19 100644 --- a/pySim/transport/pcsc.py +++ b/pySim/transport/pcsc.py @@ -39,6 +39,7 @@ raise ReaderError('No reader found for number %d' % reader_number) self._reader = r[reader_number] self._con = self._reader.createConnection() + self._reader_number = reader_number def __del__(self): try: @@ -91,3 +92,6 @@ # Return value return i2h(data), i2h(sw) + + def __str__(self): + return "PCSC:%u[%s]" % (self._reader_number, self._reader) diff --git a/pySim/transport/serial.py b/pySim/transport/serial.py index 998d1d8..f4b1621 100644 --- a/pySim/transport/serial.py +++ b/pySim/transport/serial.py @@ -236,3 +236,6 @@ # Return value return b2h(data), b2h(sw) + + def __str__(self): + return "serial:%s" % (self._sl.name) -- To view, visit https://gerrit.osmocom.org/c/pysim/+/34692?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: I200463e692245da40ea6d5b609bfc0ca02d15bdb Gerrit-Change-Number: 34692 Gerrit-PatchSet: 6 Gerrit-Owner: dexter <pmaier(a)sysmocom.de> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: dexter <pmaier(a)sysmocom.de> Gerrit-Reviewer: fixeria <vyanitskiy(a)sysmocom.de> Gerrit-Reviewer: laforge <laforge(a)osmocom.org> Gerrit-Reviewer: osmith <osmith(a)sysmocom.de> Gerrit-MessageType: merged
1 0
0 0
[S] Change in pysim[master]: transport: show full traceback on failed reader init
by dexter 10 Oct '23

10 Oct '23
Attention is currently required from: fixeria, laforge, osmith. dexter has posted comments on this change. ( https://gerrit.osmocom.org/c/pysim/+/34687?usp=email ) Change subject: transport: show full traceback on failed reader init ...................................................................... Patch Set 6: (1 comment) Commit Message: https://gerrit.osmocom.org/c/pysim/+/34687/comment/c4fdd4c7_b92988cd PS4, Line 9: failes > fails? Done -- To view, visit https://gerrit.osmocom.org/c/pysim/+/34687?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: I46e913a516dbc13f7610512484f515ab25d3fbae Gerrit-Change-Number: 34687 Gerrit-PatchSet: 6 Gerrit-Owner: dexter <pmaier(a)sysmocom.de> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: laforge <laforge(a)osmocom.org> Gerrit-Reviewer: osmith <osmith(a)sysmocom.de> Gerrit-CC: fixeria <vyanitskiy(a)sysmocom.de> Gerrit-Attention: osmith <osmith(a)sysmocom.de> Gerrit-Attention: laforge <laforge(a)osmocom.org> Gerrit-Attention: fixeria <vyanitskiy(a)sysmocom.de> Gerrit-Comment-Date: Tue, 10 Oct 2023 09:51:30 +0000 Gerrit-HasComments: Yes Gerrit-Has-Labels: No Comment-In-Reply-To: fixeria <vyanitskiy(a)sysmocom.de> Gerrit-MessageType: comment
1 0
0 0
[S] Change in pysim[master]: pySim-shell: print device info in case an exception occurs
by dexter 10 Oct '23

10 Oct '23
Attention is currently required from: dexter. Hello Jenkins Builder, fixeria, laforge, osmith, I'd like you to reexamine a change. Please visit https://gerrit.osmocom.org/c/pysim/+/34692?usp=email to look at the new patch set (#6). The following approvals got outdated and were removed: Verified+1 by Jenkins Builder The change is no longer submittable: Verified is unsatisfied now. Change subject: pySim-shell: print device info in case an exception occurs ...................................................................... pySim-shell: print device info in case an exception occurs When an exception occurs while initializing or handling the card we print a traceback, but we do not print any info that allows us to identify the device that was involved when the exception occurred. Let's include the device path or number in the error message before we print the traceback. In order to make it easier to print the device information, let's add a __str__() method to all of our devices. This method shall return the device number or path. Related: OS#6210 Change-Id: I200463e692245da40ea6d5b609bfc0ca02d15bdb --- M pySim-shell.py M pySim-trace.py M pySim/transport/__init__.py M pySim/transport/calypso.py M pySim/transport/modem_atcmd.py M pySim/transport/pcsc.py M pySim/transport/serial.py 7 files changed, 46 insertions(+), 3 deletions(-) git pull ssh://gerrit.osmocom.org:29418/pysim refs/changes/92/34692/6 -- To view, visit https://gerrit.osmocom.org/c/pysim/+/34692?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: I200463e692245da40ea6d5b609bfc0ca02d15bdb Gerrit-Change-Number: 34692 Gerrit-PatchSet: 6 Gerrit-Owner: dexter <pmaier(a)sysmocom.de> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: fixeria <vyanitskiy(a)sysmocom.de> Gerrit-Reviewer: laforge <laforge(a)osmocom.org> Gerrit-Reviewer: osmith <osmith(a)sysmocom.de> Gerrit-Attention: dexter <pmaier(a)sysmocom.de> Gerrit-MessageType: newpatchset
1 0
0 0
[S] Change in pysim[master]: pySim-shell: do not pass failed card object to PysimApp
by dexter 10 Oct '23

10 Oct '23
dexter has submitted this change. ( https://gerrit.osmocom.org/c/pysim/+/34691?usp=email ) ( 1 is the latest approved patch-set. No files were changed between the latest approved patch-set and the submitted one. )Change subject: pySim-shell: do not pass failed card object to PysimApp ...................................................................... pySim-shell: do not pass failed card object to PysimApp When the try block in which we also call init_card() fails, there may be no card object, so we must not pass the card object to PysimApp in the except block. This is also no problem, PysimApp will run without the card object until the user executes do_equip for a second attempt. Related: OS#6210 Change-Id: I28195f442ce007f05f7610c882bbc4a6520a8ce6 --- M pySim-shell.py 1 file changed, 16 insertions(+), 1 deletion(-) Approvals: laforge: Looks good to me, approved fixeria: Looks good to me, approved Jenkins Builder: Verified osmith: Looks good to me, but someone else must approve diff --git a/pySim-shell.py b/pySim-shell.py index 3b6945c..79b4d8b 100755 --- a/pySim-shell.py +++ b/pySim-shell.py @@ -1040,7 +1040,7 @@ " it should also be noted that some readers may behave strangely when no card") print(" is inserted.)") print("") - app = PysimApp(card, None, sl, ch, opts.script) + app = PysimApp(None, None, sl, ch, opts.script) # If the user supplies an ADM PIN at via commandline args authenticate # immediately so that the user does not have to use the shell commands -- To view, visit https://gerrit.osmocom.org/c/pysim/+/34691?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: I28195f442ce007f05f7610c882bbc4a6520a8ce6 Gerrit-Change-Number: 34691 Gerrit-PatchSet: 2 Gerrit-Owner: dexter <pmaier(a)sysmocom.de> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: dexter <pmaier(a)sysmocom.de> Gerrit-Reviewer: fixeria <vyanitskiy(a)sysmocom.de> Gerrit-Reviewer: laforge <laforge(a)osmocom.org> Gerrit-Reviewer: osmith <osmith(a)sysmocom.de> Gerrit-MessageType: merged
1 0
0 0
[S] Change in pysim[master]: pySim-shell: do not pass failed card object to PysimApp
by dexter 10 Oct '23

10 Oct '23
Attention is currently required from: dexter. Hello Jenkins Builder, fixeria, laforge, osmith, I'd like you to reexamine a change. Please visit https://gerrit.osmocom.org/c/pysim/+/34691?usp=email to look at the new patch set (#2). The following approvals got outdated and were removed: Verified+1 by Jenkins Builder The change is no longer submittable: Verified is unsatisfied now. Change subject: pySim-shell: do not pass failed card object to PysimApp ...................................................................... pySim-shell: do not pass failed card object to PysimApp When the try block in which we also call init_card() fails, there may be no card object, so we must not pass the card object to PysimApp in the except block. This is also no problem, PysimApp will run without the card object until the user executes do_equip for a second attempt. Related: OS#6210 Change-Id: I28195f442ce007f05f7610c882bbc4a6520a8ce6 --- M pySim-shell.py 1 file changed, 16 insertions(+), 1 deletion(-) git pull ssh://gerrit.osmocom.org:29418/pysim refs/changes/91/34691/2 -- To view, visit https://gerrit.osmocom.org/c/pysim/+/34691?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: I28195f442ce007f05f7610c882bbc4a6520a8ce6 Gerrit-Change-Number: 34691 Gerrit-PatchSet: 2 Gerrit-Owner: dexter <pmaier(a)sysmocom.de> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: fixeria <vyanitskiy(a)sysmocom.de> Gerrit-Reviewer: laforge <laforge(a)osmocom.org> Gerrit-Reviewer: osmith <osmith(a)sysmocom.de> Gerrit-Attention: dexter <pmaier(a)sysmocom.de> Gerrit-MessageType: newpatchset
1 0
0 0
[S] Change in pysim[master]: transport: show full traceback on failed reader init
by dexter 10 Oct '23

10 Oct '23
Attention is currently required from: dexter, laforge, osmith. Hello Jenkins Builder, laforge, osmith, I'd like you to reexamine a change. Please visit https://gerrit.osmocom.org/c/pysim/+/34687?usp=email to look at the new patch set (#5). The following approvals got outdated and were removed: Code-Review+1 by osmith, Verified+1 by Jenkins Builder Change subject: transport: show full traceback on failed reader init ...................................................................... transport: show full traceback on failed reader init When the reader initialization fails 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/5 -- To view, visit https://gerrit.osmocom.org/c/pysim/+/34687?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: I46e913a516dbc13f7610512484f515ab25d3fbae Gerrit-Change-Number: 34687 Gerrit-PatchSet: 5 Gerrit-Owner: dexter <pmaier(a)sysmocom.de> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: laforge <laforge(a)osmocom.org> Gerrit-Reviewer: osmith <osmith(a)sysmocom.de> Gerrit-CC: fixeria <vyanitskiy(a)sysmocom.de> Gerrit-Attention: osmith <osmith(a)sysmocom.de> Gerrit-Attention: laforge <laforge(a)osmocom.org> Gerrit-Attention: dexter <pmaier(a)sysmocom.de> Gerrit-MessageType: newpatchset
1 0
0 0
[M] Change in pysim[master]: pySim-prog, pySim-shell do not use global variables
by dexter 10 Oct '23

10 Oct '23
dexter has submitted this change. ( https://gerrit.osmocom.org/c/pysim/+/34688?usp=email ) Change subject: pySim-prog, pySim-shell do not use global variables ...................................................................... pySim-prog, pySim-shell do not use global variables When __main__ runs different variables get assigned. In particular opts, scc, sl and ch. Those variables are available in any scope and technically it is possible to access them. However, lets not do this since it leads to confusion. Also, pylint will complain about those code locations. In pySim-shell.py - Let's use the proper locations (sl and ch are stored in PysimApp. - Scc can be assigned in init_card. - In method walk, the use of the variable opts to call ection_df is wrong, lets use **kwargs (see also usage of action_ef). - The constructor of Cmd2ApduTracer has a parameter cmd2_app, but usese the global variable app. Let's use cmd2_app instead. In pySim-prog.py - Do not use opts.num in find_row_in_csv_file, use num instead. - Pass scc to process_card as parameter so that it won't access scc in the global scope. Change-Id: I7f09e9a6a6bfc658de75e86f7383ce73726f6666 Related: OS#6210 --- M pySim-prog.py M pySim-shell.py 2 files changed, 41 insertions(+), 12 deletions(-) Approvals: laforge: Looks good to me, approved Jenkins Builder: Verified fixeria: Looks good to me, but someone else must approve osmith: Looks good to me, but someone else must approve diff --git a/pySim-prog.py b/pySim-prog.py index c07bfd1..a16928c 100755 --- a/pySim-prog.py +++ b/pySim-prog.py @@ -567,7 +567,7 @@ for row in cr: # Pick a specific row by line number (num) if num is not None and iccid is None and imsi is None: - if opts.num == i: + if num == i: f.close() return row @@ -727,7 +727,7 @@ fh.close() -def process_card(opts, first, ch): +def process_card(scc, opts, first, ch): # Connect transport ch.get(first) @@ -821,7 +821,7 @@ while 1: try: - rc = process_card(opts, first, ch) + rc = process_card(scc, opts, first, ch) except (KeyboardInterrupt): print("") print("Terminated by user!") diff --git a/pySim-shell.py b/pySim-shell.py index c7b2607..3b6945c 100755 --- a/pySim-shell.py +++ b/pySim-shell.py @@ -88,6 +88,9 @@ state object (rs) is required for all pySim-shell commands. """ + # Create command layer + scc = SimCardCommands(transport=sl) + # Wait up to three seconds for a card in reader and try to detect # the card type. print("Waiting for card...") @@ -276,7 +279,7 @@ class Cmd2ApduTracer(ApduTracer): def __init__(self, cmd2_app): - self.cmd2 = app + self.cmd2 = cmd2_app def trace_response(self, cmd, sw, resp): self.cmd2.poutput("-> %s %s" % (cmd[:10], cmd[10:])) @@ -307,7 +310,7 @@ if self.rs and self.rs.profile: for cmd_set in self.rs.profile.shell_cmdsets: self.unregister_command_set(cmd_set) - rs, card = init_card(sl) + rs, card = init_card(self.sl) self.equip(card, rs) apdu_cmd_parser = argparse.ArgumentParser() @@ -440,7 +443,7 @@ # In case of failure, try multiple times. for i in range(opts.tries): # fetch card into reader bay - ch.get(first) + self.ch.get(first) # if necessary execute an action before we start processing the card if(opts.pre_card_action): @@ -463,9 +466,9 @@ # Depending on success or failure, the card goes either in the "error" bin or in the # "done" bin. if rc < 0: - ch.error() + self.ch.error() else: - ch.done() + self.ch.done() # In most cases it is possible to proceed with the next card, but the # user may decide to halt immediately when an error occurs @@ -559,7 +562,7 @@ if isinstance(self._cmd.lchan.selected_file, CardDF): if action_df: - action_df(context, opts) + action_df(context, **kwargs) files = self._cmd.lchan.selected_file.get_selectables( flags=['FNAMES', 'ANAMES']) @@ -1015,9 +1018,6 @@ if sl is None: exit(1) - # Create command layer - scc = SimCardCommands(transport=sl) - # Create a card handler (for bulk provisioning) if opts.card_handler_config: ch = CardHandlerAuto(None, opts.card_handler_config) -- To view, visit https://gerrit.osmocom.org/c/pysim/+/34688?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: I7f09e9a6a6bfc658de75e86f7383ce73726f6666 Gerrit-Change-Number: 34688 Gerrit-PatchSet: 7 Gerrit-Owner: dexter <pmaier(a)sysmocom.de> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: dexter <pmaier(a)sysmocom.de> Gerrit-Reviewer: fixeria <vyanitskiy(a)sysmocom.de> Gerrit-Reviewer: laforge <laforge(a)osmocom.org> Gerrit-Reviewer: osmith <osmith(a)sysmocom.de> Gerrit-MessageType: merged
1 0
0 0
  • ← Newer
  • 1
  • ...
  • 129
  • 130
  • 131
  • 132
  • 133
  • 134
  • 135
  • ...
  • 185
  • Older →

HyperKitty Powered by HyperKitty version 1.3.12.