commit a4a70c0a59ca202cd3e3d24771b675a7ec76aec9 Author: Damian Johnson atagar@torproject.org Date: Tue Dec 22 09:45:16 2015 -0800
Use new get_custom_conf() method
Taking advantage of Stem's new get_custom_conf() method, replacing our version. --- nyx/config_panel.py | 4 ++-- nyx/util/tor_config.py | 50 ++---------------------------------------------- 2 files changed, 4 insertions(+), 50 deletions(-)
diff --git a/nyx/config_panel.py b/nyx/config_panel.py index 6419965..05332dc 100644 --- a/nyx/config_panel.py +++ b/nyx/config_panel.py @@ -311,7 +311,7 @@ class ConfigPanel(panel.Panel): Confirmation dialog for saving tor's configuration. """
- config_lines = tor_config.get_custom_options(True) + config_lines = tor_controller().get_custom_conf([], include_values = True)
with nyx.popups.popup_window(len(config_lines) + 2) as (popup, width, height): if not popup or height <= 2: @@ -339,7 +339,7 @@ class ConfigPanel(panel.Panel): popup.addstr(i + 1, 1, option, curses.A_BOLD, 'green') popup.addstr(i + 1, len(option) + 2, arg, curses.A_BOLD, 'cyan')
- # draws selection options (drawn right to left) + # selection options (drawn right to left)
selection_options = ('Save', 'Save As...', 'Cancel') draw_x = width - 1 diff --git a/nyx/util/tor_config.py b/nyx/util/tor_config.py index dc39395..9d2d3f5 100644 --- a/nyx/util/tor_config.py +++ b/nyx/util/tor_config.py @@ -126,52 +126,6 @@ def get_multiline_parameters(): return tuple(MULTILINE_PARAM)
-def get_custom_options(include_value = False): - """ - Provides the torrc parameters that differ from their defaults. - - Arguments: - include_value - provides the current value with results if true, otherwise - this just contains the options - """ - - config_text = tor_controller().get_info('config-text', '').strip() - config_lines = config_text.split('\n') - - # removes any duplicates - - config_lines = list(set(config_lines)) - - # The "GETINFO config-text" query only provides options that differ - # from Tor's defaults with the exception of its Log and Nickname entries - # which, even if undefined, returns "Log notice stdout" as per: - # https://trac.torproject.org/projects/tor/ticket/2362 - # - # If this is from the deb then it will be "Log notice file /var/log/tor/log" - # due to special patching applied to it, as per: - # https://trac.torproject.org/projects/tor/ticket/4602 - - try: - config_lines.remove('Log notice stdout') - except ValueError: - pass - - try: - config_lines.remove('Log notice file /var/log/tor/log') - except ValueError: - pass - - try: - config_lines.remove('Nickname %s' % socket.gethostname()) - except ValueError: - pass - - if include_value: - return config_lines - else: - return [line[:line.find(' ')] for line in config_lines] - - def save_conf(destination = None, contents = None): """ Saves the configuration to the given path. If this is equivilant to @@ -192,7 +146,7 @@ def save_conf(destination = None, contents = None):
is_saveconf, start_time = True, time.time()
- current_config = get_custom_options(True) + current_config = tor_controller().get_custom_conf([], include_values = True)
if not contents: contents = current_config @@ -285,7 +239,7 @@ def validate(contents = None): """
controller = tor_controller() - custom_options = get_custom_options() + custom_options = controller.get_custom_conf([]) issues_found, seen_options = [], []
# Strips comments and collapses multiline multi-line entries, for more