diff mbox

[KVM-AUTOTEST,1/3] KVM test: kvm_utils.py: add utility function which locates program files

Message ID 1278251117-31220-1-git-send-email-mgoldish@redhat.com (mailing list archive)
State New, archived
Headers show

Commit Message

Michael Goldish July 4, 2010, 1:45 p.m. UTC
None
diff mbox

Patch

diff --git a/client/tests/kvm/kvm_utils.py b/client/tests/kvm/kvm_utils.py
index 0372565..a57a334 100644
--- a/client/tests/kvm/kvm_utils.py
+++ b/client/tests/kvm/kvm_utils.py
@@ -322,6 +322,15 @@  def env_unregister_vm(env, name):
 
 # Utility functions for dealing with external processes
 
+def find_command(cmd):
+    for dir in ["/usr/local/sbin", "/usr/local/bin",
+                "/usr/sbin", "/usr/bin", "/sbin", "/bin"]:
+        file = os.path.join(dir, cmd)
+        if os.path.exists(file):
+            return file
+    raise ValueError('Missing command: %s' % cmd)
+
+
 def pid_exists(pid):
     """
     Return True if a given PID exists.