[tor-commits] [ooni-probe/master] psiphon: use the python provided by sys.executable

art at torproject.org art at torproject.org
Fri Apr 29 09:42:22 UTC 2016


commit b899fb7f25533fef7ddc9a23afe869c4bf684f14
Author: Simone Basso <bassosimone at gmail.com>
Date:   Sat Oct 10 11:06:11 2015 +0200

    psiphon: use the python provided by sys.executable
    
    There may be more than one Python (for example on MacOS I have both
    the system Python and the one installed with brew).
    
    Make sure we use the same Python with which ooni-probe was started
    such that modules installed with pip are found.
    
    Updated to avoid setting the temporary file executable and to avoid
    removing my Python interpreter :).
---
 ooni/nettests/third_party/psiphon.py | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/ooni/nettests/third_party/psiphon.py b/ooni/nettests/third_party/psiphon.py
index 8ac287d..6a2e08e 100644
--- a/ooni/nettests/third_party/psiphon.py
+++ b/ooni/nettests/third_party/psiphon.py
@@ -1,6 +1,7 @@
 import tempfile
 import stat
 import os
+import sys
 
 from twisted.internet import defer, reactor
 from twisted.internet.endpoints import TCP4ClientEndpoint
@@ -76,15 +77,14 @@ class PsiphonTest(httpt.HTTPTest,  process.ProcessTest):
                  'psiphon-circumvention-system/pyclient')
             log.debug('psiphon path: %s' % self.psiphonpath)
 
-        x = """#!/usr/bin/env python
+        x = """
 from psi_client import connect
 connect(False)
 """
         f = tempfile.NamedTemporaryFile(delete=False)
         f.write(x)
         f.close()
-        os.chmod(f.name, os.stat(f.name).st_mode | stat.S_IEXEC)
-        self.command = [f.name]
+        self.command = [sys.executable, f.name]
         log.debug('command: %s' % ''.join(self.command))
 
     def handleRead(self, stdout, stderr):
@@ -119,7 +119,7 @@ connect(False)
         def cleanup(_):
             log.debug('PsiphonTest:cleanup')
             self.processDirector.transport.signalProcess('INT')
-            os.remove(self.command[0])
+            os.remove(self.command[1])
             return finished
         
         self.bootstrapped.addBoth(cleanup)





More information about the tor-commits mailing list