Example #1
0
 def testIsExecutable(self):
   self.assertFalse(py_utils.IsExecutable('nonexistent_file'))
   # We use actual files on disk instead of pyfakefs because the executable is
   # set different on win that posix platforms and pyfakefs doesn't support
   # win platform well.
   self.assertFalse(py_utils.IsExecutable(_GetFileInTestDir('foo.txt')))
   self.assertTrue(py_utils.IsExecutable(sys.executable))
Example #2
0
def _FindExecutableInPath(relative_executable_path, *extra_search_paths):
  search_paths = list(extra_search_paths) + os.environ['PATH'].split(os.pathsep)
  for search_path in search_paths:
    executable_path = os.path.join(search_path, relative_executable_path)
    if py_utils.IsExecutable(executable_path):
      return executable_path
  return None