laforge submitted this change.

View Change

Approvals: Jenkins Builder: Verified laforge: Looks good to me, approved
pySim-shell: New '-e' command line argument

Using '-e' it is possible to specify *multiple* pySim-shell commands
which shall be executed at startup. This extends the current ability
to execute just a single command.

Example:
./pySim-shell.py -p0 -e 'select ADF.USIM/EF.IMSI' -e 'read_binary_decoded'

Change-Id: I74004f46105553f077c039ca0f86f75afccc7342
---
M pySim-shell.py
1 file changed, 9 insertions(+), 0 deletions(-)

diff --git a/pySim-shell.py b/pySim-shell.py
index 8c260aa..37d58ae 100755
--- a/pySim-shell.py
+++ b/pySim-shell.py
@@ -1056,6 +1056,8 @@
adm_group.add_argument('-A', '--pin-adm-hex', metavar='PIN_ADM1_HEX', dest='pin_adm_hex', default=None,
help='ADM PIN used for provisioning, as hex string (16 characters long)')

+option_parser.add_argument('-e', '--execute-command', action='append', default=[],
+ help='A pySim-shell command that will be executed at startup')
option_parser.add_argument("command", nargs='?',
help="A pySim-shell command that would optionally be executed at startup")
option_parser.add_argument('command_args', nargs=argparse.REMAINDER,
@@ -1122,6 +1124,13 @@
print(e)
print("---------------------8<---------------------")

+ # Run optional commands
+ for c in opts.execute_command:
+ if not startup_errors:
+ app.onecmd_plus_hooks(c)
+ else:
+ print("Errors during startup, refusing to execute command (%s)" % c)
+
# Run optional command
if opts.command:
if not startup_errors:

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

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