From e6bc4f903297f1cc0ec19ab54c34415aa289e8cb Mon Sep 17 00:00:00 2001 From: Philipp Maier Date: Thu, 11 Mar 2021 17:13:46 +0100 Subject: [PATCH] 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 --- pySim/filesystem.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/pySim/filesystem.py b/pySim/filesystem.py index 04fa2504..cb39b94a 100644 --- a/pySim/filesystem.py +++ b/pySim/filesystem.py @@ -313,7 +313,8 @@ class TransparentEF(CardEF): 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 @@ class TransparentEF(CardEF): """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 @@ class LinFixedEF(CardEF): 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 @@ class LinFixedEF(CardEF): 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)