[Pkg-privacy-commits] [pyptlib] 90/136: declareSupports - make managedTransportVer like a tweakable setting that may be used in future, and remove the unnecessary return value

Ximin Luo infinity0 at moszumanska.debian.org
Sat Aug 22 13:25:14 UTC 2015


This is an automated email from the git hooks/post-receive script.

infinity0 pushed a commit to branch master
in repository pyptlib.

commit ed12a3ca2180286fca13a1c27cabb2cf7b34fa38
Author: Ximin Luo <infinity0 at gmx.com>
Date:   Mon Aug 19 18:45:09 2013 +0100

    declareSupports - make managedTransportVer like a tweakable setting that may be used in future, and remove the unnecessary return value
---
 pyptlib/core.py | 13 ++++++-------
 1 file changed, 6 insertions(+), 7 deletions(-)

diff --git a/pyptlib/core.py b/pyptlib/core.py
index 99ee15d..824c333 100644
--- a/pyptlib/core.py
+++ b/pyptlib/core.py
@@ -18,6 +18,7 @@ class TransportPlugin(object):
     def __init__(self, config=None, stdout=sys.stdout):
         self.config = config
         self.stdout = stdout
+        self.served_version = None # set by _declareSupports
         self.served_transports = None # set by _declareSupports
 
     def init(self, supported_transports):
@@ -52,18 +53,16 @@ class TransportPlugin(object):
         try:
             return self.configType.fromEnv()
         except EnvError, e:
-            print >>self.stdout, 'ENV-ERROR %s' % str(e)
-            self.stdout.flush()
+            self.emit('ENV-ERROR %s' % str(e))
             raise e
 
-    def _declareSupports(self, transports):
+    def _declareSupports(self, transports, versions=SUPPORTED_TRANSPORT_VERSIONS):
         """
         Declare to Tor the versions and transports that this PT supports.
 
-        :returns: {"transports": wanted_transports} -- The subset of the
-            declared inputs that were actually wanted by Tor.
+        :raises: :class:`pyptlib.config.EnvError` if this plugin does not support
+                any protocol version that Tor can communicate with us in.
         """
-        versions = SUPPORTED_TRANSPORT_VERSIONS
         cfg = self.config
 
         wanted_versions = [v for v in versions if v in cfg.managedTransportVer]
@@ -80,8 +79,8 @@ class TransportPlugin(object):
             # return able in priority-order determined by plugin
             wanted_transports = [t for t in transports if t in cfg.transports]
 
+        self.served_version = wanted_versions[0]
         self.served_transports = wanted_transports
-        return { 'transports': wanted_transports }
 
     def getServedTransports(self):
         """

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-privacy/packages/pyptlib.git



More information about the Pkg-privacy-commits mailing list