Data-Test-Executer Framework speziell zum Test von Datenverarbeitungen mit Datengenerierung, Systemvorbereitungen, Einspielungen, ganzheitlicher diversifizierender Vergleich
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

62 lines
2.1 KiB

3 years ago
import importlib, os
import basic.program
3 years ago
# -------------------------------------------------
3 years ago
def hasAttr(o, name):
print("hasAttr " + str(type(o))+" "+name)
if (isinstance(o, dict)):
if (name in o.keys()):
print("hasAttr dict ok " + str(type(o)))
return True
print("hasAttr dict "+str(type(o)))
elif (isinstance(o, list)):
print("hasAttr list "+str(type(o)))
elif hasattr(o, name):
print("hasAttr class ok "+str(type(o)))
return True
return False
3 years ago
"""
Toolmanager
"""
3 years ago
# class ToolManager:
def getDbTool(comp):
job = basic.program.Job.getInstance()
verify = int(job.getDebugLevel("db_tool"))
if not hasAttr(comp.conf["conn"], "dbtype"):
if hasAttr(comp.conf["conn"], "types") and hasAttr(comp.conf["conn"]["types"], "dbtype"):
dbtype = comp.conf["conn"]["types"]["dbtype"]
else:
raise LookupError("dbtype is not set in comp " + comp.name)
else:
dbtype = comp.conf["conn"]["dbtype"]
toolname = "db"+dbtype+"_tool"
print("toolname "+toolname)
filepath = os.path.join(job.conf.confs["paths"]["program"], "utils", toolname+".py")
print("toolname "+filepath)
if not os.path.exists(filepath):
raise FileNotFoundError("file for tool "+toolname+" does not exist "+filepath)
cmodul = importlib.import_module("utils."+toolname)
class_ = getattr(cmodul, "DbFcts")
c = class_()
c.setComp(comp)
return c
def getCliTool(comp):
job = basic.program.Job.getInstance()
verify = int(job.getDebugLevel("db_tool"))
if not hasAttr(comp.conf["conn"], "clitype"):
raise LookupError("dbtype is not set in comp " + comp.name)
toolname = "cli"+comp.conf["conn"]["clitype"]+"_tool"
print("toolname "+toolname)
filepath = os.path.join(job.conf.confs["paths"]["program"], "utils", toolname+".py")
print("toolname "+filepath)
if not os.path.exists(filepath):
raise FileNotFoundError("file for tool "+toolname+" does not exist "+filepath)
cmodul = importlib.import_module("utils."+toolname)
class_ = getattr(cmodul, "CliFcts")
c = class_()
c.setComp(comp)
return c