linux-rt-users.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Raphaël Beamonte" <raphael.beamonte@gmail.com>
To: williams@redhat.com
Cc: linux-rt-users@vger.kernel.org,
	"Raphaël Beamonte" <raphael.beamonte@gmail.com>
Subject: [PATCH 2/3] Adds getcmdpath method to use which to locate the used commands
Date: Tue, 23 Oct 2012 11:45:04 -0400	[thread overview]
Message-ID: <1351007105-7852-3-git-send-email-raphael.beamonte@gmail.com> (raw)
In-Reply-To: <1351007105-7852-1-git-send-email-raphael.beamonte@gmail.com>

Signed-off-by: Raphaël Beamonte <raphael.beamonte@gmail.com>
---
 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@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

  parent reply	other threads:[~2012-10-23 15:45 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-10-23 15:45 [PATCH 0/3] rteval cross-distribution patch Raphaël Beamonte
2012-10-23 15:45 ` [PATCH 1/3] Rewrite of the get_kthreads method to make it cross-distribution Raphaël Beamonte
2012-10-23 15:45 ` Raphaël Beamonte [this message]
2012-10-23 15:45 ` [PATCH 3/3] Rewrite of the get_services " Raphaël Beamonte
2012-10-23 17:26 ` [PATCH 0/3] rteval cross-distribution patch Clark Williams

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1351007105-7852-3-git-send-email-raphael.beamonte@gmail.com \
    --to=raphael.beamonte@gmail.com \
    --cc=linux-rt-users@vger.kernel.org \
    --cc=williams@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).