samba-tool: command that has exception, shows exception
authorDouglas Bagnall <douglas.bagnall@catalyst.net.nz>
Wed, 7 Sep 2022 20:56:45 +0000 (08:56 +1200)
committerAndrew Bartlett <abartlet@samba.org>
Thu, 8 Sep 2022 22:34:36 +0000 (22:34 +0000)
This will make a difference to the string printed in the cases that
call self.usage(), resulting in more specified usage for the
sub-command. It would also matter if the samba-tool sub-command had a
different .show_command_error() or .errf, but I don't think that
happens.

Note: usually command._run() will have caught and shown the exception,
returning -1.

We also rename away 'cmd' so we don't again imagine it is the command
we are running.

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
source4/scripting/bin/samba-tool

index b5f784beff7c8630671d08fda2ebab070903bbf7..c4e672e379876d9795304da713f4be5d4c982b2b 100755 (executable)
@@ -31,14 +31,14 @@ import signal
 signal.signal(signal.SIGINT, signal.SIG_DFL)
 
 from samba.netcmd.main import cmd_sambatool
-cmd = cmd_sambatool()
+samba_tool = cmd_sambatool()
 
 try:
-    command, args = cmd._resolve("samba-tool", *sys.argv[1:])
+    command, args = samba_tool._resolve("samba-tool", *sys.argv[1:])
     retval = command._run(*args)
 except SystemExit as e:
     retval = e.code
 except Exception as e:
-    cmd.show_command_error(e)
+    command.show_command_error(e)
     retval = 1
 sys.exit(retval)