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