1
0
mirror of https://github.com/samba-team/samba.git synced 2025-01-22 22:04:08 +03:00

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 <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
This commit is contained in:
Douglas Bagnall 2022-09-08 20:27:33 +12:00 committed by Andrew Bartlett
parent 8b23ef3003
commit a1c615f87d

View File

@ -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