# # -------------------------------------------------------------- import sys try: import ulrich.program except ImportError: print("ImportError: " + str(ImportError.with_traceback())) pass import yaml import ulrich.componentHandling import utils.path_tool import os.path def getConfigPath(modul, name): """ gets the most specified configuration of different sources Parameter: * typ -- (basic, comp, tool) * name -- the specific class sources: * programm << * install << * environ << basis-conf * release << basis-conf * testset << parameter/environ * testcase << parameter """ job = ulrich.program.Job.getInstance() verify = job.getDebugLevel("config_tool") job.debug(verify, "getConfig " + modul + ", " + name) if modul == "tool": pathname = job.conf.confs.get("paths").get("home") + "/configs/tool_" + name + ".yml" job.debug(verify, "1 " + pathname) if os.path.exists(pathname): return pathname pathname = job.conf.confs.get("paths").get("program") + "/utils/configs/" + name + ".yml" job.debug(verify, "2 " + pathname) if os.path.exists(pathname): return pathname pathname = job.conf.confs.get("paths").get("environment") + "/" + job.par.environment + "/configs/tool_" + name + ".yml" job.debug(verify, "3 " + pathname) if os.path.exists(pathname): return pathname job.debug(verify, "3x " + pathname) elif modul == "comp": pathname = job.conf.confs.get("paths").get("home") + "/configs/comp_" + name + ".yml" job.debug(verify, "4 " + pathname) if os.path.exists(pathname): return pathname pathname = job.conf.confs.get("paths").get("program") + "/components/" + ulrich.componentHandling.getComponentFolder(name) + "/CONFIG.yml" job.debug(verify, "5 " + pathname) if os.path.exists(pathname): return pathname job.debug(verify, "6 " + pathname) else: pathname = utils.path_tool.composePath("tcparfile") job.debug(verify, "7 " + pathname) if os.path.exists(pathname): return pathname pathname = utils.path_tool.composePath("tsparfile") job.debug(verify, "8 " + pathname) if os.path.exists(pathname): return pathname pathname = job.conf.confs.get("paths").get("release") + "/configs/basis.yml" job.debug(verify, "9 " + pathname) if os.path.exists(pathname): return pathname pathname = job.conf.confs.get("paths").get("environment") + "/configs/basis.yml" job.debug(verify, "10 " + pathname) if os.path.exists(pathname): return pathname pathname = job.conf.confs.get("paths").get("home") + "/config/basis.yml" job.debug(verify, "11 " + pathname) if os.path.exists(pathname): return pathname job.debug(verify, "12 " + pathname) def getConfig(modul, name): job = ulrich.program.Job.getInstance() verify = job.getDebugLevel("config_tool") pathname = getConfigPath(modul, name) confs = {} job.debug(verify, "getConfig " + pathname) with open(pathname, "r") as file: job.debug(verify, "openfile") doc = yaml.full_load(file) for i, v in doc.items(): job.debug(verify, "item " + str(i) + ": " + str(v)) confs[i] = v return confs