[tor-commits] [nyx/master] Drop missing_event_types()
atagar at torproject.org
atagar at torproject.org
Tue Jun 7 17:30:03 UTC 2016
commit 9e9be8296bb5fb70e6c462509e5613f83b713e30
Author: Damian Johnson <atagar at torproject.org>
Date: Tue Jun 7 09:40:46 2016 -0700
Drop missing_event_types()
Now that we do event selection based on what tor supports rather than a
hardcoded list of events we accept there's no longer a set of 'UNKNOWN' events.
---
nyx/arguments.py | 21 +--------------------
nyx/log.py | 5 -----
nyx/settings/strings.cfg | 1 -
nyx/starter.py | 12 ------------
test/arguments.py | 30 +-----------------------------
5 files changed, 2 insertions(+), 67 deletions(-)
diff --git a/nyx/arguments.py b/nyx/arguments.py
index 6ed405d..f771e0b 100644
--- a/nyx/arguments.py
+++ b/nyx/arguments.py
@@ -14,7 +14,7 @@ import nyx.log
import stem.util.connection
-from nyx import DATA_DIR, tor_controller, msg
+from nyx import DATA_DIR, msg
DEFAULT_ARGS = {
'control_address': '127.0.0.1',
@@ -201,22 +201,3 @@ def validate_events(events):
raise ValueError(','.join(invalid_events))
else:
return accepted_events
-
-
-def missing_event_types():
- """
- Provides the event types the current tor connection supports but nyx
- doesn't. This provides an empty list if no event types are missing or the
- GETINFO query fails.
-
- :returns: **list** of missing event types
- """
-
- response = tor_controller().get_info('events/names', None)
-
- if response is None:
- return [] # GETINFO query failed
-
- tor_event_types = response.split(' ')
- recognized_types = TOR_EVENT_TYPES.values()
- return list(filter(lambda x: x not in recognized_types, tor_event_types))
diff --git a/nyx/log.py b/nyx/log.py
index 2a60a9e..3929548 100644
--- a/nyx/log.py
+++ b/nyx/log.py
@@ -190,11 +190,6 @@ def listen_for_events(listener, events):
tor_events = events.intersection(set(nyx.arguments.TOR_EVENT_TYPES.values()))
nyx_events = events.intersection(set(NYX_RUNLEVELS))
- # adds events unrecognized by nyx if we're listening to the 'UNKNOWN' type
-
- if 'UNKNOWN' in events:
- tor_events.update(set(nyx.arguments.missing_event_types()))
-
controller = nyx.tor_controller()
controller.remove_event_listener(listener)
diff --git a/nyx/settings/strings.cfg b/nyx/settings/strings.cfg
index 51dbfde..c19930b 100644
--- a/nyx/settings/strings.cfg
+++ b/nyx/settings/strings.cfg
@@ -33,7 +33,6 @@ msg.setup.chroot_doesnt_exist The chroot path set in your config ({path}) doesn'
msg.setup.set_freebsd_chroot Adjusting paths to account for Tor running in a FreeBSD jail at: {path}
msg.setup.tor_is_running_as_root Tor is currently running with root permissions. This isn't a good idea, nor should it be necessary. See the 'User UID' option on Tor's man page for an easy method of reducing its permissions after startup.
msg.setup.unable_to_determine_pid Unable to determine Tor's pid. Some information, like its resource usage will be unavailable.
-msg.setup.unknown_event_types nyx doesn't recognize the following event types: {event_types} (log 'UNKNOWN' events to see them)
msg.setup.color_support_available Terminal color support detected and enabled
msg.setup.color_support_unavailable Terminal color support unavailable
diff --git a/nyx/starter.py b/nyx/starter.py
index 7162e53..b9df29a 100644
--- a/nyx/starter.py
+++ b/nyx/starter.py
@@ -80,7 +80,6 @@ def main(config):
_warn_if_root(controller)
_warn_if_unable_to_get_pid(controller)
_setup_freebsd_chroot(controller)
- _notify_of_unknown_events()
_use_english_subcommands()
_use_no_esc_delay()
_use_unicode()
@@ -205,17 +204,6 @@ def _setup_freebsd_chroot(controller, config):
config.set('tor.chroot', jail_chroot)
-def _notify_of_unknown_events():
- """
- Provides a notice about any event types tor supports but nyx doesn't.
- """
-
- missing_events = nyx.arguments.missing_event_types()
-
- if missing_events:
- log.info('setup.unknown_event_types', event_types = ', '.join(missing_events))
-
-
def _use_english_subcommands():
"""
Make subcommands we run (ps, netstat, etc) provide us with English results.
diff --git a/test/arguments.py b/test/arguments.py
index 9d12651..58bf954 100644
--- a/test/arguments.py
+++ b/test/arguments.py
@@ -1,8 +1,6 @@
import unittest
-from mock import Mock, patch
-
-from nyx.arguments import DEFAULT_ARGS, parse, missing_event_types
+from nyx.arguments import DEFAULT_ARGS, parse
class TestArgumentParsing(unittest.TestCase):
@@ -63,29 +61,3 @@ class TestArgumentParsing(unittest.TestCase):
for invalid_input in invalid_inputs:
self.assertRaises(ValueError, parse, ['--interface', invalid_input])
-
-
-class TestMissingEventTypes(unittest.TestCase):
- @patch('nyx.arguments.tor_controller')
- def test_with_a_failed_query(self, controller_mock):
- controller = Mock()
- controller.get_info.return_value = None
- controller_mock.return_value = controller
-
- self.assertEqual([], missing_event_types())
-
- @patch('nyx.arguments.tor_controller')
- def test_without_unrecognized_events(self, controller_mock):
- controller = Mock()
- controller.get_info.return_value = 'DEBUG INFO NOTICE WARN ERR'
- controller_mock.return_value = controller
-
- self.assertEqual([], missing_event_types())
-
- @patch('nyx.arguments.tor_controller')
- def test_with_unrecognized_events(self, controller_mock):
- controller = Mock()
- controller.get_info.return_value = 'EVENT1 DEBUG INFO NOTICE WARN EVENT2 ERR EVENT3'
- controller_mock.return_value = controller
-
- self.assertEqual(['EVENT1', 'EVENT2', 'EVENT3'], missing_event_types())
More information about the tor-commits
mailing list