samba-tool: Improve getopt.py error handling
authorGiampaolo Lauria <lauria2@yahoo.com>
Mon, 17 Oct 2011 19:22:01 +0000 (15:22 -0400)
committerJelmer Vernooij <jelmer@samba.org>
Wed, 19 Oct 2011 01:34:07 +0000 (03:34 +0200)
Raise exception when -d or --debuglevel value is <0

source4/scripting/python/samba/getopt.py

index f939180066ffbc422ce9f9753ad6269a62d83c19..c7035c1936554a63195465fa5c6d95aebf934d56 100644 (file)
@@ -64,6 +64,9 @@ class SambaOptions(optparse.OptionGroup):
         self._configfile = arg
 
     def _set_debuglevel(self, option, opt_str, arg, parser):
+        if arg < 0:
+            raise optparse.OptionValueError("invalid %s option value: %s" %
+                                            (opt_str, arg))
         self._lp.set('debug level', str(arg))
 
     def _set_realm(self, option, opt_str, arg, parser):