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
This commit is contained in:
Philipp Maier 2021-03-11 17:13:46 +01:00
parent 2558aa6999
commit e6bc4f9032
1 changed files with 8 additions and 4 deletions

View File

@ -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)