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

dexter gerrit-no-reply at lists.osmocom.org
Mon Mar 29 19:07:41 UTC 2021


dexter has uploaded this change for review. ( 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(-)



  git pull ssh://gerrit.osmocom.org:29418/pysim refs/changes/37/23537/1

diff --git a/pySim/filesystem.py b/pySim/filesystem.py
index 1f43bea..6adffd9 100644
--- a/pySim/filesystem.py
+++ b/pySim/filesystem.py
@@ -344,7 +344,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')
@@ -353,7 +354,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)
@@ -441,7 +443,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')
@@ -450,7 +453,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: 1
Gerrit-Owner: dexter <pmaier at sysmocom.de>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20210329/108f26a5/attachment.htm>


More information about the gerrit-log mailing list