[tor-commits] [stem/master] Dropping stem.prereq.is_python_26()

atagar at torproject.org atagar at torproject.org
Sun Apr 14 04:33:47 UTC 2013


commit b1f3504ac7fac93b5a26fd02525cc962228aaea2
Author: Damian Johnson <atagar at torproject.org>
Date:   Sat Apr 13 10:05:57 2013 -0700

    Dropping stem.prereq.is_python_26()
    
    The is_python_26() check was used to support python 2.5 hacks. Dropping this
    and the hacks that it was supporting.
---
 stem/descriptor/reader.py |    6 +-----
 stem/prereq.py            |   23 ++++-------------------
 stem/process.py           |   15 +++------------
 test/integ/process.py     |   19 ++-----------------
 test/runner.py            |    7 +------
 5 files changed, 11 insertions(+), 59 deletions(-)

diff --git a/stem/descriptor/reader.py b/stem/descriptor/reader.py
index 023777a..d764ef6 100644
--- a/stem/descriptor/reader.py
+++ b/stem/descriptor/reader.py
@@ -418,11 +418,7 @@ class DescriptorReader(object):
         continue
 
       if os.path.isdir(target):
-        if stem.prereq.is_python_26():
-          walker = os.walk(target, followlinks = self._follow_links)
-        else:
-          walker = os.walk(target)
-
+        walker = os.walk(target, followlinks = self._follow_links)
         self._handle_walker(walker, new_processed_files)
       else:
         self._handle_file(target, new_processed_files)
diff --git a/stem/prereq.py b/stem/prereq.py
index 41ba4b9..6017402 100644
--- a/stem/prereq.py
+++ b/stem/prereq.py
@@ -2,14 +2,10 @@
 # See LICENSE for licensing information
 
 """
-Checks for stem dependencies. We require python 2.5 or greater (in the 2.x
-series). Other requirements for complete functionality are...
+Checks for stem dependencies. We require python 2.6 or greater (including the
+3.x series). Other requirements for complete functionality are...
 
-* Python 2.6
-
-  * os.walk's followlinks argument
-
-* rsa module
+* pycrypto module
 
   * validating descriptor signature integrity
 
@@ -17,11 +13,10 @@ series). Other requirements for complete functionality are...
 
   check_requirements - checks for minimum requirements for running stem
 
-  is_python_26 - checks if python 2.6 or later is available
   is_python_27 - checks if python 2.7 or later is available
   is_python_3 - checks if python 3.0 or later is available
 
-  is_rsa_available - checks if the rsa module is available
+  is_crypto_available - checks if the pycrypto module is available
 """
 
 import sys
@@ -43,16 +38,6 @@ def check_requirements():
     raise ImportError("stem requires python version 2.6 or greater")
 
 
-def is_python_26():
-  """
-  Checks if we're running python 2.6 or above.
-
-  :returns: bool that is True if we meet this requirement and False otherwise
-  """
-
-  return _check_version(6)
-
-
 def is_python_27():
   """
   Checks if we're running python 2.7 or above.
diff --git a/stem/process.py b/stem/process.py
index 45a064a..36307fc 100644
--- a/stem/process.py
+++ b/stem/process.py
@@ -113,14 +113,7 @@ def launch_tor(tor_cmd = "tor", args = None, torrc_path = None, completion_perce
         except:
           pass
 
-      # We can't kill the subprocess on python 2.5 running Windows without the
-      # win32process module...
-      # http://stackoverflow.com/questions/552423/use-python-2-6-subprocess-module-in-python-2-5/552510#552510
-
-      if stem.prereq.is_python_26():
-        tor_process.kill()
-      elif not stem.util.system.is_windows():
-        os.kill(tor_process.pid, signal.SIGTERM)
+      tor_process.kill()
 
       raise OSError("reached a %i second timeout without success" % timeout)
 
@@ -147,10 +140,8 @@ def launch_tor(tor_cmd = "tor", args = None, torrc_path = None, completion_perce
         signal.alarm(0)  # stop alarm
 
       # ... but best make sure
-      if stem.prereq.is_python_26():
-        tor_process.kill()
-      elif not stem.util.system.is_windows():
-        os.kill(tor_process.pid, signal.SIGTERM)
+
+      tor_process.kill()
 
       raise OSError("Process terminated: %s" % last_problem)
 
diff --git a/test/integ/process.py b/test/integ/process.py
index 59663f3..414d233 100644
--- a/test/integ/process.py
+++ b/test/integ/process.py
@@ -21,11 +21,7 @@ from test import mocking
 
 
 def _kill_process(process):
-  if stem.prereq.is_python_26():
-    process.kill()
-  elif not stem.util.system.is_windows():
-    os.kill(process.pid, signal.SIGTERM)
-
+  process.kill()
   process.communicate()  # block until its definitely gone
 
 
@@ -42,10 +38,6 @@ class TestProcess(unittest.TestCase):
     Exercises launch_tor_with_config.
     """
 
-    if not stem.prereq.is_python_26() and stem.util.system.is_windows():
-      test.runner.skip(self, "(unable to kill subprocesses)")
-      return
-
     if test.runner.only_run_once(self, "test_launch_tor_with_config"):
       return
 
@@ -83,10 +75,6 @@ class TestProcess(unittest.TestCase):
     Runs launch_tor where it times out before completing.
     """
 
-    if not stem.prereq.is_python_26() and stem.util.system.is_windows():
-      test.runner.skip(self, "(unable to kill subprocesses)")
-      return
-
     if test.runner.only_run_once(self, "test_launch_tor_with_timeout"):
       return
 
@@ -105,10 +93,7 @@ class TestProcess(unittest.TestCase):
     test this we spawn a process and trick tor into thinking that it is us.
     """
 
-    if not stem.prereq.is_python_26() and stem.util.system.is_windows():
-      test.runner.skip(self, "(unable to kill subprocesses)")
-      return
-    elif not stem.util.system.is_available("sleep"):
+    if not stem.util.system.is_available("sleep"):
       test.runner.skip(self, "('sleep' command is unavailable)")
       return
     elif test.runner.only_run_once(self, "test_take_ownership_via_pid"):
diff --git a/test/runner.py b/test/runner.py
index aa4e4a9..bcff7a0 100644
--- a/test/runner.py
+++ b/test/runner.py
@@ -364,12 +364,7 @@ class Runner(object):
         # an OSError ([Errno 3] No such process)
 
         try:
-          if stem.prereq.is_python_26():
-            self._tor_process.kill()
-          elif not stem.util.system.is_windows():
-            os.kill(self._tor_process.pid, signal.SIGTERM)
-          else:
-            test.output.print_error("failed (unable to call kill() in python 2.5)")
+          self._tor_process.kill()
         except OSError:
           pass
 





More information about the tor-commits mailing list