aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPhilipp Maier <pmaier@sysmocom.de>2021-09-16 12:51:46 +0200
committerPhilipp Maier <pmaier@sysmocom.de>2021-09-22 16:11:33 +0200
commita8c9ea9cc7f71e49f8df56441c69720c67ccfeb9 (patch)
tree2f665d5818a8bd9126aa6a20b2b9f4751e538f9d
parentb18eed072c6202d207f411002fb3be4c05b0770f (diff)
pySim-shell: move command desc and verify_adm to PySimCommands
Almost all pySim-shell related commands are agrgated in PySimCommands. There are a few exceptions, so there are some commands in PysimApp. However, it makes sense to reserve PysimApp exclusively for very basic commands that do not directly relate to card operations. So lets move the command verify_adm and desc to PySimCommands. Change-Id: I4a215c8a3907d69f702a70df9b85988be1ce3dbf
-rwxr-xr-xpySim-shell.py56
1 files changed, 27 insertions, 29 deletions
diff --git a/pySim-shell.py b/pySim-shell.py
index 5644466..06e14f6 100755
--- a/pySim-shell.py
+++ b/pySim-shell.py
@@ -114,35 +114,6 @@ class PysimApp(cmd2.Cmd):
"""Display the intro banner"""
self.poutput(self.intro)
- @cmd2.with_category(CUSTOM_CATEGORY)
- def do_verify_adm(self, arg):
- """VERIFY the ADM1 PIN"""
- if arg:
- # use specified ADM-PIN
- pin_adm = sanitize_pin_adm(arg)
- else:
- # try to find an ADM-PIN if none is specified
- result = card_key_provider_get_field('ADM1', key='ICCID', value=self.iccid)
- pin_adm = sanitize_pin_adm(result)
- if pin_adm:
- self.poutput("found ADM-PIN '%s' for ICCID '%s'" % (result, self.iccid))
- else:
- self.poutput("cannot find ADM-PIN for ICCID '%s'" % (self.iccid))
- return
-
- if pin_adm:
- self.card.verify_adm(h2b(pin_adm))
- else:
- self.poutput("error: cannot authenticate, no adm-pin!")
-
- @cmd2.with_category(CUSTOM_CATEGORY)
- def do_desc(self, opts):
- """Display human readable file description for the currently selected file"""
- desc = self.rs.selected_file.desc
- if desc:
- self.poutput(desc)
- else:
- self.poutput("no description available")
@with_default_category('pySim Commands')
class PySimCommands(CommandSet):
@@ -319,6 +290,33 @@ class PySimCommands(CommandSet):
self._cmd.poutput('Card ATR: %s' % atr)
self._cmd.update_prompt()
+ def do_desc(self, opts):
+ """Display human readable file description for the currently selected file"""
+ desc = self._cmd.rs.selected_file.desc
+ if desc:
+ self._cmd.poutput(desc)
+ else:
+ self._cmd.poutput("no description available")
+
+ def do_verify_adm(self, arg):
+ """VERIFY the ADM1 PIN"""
+ if arg:
+ # use specified ADM-PIN
+ pin_adm = sanitize_pin_adm(arg)
+ else:
+ # try to find an ADM-PIN if none is specified
+ result = card_key_provider_get_field('ADM1', key='ICCID', value=self._cmd.iccid)
+ pin_adm = sanitize_pin_adm(result)
+ if pin_adm:
+ self._cmd.poutput("found ADM-PIN '%s' for ICCID '%s'" % (result, self._cmd.iccid))
+ else:
+ self._cmd.poutput("cannot find ADM-PIN for ICCID '%s'" % (self._cmd.iccid))
+ return
+
+ if pin_adm:
+ self._cmd.card.verify_adm(h2b(pin_adm))
+ else:
+ self._cmd.poutput("error: cannot authenticate, no adm-pin!")
@with_default_category('ISO7816 Commands')
class Iso7816Commands(CommandSet):