[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [stem/master] Remove awk and grep from ps call



commit c421b54e52d181e14a6677752fe2c07d2b56a796
Author: Sathyanarayanan Gunasekaran <gsathya.ceg@xxxxxxxxx>
Date:   Tue Dec 20 17:13:53 2011 +0530

    Remove awk and grep from ps call
    
    Instead of piping the output from the ps call
    to grep and awk, use python itself to parse
    the result.
---
 test/integ/util/system.py |    8 +++++---
 1 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/test/integ/util/system.py b/test/integ/util/system.py
index 7f4c68c..b255c4a 100644
--- a/test/integ/util/system.py
+++ b/test/integ/util/system.py
@@ -26,11 +26,13 @@ class TestSystem(unittest.TestCase):
     
     if self.is_extra_tor_running == None:
       if not stem.util.system.is_bsd():
-        pgrep_results = stem.util.system.call("pgrep -x tor")
+        pgrep_results = stem.util.system.call(stem.util.system.GET_PID_BY_NAME_PGREP % "tor")
         self.is_extra_tor_running = len(pgrep_results) > 1
       else:
-        pgrep_results = stem.util.system.call("ps -axo pid,command,args  | grep -i tor | awk '{ print $1}'")
-        self.is_extra_tor_running = len(pgrep_results) > 1
+        ps_results = stem.util.system.call(stem.util.system.GET_PID_BY_NAME_PS_BSD)
+        results = [r for r in ps_results if r.endswith("tor")]
+        self.is_extra_tor_running = len(results) > 1
+        
   def tearDown(self):
     # resets call mocking back to being disabled
     stem.util.system.CALL_MOCKING = None



_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits