diff options
author | Amitay Isaacs <amitay@gmail.com> | 2011-07-21 12:21:17 +1000 |
---|---|---|
committer | Andrew Tridgell <tridge@samba.org> | 2011-07-28 15:20:52 +1000 |
commit | 1a444004dddbd534a40fb0b1fd6ee72d3c8deea9 (patch) | |
tree | 25dc4a7137591c1dab54ab4a1cb34d3e9d5f8c7e /source4/scripting | |
parent | d4c1149e3ec11a59cb49cd9be71079e503eb9e19 (diff) | |
download | samba-1a444004dddbd534a40fb0b1fd6ee72d3c8deea9.tar.gz samba-1a444004dddbd534a40fb0b1fd6ee72d3c8deea9.tar.bz2 samba-1a444004dddbd534a40fb0b1fd6ee72d3c8deea9.zip |
samba-tool: Raise exception on errors and report using base class
Exceptions are captured at top-level samba-tool and reported using
the base class (Command) method show_command_error().
Signed-off-by: Andrew Tridgell <tridge@samba.org>
Diffstat (limited to 'source4/scripting')
-rw-r--r-- | source4/scripting/python/samba/netcmd/__init__.py | 13 |
1 files changed, 3 insertions, 10 deletions
diff --git a/source4/scripting/python/samba/netcmd/__init__.py b/source4/scripting/python/samba/netcmd/__init__.py index 316a819053..3d1283048c 100644 --- a/source4/scripting/python/samba/netcmd/__init__.py +++ b/source4/scripting/python/samba/netcmd/__init__.py @@ -164,18 +164,11 @@ class SuperCommand(Command): for cmd in subcmds: print " %-20s - %s" % (cmd, self.subcommands[cmd].description) if subcommand in [None]: - self.show_command_error("You must specify a subcommand") - return -1 - if subcommand in ['-h', '--help']: + raise CommandError("You must specify a subcommand") + if subcommand in ['help', '-h', '--help']: print "For more help on a specific subcommand, please type: samba-tool %s <subcommand> (-h|--help)" % myname return 0 - self.show_command_error("No such subcommand '%s'" % (subcommand)) - - def show_command_error(self, msg): - '''display a command error''' - - print >>sys.stderr, "ERROR: %s" % (msg) - sys.exit(1) + raise CommandError("No such subcommand '%s'" % subcommand) def usage(self, myname, subcommand=None, *args): if subcommand is None or not subcommand in self.subcommands: |