|
|
@ -36,7 +36,7 @@ def getExistingPath(job, pathnames): |
|
|
|
return pathname |
|
|
|
return None |
|
|
|
|
|
|
|
def getConfigPath(job, modul, name, subname=""): |
|
|
|
def select_config_path(job, modul, name, subname=""): |
|
|
|
""" |
|
|
|
gets the most specified configuration of different sources |
|
|
|
Parameter: |
|
|
@ -55,26 +55,10 @@ def getConfigPath(job, modul, name, subname=""): |
|
|
|
if job is None: |
|
|
|
verify = False # job = basic.program.Job.getInstance() |
|
|
|
else: |
|
|
|
verify = job.getDebugLevel("config_tool")-4 |
|
|
|
verify = job.getDebugLevel("config_tool") |
|
|
|
if verify: job.debug(verify, "getConfig " + modul + ", " + name) |
|
|
|
if modul == P.KEY_TOOL: |
|
|
|
path = getExistingPath(job, os.path.join(job.conf[B.SUBJECT_PATH][P.ATTR_PATH_COMPONENTS], |
|
|
|
P.VAL_CONFIG, name)) |
|
|
|
if path is not None: |
|
|
|
return path |
|
|
|
path = getExistingPath(job, os.path.join(job.conf[B.SUBJECT_PATH][P.ATTR_PATH_HOME], |
|
|
|
P.VAL_CONFIG, name)) |
|
|
|
if path is not None: |
|
|
|
return path |
|
|
|
path = getExistingPath(job, os.path.join(job.conf[B.SUBJECT_PATH][P.ATTR_PATH_PROGRAM], |
|
|
|
P.VAL_UTIL, P.VAL_CONFIG, name)) |
|
|
|
if path is not None: |
|
|
|
return path |
|
|
|
path = getExistingPath(job, os.path.join(job.conf[B.SUBJECT_PATH][P.ATTR_PATH_ENV], |
|
|
|
job.par.environment, P.VAL_CONFIG, P.KEY_TOOL+"_"+ name)) |
|
|
|
if path is not None: |
|
|
|
return path |
|
|
|
raise Exception(P.EXP_CONFIG_MISSING, modul+", "+name) |
|
|
|
return getToolPath(job, name, subname) |
|
|
|
elif modul == P.KEY_COMP: |
|
|
|
for format in CONFIG_FORMAT: |
|
|
|
pathname = os.path.join(job.conf[B.SUBJECT_PATH][P.ATTR_PATH_HOME], |
|
|
@ -91,66 +75,15 @@ def getConfigPath(job, modul, name, subname=""): |
|
|
|
if verify: job.debug(verify, "6 " + pathname) |
|
|
|
raise Exception(P.EXP_CONFIG_MISSING, modul+", "+name) |
|
|
|
elif modul in COMP_FILES: |
|
|
|
# for example DATASTRUCURE or the table |
|
|
|
pathnames = [] |
|
|
|
pathnames.append(os.path.join(job.conf[B.SUBJECT_PATH][P.ATTR_PATH_COMPONENTS], |
|
|
|
basic.componentHandling.getComponentFolder(name), modul)) |
|
|
|
pathnames.append(os.path.join(job.conf[B.SUBJECT_PATH][P.ATTR_PATH_COMPONENTS], |
|
|
|
basic.componentHandling.getComponentFolder(subname), modul)) |
|
|
|
pathnames.append(os.path.join(job.conf[B.SUBJECT_PATH][P.ATTR_PATH_PROGRAM], P.VAL_BASIC, modul)) |
|
|
|
pathnames.append(os.path.join(job.conf[B.SUBJECT_PATH][P.ATTR_PATH_PROGRAM], P.VAL_BASIC, subname)) |
|
|
|
configpath = getExistingPath(job, pathnames) |
|
|
|
if configpath is not None: |
|
|
|
return configpath |
|
|
|
for format in CONFIG_FORMAT: |
|
|
|
pathname = os.path.join(job.conf[B.SUBJECT_PATH][P.ATTR_PATH_COMPONENTS], |
|
|
|
basic.componentHandling.getComponentFolder(name), modul+"."+format) |
|
|
|
if os.path.exists(pathname): |
|
|
|
return pathname |
|
|
|
for format in CONFIG_FORMAT: |
|
|
|
if len(subname) > 1: |
|
|
|
pathname = os.path.join(job.conf[B.SUBJECT_PATH][P.ATTR_PATH_COMPONENTS], |
|
|
|
basic.componentHandling.getComponentFolder(name), subname+"."+format) |
|
|
|
if os.path.exists(pathname): |
|
|
|
return pathname |
|
|
|
raise Exception(P.EXP_CONFIG_MISSING, modul+", "+name) |
|
|
|
return getCompPath(job, name, subname, modul) |
|
|
|
elif modul == P.KEY_BASIC: |
|
|
|
path = getExistingPath(job, os.path.join(job.conf[B.SUBJECT_PATH][P.ATTR_PATH_COMPONENTS], |
|
|
|
P.VAL_CONFIG, name)) |
|
|
|
if path is not None: |
|
|
|
return path |
|
|
|
path = getExistingPath(job, os.path.join(job.conf[B.SUBJECT_PATH][P.ATTR_PATH_HOME], |
|
|
|
P.VAL_CONFIG, name)) |
|
|
|
if path is not None: |
|
|
|
return path |
|
|
|
return getBasicPath(job, name) |
|
|
|
elif modul == P.KEY_TESTCASE: |
|
|
|
for format in CONFIG_FORMAT: |
|
|
|
pathname = os.path.join(job.conf[B.SUBJECT_PATH][P.ATTR_PATH_TDATA], |
|
|
|
name, D.DFILE_TESTCASE_NAME + "."+format) |
|
|
|
if verify: job.debug(verify, "4 " + pathname) |
|
|
|
if os.path.exists(pathname): |
|
|
|
return pathname |
|
|
|
return getTestPath(job, name, D.DFILE_TESTCASE_NAME) |
|
|
|
elif modul == P.KEY_TESTSUITE: |
|
|
|
for format in CONFIG_FORMAT: |
|
|
|
pathname = os.path.join(job.conf[B.SUBJECT_PATH][P.ATTR_PATH_TDATA], |
|
|
|
name, D.DFILE_TESTSUITE_NAME + "." + format) |
|
|
|
if verify: job.debug(verify, "4 " + pathname) |
|
|
|
if os.path.exists(pathname): |
|
|
|
return pathname |
|
|
|
return getTestPath(job, name, D.DFILE_TESTSUITE_NAME) |
|
|
|
elif modul == P.KEY_CATALOG: |
|
|
|
path = getExistingPath(job, os.path.join(job.conf[B.SUBJECT_PATH][P.ATTR_PATH_TDATA], |
|
|
|
P.KEY_CATALOG, name)) |
|
|
|
if path is not None: |
|
|
|
return path |
|
|
|
path = getExistingPath(job, os.path.join(job.conf[B.SUBJECT_PATH][P.ATTR_PATH_COMPONENTS], |
|
|
|
P.KEY_CATALOG, name)) |
|
|
|
if path is not None: |
|
|
|
return path |
|
|
|
path = getExistingPath(job, os.path.join(job.conf[B.SUBJECT_PATH][P.ATTR_PATH_PROGRAM], |
|
|
|
P.KEY_CATALOG, name)) |
|
|
|
if path is not None: |
|
|
|
return path |
|
|
|
raise Exception(P.EXP_CONFIG_MISSING, name) |
|
|
|
return getCatalogPath(job, name) |
|
|
|
else: |
|
|
|
pathname = tools.path_tool.compose_path(job, P.P_TCPARFILE) |
|
|
|
if verify: job.debug(verify, "7 " + pathname) |
|
|
@ -183,6 +116,95 @@ def getConfigPath(job, modul, name, subname=""): |
|
|
|
return pathname |
|
|
|
raise Exception(P.EXP_CONFIG_MISSING, modul+", "+name) |
|
|
|
|
|
|
|
def getToolPath(job, name, subname): |
|
|
|
if subname != "": |
|
|
|
envdir = subname |
|
|
|
elif hasattr(job.par, "environment"): |
|
|
|
envdir = job.par.environment |
|
|
|
else: |
|
|
|
envdir = "xxxxx" |
|
|
|
path = getExistingPath(job, os.path.join(job.conf[B.SUBJECT_PATH][P.ATTR_PATH_ENV], |
|
|
|
envdir, P.VAL_CONFIG, P.KEY_TOOL + "_" + name)) |
|
|
|
if path is not None: |
|
|
|
return path |
|
|
|
path = getExistingPath(job, os.path.join(job.conf[B.SUBJECT_PATH][P.ATTR_PATH_COMPONENTS], |
|
|
|
P.VAL_CONFIG, name)) |
|
|
|
if path is not None: |
|
|
|
return path |
|
|
|
path = getExistingPath(job, os.path.join(job.conf[B.SUBJECT_PATH][P.ATTR_PATH_HOME], |
|
|
|
P.VAL_CONFIG, name)) |
|
|
|
if path is not None: |
|
|
|
return path |
|
|
|
path = getExistingPath(job, os.path.join(job.conf[B.SUBJECT_PATH][P.ATTR_PATH_PROGRAM], |
|
|
|
P.VAL_UTIL, P.VAL_CONFIG, name)) |
|
|
|
if path is not None: |
|
|
|
return path |
|
|
|
raise Exception(P.EXP_CONFIG_MISSING, envdir + ", " + name) |
|
|
|
|
|
|
|
def getCompPath(job, name, subname, filename): |
|
|
|
# for example DATASTRUCURE or the table |
|
|
|
pathnames = [] |
|
|
|
pathnames.append(os.path.join(job.conf[B.SUBJECT_PATH][P.ATTR_PATH_COMPONENTS], |
|
|
|
basic.componentHandling.getComponentFolder(name), filename)) |
|
|
|
pathnames.append(os.path.join(job.conf[B.SUBJECT_PATH][P.ATTR_PATH_COMPONENTS], |
|
|
|
basic.componentHandling.getComponentFolder(subname), filename)) |
|
|
|
pathnames.append(os.path.join(job.conf[B.SUBJECT_PATH][P.ATTR_PATH_PROGRAM], P.VAL_BASIC, filename)) |
|
|
|
pathnames.append(os.path.join(job.conf[B.SUBJECT_PATH][P.ATTR_PATH_PROGRAM], P.VAL_BASIC, subname)) |
|
|
|
configpath = getExistingPath(job, pathnames) |
|
|
|
if configpath is not None: |
|
|
|
return configpath |
|
|
|
for format in CONFIG_FORMAT: |
|
|
|
pathname = os.path.join(job.conf[B.SUBJECT_PATH][P.ATTR_PATH_COMPONENTS], |
|
|
|
basic.componentHandling.getComponentFolder(name), filename + "." + format) |
|
|
|
if os.path.exists(pathname): |
|
|
|
return pathname |
|
|
|
for format in CONFIG_FORMAT: |
|
|
|
if len(subname) > 1: |
|
|
|
pathname = os.path.join(job.conf[B.SUBJECT_PATH][P.ATTR_PATH_COMPONENTS], |
|
|
|
basic.componentHandling.getComponentFolder(name), subname + "." + format) |
|
|
|
if os.path.exists(pathname): |
|
|
|
return pathname |
|
|
|
raise Exception(P.EXP_CONFIG_MISSING, filename + ", " + name) |
|
|
|
|
|
|
|
|
|
|
|
def getBasicPath(job, name): |
|
|
|
path = getExistingPath(job, os.path.join(job.conf[B.SUBJECT_PATH][P.ATTR_PATH_COMPONENTS], |
|
|
|
P.VAL_CONFIG, name)) |
|
|
|
if path is not None: |
|
|
|
return path |
|
|
|
path = getExistingPath(job, os.path.join(job.conf[B.SUBJECT_PATH][P.ATTR_PATH_HOME], |
|
|
|
P.VAL_CONFIG, name)) |
|
|
|
if path is not None: |
|
|
|
return path |
|
|
|
|
|
|
|
def getTestPath(job, name, filename): |
|
|
|
for format in CONFIG_FORMAT: |
|
|
|
pathname = os.path.join(job.conf[B.SUBJECT_PATH][P.ATTR_PATH_TDATA], |
|
|
|
name, filename + "." + format) |
|
|
|
if os.path.exists(pathname): |
|
|
|
return pathname |
|
|
|
|
|
|
|
def getCatalogPath(job, name): |
|
|
|
if hasattr(job, "par") and hasattr(job.par, "project"): |
|
|
|
path = getExistingPath(job, os.path.join(job.conf[B.SUBJECT_PATH][P.ATTR_PATH_TDATA], |
|
|
|
getattr(job.par, "project"), P.KEY_CATALOG, name)) |
|
|
|
if path is not None: |
|
|
|
return path |
|
|
|
|
|
|
|
path = getExistingPath(job, os.path.join(job.conf[B.SUBJECT_PATH][P.ATTR_PATH_TDATA], |
|
|
|
P.KEY_CATALOG, name)) |
|
|
|
if path is not None: |
|
|
|
return path |
|
|
|
path = getExistingPath(job, os.path.join(job.conf[B.SUBJECT_PATH][P.ATTR_PATH_COMPONENTS], |
|
|
|
P.KEY_CATALOG, name)) |
|
|
|
if path is not None: |
|
|
|
return path |
|
|
|
path = getExistingPath(job, os.path.join(job.conf[B.SUBJECT_PATH][P.ATTR_PATH_PROGRAM], |
|
|
|
P.KEY_CATALOG, name)) |
|
|
|
if path is not None: |
|
|
|
return path |
|
|
|
raise Exception(P.EXP_CONFIG_MISSING, name) |
|
|
|
|
|
|
|
|
|
|
|
def getConfValue(attribute, comp): |
|
|
|
if attribute == B.ATTR_CONN_DBTYPE: |
|
|
@ -223,12 +245,12 @@ def hasAttr(o, name): |
|
|
|
|
|
|
|
def getConfig(job, modul, name, subname=""): |
|
|
|
if job is None: |
|
|
|
verify = 24 |
|
|
|
verify = 0 |
|
|
|
else: |
|
|
|
verify = job.getDebugLevel("config_tool")-4 |
|
|
|
verify = job.getDebugLevel("config_tool") |
|
|
|
msg = None |
|
|
|
if hasattr(job, "m"): msg = job.m |
|
|
|
pathname = getConfigPath(job, modul, name, subname) |
|
|
|
pathname = select_config_path(job, modul, name, subname) |
|
|
|
confs = {} |
|
|
|
job.debug(verify, "getConfig " + pathname) |
|
|
|
if len(pathname) < 1: |
|
|
|