commit c1f1602c9f9c8b426d078751cf2e9d2af0f471d5 Author: Damian Johnson atagar@torproject.org Date: Sun Sep 8 14:42:58 2013 -0700
Moving --help output to settings.cfg
Big blocks of text like our --help output belong in our configuration. While moving it there I realized that we actually weren't loading our settings.cfg *at all*. Nice. :P --- arm/settings.cfg | 20 ++++++++++++++++++++ arm/starter.py | 48 +++++++++++++++--------------------------------- 2 files changed, 35 insertions(+), 33 deletions(-)
diff --git a/arm/settings.cfg b/arm/settings.cfg index 8cd92c1..c73a16f 100644 --- a/arm/settings.cfg +++ b/arm/settings.cfg @@ -1,3 +1,23 @@ +msg.help +|Usage arm [OPTION] +|Terminal status monitor for Tor relays. +| +| -i, --interface [ADDRESS:]PORT change control interface from %s:%i +| -s, --socket SOCKET_PATH attach using unix domain socket if present, +| SOCKET_PATH defaults to: %s +| -c, --config CONFIG_PATH loaded configuration options, CONFIG_PATH +| defaults to: %s +| -d, --debug writes all arm logs to %s +| -b, --blind disable connection lookups +| -e, --event EVENT_FLAGS event types in message log (default: %s) +|%s +| -v, --version provides version information +| -h, --help presents this help +| +|Example: +|arm -b -i 1643 hide connection data, attaching to control port 1643 +|arm -e we -c /tmp/cfg use this configuration file with 'WARN'/'ERR' events + # Important tor configuration options (shown by default) config.important BandwidthRate config.important BandwidthBurst diff --git a/arm/starter.py b/arm/starter.py index 37c048d..09fa088 100644 --- a/arm/starter.py +++ b/arm/starter.py @@ -48,28 +48,9 @@ CONFIG = stem.util.conf.config_dict("arm", { "startup.dataDirectory": "~/.arm", "features.config.descriptions.enabled": True, "features.config.descriptions.persist": True, + "msg.help": "", })
-HELP_MSG = """Usage arm [OPTION] -Terminal status monitor for Tor relays. - - -i, --interface [ADDRESS:]PORT change control interface from %s:%i - -s, --socket SOCKET_PATH attach using unix domain socket if present, - SOCKET_PATH defaults to: %s - -c, --config CONFIG_PATH loaded configuration options, CONFIG_PATH - defaults to: %s - -d, --debug writes all arm logs to %s - -b, --blind disable connection lookups - -e, --event EVENT_FLAGS event types in message log (default: %s) -%s - -v, --version provides version information - -h, --help presents this help - -Example: -arm -b -i 1643 hide connection data, attaching to control port 1643 -arm -e we -c /tmp/cfg use this configuration file with 'WARN'/'ERR' events -""" % (CONFIG["startup.interface.ipAddress"], CONFIG["startup.interface.port"], CONFIG["startup.interface.socket"], DEFAULT_CONFIG, LOG_DUMP_PATH, CONFIG["startup.events"], arm.logPanel.EVENT_LISTING) - # filename used for cached tor config descriptions CONFIG_DESC_FILENAME = "torConfigDesc.txt"
@@ -332,6 +313,19 @@ def main(): print str(exc) + " (for usage provide --help)" sys.exit()
+ # attempts to fetch attributes for parsing tor's logs, configuration, etc + + config = stem.util.conf.get_config("arm") + + pathPrefix = os.path.dirname(sys.argv[0]) + if pathPrefix and not pathPrefix.endswith("/"): + pathPrefix = pathPrefix + "/" + + try: + config.load("%sarm/settings.cfg" % pathPrefix) + except IOError, exc: + stem.util.log.warn(NO_INTERNAL_CFG_MSG % arm.util.sysTools.getFileErrorMsg(exc)) + for opt, arg in opts: if opt in ("-i", "--interface"): # defines control interface address/port @@ -362,7 +356,7 @@ def main(): print "arm version %s (released %s)\n" % (__version__, __release_date__) sys.exit() elif opt in ("-h", "--help"): - print HELP_MSG + print CONFIG['msg.help'] % (ARGS['control_address'], ARGS['control_port'], ARGS['control_socket'], DEFAULT_CONFIG, LOG_DUMP_PATH, ARGS['logged_events'], arm.logPanel.EVENT_LISTING) sys.exit()
if isDebugMode: @@ -388,18 +382,6 @@ def main(): except (OSError, IOError), exc: print "Unable to write to debug log file: %s" % arm.util.sysTools.getFileErrorMsg(exc)
- config = stem.util.conf.get_config("arm") - - # attempts to fetch attributes for parsing tor's logs, configuration, etc - pathPrefix = os.path.dirname(sys.argv[0]) - if pathPrefix and not pathPrefix.endswith("/"): - pathPrefix = pathPrefix + "/" - - try: - config.load("%ssettings.cfg" % pathPrefix) - except IOError, exc: - stem.util.log.warn(NO_INTERNAL_CFG_MSG % arm.util.sysTools.getFileErrorMsg(exc)) - # loads user's personal armrc if available if os.path.exists(configPath): try:
tor-commits@lists.torproject.org