]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
pytest/samba-tool: entry function follows too logic
authorDouglas Bagnall <douglas.bagnall@catalyst.net.nz>
Thu, 8 Sep 2022 08:27:33 +0000 (20:27 +1200)
committerAndrew Bartlett <abartlet@samba.org>
Thu, 8 Sep 2022 22:34:36 +0000 (22:34 +0000)
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>
python/samba/netcmd/main.py

index 0565aff5406ef4abb450c15d79e9ac080eeb87ba..0fd4f20d9412650226a3f02f483c1058a1ea9f5f 100644 (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