|
|
@ -9,12 +9,16 @@ |
|
|
|
#import sys, getopt |
|
|
|
import argparse |
|
|
|
import copy |
|
|
|
import time |
|
|
|
|
|
|
|
import yaml |
|
|
|
import os |
|
|
|
from datetime import datetime |
|
|
|
import basic.constants as B |
|
|
|
import basic.message |
|
|
|
import basic.componentHandling |
|
|
|
import objects.catalog |
|
|
|
import tools.value_tool |
|
|
|
import tools.date_tool |
|
|
|
import tools.path_tool |
|
|
|
import tools.file_tool |
|
|
@ -26,128 +30,13 @@ import tools.job_tool |
|
|
|
LIMIT_INFO = 16 #basic.message.LIMIT_INFO |
|
|
|
LIMIT_DEBUG = 12 #basic.message.LIMIT_DEBUG |
|
|
|
|
|
|
|
jobdef = { |
|
|
|
"webflask": { |
|
|
|
"pardef": "", |
|
|
|
"pfilesource": "", |
|
|
|
"pfiletarget": "", |
|
|
|
"basedir": "workbase", |
|
|
|
"dirname": "workdir", |
|
|
|
"loglevel": LIMIT_INFO, |
|
|
|
"logpath": "{job.conf.data}/workspace/webflask_{job.start:H}.txt" }, |
|
|
|
"declare_result": { |
|
|
|
"pardef": "", |
|
|
|
"pfilesource": "", |
|
|
|
"pfiletarget": "", |
|
|
|
"basedir": "workbase", |
|
|
|
"dirname": "workdir", |
|
|
|
"loglevel": LIMIT_INFO, |
|
|
|
"logpath": "{job.conf.data}/workspace/reorg_{job.start:H}.txt" }, |
|
|
|
"service": { |
|
|
|
"pardef": "", |
|
|
|
"pfilesource": "", |
|
|
|
"pfiletarget": "", |
|
|
|
"basedir": "workbase", |
|
|
|
"dirname": "workdir", |
|
|
|
"loglevel": LIMIT_INFO, |
|
|
|
"logpath": "{job.conf.data}/workspace/service_{job.start:H}.txt" }, |
|
|
|
"unit": { |
|
|
|
"pardef": "", |
|
|
|
"pfilesource": "", |
|
|
|
"pfiletarget": "", |
|
|
|
"basedir": "workbase", |
|
|
|
"dirname": "workdir", |
|
|
|
"loglevel": LIMIT_DEBUG, |
|
|
|
"logpath": "{job.conf.data}/workspace/unittest_{job.start:H}.txt" }, |
|
|
|
"check_environment": { |
|
|
|
"pardef": "", |
|
|
|
"pfilesource": "", |
|
|
|
"pfiletarget": "envparfile", |
|
|
|
"basedir": "envbase", |
|
|
|
"dirname": "envdir", |
|
|
|
"loglevel": LIMIT_INFO, |
|
|
|
"logpath": "{job.par.envdir}/{log}/log_{job.start}.txt" }, |
|
|
|
"test_executer": { |
|
|
|
"pardef": "", |
|
|
|
"pfilesource": "tsparfile", |
|
|
|
"pfiletarget": "tsparfile", |
|
|
|
"basedir": "tsbase", |
|
|
|
"dirname": "tsdir", |
|
|
|
"loglevel": LIMIT_INFO, |
|
|
|
"logpath": "{job.par.tsdir}/{log}/{job.program}_{job.start}.txt" }, |
|
|
|
"init_testsuite": { |
|
|
|
"pardef": "tsdir", # ,tdtyp,tdsrc,tdname", |
|
|
|
"pfilesource": "envparfile", |
|
|
|
"pfiletarget": "tsparfile", |
|
|
|
"basedir": "tsbase", |
|
|
|
"dirname": "tsdir", |
|
|
|
"loglevel": LIMIT_INFO, |
|
|
|
"logpath": "{job.par.tsdir}/{log}/{job.program}_{job.start}.txt" }, |
|
|
|
"init_testcase": { |
|
|
|
"pardef": "tcdir", # ",tdtyp,tdsrc,tdname", |
|
|
|
"pfilesource": "envparfile", |
|
|
|
"pfiletarget": "tcparfile", |
|
|
|
"basedir": "tcbase", |
|
|
|
"dirname": "tcdir", |
|
|
|
"loglevel": LIMIT_INFO, |
|
|
|
"logpath": "{job.par.tcdir}/{log}/{job.program}_{job.start}.txt" }, |
|
|
|
"execute_testcase": { |
|
|
|
"pardef": "tcdir", # ",tdtyp,tdsrc,tdname", |
|
|
|
"pfilesource": "tcparfile", |
|
|
|
"pfiletarget": "tcparfile", |
|
|
|
"basedir": "tcbase", |
|
|
|
"dirname": "tcdir", |
|
|
|
"loglevel": LIMIT_INFO, |
|
|
|
"logpath": "{job.par.tcdir}/{log}/{job.program}_{job.start}.txt" }, |
|
|
|
"collect_testcase": { |
|
|
|
"pardef": "tcdir", # ",tdtyp,tdsrc,tdname", |
|
|
|
"pfilesource": "tcparfile", |
|
|
|
"pfiletarget": "tcparfile", |
|
|
|
"basedir": "tcbase", |
|
|
|
"dirname": "tcdir", |
|
|
|
"loglevel": LIMIT_INFO, |
|
|
|
"logpath": "{job.par.tcdir}/{log}/{job.program}_{job.start}.txt" }, |
|
|
|
"copy_appdummy": { |
|
|
|
"pardef": "tcdir", # ",tdtyp,tdsrc,tdname", |
|
|
|
"pfilesource": "tcparfile", |
|
|
|
"pfiletarget": "tcparfile", |
|
|
|
"basedir": "tcbase", |
|
|
|
"dirname": "tcdir", |
|
|
|
"loglevel": LIMIT_INFO, |
|
|
|
"logpath": "{job.par.tcdir}/{log}/{job.program}_{job.start}.txt"}, |
|
|
|
"compare_testcase": { |
|
|
|
"pardef": "tcdir", # ",tdtyp,tdsrc,tdname", |
|
|
|
"pfilesource": "tcparfile", |
|
|
|
"pfiletarget": "tcparfile", |
|
|
|
"basedir": "tcbase", |
|
|
|
"dirname": "tcdir", |
|
|
|
"loglevel": LIMIT_INFO, |
|
|
|
"logpath": "{job.par.tcdir}/{log}/{job.program}_{job.start}.txt" }, |
|
|
|
"test_system": { |
|
|
|
"pardef": "tcdir,tdtyp,tdsrc,tdname", |
|
|
|
"pfilesource": "tsparfile", |
|
|
|
"pfiletarget": "tsparfile", |
|
|
|
"basedir": "tcbase", |
|
|
|
"dirname": "tcdir", |
|
|
|
"loglevel": LIMIT_INFO, |
|
|
|
"logpath": "{job.par.tcdir}/{log}/{job.program}_{job.start}.txt"}, |
|
|
|
"finish_testcase": { |
|
|
|
"pardef": "tcdir", |
|
|
|
"pfilesource": "tcparfile", |
|
|
|
"pfiletarget": "tcparfile", |
|
|
|
"basedir": "tcbase", |
|
|
|
"dirname": "tcdir", |
|
|
|
"loglevel": LIMIT_INFO, |
|
|
|
"logpath": "{job.par.tcdir}/{log}/{job.program}_{job.start}.txt"}, |
|
|
|
"finish_testsuite": { |
|
|
|
"pardef": "tsdir", |
|
|
|
"pfilesource": "tsparfile", |
|
|
|
"pfiletarget": "tssarfile", |
|
|
|
"basedir": "tsbase", |
|
|
|
"dirname": "tsdir", |
|
|
|
"loglevel": LIMIT_INFO, |
|
|
|
"logpath": "{job.par.tcdir}/{log}/{job.program}_{job.start}.txt"} |
|
|
|
} |
|
|
|
CTLG_NAME = "programs" |
|
|
|
CTLG_PARDEF = "pardef" |
|
|
|
CTLG_PARSOURCE = "pfilesource" |
|
|
|
CTLG_PARTARGET = "pfiletarget" |
|
|
|
CTLG_BASEDIR = "basedir" |
|
|
|
CTLG_LOGPATH = "logpath" |
|
|
|
CTLG_LOGLEVEL = "loglevel" |
|
|
|
|
|
|
|
|
|
|
|
def setGlobal(): |
|
|
@ -168,7 +57,7 @@ DEFAULT_TIME = "2022-08-29_17-29-59" |
|
|
|
|
|
|
|
def createJob(pprg="", pgran="", papp="", penv="", ptstamp="", pmode=""): |
|
|
|
""" |
|
|
|
this creates a Job-Object with the main arguments. |
|
|
|
this creates a Job-Object with the main arguments ## same as in testtools? |
|
|
|
:param pprg: program-name |
|
|
|
:param pgran: tc|ts| |
|
|
|
:param papp: application |
|
|
@ -213,7 +102,7 @@ def createJob(pprg="", pgran="", papp="", penv="", ptstamp="", pmode=""): |
|
|
|
path = T.DATA_PATH + "/workspace/" |
|
|
|
|
|
|
|
job = basic.program.Job(prgname) |
|
|
|
# job.conf.confs[B.SUBJECT_PATH]["components"] = T.COMP_PATH |
|
|
|
# job.conf[B.SUBJECT_PATH]["components"] = T.COMP_PATH |
|
|
|
args = {"application": app, "environment": env, "modus": mode, gran + "time": tstamp, |
|
|
|
gran + "dir": path, |
|
|
|
"step": 1} |
|
|
@ -222,13 +111,65 @@ def createJob(pprg="", pgran="", papp="", penv="", ptstamp="", pmode=""): |
|
|
|
job.par.setParameterArgs(job, args) |
|
|
|
return job |
|
|
|
|
|
|
|
class SimpleJob: |
|
|
|
""" |
|
|
|
the simple job is just used for test issues |
|
|
|
""" |
|
|
|
__logtime = "20200101_000000" |
|
|
|
def __init__(self, program, username="", args=None): |
|
|
|
self.program = program |
|
|
|
self.username = username |
|
|
|
path = tools.path_tool.getBasisConfigPath() |
|
|
|
self.conf = getConfiguration(self, path) |
|
|
|
self.jobid = str(100000) |
|
|
|
catalog = objects.catalog.Catalog.getInstance() |
|
|
|
self.programDef = catalog.getValue(self, CTLG_NAME, program, "") |
|
|
|
|
|
|
|
if args is not None: |
|
|
|
if "par" in args: |
|
|
|
self.par = Parameter(self, args["par"]) |
|
|
|
for k in args: |
|
|
|
if k == "par": |
|
|
|
continue |
|
|
|
setattr(self, k, args[k]) |
|
|
|
else: |
|
|
|
self.par == Parameter(self, None) |
|
|
|
if not hasattr(self, "start"): |
|
|
|
logTime = tools.date_tool.getActdate(tools.date_tool.F_LOG) |
|
|
|
while logTime <= SimpleJob.__logtime: |
|
|
|
time.sleep(1) |
|
|
|
logTime = tools.date_tool.getActdate(tools.date_tool.F_LOG) |
|
|
|
self.start = logTime |
|
|
|
|
|
|
|
def getDebugLevel(self, arg): |
|
|
|
return 12 |
|
|
|
|
|
|
|
def debug(self, prio, text): |
|
|
|
pass |
|
|
|
|
|
|
|
def getParameter(self, parameter): |
|
|
|
if hasattr(self.par, parameter) and getattr(self.par, parameter) is not None: |
|
|
|
return getattr(self.par, parameter) |
|
|
|
else: |
|
|
|
val = tools.value_tool.compose_pattern(self, parameter, None) |
|
|
|
if val is None: |
|
|
|
self.m.logError("Parameter "+parameter+" nicht in job.par ") |
|
|
|
return |
|
|
|
setattr(self.par, parameter, val) |
|
|
|
return val |
|
|
|
|
|
|
|
class SimpleParameter(): |
|
|
|
def __init__(self, job, args=None): |
|
|
|
self.program = job.program |
|
|
|
|
|
|
|
class Job: |
|
|
|
__instance = None |
|
|
|
__instances = [] |
|
|
|
__jobid = 100000 |
|
|
|
__logtime = "20200101_000000" |
|
|
|
#catalog = objects.catalog.Catalog.getInstance() |
|
|
|
|
|
|
|
def __init__ (self, program, args=None): |
|
|
|
def __init__ (self, program, username="", args=None): |
|
|
|
""" |
|
|
|
initializing the job-object as a global structure for the actual doing |
|
|
|
type of job: |
|
|
@ -249,40 +190,73 @@ class Job: |
|
|
|
# - job.conf with basis config |
|
|
|
# - job.par with parameter-args or cli-args |
|
|
|
# - job.msg |
|
|
|
print ("################# init Job ## " + program + " #################") |
|
|
|
print("################# init Job ## " + program + " #################") |
|
|
|
# logtime muss unique sein denn logDateien und Verzeichnisse muessen eindeutig sein |
|
|
|
logTime = tools.date_tool.getActdate(tools.date_tool.F_LOG) |
|
|
|
while logTime <= Job.__logtime: |
|
|
|
time.sleep(1) |
|
|
|
logTime = tools.date_tool.getActdate(tools.date_tool.F_LOG) |
|
|
|
self.start = logTime |
|
|
|
self.m = basic.message.TempMessage(self, logTime) |
|
|
|
Job.__jobid += 1 |
|
|
|
self.jobid = str(Job.__jobid) |
|
|
|
if len(program) < 3: |
|
|
|
print("FATAL: programname is missing") |
|
|
|
exit(3) |
|
|
|
self.program = program |
|
|
|
conf = Configuration(self, program) |
|
|
|
self.conf = conf.confs |
|
|
|
if len(username) < 2: |
|
|
|
self.username = os.getlogin() |
|
|
|
path = tools.path_tool.getBasisConfigPath() |
|
|
|
self.conf = getConfiguration(self, path) |
|
|
|
catalog = objects.catalog.Catalog.getInstance() |
|
|
|
self.programDef = catalog.getValue(self, CTLG_NAME, program, "") |
|
|
|
try: |
|
|
|
path = tools.config_tool.getConfigPath(self, P.KEY_BASIC, B.BASIS_FILE) |
|
|
|
print("comps.basispath "+path) |
|
|
|
self.conf.setConfiguration(self, path) |
|
|
|
# conf = self.readConfiguration(path) |
|
|
|
self.conf = self.getConfiguration(path) |
|
|
|
except: |
|
|
|
pass # the special path is not necessary |
|
|
|
logTime = tools.date_tool.getActdate(tools.date_tool.F_LOG) |
|
|
|
self.start = logTime |
|
|
|
self.m = basic.message.Message(self, jobdef[program]["loglevel"], logTime, None) |
|
|
|
print("FATAL: config-file could not be loaded") |
|
|
|
exit(3) |
|
|
|
if args is not None: |
|
|
|
self.setParameter(args) |
|
|
|
self.m = basic.message.Message(self, self.programDef[CTLG_LOGLEVEL], logTime, None) |
|
|
|
|
|
|
|
def altinit(self, program, args): |
|
|
|
appl = tools.config_tool.getConfig(self, P.KEY_BASIC, B.SUBJECT_APPS) |
|
|
|
if appl is not None: |
|
|
|
self.conf.confs[B.SUBJECT_APPS] = appl[B.SUBJECT_APPS] |
|
|
|
if B.SUBJECT_PROJECTS in self.conf.confs: |
|
|
|
for k in self.conf.confs[B.SUBJECT_PROJECTS]: |
|
|
|
self.conf[B.SUBJECT_APPS] = appl[B.SUBJECT_APPS] |
|
|
|
if B.SUBJECT_PROJECTS in self.conf: |
|
|
|
for k in self.conf[B.SUBJECT_PROJECTS]: |
|
|
|
if k not in appl[B.SUBJECT_PROJECTS]: |
|
|
|
raise Exception("Workspace has project "+k+" which is not configured") |
|
|
|
self.conf.confs[B.SUBJECT_PROJECTS][k] = appl[B.SUBJECT_PROJECTS][k] |
|
|
|
self.conf[B.SUBJECT_PROJECTS][k] = appl[B.SUBJECT_PROJECTS][k] |
|
|
|
else: |
|
|
|
self.conf.confs[B.SUBJECT_PROJECTS] = appl[B.SUBJECT_PROJECTS] |
|
|
|
self.conf[B.SUBJECT_PROJECTS] = appl[B.SUBJECT_PROJECTS] |
|
|
|
par = Parameter(self, program, args) |
|
|
|
self.par = par |
|
|
|
|
|
|
|
def getLogpath(self): |
|
|
|
path = tools.path_tool.composePattern(self, jobdef[self.program]["logpath"], None) |
|
|
|
path = tools.path_tool.compose_path(self, self.programDef[CTLG_LOGPATH], None) |
|
|
|
return path |
|
|
|
|
|
|
|
def getConfiguration(self, path): |
|
|
|
conf = {} |
|
|
|
conf["configpath"] = [] |
|
|
|
if hasattr(self, "conf"): |
|
|
|
conf = self.conf |
|
|
|
conf["configpath"].append(path) |
|
|
|
doc = tools.file_tool.readFileDict(self, path, None) |
|
|
|
if "basic" in doc: |
|
|
|
for k, v in doc["basic"].items(): |
|
|
|
if k not in conf: |
|
|
|
conf[k] = v |
|
|
|
else: |
|
|
|
for k, v in doc.items(): |
|
|
|
if k not in conf: |
|
|
|
conf[k] = v |
|
|
|
return conf |
|
|
|
|
|
|
|
def murks(self, par, program): |
|
|
|
self.par = par |
|
|
|
dirpath = self.par.getDirParameter() |
|
|
@ -298,18 +272,18 @@ class Job: |
|
|
|
|
|
|
|
def setProgram(self, program): |
|
|
|
self.program = program |
|
|
|
basedir = jobdef[program]["basedir"] |
|
|
|
basedir = self.programDef[CTLG_BASEDIR] |
|
|
|
self.basedir = basedir |
|
|
|
if (self.par is not None) and self.par in B.LIST_MAIN_PAR: |
|
|
|
setattr(self.par, "program", program) |
|
|
|
setattr(self.par, "basedir", basedir) |
|
|
|
parstring = getattr(self.par, "parstring") |
|
|
|
setattr(self.par, B.PAR_PROGRAM, program) |
|
|
|
setattr(self.par, B.PAR_BASEDIR, basedir) |
|
|
|
parstring = getattr(self.par, B.PAR_STRING) |
|
|
|
parstring = parstring[parstring.find("--"):] |
|
|
|
parstring = "python "+program+" "+parstring |
|
|
|
setattr(self.par, "parstring", parstring) |
|
|
|
if not hasattr(self.par, jobdef[program]["dirname"]): |
|
|
|
setattr(self.par, jobdef[program]["dirname"], |
|
|
|
tools.path_tool.composePattern(self, "{"+basedir+"}", None)) |
|
|
|
if not hasattr(self.par, self.programDef[B.PAR_DIRNAME]): |
|
|
|
setattr(self.par, self.programDef[B.PAR_DIRNAME], |
|
|
|
tools.path_tool.compose_path(self, "{"+basedir+"}", None)) |
|
|
|
print(parstring) |
|
|
|
self.par.setParameterLoaded(self) |
|
|
|
|
|
|
@ -349,9 +323,9 @@ class Job: |
|
|
|
|
|
|
|
|
|
|
|
def dumpParameter(self): |
|
|
|
if len(jobdef[self.program]["pfiletarget"]) < 2: |
|
|
|
if len(self.programDef[CTLG_PARTARGET]) < 2: |
|
|
|
return |
|
|
|
parpath = tools.path_tool.composePath(self, jobdef[self.program]["pfiletarget"], None) |
|
|
|
parpath = tools.path_tool.compose_path(self, self.programDef[CTLG_PARTARGET], None) |
|
|
|
output = {} |
|
|
|
cconf = basic.componentHandling.getComponentDict() |
|
|
|
output["par"] = self.par.__dict__ |
|
|
@ -372,9 +346,9 @@ class Job: |
|
|
|
|
|
|
|
def loadParameter(self): |
|
|
|
output = {} |
|
|
|
if len(str(jobdef[self.program]["pfilesource"])) < 2: |
|
|
|
if len(str(self.programDef[CTLG_PARSOURCE])) < 2: |
|
|
|
return None |
|
|
|
parpath = tools.path_tool.composePath(self, jobdef[self.program]["pfilesource"], None) |
|
|
|
parpath = tools.path_tool.compose_path(self, self.programDef[CTLG_PARSOURCE], None) |
|
|
|
print("parpath "+parpath) |
|
|
|
if not os.path.join(parpath): |
|
|
|
return None |
|
|
@ -385,17 +359,23 @@ class Job: |
|
|
|
return output |
|
|
|
|
|
|
|
|
|
|
|
def setParameter(self, args): |
|
|
|
self.par = Parameter(self, args) |
|
|
|
|
|
|
|
def getParameter(self, parameter): |
|
|
|
if hasattr(self.par, parameter): |
|
|
|
if hasattr(self.par, parameter) and getattr(self.par, parameter) is not None: |
|
|
|
return getattr(self.par, parameter) |
|
|
|
elif "xxxtime" in parameter: |
|
|
|
neu = tools.date_tool.getActdate(tools.date_tool.F_DIR) |
|
|
|
# setattr(self.par, parameter, neu) |
|
|
|
return neu |
|
|
|
else: |
|
|
|
print("Parameter "+parameter+" nicht in job.par ") |
|
|
|
for attr, value in self.par.__dict__.items(): |
|
|
|
print(attr, value) |
|
|
|
val = tools.value_tool.compose_pattern(self, parameter, None) |
|
|
|
if val is None: |
|
|
|
self.m.logError("Parameter "+parameter+" nicht in job.par ") |
|
|
|
return |
|
|
|
setattr(self.par, parameter, val) |
|
|
|
return val |
|
|
|
|
|
|
|
|
|
|
|
def hasElement(self, parameter, elem): |
|
|
@ -440,11 +420,12 @@ class Job: |
|
|
|
return basic.message.LIMIT_DEBUG |
|
|
|
elif elem.find("tool") > 1 and hasattr(self, "par"): |
|
|
|
if not hasattr(self.par, "tool") or getattr(self.par, "tool").find(elem) <= 0: |
|
|
|
return int(self.m.CONST_ERRTYP[errtyp]) -1 |
|
|
|
return 4 |
|
|
|
else: |
|
|
|
return int(self.m.CONST_ERRTYP[errtyp]) |
|
|
|
return 4 |
|
|
|
else: |
|
|
|
return int(self.m.CONST_ERRTYP[errtyp]) |
|
|
|
# TODO quickfix |
|
|
|
return 4 |
|
|
|
def getInfoLevel(self, elem): |
|
|
|
return self.getMessageLevel("info", elem) |
|
|
|
def getDebugLevel(self, elem): |
|
|
@ -458,6 +439,24 @@ class Job: |
|
|
|
else: |
|
|
|
print(text) |
|
|
|
|
|
|
|
def getConfiguration(job, path): |
|
|
|
conf = {} |
|
|
|
conf["configpath"] = [] |
|
|
|
if hasattr(job, "conf"): |
|
|
|
conf = job.conf |
|
|
|
conf["configpath"].append(path) |
|
|
|
doc = tools.file_tool.readFileDict(job, path, None) |
|
|
|
if "basic" in doc: |
|
|
|
for k, v in doc["basic"].items(): |
|
|
|
if k not in conf: |
|
|
|
conf[k] = v |
|
|
|
else: |
|
|
|
for k, v in doc.items(): |
|
|
|
if k not in conf: |
|
|
|
conf[k] = v |
|
|
|
return conf |
|
|
|
|
|
|
|
|
|
|
|
# ------------------------------------------------------------------------------------------------------------------ |
|
|
|
class Parameter: |
|
|
|
""" |
|
|
@ -468,45 +467,32 @@ class Parameter: |
|
|
|
comparison with a parameter-file from the work-folder |
|
|
|
""" |
|
|
|
print ("class Parameter") |
|
|
|
def __init__ (self, job, program, args=None): |
|
|
|
print ("# init Parameter for " + program) |
|
|
|
self.program = program |
|
|
|
def __init__ (self, job, args=None): |
|
|
|
print ("# init Parameter for " + job.program) |
|
|
|
self.program = job.program |
|
|
|
if args is not None and isinstance(args, dict): |
|
|
|
self.setParameterArgs(job, args) |
|
|
|
else: |
|
|
|
self.setParameter(job) |
|
|
|
self.basedir = jobdef[program]["basedir"] |
|
|
|
job.basedir = jobdef[program]["basedir"] |
|
|
|
self.basedir = job.programDef[B.PAR_BASEDIR] |
|
|
|
job.basedir = job.programDef[B.PAR_BASEDIR] |
|
|
|
print (f"# Parameter initialisiert {self.program} mit basedir {self.basedir}") |
|
|
|
job.par = self |
|
|
|
if not hasattr(self, jobdef[program]["dirname"]): |
|
|
|
setattr(self, jobdef[program]["dirname"], |
|
|
|
tools.path_tool.composePattern(job, "{"+self.basedir+"}", None)) |
|
|
|
# Parameter aus Verzeichnis extraieren bzw. Verzeichnis aus Parameter erstellen |
|
|
|
if not hasattr(self, job.programDef[B.PAR_DIRNAME]): |
|
|
|
setattr(self, job.programDef[B.PAR_DIRNAME], |
|
|
|
tools.value_tool.compose_pattern(job, self.basedir, None)) |
|
|
|
else: |
|
|
|
tools.path_tool.extractPath(job, jobdef[program]["basedir"], getattr(self, jobdef[program]["dirname"])) |
|
|
|
self.setParameterLoaded(job) |
|
|
|
|
|
|
|
|
|
|
|
def setBasedir(self, job, program): |
|
|
|
if jobdef[program]: |
|
|
|
self.basedir = jobdef[program]["basedir"] |
|
|
|
if hasattr(self, jobdef[program]["dirname"]): |
|
|
|
tools.path_tool.extractPath(self.basedir, getattr(self, jobdef[program]["dirname"])) |
|
|
|
elif self.basedir == "workbase": |
|
|
|
home = tools.path_tool.getHome() |
|
|
|
dirpath = os.path.join(home, "data", "workspace") |
|
|
|
setattr(self, jobdef[program]["dirname"], dirpath) |
|
|
|
elif program != "unit": |
|
|
|
# compose after setargs |
|
|
|
dirpath = tools.path_tool.composePattern(job, "{"+jobdef[program]["basedir"]+"}", None) |
|
|
|
setattr(self, jobdef[program]["dirname"], dirpath) |
|
|
|
else: |
|
|
|
self.basedir = "debugs" |
|
|
|
tools.path_tool.extractPath(job, job.programDef[B.PAR_BASEDIR], |
|
|
|
getattr(self, job.programDef[B.PAR_DIRNAME])) |
|
|
|
# Abgleich mit zuvor gespeicherten Parametern |
|
|
|
if len(job.programDef["pfilesource"]) > 2: |
|
|
|
self.setParameterLoaded(job) |
|
|
|
|
|
|
|
|
|
|
|
def checkParameter(self, job): |
|
|
|
print (f"Parameter initialisiert {self.program}") |
|
|
|
pardef = jobdef[job.program]["pardef"] |
|
|
|
pardef = self.programDef[CTLG_PARDEF] |
|
|
|
for p in pardef.split(","): |
|
|
|
print(p) |
|
|
|
if len(p) > 1 and not hasattr(self, p): |
|
|
@ -578,9 +564,10 @@ class Parameter: |
|
|
|
dirpath = self.getDirParameter() |
|
|
|
#if dirpath is not None: |
|
|
|
# tools.path_tool.extractPath(job, dirpath[0], dirpath[1]) |
|
|
|
if hasattr(self, "application") and self.application in job.conf.confs[B.SUBJECT_APPS]: |
|
|
|
if B.ATTR_APPS_PROJECT in job.conf.confs[B.SUBJECT_APPS][self.application]: |
|
|
|
setattr(self, B.ATTR_APPS_PROJECT, job.conf.confs[B.SUBJECT_APPS][self.application][B.ATTR_APPS_PROJECT]) |
|
|
|
if hasattr(self, "application") and B.SUBJECT_APPS in job.conf \ |
|
|
|
and getattr(self, "application") in job.conf[B.SUBJECT_APPS]: |
|
|
|
if B.ATTR_APPS_PROJECT in job.conf[B.SUBJECT_APPS][self.application]: |
|
|
|
setattr(self, B.ATTR_APPS_PROJECT, job.conf[B.SUBJECT_APPS][self.application][B.ATTR_APPS_PROJECT]) |
|
|
|
proj = getattr(self, B.ATTR_APPS_PROJECT) |
|
|
|
|
|
|
|
|
|
|
@ -605,52 +592,3 @@ class Parameter: |
|
|
|
if len(a) == 2: |
|
|
|
return self[a[0]][a[1]] |
|
|
|
return |
|
|
|
|
|
|
|
|
|
|
|
# ------------------------------------------------------------------------------------------------------------------ |
|
|
|
class Configuration: |
|
|
|
def __init__ (self, job, program): |
|
|
|
self.program = program |
|
|
|
path = tools.path_tool.getBasisConfigPath() |
|
|
|
print ("conf initialisieren "+self.program+" > "+path) |
|
|
|
self.setConfiguration(job, path) |
|
|
|
return |
|
|
|
|
|
|
|
def debug(self, verify, text): |
|
|
|
if hasattr(self, "m"): |
|
|
|
self.m.debug(verify, text) |
|
|
|
|
|
|
|
def setConfiguration(self, job, path): |
|
|
|
if not hasattr(self, "confs"): |
|
|
|
self.confs = {} |
|
|
|
self.confs["configpath"] = [] |
|
|
|
doc = tools.file_tool.readFileDict(job, path, None) |
|
|
|
self.confs["configpath"].append(path) |
|
|
|
if "basic" in doc: |
|
|
|
for k, v in doc["basic"].items(): |
|
|
|
if k not in self.confs: |
|
|
|
self.confs[k] = v |
|
|
|
else: |
|
|
|
for k, v in doc.items(): |
|
|
|
if k not in self.confs: |
|
|
|
self.confs[k] = v |
|
|
|
|
|
|
|
def setConfig(self, path, val): |
|
|
|
a = path.split(".") |
|
|
|
if len(a) == 1: |
|
|
|
self.confs[a[0]] = val |
|
|
|
elif len(a) == 2: |
|
|
|
self.confs[a[0]][a[1]] = val |
|
|
|
elif len(a) == 3: |
|
|
|
self.confs[a[0]][a[1]][a[2]] = val |
|
|
|
|
|
|
|
|
|
|
|
def getPath(self, key): |
|
|
|
return self.confs.get(B.SUBJECT_PATH).get(key) |
|
|
|
|
|
|
|
def getJobConf(self, key): |
|
|
|
a = key.split(":") |
|
|
|
if len(a) == 1: |
|
|
|
return self.confs[a[0]] |
|
|
|
if len(a) == 2: |
|
|
|
return self.confs[a[0]][a[1]] |
|
|
|