def find_file(name):
    """Returns full path to file if found on system."""
    ret_path = None
    try:
        # see if it is already in the path by using the 'which' command
        process = subprocess.Popen(
            "which %s" % name,
            stdout=subprocess.PIPE,
            stderr=subprocess.PIPE,
            shell=True,
        )
        stdout, stderr = process.communicate()
        if stderr:
            raise
        else:
            ret_path = stdout.decode("utf-8").strip()
    except Exception:
        # file not in PATH, try manually searching
        paths = ["/usr/sbin", "/usr/bin", "/usr/local/bin", "/usr/local/sbin"]
        for path in paths:
            candidate = os.path.join(path, name)
            if os.path.exists(candidate):
                break
    return ret_path
Returns full path to file if found on system.
dalton-agent/dalton-agent.py