From 44ec50e66923f732f463804688de6d19bc12e436 Mon Sep 17 00:00:00 2001 From: Ulrich Date: Tue, 13 Sep 2022 20:47:38 +0200 Subject: [PATCH] some new files --- basic/user.py | 31 +++++++++++++++++++++++++++ copy_appdummy.py | 56 ++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 87 insertions(+) create mode 100644 basic/user.py create mode 100644 copy_appdummy.py diff --git a/basic/user.py b/basic/user.py new file mode 100644 index 0000000..e24021a --- /dev/null +++ b/basic/user.py @@ -0,0 +1,31 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- +# --------------------------------------------------------------------------------------------------------- +# Author : Ulrich Carmesin +# Source : gitea.ucarmesin.de +# --------------------------------------------------------------------------------------------------------- +import basic.toolHandling +import utils.data_const as D +import basic.constants as B +import basic.entity + +class User(basic.entity.Entity): + username = "" + password = "" + + def __init__(self, job): + """ + to be initialized by readSpec + :param job: + """ + self.job = job + + def getSchema(self): + dbtype = self.job.conf.confs[B.TOPIC_NODE_DB][B.ATTR_TYPE] + dbi = basic.toolHandling.getDbTool(self.job, None, dbtype) + sql = dbi.getCreateTable("user") + sql += dbi.getSchemaAttribut("id", "id")+"," + sql += dbi.getSchemaAttribut("username", D.TYPE_STR)+"," + sql += dbi.getSchemaAttribut("password", D.TYPE_STR) + sql += ");\n" + return sql \ No newline at end of file diff --git a/copy_appdummy.py b/copy_appdummy.py new file mode 100644 index 0000000..b2e1f4e --- /dev/null +++ b/copy_appdummy.py @@ -0,0 +1,56 @@ +# program to copy dummy-file as testcase-results +# ------------------------------------------------------------------------------------------------------------- +""" + +""" +import os +import shutil +import basic.program +import utils.path_tool +import utils.file_tool +import basic.constants as B +import utils.tdata_tool +import basic.componentHandling +import utils.path_const as P +import basic.message as message + + +PROGRAM_NAME = "copy_appdummy" +PROGRAM_DUMMY = "collect_testcase" + +def startPyJob(job): + cm = basic.componentHandling.ComponentManager.getInstance(job) + cm.initComponents() + comps = cm.getComponents(PROGRAM_DUMMY) + job.m.setMsg("# Components initialized with these relevant components " + str(comps)) + cm = basic.componentHandling.ComponentManager.getInstance(job, "init") + print("cm " + str(cm)) + cm.initComponents() + comps = cm.getComponents(PROGRAM_DUMMY) + for c in comps: + comp = cm.getComponent(c) + for cond in ["pre", "post"]: + tdatapath = utils.path_tool.composePattern(job, "{td"+cond+"exec}", comp) + envapppath = utils.path_tool.composePattern(job, "{tc"+cond+"cond}", comp) + if os.path.exists(tdatapath): + files = utils.file_tool.getFiles(job.m, job, tdatapath, ".+\.csv", None) + for f in files: + # shutil.copy() + print("cp " + os.path.join(tdatapath, f) + " " + os.path.join(envapppath, f)) + utils.file_tool.mkPaths(job, os.path.join(envapppath, f), job.m) + shutil.copy(os.path.join(tdatapath, f), os.path.join(envapppath, f)) + print(tdatapath) + +# Press the green button in the gutter to run the script. +if __name__ == '__main__': + print(PROGRAM_NAME) + x = basic.program.Job(PROGRAM_NAME) + x.startJob() + x.m.logDebug(str(vars(x.par)) + "\n" + str(vars(x.conf))) + if x.m.isRc("fatal"): + x.stopJob() + exit(x.m.rc * (-1) + 3) + startPyJob(x) + x.stopJob() +# See PyCharm help at https://www.jetbrains.com/help/pycharm/ +