Add findInPath method; search for toolchains in system path.
authorbatt <batt@38d2e660-2303-0410-9eaa-f027e97ec537>
Thu, 17 Feb 2011 11:12:48 +0000 (11:12 +0000)
committerbatt <batt@38d2e660-2303-0410-9eaa-f027e97ec537>
Thu, 17 Feb 2011 11:12:48 +0000 (11:12 +0000)
git-svn-id: https://src.develer.com/svnoss/bertos/trunk@4709 38d2e660-2303-0410-9eaa-f027e97ec537

wizard/BProject.py
wizard/bertos_utils.py

index 2afcadf98946e5e2468061134c58043424d1b0e4..0a1adea95d4a7640f2c5555be6b15547c17694d4 100644 (file)
@@ -150,7 +150,7 @@ class BProject(object):
         toolchain = toolchain
         if forced_toolchain:
             toolchain = forced_toolchain
-        if os.path.exists(toolchain["path"]):
+        if os.path.exists(toolchain["path"]) or bertos_utils.findInPath(toolchain["path"]):
             self.infos["TOOLCHAIN"] = toolchain
         else:
             raise ToolchainException(self)
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: