[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[tor-commits] [nyx/master] Allow us to listen to events besides a hardcoded list
commit 05de899d707859e66cbc82c8d72427a0276c2c58
Author: Damian Johnson <atagar@xxxxxxxxxxxxxx>
Date: Tue Jun 7 10:09:33 2016 -0700
Allow us to listen to events besides a hardcoded list
Despite having a dialog that populates from tor we filtered down to a hardcoded
list of acceptable events when registering the actual listener.
---
nyx/arguments.py | 71 ------------------------------------------------
nyx/log.py | 6 +---
nyx/panel/log.py | 2 +-
nyx/settings/strings.cfg | 1 -
4 files changed, 2 insertions(+), 78 deletions(-)
diff --git a/nyx/arguments.py b/nyx/arguments.py
index f771e0b..bb0939e 100644
--- a/nyx/arguments.py
+++ b/nyx/arguments.py
@@ -41,50 +41,6 @@ OPT_EXPANDED = [
'help',
]
-TOR_EVENT_TYPES = {
- # runlevels
-
- 'd': 'DEBUG',
- 'i': 'INFO',
- 'n': 'NOTICE',
- 'w': 'WARN',
- 'e': 'ERR',
-
- # important events
-
- 'b': 'BW',
- 'c': 'CIRC',
- 's': 'STREAM',
-
- # everything else
-
- 'a': 'ADDRMAP',
- 'f': 'AUTHDIR_NEWDESCS',
- 'j': 'BUILDTIMEOUT_SET',
- 'k': 'CELL_STATS',
- 'l': 'CIRC_BW',
- 'm': 'CIRC_MINOR',
- 'p': 'CONF_CHANGED',
- 'q': 'CONN_BW',
- 'r': 'CLIENTS_SEEN',
- 'u': 'DESCCHANGED',
- 'g': 'GUARD',
- 'h': 'HS_DESC',
- 'v': 'HS_DESC_CONTENT',
- 'x': 'NETWORK_LIVENESS',
- 'y': 'NEWCONSENSUS',
- 'z': 'NEWDESC',
- 'B': 'NS',
- 'o': 'ORCONN',
- 'C': 'SIGNAL',
- 'F': 'STREAM_BW',
- 'G': 'STATUS_CLIENT',
- 'H': 'STATUS_GENERAL',
- 'I': 'STATUS_SERVER',
- 'J': 'TB_EMPTY',
- 't': 'TRANSPORT_LAUNCHED',
-}
-
def parse(argv):
"""
@@ -134,11 +90,6 @@ def parse(argv):
elif opt in ('-d', '--debug'):
args['debug_path'] = os.path.expanduser(arg)
elif opt in ('-l', '--log'):
- try:
- validate_events(arg)
- except ValueError as exc:
- raise ValueError(msg('usage.unrecognized_log_events', events = exc))
-
args['logged_events'] = arg
elif opt in ('-v', '--version'):
args['print_version'] = True
@@ -179,25 +130,3 @@ def get_version():
version = nyx.__version__,
date = nyx.__release_date__,
)
-
-
-def validate_events(events):
- """
- Check whether the events are any one of Tor runlevels, Nyx runlevels or
- Tor events.
- """
-
- valid_events = set(TOR_EVENT_TYPES.values() + nyx.log.NYX_RUNLEVELS)
- accepted_events, invalid_events = set(), set()
-
- events = events.split(',')
- for event in events:
- if event in valid_events:
- accepted_events.update([event])
- else:
- invalid_events.update([event])
-
- if invalid_events:
- raise ValueError(','.join(invalid_events))
- else:
- return accepted_events
diff --git a/nyx/log.py b/nyx/log.py
index 3929548..255fac7 100644
--- a/nyx/log.py
+++ b/nyx/log.py
@@ -182,13 +182,9 @@ def listen_for_events(listener, events):
:returns: **list** of event types we're successfully now listening to
"""
- import nyx.arguments
events = set(events) # drops duplicates
-
- # accounts for runlevel naming difference
-
- tor_events = events.intersection(set(nyx.arguments.TOR_EVENT_TYPES.values()))
nyx_events = events.intersection(set(NYX_RUNLEVELS))
+ tor_events = events.difference(nyx_events)
controller = nyx.tor_controller()
controller.remove_event_listener(listener)
diff --git a/nyx/panel/log.py b/nyx/panel/log.py
index 9e530c1..5fd0cdf 100644
--- a/nyx/panel/log.py
+++ b/nyx/panel/log.py
@@ -68,7 +68,7 @@ class LogPanel(nyx.panel.DaemonPanel):
def __init__(self):
nyx.panel.DaemonPanel.__init__(self, 'log', UPDATE_RATE)
- logged_events = nyx.arguments.validate_events(CONFIG['startup.events'])
+ logged_events = CONFIG['startup.events'].split(',')
self._event_log = nyx.log.LogGroup(CONFIG['cache.log_panel.size'], group_by_day = True)
self._event_log_paused = None
self._event_types = nyx.log.listen_for_events(self._register_tor_event, logged_events)
diff --git a/nyx/settings/strings.cfg b/nyx/settings/strings.cfg
index c19930b..98df411 100644
--- a/nyx/settings/strings.cfg
+++ b/nyx/settings/strings.cfg
@@ -48,7 +48,6 @@ msg.tracker.unable_to_use_resolver Unable to query connections with {old_resolve
msg.usage.invalid_arguments {error} (for usage provide --help)
msg.usage.not_a_valid_address '{address_input}' isn't a valid IPv4 address
msg.usage.not_a_valid_port '{port_input}' isn't a valid port number
-msg.usage.unrecognized_log_events Unrecognized events: {events}
msg.usage.unable_to_set_color_override "{color}" isn't a valid color
msg.debug.header
_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits