Kaydet (Commit) 484e584f authored tarafından Ozan Çağlayan's avatar Ozan Çağlayan

util: add search_executable() to find search for an executable in PATH

üst 7ca858c8
......@@ -175,6 +175,14 @@ def format_by_columns(strings, sep_width=2):
# Process Releated Functions #
##############################
def search_executable(executable):
"""Search for the executable in user's paths and return it."""
for _path in os.environ["PATH"].split(":"):
full_path = os.path.join(_path, executable)
if os.path.exists(full_path) and os.access(full_path, os.X_OK):
return full_path
return None
def run_batch(cmd):
"""Run command and report return value and output."""
ctx.ui.info(_('Running ') + cmd, verbose=True)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment