From 00b4afda1825471f9f536a638282f8efb610f739 Mon Sep 17 00:00:00 2001 From: batt Date: Thu, 17 Feb 2011 11:12:48 +0000 Subject: [PATCH] Add findInPath method; search for toolchains in system path. git-svn-id: https://src.develer.com/svnoss/bertos/trunk@4709 38d2e660-2303-0410-9eaa-f027e97ec537 --- wizard/BProject.py | 2 +- wizard/bertos_utils.py | 13 +++++++++---- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/wizard/BProject.py b/wizard/BProject.py index 2afcadf9..0a1adea9 100644 --- a/wizard/BProject.py +++ b/wizard/BProject.py @@ -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) diff --git a/wizard/bertos_utils.py b/wizard/bertos_utils.py index f0d54944..204c4fe4 100644 --- a/wizard/bertos_utils.py +++ b/wizard/bertos_utils.py @@ -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: -- 2.25.1