spawn.py 351 B

12345678910111213141516
  1. __all__ = [ "find_executable", ]
  2. import os
  3. def find_executable(executable, path=None):
  4. if executable:
  5. import os.path
  6. if path is None:
  7. path = os.getenv("PATH", "")
  8. for p in path.split(":"):
  9. fullpath = os.path.join(p, executable)
  10. if os.access(fullpath, os.X_OK) and\
  11. not os.path.isdir(fullpath):
  12. return fullpath
  13. return None