From c85d4067fdbf641f6ca63be862023c0aca726c29 Mon Sep 17 00:00:00 2001 From: Harald Welte Date: Thu, 27 Apr 2023 17:10:17 +0200 Subject: [PATCH] pySim-shell: fix compatibility problem with cmd2 >= 2.0.0 (include_ipy) In version 2.0.0, the use_ipython parameter in the Cmd constructor is renamed to include_ipy. There are still plenty of older cmd2 installations around, so let's work around this using a version check. See also: https://github.com/python-cmd2/cmd2 Commit: 2397280cad072a27a51f5ec1cc64908039d14bd1 Author: Kevin Van Brunt Date: 2021-03-26 18:56:33 This commit is based on pySim gerrit changes: Ifce40410587c85ae932774144b9548b154ee8ad0 I19d28276e73e7024f64ed693c3b5e37c1344c687 Change-Id: Ibc0e18b002a03ed17933be4d0b4f4e86ad99c26e --- pySim-shell.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/pySim-shell.py b/pySim-shell.py index fab5d096..ae783c64 100755 --- a/pySim-shell.py +++ b/pySim-shell.py @@ -135,8 +135,13 @@ class PysimApp(cmd2.Cmd): CUSTOM_CATEGORY = 'pySim Commands' def __init__(self, card, rs, sl, ch, script=None): + if version.parse(cmd2.__version__) < version.parse("2.0.0"): + kwargs = {'use_ipython': True} + else: + kwargs = {'include_ipy': True} + super().__init__(persistent_history_file='~/.pysim_shell_history', allow_cli_args=False, - use_ipython=True, auto_load_commands=False, startup_script=script) + auto_load_commands=False, startup_script=script, **kwargs) self.intro = style('Welcome to pySim-shell!', fg=fg.red) self.default_category = 'pySim-shell built-in commands' self.card = None