[tor-commits] [nyx/master] Move _load_user_nyxrc() helper into main

atagar at torproject.org atagar at torproject.org
Tue Sep 12 18:47:18 UTC 2017


commit 4fe97b17de9b0999ea87c9c13978eb3f7d80a06a
Author: Damian Johnson <atagar at torproject.org>
Date:   Sun Sep 10 03:50:04 2017 -0700

    Move _load_user_nyxrc() helper into main
    
    This helper stands out from the rest in that it's invoked before established a
    controller connection. Think I like it a bit better above, like the debug
    handling.
---
 nyx/starter.py | 33 +++++++++++----------------------
 1 file changed, 11 insertions(+), 22 deletions(-)

diff --git a/nyx/starter.py b/nyx/starter.py
index 40cfc6b..789e67c 100644
--- a/nyx/starter.py
+++ b/nyx/starter.py
@@ -63,7 +63,13 @@ def main(config):
       print('Unable to write to our debug log file (%s): %s' % (args.debug_path, exc.strerror))
       sys.exit(1)
 
-  _load_user_nyxrc(args.config)
+  if os.path.exists(args.config):
+    try:
+      config.load(args.config)
+    except IOError as exc:
+      stem.util.log.warn('Failed to load configuration (using defaults): "%s"' % exc.strerror)
+  else:
+    stem.util.log.notice('No nyxrc loaded, using defaults. You can customize nyx by placing a configuration file at %s (see https://nyx.torproject.org/nyxrc.sample for its options).' % args.config)
 
   controller = init_controller(
     control_port = args.control_port,
@@ -134,21 +140,6 @@ def _setup_debug_logging(args):
   ))
 
 
- at uses_settings
-def _load_user_nyxrc(path, config):
-  """
-  Loads user's personal nyxrc if it's available.
-  """
-
-  if os.path.exists(path):
-    try:
-      config.load(path)
-    except IOError as exc:
-      stem.util.log.warn('Failed to load configuration (using defaults): "%s"' % exc.strerror)
-  else:
-    stem.util.log.notice('No nyxrc loaded, using defaults. You can customize nyx by placing a configuration file at %s (see https://nyx.torproject.org/nyxrc.sample for its options).' % path)
-
-
 def _warn_if_root(controller):
   """
   Give a notice if tor or nyx are running with root.
@@ -191,13 +182,11 @@ def _use_unicode(config):
   initializing curses.
   """
 
-  if not config.get('unicode_support', True):
-    return
-
-  is_lang_unicode = 'utf-' in os.getenv('LANG', '').lower()
+  if config.get('unicode_support', True):
+    is_lang_unicode = 'utf-' in os.getenv('LANG', '').lower()
 
-  if is_lang_unicode and nyx.curses.is_wide_characters_supported():
-    locale.setlocale(locale.LC_ALL, '')
+    if is_lang_unicode and nyx.curses.is_wide_characters_supported():
+      locale.setlocale(locale.LC_ALL, '')
 
 
 def _set_process_name():





More information about the tor-commits mailing list