]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph-deploy.git/commitdiff
create a new 'which' helper to find executable paths
authorAlfredo Deza <alfredo.deza@inktank.com>
Mon, 25 Nov 2013 17:31:56 +0000 (11:31 -0600)
committerAlfredo Deza <alfredo.deza@inktank.com>
Mon, 25 Nov 2013 17:31:56 +0000 (11:31 -0600)
Signed-off-by: Alfredo Deza <alfredo.deza@inktank.com>
ceph_deploy/hosts/remotes.py

index b5e0420dfb978de3577c434020f233737c39f0b3..0c74a4fa22ca61e686ff75fa0dff2cc79728afd0 100644 (file)
@@ -149,6 +149,23 @@ def which_service():
             return location
 
 
+def which(executable):
+    """find the location of an executable"""
+    locations = (
+        '/usr/local/bin',
+        '/bin',
+        '/usr/bin',
+        '/usr/local/sbin',
+        '/usr/sbin',
+        '/sbin',
+    )
+
+    for location in locations:
+        executable_path = os.path.join(location, executable)
+        if os.path.exists(executable_path):
+            return executable_path
+
+
 def make_mon_removed_dir(path, file_name):
     """ move old monitor data """
     try: