# This is a sample Python script. import os import traceback import sys import yaml import basic.program import basic.constants as B import basic.message import tools.path_const as P import tools.config_tool as config_tool import tools.file_tool as file_tool import model.component PROGRAM_NAME = "check_configuration" def startPyJob(job): try: job.m.logDebug("--- start " + PROGRAM_NAME + " ------>>>>") components = job.par.component.split(",") for c in components: print("component "+c) checkComponent(job, c) job.m.setMsg("Job " + PROGRAM_NAME + " fertig") job.m.logDebug("<<<<<<<<----- " + PROGRAM_NAME + " ------") except Exception as e: job.m.logDebug("+++++++++++++++++++++++++++++++++++++++++++++") job.m.setFatal(str(e)) job.m.logDebug("+++++++++++++++++++++++++++++++++++++++++++++") job.m.logDebug("execpt "+traceback.format_exc()) job.m.logDebug("+++++++++++++++++++++++++++++++++++++++++++++") def checkComponent(job, componentName): """ checks the configurations of the component :param job: :param componentName: :return: """ configPath = config_tool.getExistingPath(job, [os.path.join(job.conf[B.SUBJECT_PATH][B.ATTR_PATH_COMPS], componentName, "CONFIG")]) configTree = file_tool.read_file_dict(job, configPath, job.m) for x in model.component.LIST_CP_SUBJECTS: if "conf" not in configTree: job.m.setError(componentName + ": root conf is not set: ") break if x not in configTree["conf"]: job.m.setError(componentName + ": subject is not set: " + x) else: for c in configTree["conf"][x]: if c == "none": if len(configTree["conf"][x]) != 1: job.m.setWarn("none is not the only subject in "+x) continue if __name__ == '__main__': job = basic.program.Job(PROGRAM_NAME) print ("job "+str(job.__dict__)) job.startJob() if job.m.isRc("fatal"): job.stopJob() # now in theory the program is runnable startPyJob(job) job.stopJob() # See PyCharm help at https://www.jetbrains.com/help/pycharm/