add a couple of utils to the server side
Signed-off-by: Martin J. Bligh <mbligh@google.com>
git-svn-id: http://test.kernel.org/svn/autotest/trunk@1051 592f7852-d20e-0410-864c-8624ca9c26a4
diff --git a/server/utils.py b/server/utils.py
index 0e007da..88862c3 100644
--- a/server/utils.py
+++ b/server/utils.py
@@ -375,6 +375,28 @@
return os.path.abspath(path)
+def find_pid(command):
+ for line in system_output('ps -eo pid,cmd').rstrip().split('\n'):
+ (pid, cmd) = line.split(None, 1)
+ if re.search(command, cmd):
+ return int(pid)
+ return None
+
+
+def nohup(command, stdout='/dev/null', stderr='/dev/null', background=True,
+ env = {}):
+ cmd = ' '.join(key+'='+val for key, val in env.iteritems())
+ cmd += ' nohup ' + command
+ cmd += ' > %s' % stdout
+ if stdout == stderr:
+ cmd += ' 2>&1'
+ else:
+ cmd += ' 2> %s' % stderr
+ if background:
+ cmd += ' &'
+ system(cmd)
+
+
class AutoservOptionParser:
"""Custom command-line options parser for autoserv.