[tor-commits] [stem/master] Using new system api for protocolinfo queries

atagar at torproject.org atagar at torproject.org
Sun Nov 20 23:57:22 UTC 2011


commit 5847301f6011df37d517041c00ff23419e107316
Author: Damian Johnson <atagar at torproject.org>
Date:   Sat Nov 19 22:25:21 2011 -0800

    Using new system api for protocolinfo queries
    
    The protocolinfo uses system utils for expansion of relative cookie paths.
    Making it use the new api (the breakup of the get_pid_by_* functions was
    largely for this class).
---
 stem/connection.py |    8 ++++++--
 1 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/stem/connection.py b/stem/connection.py
index 2b96899..3165fba 100644
--- a/stem/connection.py
+++ b/stem/connection.py
@@ -158,8 +158,12 @@ class ProtocolInfoResponse(stem.types.ControlMessage):
           # attempt to expand relative cookie paths
           if stem.util.system.is_relative_path(self.cookie_file):
             try:
-              tor_pid = stem.util.system.get_pid("tor", suppress_exc = False)
-              tor_cwd = stem.util.system.get_cwd(tor_pid, False)
+              tor_pid = stem.util.system.get_pid_by_name("tor")
+              if not tor_pid: raise IOError("pid lookup failed")
+              
+              tor_cwd = stem.util.system.get_cwd(tor_pid)
+              if not tor_cwd: raise IOError("cwd lookup failed")
+              
               self.cookie_file = stem.util.system.expand_path(self.cookie_file, tor_cwd)
             except IOError, exc:
               LOGGER.debug("unable to expand relative tor cookie path: %s" % exc)





More information about the tor-commits mailing list