|
@ -9,12 +9,16 @@ |
|
|
#import sys, getopt |
|
|
#import sys, getopt |
|
|
import argparse |
|
|
import argparse |
|
|
import copy |
|
|
import copy |
|
|
|
|
|
import time |
|
|
|
|
|
|
|
|
import yaml |
|
|
import yaml |
|
|
import os |
|
|
import os |
|
|
from datetime import datetime |
|
|
from datetime import datetime |
|
|
import basic.constants as B |
|
|
import basic.constants as B |
|
|
import basic.message |
|
|
import basic.message |
|
|
import basic.componentHandling |
|
|
import basic.componentHandling |
|
|
|
|
|
import objects.catalog |
|
|
|
|
|
import tools.value_tool |
|
|
import tools.date_tool |
|
|
import tools.date_tool |
|
|
import tools.path_tool |
|
|
import tools.path_tool |
|
|
import tools.file_tool |
|
|
import tools.file_tool |
|
@ -26,128 +30,13 @@ import tools.job_tool |
|
|
LIMIT_INFO = 16 #basic.message.LIMIT_INFO |
|
|
LIMIT_INFO = 16 #basic.message.LIMIT_INFO |
|
|
LIMIT_DEBUG = 12 #basic.message.LIMIT_DEBUG |
|
|
LIMIT_DEBUG = 12 #basic.message.LIMIT_DEBUG |
|
|
|
|
|
|
|
|
jobdef = { |
|
|
CTLG_NAME = "programs" |
|
|
"webflask": { |
|
|
CTLG_PARDEF = "pardef" |
|
|
"pardef": "", |
|
|
CTLG_PARSOURCE = "pfilesource" |
|
|
"pfilesource": "", |
|
|
CTLG_PARTARGET = "pfiletarget" |
|
|
"pfiletarget": "", |
|
|
CTLG_BASEDIR = "basedir" |
|
|
"basedir": "workbase", |
|
|
CTLG_LOGPATH = "logpath" |
|
|
"dirname": "workdir", |
|
|
CTLG_LOGLEVEL = "loglevel" |
|
|
"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"} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def setGlobal(): |
|
|
def setGlobal(): |
|
@ -168,7 +57,7 @@ DEFAULT_TIME = "2022-08-29_17-29-59" |
|
|
|
|
|
|
|
|
def createJob(pprg="", pgran="", papp="", penv="", ptstamp="", pmode=""): |
|
|
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 pprg: program-name |
|
|
:param pgran: tc|ts| |
|
|
:param pgran: tc|ts| |
|
|
:param papp: application |
|
|
:param papp: application |
|
@ -213,7 +102,7 @@ def createJob(pprg="", pgran="", papp="", penv="", ptstamp="", pmode=""): |
|
|
path = T.DATA_PATH + "/workspace/" |
|
|
path = T.DATA_PATH + "/workspace/" |
|
|
|
|
|
|
|
|
job = basic.program.Job(prgname) |
|
|
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, |
|
|
args = {"application": app, "environment": env, "modus": mode, gran + "time": tstamp, |
|
|
gran + "dir": path, |
|
|
gran + "dir": path, |
|
|
"step": 1} |
|
|
"step": 1} |
|
@ -222,13 +111,65 @@ def createJob(pprg="", pgran="", papp="", penv="", ptstamp="", pmode=""): |
|
|
job.par.setParameterArgs(job, args) |
|
|
job.par.setParameterArgs(job, args) |
|
|
return job |
|
|
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: |
|
|
class Job: |
|
|
__instance = None |
|
|
__instance = None |
|
|
__instances = [] |
|
|
__instances = [] |
|
|
__jobid = 100000 |
|
|
__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 |
|
|
initializing the job-object as a global structure for the actual doing |
|
|
type of job: |
|
|
type of job: |
|
@ -250,39 +191,72 @@ class Job: |
|
|
# - job.par with parameter-args or cli-args |
|
|
# - job.par with parameter-args or cli-args |
|
|
# - job.msg |
|
|
# - 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 |
|
|
Job.__jobid += 1 |
|
|
self.jobid = str(Job.__jobid) |
|
|
self.jobid = str(Job.__jobid) |
|
|
|
|
|
if len(program) < 3: |
|
|
|
|
|
print("FATAL: programname is missing") |
|
|
|
|
|
exit(3) |
|
|
self.program = program |
|
|
self.program = program |
|
|
conf = Configuration(self, program) |
|
|
if len(username) < 2: |
|
|
self.conf = conf.confs |
|
|
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: |
|
|
try: |
|
|
path = tools.config_tool.getConfigPath(self, P.KEY_BASIC, B.BASIS_FILE) |
|
|
path = tools.config_tool.getConfigPath(self, P.KEY_BASIC, B.BASIS_FILE) |
|
|
print("comps.basispath "+path) |
|
|
print("comps.basispath "+path) |
|
|
self.conf.setConfiguration(self, path) |
|
|
# conf = self.readConfiguration(path) |
|
|
|
|
|
self.conf = self.getConfiguration(path) |
|
|
except: |
|
|
except: |
|
|
pass # the special path is not necessary |
|
|
print("FATAL: config-file could not be loaded") |
|
|
logTime = tools.date_tool.getActdate(tools.date_tool.F_LOG) |
|
|
exit(3) |
|
|
self.start = logTime |
|
|
if args is not None: |
|
|
self.m = basic.message.Message(self, jobdef[program]["loglevel"], logTime, None) |
|
|
self.setParameter(args) |
|
|
|
|
|
self.m = basic.message.Message(self, self.programDef[CTLG_LOGLEVEL], logTime, None) |
|
|
|
|
|
|
|
|
def altinit(self, program, args): |
|
|
def altinit(self, program, args): |
|
|
appl = tools.config_tool.getConfig(self, P.KEY_BASIC, B.SUBJECT_APPS) |
|
|
appl = tools.config_tool.getConfig(self, P.KEY_BASIC, B.SUBJECT_APPS) |
|
|
if appl is not None: |
|
|
if appl is not None: |
|
|
self.conf.confs[B.SUBJECT_APPS] = appl[B.SUBJECT_APPS] |
|
|
self.conf[B.SUBJECT_APPS] = appl[B.SUBJECT_APPS] |
|
|
if B.SUBJECT_PROJECTS in self.conf.confs: |
|
|
if B.SUBJECT_PROJECTS in self.conf: |
|
|
for k in self.conf.confs[B.SUBJECT_PROJECTS]: |
|
|
for k in self.conf[B.SUBJECT_PROJECTS]: |
|
|
if k not in appl[B.SUBJECT_PROJECTS]: |
|
|
if k not in appl[B.SUBJECT_PROJECTS]: |
|
|
raise Exception("Workspace has project "+k+" which is not configured") |
|
|
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: |
|
|
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) |
|
|
par = Parameter(self, program, args) |
|
|
self.par = par |
|
|
self.par = par |
|
|
|
|
|
|
|
|
def getLogpath(self): |
|
|
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 |
|
|
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): |
|
|
def murks(self, par, program): |
|
|
self.par = par |
|
|
self.par = par |
|
|
dirpath = self.par.getDirParameter() |
|
|
dirpath = self.par.getDirParameter() |
|
@ -298,18 +272,18 @@ class Job: |
|
|
|
|
|
|
|
|
def setProgram(self, program): |
|
|
def setProgram(self, program): |
|
|
self.program = program |
|
|
self.program = program |
|
|
basedir = jobdef[program]["basedir"] |
|
|
basedir = self.programDef[CTLG_BASEDIR] |
|
|
self.basedir = basedir |
|
|
self.basedir = basedir |
|
|
if (self.par is not None) and self.par in B.LIST_MAIN_PAR: |
|
|
if (self.par is not None) and self.par in B.LIST_MAIN_PAR: |
|
|
setattr(self.par, "program", program) |
|
|
setattr(self.par, B.PAR_PROGRAM, program) |
|
|
setattr(self.par, "basedir", basedir) |
|
|
setattr(self.par, B.PAR_BASEDIR, basedir) |
|
|
parstring = getattr(self.par, "parstring") |
|
|
parstring = getattr(self.par, B.PAR_STRING) |
|
|
parstring = parstring[parstring.find("--"):] |
|
|
parstring = parstring[parstring.find("--"):] |
|
|
parstring = "python "+program+" "+parstring |
|
|
parstring = "python "+program+" "+parstring |
|
|
setattr(self.par, "parstring", parstring) |
|
|
setattr(self.par, "parstring", parstring) |
|
|
if not hasattr(self.par, jobdef[program]["dirname"]): |
|
|
if not hasattr(self.par, self.programDef[B.PAR_DIRNAME]): |
|
|
setattr(self.par, jobdef[program]["dirname"], |
|
|
setattr(self.par, self.programDef[B.PAR_DIRNAME], |
|
|
tools.path_tool.composePattern(self, "{"+basedir+"}", None)) |
|
|
tools.path_tool.compose_path(self, "{"+basedir+"}", None)) |
|
|
print(parstring) |
|
|
print(parstring) |
|
|
self.par.setParameterLoaded(self) |
|
|
self.par.setParameterLoaded(self) |
|
|
|
|
|
|
|
@ -349,9 +323,9 @@ class Job: |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def dumpParameter(self): |
|
|
def dumpParameter(self): |
|
|
if len(jobdef[self.program]["pfiletarget"]) < 2: |
|
|
if len(self.programDef[CTLG_PARTARGET]) < 2: |
|
|
return |
|
|
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 = {} |
|
|
output = {} |
|
|
cconf = basic.componentHandling.getComponentDict() |
|
|
cconf = basic.componentHandling.getComponentDict() |
|
|
output["par"] = self.par.__dict__ |
|
|
output["par"] = self.par.__dict__ |
|
@ -372,9 +346,9 @@ class Job: |
|
|
|
|
|
|
|
|
def loadParameter(self): |
|
|
def loadParameter(self): |
|
|
output = {} |
|
|
output = {} |
|
|
if len(str(jobdef[self.program]["pfilesource"])) < 2: |
|
|
if len(str(self.programDef[CTLG_PARSOURCE])) < 2: |
|
|
return None |
|
|
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) |
|
|
print("parpath "+parpath) |
|
|
if not os.path.join(parpath): |
|
|
if not os.path.join(parpath): |
|
|
return None |
|
|
return None |
|
@ -385,17 +359,23 @@ class Job: |
|
|
return output |
|
|
return output |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def setParameter(self, args): |
|
|
|
|
|
self.par = Parameter(self, args) |
|
|
|
|
|
|
|
|
def getParameter(self, parameter): |
|
|
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) |
|
|
return getattr(self.par, parameter) |
|
|
elif "xxxtime" in parameter: |
|
|
elif "xxxtime" in parameter: |
|
|
neu = tools.date_tool.getActdate(tools.date_tool.F_DIR) |
|
|
neu = tools.date_tool.getActdate(tools.date_tool.F_DIR) |
|
|
# setattr(self.par, parameter, neu) |
|
|
# setattr(self.par, parameter, neu) |
|
|
return neu |
|
|
return neu |
|
|
else: |
|
|
else: |
|
|
print("Parameter "+parameter+" nicht in job.par ") |
|
|
val = tools.value_tool.compose_pattern(self, parameter, None) |
|
|
for attr, value in self.par.__dict__.items(): |
|
|
if val is None: |
|
|
print(attr, value) |
|
|
self.m.logError("Parameter "+parameter+" nicht in job.par ") |
|
|
|
|
|
return |
|
|
|
|
|
setattr(self.par, parameter, val) |
|
|
|
|
|
return val |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def hasElement(self, parameter, elem): |
|
|
def hasElement(self, parameter, elem): |
|
@ -440,11 +420,12 @@ class Job: |
|
|
return basic.message.LIMIT_DEBUG |
|
|
return basic.message.LIMIT_DEBUG |
|
|
elif elem.find("tool") > 1 and hasattr(self, "par"): |
|
|
elif elem.find("tool") > 1 and hasattr(self, "par"): |
|
|
if not hasattr(self.par, "tool") or getattr(self.par, "tool").find(elem) <= 0: |
|
|
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: |
|
|
else: |
|
|
return int(self.m.CONST_ERRTYP[errtyp]) |
|
|
return 4 |
|
|
else: |
|
|
else: |
|
|
return int(self.m.CONST_ERRTYP[errtyp]) |
|
|
# TODO quickfix |
|
|
|
|
|
return 4 |
|
|
def getInfoLevel(self, elem): |
|
|
def getInfoLevel(self, elem): |
|
|
return self.getMessageLevel("info", elem) |
|
|
return self.getMessageLevel("info", elem) |
|
|
def getDebugLevel(self, elem): |
|
|
def getDebugLevel(self, elem): |
|
@ -458,6 +439,24 @@ class Job: |
|
|
else: |
|
|
else: |
|
|
print(text) |
|
|
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: |
|
|
class Parameter: |
|
|
""" |
|
|
""" |
|
@ -468,45 +467,32 @@ class Parameter: |
|
|
comparison with a parameter-file from the work-folder |
|
|
comparison with a parameter-file from the work-folder |
|
|
""" |
|
|
""" |
|
|
print ("class Parameter") |
|
|
print ("class Parameter") |
|
|
def __init__ (self, job, program, args=None): |
|
|
def __init__ (self, job, args=None): |
|
|
print ("# init Parameter for " + program) |
|
|
print ("# init Parameter for " + job.program) |
|
|
self.program = program |
|
|
self.program = job.program |
|
|
if args is not None and isinstance(args, dict): |
|
|
if args is not None and isinstance(args, dict): |
|
|
self.setParameterArgs(job, args) |
|
|
self.setParameterArgs(job, args) |
|
|
else: |
|
|
else: |
|
|
self.setParameter(job) |
|
|
self.setParameter(job) |
|
|
self.basedir = jobdef[program]["basedir"] |
|
|
self.basedir = job.programDef[B.PAR_BASEDIR] |
|
|
job.basedir = jobdef[program]["basedir"] |
|
|
job.basedir = job.programDef[B.PAR_BASEDIR] |
|
|
print (f"# Parameter initialisiert {self.program} mit basedir {self.basedir}") |
|
|
print (f"# Parameter initialisiert {self.program} mit basedir {self.basedir}") |
|
|
job.par = self |
|
|
job.par = self |
|
|
if not hasattr(self, jobdef[program]["dirname"]): |
|
|
# Parameter aus Verzeichnis extraieren bzw. Verzeichnis aus Parameter erstellen |
|
|
setattr(self, jobdef[program]["dirname"], |
|
|
if not hasattr(self, job.programDef[B.PAR_DIRNAME]): |
|
|
tools.path_tool.composePattern(job, "{"+self.basedir+"}", None)) |
|
|
setattr(self, job.programDef[B.PAR_DIRNAME], |
|
|
|
|
|
tools.value_tool.compose_pattern(job, self.basedir, None)) |
|
|
else: |
|
|
else: |
|
|
tools.path_tool.extractPath(job, jobdef[program]["basedir"], getattr(self, jobdef[program]["dirname"])) |
|
|
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) |
|
|
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" |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def checkParameter(self, job): |
|
|
def checkParameter(self, job): |
|
|
print (f"Parameter initialisiert {self.program}") |
|
|
print (f"Parameter initialisiert {self.program}") |
|
|
pardef = jobdef[job.program]["pardef"] |
|
|
pardef = self.programDef[CTLG_PARDEF] |
|
|
for p in pardef.split(","): |
|
|
for p in pardef.split(","): |
|
|
print(p) |
|
|
print(p) |
|
|
if len(p) > 1 and not hasattr(self, p): |
|
|
if len(p) > 1 and not hasattr(self, p): |
|
@ -578,9 +564,10 @@ class Parameter: |
|
|
dirpath = self.getDirParameter() |
|
|
dirpath = self.getDirParameter() |
|
|
#if dirpath is not None: |
|
|
#if dirpath is not None: |
|
|
# tools.path_tool.extractPath(job, dirpath[0], dirpath[1]) |
|
|
# tools.path_tool.extractPath(job, dirpath[0], dirpath[1]) |
|
|
if hasattr(self, "application") and self.application in job.conf.confs[B.SUBJECT_APPS]: |
|
|
if hasattr(self, "application") and B.SUBJECT_APPS in job.conf \ |
|
|
if B.ATTR_APPS_PROJECT in job.conf.confs[B.SUBJECT_APPS][self.application]: |
|
|
and getattr(self, "application") in job.conf[B.SUBJECT_APPS]: |
|
|
setattr(self, B.ATTR_APPS_PROJECT, job.conf.confs[B.SUBJECT_APPS][self.application][B.ATTR_APPS_PROJECT]) |
|
|
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) |
|
|
proj = getattr(self, B.ATTR_APPS_PROJECT) |
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -605,52 +592,3 @@ class Parameter: |
|
|
if len(a) == 2: |
|
|
if len(a) == 2: |
|
|
return self[a[0]][a[1]] |
|
|
return self[a[0]][a[1]] |
|
|
return |
|
|
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]] |
|
|
|
|
|