dexter has uploaded this change for review. ( https://gerrit.osmocom.org/c/pysim/+/37932?usp=email )
Change subject: pySim-shell: rework startup procedure and introduce headless mode
......................................................................
pySim-shell: rework startup procedure and introduce headless mode
When pySim-shell is used in a scripted environment, we may easily get trapped in
the pySim-shell prompt. This may happen in particular in case the script file
is not executed due to problem with the reader initialization. In such a case
pySim-shell will not exit automatically and the shellscript that was calling
pySim-shell will stall indefinetly.
To make the use of pySim-shell more reliable in scripted environments, let's
add a --headless option that ensures the interactive mode is never entered.
Let's also exit with an appropriate return code in case of initialization
errors, so that the calling script can know that something went wrong.
Related: OS#6531
Change-Id: I07ecb27b37e2573629981a0d032cc95cd156be7e
---
M pySim-shell.py
1 file changed, 36 insertions(+), 19 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/pysim refs/changes/32/37932/1
diff --git a/pySim-shell.py b/pySim-shell.py
index 0ba8a25..565d569 100755
--- a/pySim-shell.py
+++ b/pySim-shell.py
@@ -1026,6 +1026,8 @@
help='per-CSV-column AES transport key')
global_group.add_argument("--card_handler", dest="card_handler_config", metavar="FILE",
help="Use automatic card handling machine")
+global_group.add_argument("--headless", help="Run in non interactive mode",
+ action='store_true', default=False)
adm_group = global_group.add_mutually_exclusive_group()
adm_group.add_argument('-a', '--pin-adm', metavar='PIN_ADM1', dest='pin_adm', default=None,
@@ -1041,22 +1043,15 @@
if __name__ == '__main__':
- # Parse options
+ startup_errors = False
opts = option_parser.parse_args()
- # If a script file is specified, be sure that it actually exists
- if opts.script:
- if not os.access(opts.script, os.R_OK):
- print("Invalid script file!")
- sys.exit(2)
-
+ # Register csv-file as card data provider, either from specified CSV
+ # or from CSV file in home directory
csv_column_keys = {}
for par in opts.csv_column_key:
name, key = par.split(':')
csv_column_keys[name] = key
-
- # Register csv-file as card data provider, either from specified CSV
- # or from CSV file in home directory
csv_default = str(Path.home()) + "/.osmocom/pysim/card_data.csv"
if opts.csv:
card_key_provider_register(CardKeyProviderCsv(opts.csv, csv_column_keys))
@@ -1077,18 +1072,18 @@
# able to tolerate and recover from that.
try:
rs, card = init_card(sl)
- app = PysimApp(card, rs, sl, ch, opts.script)
+ app = PysimApp(card, rs, sl, ch)
except:
+ startup_errors = True
print("Card initialization (%s) failed with an exception:" % str(sl))
print("---------------------8<---------------------")
traceback.print_exc()
print("---------------------8<---------------------")
- print("(you may still try to recover from this manually by using the 'equip' command.)")
- print(" it should also be noted that some readers may behave strangely when no card")
- print(" is inserted.)")
- print("")
- if opts.script:
- print("will not execute startup script due to card initialization errors!")
+ if not opts.headless:
+ print("(you may still try to recover from this manually by using the 'equip' command.)")
+ print(" it should also be noted that some readers may behave strangely when no card")
+ print(" is inserted.)")
+ print("")
app = PysimApp(None, None, sl, ch)
# If the user supplies an ADM PIN at via commandline args authenticate
@@ -1100,9 +1095,31 @@
try:
card._scc.verify_chv(card._adm_chv_num, h2b(pin_adm))
except Exception as e:
+ startup_errors = True
+ print("ADM verification (%s) failed with an exception:" % str(pin_adm))
+ print("---------------------8<---------------------")
print(e)
+ print("---------------------8<---------------------")
+ # Run optional command
if opts.command:
- app.onecmd_plus_hooks('{} {}'.format(opts.command, ' '.join(opts.command_args)))
- else:
+ if not startup_errors:
+ app.onecmd_plus_hooks('{} {}'.format(opts.command, ' '.join(opts.command_args)))
+ else:
+ print("Errors during startup, refusing to execute command (%s)" % opts.command)
+
+ # Run optional script file
+ if opts.script:
+ if not startup_errors:
+ if not os.access(opts.script, os.R_OK):
+ print("Error: script file (%s) not readable!" % opts.script)
+ startup_errors = True
+ else:
+ app.onecmd_plus_hooks('{} {}'.format('run_script', opts.script), add_to_history = False)
+ else:
+ print("Errors during startup, refusing to execute script (%s)" % opts.script)
+
+ if not opts.headless:
app.cmdloop()
+ elif startup_errors:
+ sys.exit(2)
--
To view, visit https://gerrit.osmocom.org/c/pysim/+/37932?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email
Gerrit-MessageType: newchange
Gerrit-Project: pysim
Gerrit-Branch: master
Gerrit-Change-Id: I07ecb27b37e2573629981a0d032cc95cd156be7e
Gerrit-Change-Number: 37932
Gerrit-PatchSet: 1
Gerrit-Owner: dexter <pmaier(a)sysmocom.de>
dexter has uploaded this change for review. ( https://gerrit.osmocom.org/c/pysim/+/37930?usp=email )
Change subject: pySim-shell: fix sourcecode formatting
......................................................................
pySim-shell: fix sourcecode formatting
Change-Id: I7133e93366eaacca5ace301172a08ae84e211c0e
---
M pySim-shell.py
1 file changed, 1 insertion(+), 2 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/pysim refs/changes/30/37930/1
diff --git a/pySim-shell.py b/pySim-shell.py
index 78d20e6..d166008 100755
--- a/pySim-shell.py
+++ b/pySim-shell.py
@@ -1084,8 +1084,7 @@
traceback.print_exc()
print("---------------------8<---------------------")
print("(you may still try to recover from this manually by using the 'equip' command.)")
- print(
- " it should also be noted that some readers may behave strangely when no card")
+ print(" it should also be noted that some readers may behave strangely when no card")
print(" is inserted.)")
print("")
if opts.script:
--
To view, visit https://gerrit.osmocom.org/c/pysim/+/37930?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email
Gerrit-MessageType: newchange
Gerrit-Project: pysim
Gerrit-Branch: master
Gerrit-Change-Id: I7133e93366eaacca5ace301172a08ae84e211c0e
Gerrit-Change-Number: 37930
Gerrit-PatchSet: 1
Gerrit-Owner: dexter <pmaier(a)sysmocom.de>
Attention is currently required from: laforge.
lynxis lazus has posted comments on this change by laforge. ( https://gerrit.osmocom.org/c/libosmocore/+/37894?usp=email )
Change subject: src/core/socket.c: Fix close of negative fd in system_supports_inet6()
......................................................................
Patch Set 1: Code-Review+2
--
To view, visit https://gerrit.osmocom.org/c/libosmocore/+/37894?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email
Gerrit-MessageType: comment
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Change-Id: Iedd0f74688cacd8dbe4b46b2c7e03a6c2f56fbbf
Gerrit-Change-Number: 37894
Gerrit-PatchSet: 1
Gerrit-Owner: laforge <laforge(a)osmocom.org>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: lynxis lazus <lynxis(a)fe80.eu>
Gerrit-Reviewer: pespin <pespin(a)sysmocom.de>
Gerrit-Attention: laforge <laforge(a)osmocom.org>
Gerrit-Comment-Date: Mon, 26 Aug 2024 16:41:06 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
dexter has submitted this change. ( https://gerrit.osmocom.org/c/pysim/+/37916?usp=email )
Change subject: filesystem: fix double space in docstring
......................................................................
filesystem: fix double space in docstring
Change-Id: I69ef171ac2dd2e2717404b1f3b10f986af419f6e
---
M pySim/filesystem.py
1 file changed, 1 insertion(+), 1 deletion(-)
Approvals:
Jenkins Builder: Verified
dexter: Looks good to me, approved
diff --git a/pySim/filesystem.py b/pySim/filesystem.py
index 805983b..35af140 100644
--- a/pySim/filesystem.py
+++ b/pySim/filesystem.py
@@ -1333,7 +1333,7 @@
@cmd2.with_argparser(del_data_parser)
def do_delete_data(self, opts):
- """Delete data for a given tag in a BER-TLV EF"""
+ """Delete data for a given tag in a BER-TLV EF"""
(data, _sw) = self._cmd.lchan.set_data(opts.tag, None)
if data:
self._cmd.poutput(data)
--
To view, visit https://gerrit.osmocom.org/c/pysim/+/37916?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email
Gerrit-MessageType: merged
Gerrit-Project: pysim
Gerrit-Branch: master
Gerrit-Change-Id: I69ef171ac2dd2e2717404b1f3b10f986af419f6e
Gerrit-Change-Number: 37916
Gerrit-PatchSet: 1
Gerrit-Owner: dexter <pmaier(a)sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: dexter <pmaier(a)sysmocom.de>
dexter has posted comments on this change by dexter. ( https://gerrit.osmocom.org/c/pysim/+/37916?usp=email )
Change subject: filesystem: fix double space in docstring
......................................................................
Patch Set 1: Code-Review+2
--
To view, visit https://gerrit.osmocom.org/c/pysim/+/37916?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email
Gerrit-MessageType: comment
Gerrit-Project: pysim
Gerrit-Branch: master
Gerrit-Change-Id: I69ef171ac2dd2e2717404b1f3b10f986af419f6e
Gerrit-Change-Number: 37916
Gerrit-PatchSet: 1
Gerrit-Owner: dexter <pmaier(a)sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: dexter <pmaier(a)sysmocom.de>
Gerrit-Comment-Date: Mon, 26 Aug 2024 12:03:48 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
Attention is currently required from: fixeria, pespin.
Hello Jenkins Builder, fixeria,
I'd like you to reexamine a change. Please visit
https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/37920?usp=email
to look at the new patch set (#5).
The following approvals got outdated and were removed:
Code-Review+1 by fixeria, Verified+1 by Jenkins Builder
Change subject: s1gw: Add initial PFCP support emulating UPF
......................................................................
s1gw: Add initial PFCP support emulating UPF
Change-Id: If2b135e113d2568092e90ac9b6c5f651ab30f5d0
---
M library/PFCP_Emulation.ttcn
M s1gw/ConnHdlr.ttcn
M s1gw/S1GW_Tests.ttcn
M s1gw/gen_links.sh
M s1gw/osmo-s1gw.config
M s1gw/regen_makefile.sh
6 files changed, 144 insertions(+), 32 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/osmo-ttcn3-hacks refs/changes/20/37920/5
--
To view, visit https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/37920?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email
Gerrit-MessageType: newpatchset
Gerrit-Project: osmo-ttcn3-hacks
Gerrit-Branch: master
Gerrit-Change-Id: If2b135e113d2568092e90ac9b6c5f651ab30f5d0
Gerrit-Change-Number: 37920
Gerrit-PatchSet: 5
Gerrit-Owner: pespin <pespin(a)sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: fixeria <vyanitskiy(a)sysmocom.de>
Gerrit-Attention: fixeria <vyanitskiy(a)sysmocom.de>
Gerrit-Attention: pespin <pespin(a)sysmocom.de>
Attention is currently required from: pespin.
fixeria has posted comments on this change by pespin. ( https://gerrit.osmocom.org/c/erlang/osmo-s1gw/+/37923?usp=email )
Change subject: erab_fsm: Abort and reply call with error if unable to establish PFCP sess
......................................................................
Patch Set 2: Code-Review+2
(1 comment)
File src/erab_fsm.erl:
https://gerrit.osmocom.org/c/erlang/osmo-s1gw/+/37923/comment/5cf30d3c_c0d8… :
PS1, Line 181: timeout
> well, in hear clearly the error is not a timeout, but some error with reason=Reason. […]
Done
--
To view, visit https://gerrit.osmocom.org/c/erlang/osmo-s1gw/+/37923?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email
Gerrit-MessageType: comment
Gerrit-Project: erlang/osmo-s1gw
Gerrit-Branch: master
Gerrit-Change-Id: If23881205b995e76647289d5e6c1c85d02f93b47
Gerrit-Change-Number: 37923
Gerrit-PatchSet: 2
Gerrit-Owner: pespin <pespin(a)sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: fixeria <vyanitskiy(a)sysmocom.de>
Gerrit-Attention: pespin <pespin(a)sysmocom.de>
Gerrit-Comment-Date: Mon, 26 Aug 2024 10:54:36 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes
Comment-In-Reply-To: pespin <pespin(a)sysmocom.de>
Comment-In-Reply-To: fixeria <vyanitskiy(a)sysmocom.de>