diff options
author | Ben Howard <ben.howard@canonical.com> | 2013-07-18 15:37:18 -0600 |
---|---|---|
committer | Ben Howard <ben.howard@canonical.com> | 2013-07-18 15:37:18 -0600 |
commit | 6b7e65e4f57902c25363c78a7e47aa2caa579b7b (patch) | |
tree | 92939a2c3b8a136f0fee013b55ee3465102393ea /cloudinit/util.py | |
parent | 1edfb2a7a36a2bdddfe0ca48ba5d23721bf17a35 (diff) | |
download | vyos-cloud-init-6b7e65e4f57902c25363c78a7e47aa2caa579b7b.tar.gz vyos-cloud-init-6b7e65e4f57902c25363c78a7e47aa2caa579b7b.zip |
Added SmartOS datasource and unit tests.
Diffstat (limited to 'cloudinit/util.py')
-rw-r--r-- | cloudinit/util.py | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/cloudinit/util.py b/cloudinit/util.py index c45aae06..7163225f 100644 --- a/cloudinit/util.py +++ b/cloudinit/util.py @@ -1743,3 +1743,21 @@ def get_mount_info(path, log=LOG): mountinfo_path = '/proc/%s/mountinfo' % os.getpid() lines = load_file(mountinfo_path).splitlines() return parse_mount_info(path, lines, log) + +def which(program): + # Return path of program for execution if found in path + def is_exe(fpath): + return os.path.isfile(fpath) and os.access(fpath, os.X_OK) + + fpath, fname = os.path.split(program) + if fpath: + if is_exe(program): + return program + else: + for path in os.environ["PATH"].split(os.pathsep): + path = path.strip('"') + exe_file = os.path.join(path, program) + if is_exe(exe_file): + return exe_file + + return None |