From: Douglas Bagnall Date: Thu, 8 Sep 2022 08:27:33 +0000 (+1200) Subject: pytest/samba-tool: entry function follows too logic X-Git-Tag: talloc-2.4.0~1120 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=a1c615f87de8184eeb7ba7fb5f959a0b6a5ccac3;p=thirdparty%2Fsamba.git pytest/samba-tool: entry function follows too logic To further align the logic of the tool and the tests, we use the same logic in the test function as in samba-tool. In effect, this means the function is even less likely to raise an exception, rahter printing it out and returning an error code. Signed-off-by: Douglas Bagnall Reviewed-by: Andrew Bartlett --- diff --git a/python/samba/netcmd/main.py b/python/samba/netcmd/main.py index 0565aff5406..0fd4f20d941 100644 --- a/python/samba/netcmd/main.py +++ b/python/samba/netcmd/main.py @@ -86,5 +86,12 @@ class cmd_sambatool(SuperCommand): def samba_tool(*args, **kwargs): """A single function that runs samba-tool, returning an error code on error, and None on success.""" - cmd, argv = cmd_sambatool()._resolve("samba-tool", *args, **kwargs) - return cmd._run(*argv) + try: + cmd, argv = cmd_sambatool()._resolve("samba-tool", *args, **kwargs) + ret = cmd._run(*argv) + except SystemExit as e: + ret = e.code + except Exception as e: + cmd.show_command_error(e) + ret = 1 + return ret