diff options
author | Raphaël Beamonte <raphael.beamonte@gmail.com> | 2012-10-23 11:45:04 -0400 |
---|---|---|
committer | Clark Williams <williams@redhat.com> | 2012-10-23 12:03:17 -0500 |
commit | 0a4cb7526bf5734c0995e9e19e9a1d8990c687f4 (patch) | |
tree | 4018bebf70e7944c8fd8c0739557d94f6ff2ff86 | |
parent | 565f66981b31f3f82d0c08a08b6f316de34d03fa (diff) | |
download | rteval-0a4cb7526bf5734c0995e9e19e9a1d8990c687f4.tar.gz rteval-0a4cb7526bf5734c0995e9e19e9a1d8990c687f4.tar.xz rteval-0a4cb7526bf5734c0995e9e19e9a1d8990c687f4.zip |
Adds getcmdpath method to use which to locate the used commands
Signed-off-by: Raphaël Beamonte <raphael.beamonte@gmail.com>
-rw-r--r-- | rteval/rteval.py | 13 |
1 files changed, 12 insertions, 1 deletions
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: |