Change in pysim[master]: filesystem: allow dumping multiple records of a file

laforge gerrit-no-reply at lists.osmocom.org
Fri Mar 19 07:12:04 UTC 2021


laforge has submitted this change. ( https://gerrit.osmocom.org/c/pysim/+/23206 )

Change subject: filesystem: allow dumping multiple records of a file
......................................................................

filesystem: allow dumping multiple records of a file

At the moment we can only request pySim-shell to dump a specific record
of a file. However, it may be useful to dump multiple records of a
record oriented file at once.

Change-Id: Id62db2cba4e3dfb6a7b3e6be8b892c16d11a8e3e
Related: OS#4963
---
M pySim/filesystem.py
1 file changed, 10 insertions(+), 3 deletions(-)

Approvals:
  Jenkins Builder: Verified
  laforge: Looks good to me, approved



diff --git a/pySim/filesystem.py b/pySim/filesystem.py
index 73401d6..664c722 100644
--- a/pySim/filesystem.py
+++ b/pySim/filesystem.py
@@ -378,11 +378,18 @@
 
         read_rec_parser = argparse.ArgumentParser()
         read_rec_parser.add_argument('record_nr', type=int, help='Number of record to be read')
+        read_rec_parser.add_argument('--count', type=int, default=1, help='Number of records to be read, beginning at record_nr')
         @cmd2.with_argparser(read_rec_parser)
         def do_read_record(self, opts):
-            """Read a record from a record-oriented EF"""
-            (data, sw) = self._cmd.rs.read_record(opts.record_nr)
-            self._cmd.poutput(data)
+            """Read one or multiple records from a record-oriented EF"""
+            for r in range(opts.count):
+                recnr = opts.record_nr + r
+                (data, sw) = self._cmd.rs.read_record(recnr)
+                if (len(data) > 0):
+                   recstr = str(data)
+                else:
+                   recstr = "(empty)"
+                self._cmd.poutput("%03d %s" % (recnr, recstr))
 
         read_rec_dec_parser = argparse.ArgumentParser()
         read_rec_dec_parser.add_argument('record_nr', type=int, help='Number of record to be read')

-- 
To view, visit https://gerrit.osmocom.org/c/pysim/+/23206
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: pysim
Gerrit-Branch: master
Gerrit-Change-Id: Id62db2cba4e3dfb6a7b3e6be8b892c16d11a8e3e
Gerrit-Change-Number: 23206
Gerrit-PatchSet: 6
Gerrit-Owner: laforge <laforge at osmocom.org>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge <laforge at osmocom.org>
Gerrit-CC: dexter <pmaier at sysmocom.de>
Gerrit-CC: fixeria <vyanitskiy at sysmocom.de>
Gerrit-MessageType: merged
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20210319/ec14f08d/attachment.htm>


More information about the gerrit-log mailing list