Change in pysim[master]: pySim-shell: catch exceptions from walk() while exporting
dexter has uploaded this change for review. ( https://gerrit.osmocom.org/c/pysim/+/28162 ) Change subject: pySim-shell: catch exceptions from walk() while exporting ...................................................................... pySim-shell: catch exceptions from walk() while exporting When we run the exporter we also get an error summary at the end. However, if walk() throws an eception this stops the exporter immediately and we won't get the summpary. Lets catch exceptions from walk as well so that we are able to end gracefully. Change-Id: I3edc250ef2a84550c5b821a72e207e4d685790a5 --- M pySim-shell.py 1 file changed, 12 insertions(+), 5 deletions(-) git pull ssh://gerrit.osmocom.org:29418/pysim refs/changes/62/28162/1 diff --git a/pySim-shell.py b/pySim-shell.py index 8c6db2f..49c794f 100755 --- a/pySim-shell.py +++ b/pySim-shell.py @@ -669,10 +669,17 @@ context = {'ERR': 0, 'COUNT': 0, 'BAD': [], 'DF_SKIP': 0, 'DF_SKIP_REASON': []} opts_export = {'JSON': opts.json, 'CREATE': opts.create} + exception_str_add = "" + if opts.filename: self.export_ef(opts.filename, context, opts_export) else: - self.walk(0, self.export_ef, self.export_df, context, opts_export) + try: + self.walk(0, self.export_ef, self.export_df, context, opts_export) + except Exception as e: + print("# Stopping early here due to exception: " + str(e)) + print("#") + exception_str_add = ", also had to stop early due to exception:" + str(e) self._cmd.poutput(boxed_heading_str("Export summary")) @@ -687,14 +694,14 @@ self._cmd.poutput("# " + b) if context['ERR'] and context['DF_SKIP']: - raise RuntimeError("unable to export %i elementary file(s) and %i dedicated file(s)" % ( - context['ERR'], context['DF_SKIP'])) + raise RuntimeError("unable to export %i elementary file(s) and %i dedicated file(s)%s" % ( + context['ERR'], context['DF_SKIP'], exception_str_add)) elif context['ERR']: raise RuntimeError( - "unable to export %i elementary file(s)" % context['ERR']) + "unable to export %i elementary file(s)%s" % (context['ERR'], exception_str_add)) elif context['DF_SKIP']: raise RuntimeError( - "unable to export %i dedicated files(s)" % context['ERR']) + "unable to export %i dedicated files(s)%s" % (context['ERR'], exception_str_add)) def do_reset(self, opts): """Reset the Card.""" -- To view, visit https://gerrit.osmocom.org/c/pysim/+/28162 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: pysim Gerrit-Branch: master Gerrit-Change-Id: I3edc250ef2a84550c5b821a72e207e4d685790a5 Gerrit-Change-Number: 28162 Gerrit-PatchSet: 1 Gerrit-Owner: dexter <pmaier@sysmocom.de> Gerrit-MessageType: newchange
participants (1)
-
dexter