def __init__(self): """ Constructor initializes logger, config file reader and db handle """ self.lctx = LOG.getLogger("dblog", "DH") self.cfg = config.CFG("DaytonaHost", self.lctx) self.cfg.readCFG("config.ini") self.db = dbaccess.DBAccess(self.cfg, self.lctx)
def checkTestRunning(testid): lctx = LOG.getLogger("dblog", "DH") cfg = config.CFG("DaytonaHost", lctx) cfg.readCFG("config.ini") db = dbaccess.DBAccess(cfg, LOG.getLogger("dblog", "DH")) check = db.query( """SELECT COUNT(*) FROM CommonFrameworkSchedulerQueue where testid=%s""", (testid, ), False, False) db.close() if check[0] == 0: return False else: return True
def checkTestRunning(testid): """ This function checks whether user has not initiated test termination from UI. CommonFrameworkSchedulerQueue table keep the list of all running test initiated by user from UI or CLI. When user terminate any running test from UI, daytona removes the entry of this test from CommonFrameworkSchedulerQueue table. This functions polls database to check if test is still present in the CommonFrameworkSchedulerQueue table """ lctx = LOG.getLogger("dblog", "DH") cfg = config.CFG("DaytonaHost", lctx) cfg.readCFG("config.ini") db = dbaccess.DBAccess(cfg, LOG.getLogger("dblog", "DH")) check = db.query( """SELECT COUNT(*) FROM CommonFrameworkSchedulerQueue where testid=%s""", (testid, ), False, False) db.close() if check[0] == 0: return False else: return True
def __init__(self): self.lctx = LOG.getLogger("dblog", "DH") self.cfg = config.CFG("DaytonaHost", self.lctx) self.cfg.readCFG("config.ini") self.db = dbaccess.DBAccess(self.cfg, self.lctx)
def construct(self, tid): import dbaccess import config lctx = LOG.getLogger("dblog", "DH") cfg = config.CFG("DaytonaHost", lctx) cfg.readCFG("config.ini") self.db = dbaccess.DBAccess(cfg, LOG.getLogger("dblog", "DH")) self.testobj.TestInputData.testid = tid query_result = self.db.query( """select testid, frameworkid, start_time, end_time, end_status, end_detail, exechostname, stathostname, timeout, cc_list, title, purpose, creation_time from TestInputData where testid = %s""", (self.testobj.TestInputData.testid, ), False, False) (self.testobj.TestInputData.testid, self.testobj.TestInputData.frameworkid, self.testobj.TestInputData.start_time, self.testobj.TestInputData.end_time, self.testobj.TestInputData.end_status, self.testobj.TestInputData.end_detail, self.testobj.TestInputData.exechostname, self.testobj.TestInputData.stathostname, self.testobj.TestInputData.timeout, self.testobj.TestInputData.email, self.testobj.TestInputData.title, self.testobj.TestInputData.purpose, self.testobj.TestInputData.creation_time) = query_result lctx.debug(query_result) query_result = self.db.query( """select ha.hostname, hat.name, hat.shared, hat.execution, hat.statistics from HostAssociation ha join HostAssociationType hat on ha.hostassociationtypeid = hat.hostassociationtypeid where testid = %s and hat.frameworkid = %s""", (self.testobj.TestInputData.testid, self.testobj.TestInputData.frameworkid), True, False) for r in query_result: lctx.debug(r) if r[1] == 'statistics' and r[4] == 1: self.testobj.TestInputData.stathostname = r[ 0] + "," + self.testobj.TestInputData.stathostname elif r[1] == 'execution' and r[3] == 1: self.testobj.TestInputData.exechostname = r[ 0] + "," + self.testobj.TestInputData.exechostname self.testobj.TestInputData.stathostname = self.testobj.TestInputData.stathostname[: -1] self.testobj.TestInputData.exechostname = self.testobj.TestInputData.exechostname[: -1] lctx.debug(self.testobj.TestInputData.exechostname) lctx.debug(self.testobj.TestInputData.stathostname) query_result = self.db.query( """select * from TestArgs where testid = %s""", (self.testobj.TestInputData.testid, ), True, False) self.testobj.TestInputData.execScriptArgs = query_result lctx.debug(query_result) query_result = self.db.query( """select file_root, execution_script_location, frameworkname from ApplicationFrameworkMetadata where frameworkid = %s""", (self.testobj.TestInputData.frameworkid, ), False, False) (self.testobj.TestInputData.file_root, self.testobj.TestInputData.execution_script_location, self.testobj.TestInputData.frameworkname) = query_result lctx.debug(query_result) query_result = self.db.query( """select processname, delay, duration from ProfilerFramework where testid = %s and profiler = %s""", (self.testobj.TestInputData.testid, 'STRACE'), False, False) if query_result: self.testobj.TestInputData.strace = True (self.testobj.TestInputData.strace_process, self.testobj.TestInputData.strace_delay, self.testobj.TestInputData.strace_duration) = query_result query_result = self.db.query( """select processname, delay, duration from ProfilerFramework where testid = %s and profiler = %s""", (self.testobj.TestInputData.testid, 'PERF'), False, False) if query_result: (self.testobj.TestInputData.perf_process, self.testobj.TestInputData.perf_delay, self.testobj.TestInputData.perf_duration) = query_result
#!/usr/bin/env python # -*- coding:cp949 -*- import dbaccess from logger import LOG import mysql.connector from mysql.connector import Error as DBERROR _db_connection = None _db_cur = None _db_connection = mysql.connector.connect(host='localhost', database='daytona', user='******', password='******') _db_cur = _db_connection.cursor() lctx = LOG.getLogger("schedulerlog", "DH") dba = dbaccess.DBAccess(lctx) query_result = dba.query("""select * from TestInputData""", (""), True, False) print query_result
* http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the * License for the specific language governing permissions and limitations * under the License. """ import requests import time import settings import dbaccess import arguments settings = settings.Settings('conf.ini') dbaccess = dbaccess.DBAccess(settings) def addrule(target, path): with open(path, 'r') as file: rule = file.read() if target == 'cdr': r = requests.post(settings.cdrRuleEndpoint, data=rule) print(r.status_code) elif target == 'bill': r = requests.post(settings.billRuleEndpoint, data=rule) print(r.status_code) print(rule) def removerule(target, rule):
if key == 27: self.go_back() return True def go_back(self): self.screen_stack.pop() # pop current screen if not self.screen_stack: # if list is empty, exit application self.screen_select('') else: # else, go to last screen self.screen_select(self.screen_stack.pop()) if __name__ == '__main__': '''Start the application''' database = db.DBAccess() # Check if json file exists. If it does if len(database.searchQuery('test')) < 5: for i in range(0, 5): invention = inv.invention("Test " + str(i), i%2 == 0, "Description of invention...", "test_user") database.insertInvention(invention) # Temporary to figure out proper parameters passing between screens. inv_id = 0 root = InventifyApp() root.run()