[Pkg-privacy-commits] [onionbalance] 29/117: Cleaner handling of Tor events with direct attachment of event handlers - tip from atagar
Donncha O'Cearbahill
donncha-guest at moszumanska.debian.org
Wed Dec 16 23:18:43 UTC 2015
This is an automated email from the git hooks/post-receive script.
donncha-guest pushed a commit to branch debian/sid
in repository onionbalance.
commit bb6d516c9dbe62b8fe6d4ff192852af156f462bc
Author: Donncha O'Cearbhaill <donncha at donncha.is>
Date: Mon Jun 22 17:09:54 2015 +0100
Cleaner handling of Tor events with direct attachment of event handlers - tip from atagar
---
onionbalance/eventhandler.py | 19 ++-----------------
onionbalance/manager.py | 5 +++--
2 files changed, 5 insertions(+), 19 deletions(-)
diff --git a/onionbalance/eventhandler.py b/onionbalance/eventhandler.py
index 541cf8a..668963c 100644
--- a/onionbalance/eventhandler.py
+++ b/onionbalance/eventhandler.py
@@ -1,6 +1,4 @@
# -*- coding: utf-8 -*-
-import stem
-
from onionbalance import log
from onionbalance import descriptor
@@ -14,14 +12,14 @@ class EventHandler(object):
"""
@staticmethod
- def _new_desc(desc_event):
+ def new_desc(desc_event):
"""
Parse HS_DESC response events
"""
logger.debug("Received new HS_DESC event: %s", str(desc_event))
@staticmethod
- def _new_desc_content(desc_content_event):
+ def new_desc_content(desc_content_event):
"""
Parse HS_DESC_CONTENT response events for descriptor content
@@ -41,16 +39,3 @@ class EventHandler(object):
descriptor.descriptor_received(descriptor_text)
return None
-
- def new_event(self, event):
- """
- Dispatches new Tor controller events to the appropriate handlers.
- """
- if isinstance(event, stem.response.events.HSDescEvent):
- self._new_desc(event)
-
- elif isinstance(event, stem.response.events.HSDescContentEvent):
- self._new_desc_content(event)
-
- else:
- logger.warning("Received unexpected event %s.", str(event))
diff --git a/onionbalance/manager.py b/onionbalance/manager.py
index 16dba17..c37963c 100644
--- a/onionbalance/manager.py
+++ b/onionbalance/manager.py
@@ -161,8 +161,9 @@ def main():
# Finished parsing all the config file.
handler = eventhandler.EventHandler()
- controller.add_event_listener(handler.new_event,
- EventType.HS_DESC,
+ controller.add_event_listener(handler.new_desc,
+ EventType.HS_DESC)
+ controller.add_event_listener(handler.new_desc_content,
EventType.HS_DESC_CONTENT)
# Schedule descriptor fetch and upload events
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-privacy/packages/onionbalance.git
More information about the Pkg-privacy-commits
mailing list