When “ganeti-watcher” is called with an argument, it would hint at a non-existing “-f” parameter. With this patch the separate usage string is no longer necessary.
Signed-off-by: Michael Hanselmann <[email protected]> --- lib/watcher/__init__.py | 18 +++++++++--------- 1 files changed, 9 insertions(+), 9 deletions(-) diff --git a/lib/watcher/__init__.py b/lib/watcher/__init__.py index 098f8c2..df2ace2 100644 --- a/lib/watcher/__init__.py +++ b/lib/watcher/__init__.py @@ -683,7 +683,7 @@ def IsRapiResponding(hostname): def ParseOptions(): """Parse the command line options. - @return: (options, args) as from OptionParser.parse_args() + @return: options as returned by OptionParser.parse_args """ parser = OptionParser(description="Ganeti cluster watcher", @@ -693,13 +693,17 @@ def ParseOptions(): parser.add_option(cli.DEBUG_OPT) parser.add_option("-A", "--job-age", dest="job_age", - help="Autoarchive jobs older than this age (default" - " 6 hours)", default=6*3600) + help=("Autoarchive jobs older than this age (default" + " 6 hours)"), default=6 * 3600) parser.add_option("--ignore-pause", dest="ignore_pause", default=False, action="store_true", help="Ignore cluster pause setting") options, args = parser.parse_args() options.job_age = cli.ParseTimespec(options.job_age) - return options, args + + if args: + parser.error("No arguments expected") + + return options @rapi.client.UsesRapiClient @@ -709,11 +713,7 @@ def Main(): """ global client # pylint: disable-msg=W0603 - options, args = ParseOptions() - - if args: # watcher doesn't take any arguments - print >> sys.stderr, ("Usage: %s [-f] " % sys.argv[0]) - return constants.EXIT_FAILURE + options = ParseOptions() utils.SetupLogging(constants.LOG_WATCHER, sys.argv[0], debug=options.debug, stderr_logging=options.debug) -- 1.7.3.5
