laforge submitted this change.

View Change

Approvals: Jenkins Builder: Verified laforge: Looks good to me, approved
pySim-shell: add command to manually query the Card Key Provider

The Card Key Provider is a built in mechanism of pySim-shell which
allows the user to read key material from a CSV file in order to
avoid having to lookup and enter the key material himself. The
lookup normally done by the pySim-shell commands automatically.

However, in some cases it may also be useful to be able to query the
CSV file manually in order to get certain fields displayed. Such a
command is in particular helpful to check and diagnose the CSV data
source.

Related: SYS#7725
Change-Id: I76e0f883572a029bdca65a5a6b3eef306db1c221
---
M pySim-shell.py
1 file changed, 19 insertions(+), 1 deletion(-)

diff --git a/pySim-shell.py b/pySim-shell.py
index c629656..878aea0 100755
--- a/pySim-shell.py
+++ b/pySim-shell.py
@@ -69,7 +69,8 @@
from pySim.gsm_r import DF_EIRENE
from pySim.cat import ProactiveCommand

-from pySim.card_key_provider import CardKeyProviderCsv, card_key_provider_register, card_key_provider_get_field
+from pySim.card_key_provider import CardKeyProviderCsv
+from pySim.card_key_provider import card_key_provider_register, card_key_provider_get_field, card_key_provider_get

from pySim.app import init_card

@@ -498,6 +499,23 @@
"""Echo (print) a string on the console"""
self.poutput(' '.join(opts.STRING))

+ query_card_key_parser = argparse.ArgumentParser()
+ query_card_key_parser.add_argument('FIELDS', help="fields to query", type=str, nargs='+')
+ query_card_key_parser.add_argument('--key', help='lookup key (typically \'ICCID\' or \'EID\')',
+ type=str, required=True)
+ query_card_key_parser.add_argument('--value', help='lookup key match value (e.g \'8988211000000123456\')',
+ type=str, required=True)
+ @cmd2.with_argparser(query_card_key_parser)
+ @cmd2.with_category(CUSTOM_CATEGORY)
+ def do_query_card_key(self, opts):
+ """Manually query the Card Key Provider"""
+ result = card_key_provider_get(opts.FIELDS, opts.key, opts.value)
+ self.poutput("Result:")
+ if result == {}:
+ self.poutput(" (none)")
+ for k in result.keys():
+ self.poutput(" %s: %s" % (str(k), str(result.get(k))))
+
@cmd2.with_category(CUSTOM_CATEGORY)
def do_version(self, opts):
"""Print the pySim software version."""

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

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