From: David-Sarah Hopwood Date: Thu, 3 Jan 2013 18:53:39 +0000 (+0000) Subject: startstop_node.py: improve error reporting and help. X-Git-Url: https://git.rkrishnan.org/pf/statistics?a=commitdiff_plain;h=770fd45ccc3baa44886c420858bc3899b2741d7b;p=tahoe-lafs%2Ftahoe-lafs.git startstop_node.py: improve error reporting and help. --- diff --git a/src/allmydata/scripts/startstop_node.py b/src/allmydata/scripts/startstop_node.py index 90ec1046..a0c69bb6 100644 --- a/src/allmydata/scripts/startstop_node.py +++ b/src/allmydata/scripts/startstop_node.py @@ -7,7 +7,12 @@ from allmydata.util import fileutil from allmydata.util.encodingutil import listdir_unicode, quote_output +def format_twisted_options(config): + return "twistd %s\n" % (str(config).partition("\n")[2].partition("\n\n")[0],) + class StartOptions(BasedirOptions): + subcommand_name = "start" + def parseArgs(self, basedir=None, *twistd_args): # this can't handle e.g. 'tahoe start --nodaemon', since then # --nodaemon looks like a basedir. So you can either use 'tahoe @@ -19,22 +24,22 @@ class StartOptions(BasedirOptions): self.twistd_args = twistd_args def getSynopsis(self): - return "Usage: %s [global-opts] start [options] [NODEDIR]" % (self.command_name,) + return "Usage: %s [global-opts] %s [options] [NODEDIR] [twistd_options]" % (self.command_name, self.subcommand_name) + def getUsage(self, width=None): + t = BaseOptions.getUsage(self, width) + "\n" + t += format_twisted_options(MyTwistdConfig()) + return t class StopOptions(BasedirOptions): def getSynopsis(self): return "Usage: %s [global-opts] stop [options] [NODEDIR]" % (self.command_name,) - class RestartOptions(StartOptions): - def getSynopsis(self): - return "Usage: %s [global-opts] restart [options] [NODEDIR]" % (self.command_name,) - + subcommand_name = "restart" class RunOptions(StartOptions): - def getSynopsis(self): - return "Usage: %s [global-opts] run [options] [NODEDIR]" % (self.command_name,) + subcommand_name = "run" class MyTwistdConfig(twistd.ServerOptions): @@ -111,8 +116,9 @@ def start(config, out=sys.stdout, err=sys.stderr): twistd_config.parseOptions(twistd_args) except usage.error, ue: # these arguments were unsuitable for 'twistd' - print >>err, twistd_config - print >>err, "tahoe start: %s" % (config.subCommand, ue) + print >>err, config + print >>err, format_twisted_options(twistd_config) + print >>err, "tahoe %s: %s\n" % (config.subcommand_name, ue) return 1 twistd_config.loadedPlugins = {"StartTahoeNode": StartTahoeNodePlugin(nodetype, basedir)}