Add findInPath method; search for toolchains in system path.
[bertos.git] / wizard / bertos_utils.py
index f0d5494469e33955d203ba5d937a1c87bbfbe201..204c4fe4ea1e602f9f61ecbaf5756451dee36b88 100644 (file)
@@ -340,12 +340,17 @@ def replaceSeparators(path):
 
 def getSystemPath():
     path = os.environ["PATH"]
-    if os.name == "nt":
-        path = path.split(";")
-    else:
-        path = path.split(":")
+    path = path.split(os.pathsep)
     return path
 
+def findInPath(file, path=None):
+    if path is None:
+        path = os.environ.get('PATH', '')
+    if type(path) is type(''):
+        path = path.split(os.pathsep)
+    return filter(os.path.exists, map(lambda dir, file=file: os.path.join(dir, file), path))
+
+
 def findToolchains(path_list):
     toolchains = []
     for element in path_list: