laforge submitted this change.

View Change

Approvals: Jenkins Builder: Verified laforge: Looks good to me, approved
pySim-shell: improve command "desc"

The "desc" command displays a string with a file description, let's also
display some size information as part of the description as well.

Related: OS#5714
Change-Id: I98e139ba2bf35df5524245cdd96f5c52cf09b986
---
M pySim-shell.py
M pySim/runtime.py
2 files changed, 28 insertions(+), 3 deletions(-)

diff --git a/pySim-shell.py b/pySim-shell.py
index 7db77f0..d3f0d87 100755
--- a/pySim-shell.py
+++ b/pySim-shell.py
@@ -56,7 +56,7 @@
from pySim.utils import sanitize_pin_adm, tabulate_str_list, boxed_heading_str, dec_iccid, sw_match
from pySim.card_handler import CardHandler, CardHandlerAuto

-from pySim.filesystem import CardMF, CardEF, CardDF, CardADF
+from pySim.filesystem import CardMF, CardEF, CardDF, CardADF, LinFixedEF, TransparentEF, BerTlvEF
from pySim.ts_102_221 import pin_names
from pySim.ts_102_222 import Ts102222Commands
from pySim.gsm_r import DF_EIRENE
@@ -766,9 +766,28 @@
"""Display human readable file description for the currently selected file"""
desc = self._cmd.lchan.selected_file.desc
if desc:
- self._cmd.poutput(desc)
+ self._cmd.poutput("%s: %s" % (self._cmd.lchan.selected_file, desc))
else:
- self._cmd.poutput("no description available")
+ self._cmd.poutput("%s: no description available" % self._cmd.lchan.selected_file)
+ self._cmd.poutput(" file structure: %s" % self._cmd.lchan.selected_file_structure())
+ if isinstance(self._cmd.lchan.selected_file, LinFixedEF):
+ self._cmd.poutput(" record length:")
+ self._cmd.poutput(" minimum_length: %s" % str(self._cmd.lchan.selected_file.rec_len[0]))
+ self._cmd.poutput(" recommended_length: %s" % str(self._cmd.lchan.selected_file.rec_len[1]))
+ self._cmd.poutput(" actual_length: %s" % str(self._cmd.lchan.selected_file_record_len()))
+ self._cmd.poutput(" number of records: %s" % str(self._cmd.lchan.selected_file_num_of_rec()))
+ elif isinstance(self._cmd.lchan.selected_file, TransparentEF):
+ self._cmd.poutput(" file size:")
+ self._cmd.poutput(" minimum_size: %s" % str(self._cmd.lchan.selected_file.size[0]))
+ self._cmd.poutput(" recommended_size: %s" % str(self._cmd.lchan.selected_file.size[1]))
+ self._cmd.poutput(" actual_size: %s" % str(self._cmd.lchan.selected_file_size()))
+ elif isinstance(self._cmd.lchan.selected_file, BerTlvEF):
+ self._cmd.poutput(" file size:")
+ self._cmd.poutput(" minimum_size: %s" % str(self._cmd.lchan.selected_file.size[0]))
+ self._cmd.poutput(" recommended_size: %s" % str(self._cmd.lchan.selected_file.size[1]))
+ self._cmd.poutput(" actual_size: %s" % str(self._cmd.lchan.selected_file_size()))
+ self._cmd.poutput(" reserved_file_size: %s" % str(self._cmd.lchan.selected_file_reserved_file_size()))
+ self._cmd.poutput(" maximum_file_size: %s" % str(self._cmd.lchan.selected_file_maximum_file_size()))

verify_adm_parser = argparse.ArgumentParser()
verify_adm_parser.add_argument('--pin-is-hex', action='store_true',
diff --git a/pySim/runtime.py b/pySim/runtime.py
index 898008e..3714832 100644
--- a/pySim/runtime.py
+++ b/pySim/runtime.py
@@ -217,6 +217,12 @@
def selected_file_size(self) -> Optional[int]:
return self.selected_file_fcp.get('file_size')

+ def selected_file_reserved_file_size(self) -> Optional[int]:
+ return self.selected_file_fcp['proprietary_information'].get('reserved_file_size')
+
+ def selected_file_maximum_file_size(self) -> Optional[int]:
+ return self.selected_file_fcp['proprietary_information'].get('maximum_file_size')
+
def get_cwd(self) -> CardDF:
"""Obtain the current working directory.


To view, visit change 38194. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-MessageType: merged
Gerrit-Project: pysim
Gerrit-Branch: master
Gerrit-Change-Id: I98e139ba2bf35df5524245cdd96f5c52cf09b986
Gerrit-Change-Number: 38194
Gerrit-PatchSet: 2
Gerrit-Owner: dexter <pmaier@sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge <laforge@osmocom.org>