Change in pysim[master]: filesystem: avoid outputting empty lines when there is no data

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/.

dexter gerrit-no-reply at lists.osmocom.org
Tue Mar 30 10:06:12 UTC 2021


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

Change subject: filesystem: avoid outputting empty lines when there is no data
......................................................................

filesystem: avoid outputting empty lines when there is no data

The do_update_... functions do always print the returned data. However,
there may be no data. If this is the case than an empty line is printed.
This may cause ugly log output, especially when working with scripts.

Change-Id: Ia9715d46ec957544cfbeea98d2fe15eb74f5b884
Related: OS#4963
---
M pySim/filesystem.py
1 file changed, 8 insertions(+), 4 deletions(-)

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



diff --git a/pySim/filesystem.py b/pySim/filesystem.py
index 04fa250..cb39b94 100644
--- a/pySim/filesystem.py
+++ b/pySim/filesystem.py
@@ -313,7 +313,8 @@
         def do_update_binary(self, opts):
             """Update (Write) data of a transparent EF"""
             (data, sw) = self._cmd.rs.update_binary(opts.data, opts.offset)
-            self._cmd.poutput(data)
+            if data:
+                self._cmd.poutput(data)
 
         upd_bin_dec_parser = argparse.ArgumentParser()
         upd_bin_dec_parser.add_argument('data', help='Abstract data (JSON format) to write')
@@ -322,7 +323,8 @@
             """Encode + Update (Write) data of a transparent EF"""
             data_json = json.loads(opts.data)
             (data, sw) = self._cmd.rs.update_binary_dec(data_json)
-            self._cmd.poutput(json.dumps(data, indent=4))
+            if data:
+                self._cmd.poutput(json.dumps(data, indent=4))
 
     def __init__(self, fid, sfid=None, name=None, desc=None, parent=None, size={1,None}):
         super().__init__(fid=fid, sfid=sfid, name=name, desc=desc, parent=parent)
@@ -410,7 +412,8 @@
         def do_update_record(self, opts):
             """Update (write) data to a record-oriented EF"""
             (data, sw) = self._cmd.rs.update_record(opts.record_nr, opts.data)
-            self._cmd.poutput(data)
+            if data:
+                self._cmd.poutput(data)
 
         upd_rec_dec_parser = argparse.ArgumentParser()
         upd_rec_dec_parser.add_argument('record_nr', type=int, help='Number of record to be read')
@@ -419,7 +422,8 @@
         def do_update_record_decoded(self, opts):
             """Encode + Update (write) data to a record-oriented EF"""
             (data, sw) = self._cmd.rs.update_record_dec(opts.record_nr, opts.data)
-            self._cmd.poutput(data)
+            if data:
+                self._cmd.poutput(data)
 
     def __init__(self, fid, sfid=None, name=None, desc=None, parent=None, rec_len={1,None}):
         super().__init__(fid=fid, sfid=sfid, name=name, desc=desc, parent=parent)

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

Gerrit-Project: pysim
Gerrit-Branch: master
Gerrit-Change-Id: Ia9715d46ec957544cfbeea98d2fe15eb74f5b884
Gerrit-Change-Number: 23537
Gerrit-PatchSet: 2
Gerrit-Owner: dexter <pmaier at sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: dexter <pmaier 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/20210330/b6590444/attachment.htm>


More information about the gerrit-log mailing list