commit b5211c359ea83bd0bb10ed56e841644b300c78e0 Author: Damian Johnson atagar@torproject.org Date: Sun Dec 15 17:21:18 2013 -0800
Sentinel to indicate when settings are loaded
Replacing our IS_SETTINGS_LOADED global with a sentinel within our settings.cfg. Functionally this is equivilent - I just like avoiding this global. --- arm/settings.cfg | 2 ++ arm/starter.py | 10 +++------- 2 files changed, 5 insertions(+), 7 deletions(-)
diff --git a/arm/settings.cfg b/arm/settings.cfg index 6998de0..d5a34ba 100644 --- a/arm/settings.cfg +++ b/arm/settings.cfg @@ -1,3 +1,5 @@ +settings_loaded true + msg.help |Usage arm [OPTION] |Terminal status monitor for Tor relays. diff --git a/arm/starter.py b/arm/starter.py index 035fa70..8b224a9 100644 --- a/arm/starter.py +++ b/arm/starter.py @@ -36,6 +36,7 @@ import stem.util.system LOG_DUMP_PATH = os.path.expanduser("~/.arm/log")
CONFIG = stem.util.conf.config_dict("arm", { + 'settings_loaded': False, 'tor.password': None, 'startup.events': 'N3', 'msg.help': '', @@ -70,11 +71,9 @@ ARGS = { 'print_help': False, }
-OPT = "gi:s:c:dbe:vh" +OPT = "i:s:c:dbe:vh" OPT_EXPANDED = ["interface=", "socket=", "config=", "debug", "blind", "event=", "version", "help"]
-IS_SETTINGS_LOADED = False -
def _load_settings(): """ @@ -85,15 +84,12 @@ def _load_settings(): :raises: **ValueError** if the settings can't be loaded """
- global IS_SETTINGS_LOADED - - if not IS_SETTINGS_LOADED: + if not CONFIG['settings_loaded']: config = stem.util.conf.get_config("arm") settings_path = os.path.join(os.path.dirname(__file__), 'settings.cfg')
try: config.load(settings_path) - IS_SETTINGS_LOADED = True except IOError as exc: raise ValueError("Unable to load arm's internal configuration (%s): %s" % (settings_path, exc))
tor-commits@lists.torproject.org