This is merely a historical archive of years 2008-2021, before the migration to mailman3.
A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.
laforge gerrit-no-reply at lists.osmocom.orglaforge has submitted this change. ( https://gerrit.osmocom.org/c/pysim/+/23803 )
Change subject: pySim-shell: separate export summary with a headline
......................................................................
pySim-shell: separate export summary with a headline
the export summary is printed after the log entry for the last file
without separation. This is confusing because it looks like if the
summary would refer to the last file only. Lets add a headline to make
clear that the last few lines are the "Export summary"
Change-Id: I90771e525b2b114bdb41a8e90d298ca991c09c3d
Related: OS#4963
---
M pySim-shell.py
M pySim/utils.py
2 files changed, 18 insertions(+), 5 deletions(-)
Approvals:
Jenkins Builder: Verified
laforge: Looks good to me, approved
diff --git a/pySim-shell.py b/pySim-shell.py
index a8db263..d622128 100755
--- a/pySim-shell.py
+++ b/pySim-shell.py
@@ -39,7 +39,7 @@
from pySim.transport import init_reader, ApduTracer
from pySim.cards import card_detect, Card
from pySim.utils import h2b, swap_nibbles, rpad, h2s, JsonEncoder
-from pySim.utils import dec_st, sanitize_pin_adm, tabulate_str_list, is_hex
+from pySim.utils import dec_st, sanitize_pin_adm, tabulate_str_list, is_hex, boxed_heading_str
from pySim.card_handler import card_handler
from pySim.filesystem import CardMF, RuntimeState, CardDF, CardADF
@@ -237,10 +237,8 @@
df_path_list = df.fully_qualified_path(True)
df_path_list_fid = df.fully_qualified_path(False)
- self._cmd.poutput("#" * 80)
- file_str = '/'.join(df_path_list) + "/" + str(filename) + " " * 80
- self._cmd.poutput("# " + file_str[0:77] + "#")
- self._cmd.poutput("#" * 80)
+ file_str = '/'.join(df_path_list) + "/" + str(filename)
+ self._cmd.poutput(boxed_heading_str(file_str))
self._cmd.poutput("# directory: %s (%s)" % ('/'.join(df_path_list), '/'.join(df_path_list_fid)))
try:
@@ -288,6 +286,9 @@
self.export(opts.filename, context)
else:
self.walk(0, self.export, context)
+
+ self._cmd.poutput(boxed_heading_str("Export summary"))
+
self._cmd.poutput("# total files visited: %u" % context['COUNT'])
self._cmd.poutput("# bad files: %u" % context['ERR'])
for b in context['BAD']:
diff --git a/pySim/utils.py b/pySim/utils.py
index a0da03a..2da93a5 100644
--- a/pySim/utils.py
+++ b/pySim/utils.py
@@ -841,3 +841,15 @@
if isinstance(o, BytesIO) or isinstance(o, bytes) or isinstance(o, bytearray):
return b2h(o)
return json.JSONEncoder.default(self, o)
+
+def boxed_heading_str(heading, width=80):
+ """Generate a string that contains a boxed heading."""
+ # Auto-enlarge box if heading exceeds length
+ if len(heading) > width - 4:
+ width = len(heading) + 4
+
+ res = "#" * width
+ fstr = "\n# %-" + str(width - 4) + "s #\n"
+ res += fstr % (heading)
+ res += "#" * width
+ return res
--
To view, visit https://gerrit.osmocom.org/c/pysim/+/23803
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: pysim
Gerrit-Branch: master
Gerrit-Change-Id: I90771e525b2b114bdb41a8e90d298ca991c09c3d
Gerrit-Change-Number: 23803
Gerrit-PatchSet: 2
Gerrit-Owner: dexter <pmaier at sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: daniel <dwillmann at sysmocom.de>
Gerrit-Reviewer: laforge <laforge at osmocom.org>
Gerrit-MessageType: merged
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20210421/c3c6862b/attachment.htm>