Change in pysim[master]: pySim-shell: move command desc and verify_adm to PySimCommands

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

dexter gerrit-no-reply at lists.osmocom.org
Wed Sep 22 14:19:06 UTC 2021


dexter has submitted this change. ( https://gerrit.osmocom.org/c/pysim/+/25483 )

Change subject: pySim-shell: move command desc and verify_adm to PySimCommands
......................................................................

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
---
M pySim-shell.py
1 file changed, 27 insertions(+), 29 deletions(-)

Approvals:
  Jenkins Builder: Verified
  osmith: Looks good to me, but someone else must approve
  laforge: Looks good to me, approved



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

-- 
To view, visit https://gerrit.osmocom.org/c/pysim/+/25483
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: pysim
Gerrit-Branch: master
Gerrit-Change-Id: I4a215c8a3907d69f702a70df9b85988be1ce3dbf
Gerrit-Change-Number: 25483
Gerrit-PatchSet: 4
Gerrit-Owner: dexter <pmaier at sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: dexter <pmaier at sysmocom.de>
Gerrit-Reviewer: fixeria <vyanitskiy at sysmocom.de>
Gerrit-Reviewer: laforge <laforge at osmocom.org>
Gerrit-Reviewer: osmith <osmith at sysmocom.de>
Gerrit-MessageType: merged
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20210922/41fe8250/attachment.htm>


More information about the gerrit-log mailing list