[PATCH 2/3] Adds getcmdpath method to use which to locate the used commands

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Signed-off-by: Raphaël Beamonte <raphael.beamonte@xxxxxxxxx>
---
 rteval/rteval.py |   13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/rteval/rteval.py b/rteval/rteval.py
index a432233..f54c1f4 100644
--- a/rteval/rteval.py
+++ b/rteval/rteval.py
@@ -63,6 +63,17 @@ import rtevalMailer
 from cputopology import CPUtopology
 
 
+pathSave={}
+def getcmdpath(which):
+    if not pathSave.has_key(which):
+        cmd = '/usr/bin/which %s' % which
+        c = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE)
+        pathSave[which] = c.stdout.read().strip()
+        if not pathSave[which]:
+            raise RuntimeError, "Command '%s' is unknown on this system" % which
+    return pathSave[which]
+
+
 sigint_received = False
 def sigint_handler(signum, frame):
     global sigint_received
@@ -249,7 +260,7 @@ class RtEval(object):
         policies = {'FF':'fifo', 'RR':'rrobin', 'TS':'other', '?':'unknown' }
         ret_kthreads = {}
         self.debug("getting kthread status")
-        cmd = '/bin/ps -eocommand,pid,policy,rtprio,comm'
+        cmd = '%s -eocommand,pid,policy,rtprio,comm' % getcmdpath('ps')
         self.debug("cmd: %s" % cmd)
         c = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE)
         for p in c.stdout:
-- 
1.7.10.4

--
To unsubscribe from this list: send the line "unsubscribe linux-rt-users" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [RT Stable]     [Kernel Newbies]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Samba]     [Video 4 Linux]     [Device Mapper]

  Powered by Linux