浏览代码

AMBARI-8557 - Python EXE path seems to be hardcoded in ambari-env.cmd (Eugene Chekanskiy via abaranchuk)

Artem Baranchuk 10 年之前
父节点
当前提交
e643e40b06
共有 1 个文件被更改,包括 9 次插入0 次删除
  1. 9 0
      ambari-common/src/main/python/ambari_commons/os_utils.py

+ 9 - 0
ambari-common/src/main/python/ambari_commons/os_utils.py

@@ -20,6 +20,7 @@ limitations under the License.
 
 import shutil
 import string
+import os
 
 from os_check import *
 
@@ -100,3 +101,11 @@ def set_open_files_limit(maxOpenFiles):
 
 def get_password(prompt):
   return os_getpass(prompt)
+
+def find_in_path(file):
+  dirs = os.environ["PATH"].split(os.pathsep)
+  for dir in dirs:
+    full_path = os.path.join(dir, file)
+    if os.path.exists(full_path):
+      return full_path
+  raise Exception("File {} not found in PATH".format(file))