From: Alfredo Deza Date: Mon, 25 Nov 2013 17:31:56 +0000 (-0600) Subject: create a new 'which' helper to find executable paths X-Git-Tag: v1.3.3~4^2~5 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=b5f4d347c06e42c7965ee52f021e7acf0a23498c;p=ceph-deploy.git create a new 'which' helper to find executable paths Signed-off-by: Alfredo Deza --- diff --git a/ceph_deploy/hosts/remotes.py b/ceph_deploy/hosts/remotes.py index b5e0420..0c74a4f 100644 --- a/ceph_deploy/hosts/remotes.py +++ b/ceph_deploy/hosts/remotes.py @@ -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: