Change in pysim[master]: pySim-shell: add option to execute script on startup

laforge gerrit-no-reply at lists.osmocom.org
Sat Mar 27 18:20:29 UTC 2021


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

Change subject: pySim-shell: add option to execute script on startup
......................................................................

pySim-shell: add option to execute script on startup

Add a commondline option so that the user can supply pySim-shell with a
script file name. This script then runs automatically on startup. (to
avoid ending up at the shell prompt a quit command at the end can be
used to exit after script execution)

Change-Id: I69f5224087023650340fbfee74668e1850345f54
Related: OS#4963
---
M pySim-shell.py
1 file changed, 7 insertions(+), 3 deletions(-)

Approvals:
  Jenkins Builder: Verified
  fixeria: 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 e7bb7c0..09749dc 100755
--- a/pySim-shell.py
+++ b/pySim-shell.py
@@ -49,10 +49,10 @@
 
 class PysimApp(cmd2.Cmd):
 	CUSTOM_CATEGORY = 'pySim Commands'
-	def __init__(self, card, rs):
+	def __init__(self, card, rs, script = None):
 		basic_commands = [Iso7816Commands(), UsimCommands()]
 		super().__init__(persistent_history_file='~/.pysim_shell_history', allow_cli_args=False,
-				use_ipython=True, auto_load_commands=False, command_sets=basic_commands)
+				 use_ipython=True, auto_load_commands=False, command_sets=basic_commands, startup_script=script)
 		self.intro = style('Welcome to pySim-shell!', fg=fg.red)
 		self.default_category = 'pySim-shell built-in commands'
 		self.card = card
@@ -212,6 +212,10 @@
 			help="Socket path for Calypso (e.g. Motorola C1XX) based reader (via OsmocomBB)",
 			default=None,
 		)
+	parser.add_option("--script", dest="script", metavar="PATH",
+			help="script with shell commands to be executed automatically",
+			default=None,
+		)
 
 	parser.add_option("-a", "--pin-adm", dest="pin_adm",
 			help="ADM PIN used for provisioning (overwrites default)",
@@ -261,6 +265,6 @@
 	rs.mf.add_file(DF_TELECOM())
 	rs.mf.add_file(DF_GSM())
 
-	app = PysimApp(card, rs)
+	app = PysimApp(card, rs, opts.script)
 	rs.select('MF', app)
 	app.cmdloop()

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

Gerrit-Project: pysim
Gerrit-Branch: master
Gerrit-Change-Id: I69f5224087023650340fbfee74668e1850345f54
Gerrit-Change-Number: 23474
Gerrit-PatchSet: 3
Gerrit-Owner: dexter <pmaier at sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: fixeria <vyanitskiy at sysmocom.de>
Gerrit-Reviewer: laforge <laforge at osmocom.org>
Gerrit-MessageType: merged
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20210327/f7986e26/attachment.htm>


More information about the gerrit-log mailing list