def test_log_api(self): """ Test get exist option """ OrcTest.test_print_begin() init_log() _log = OrcLog("api.test01") _log.info("This 001!") _log.warning("This 002!") _log.error("This 003!") _log.critical("This 004!") _log.debug("This 005!") OrcTest.test_print_end()
def __init__(self): QThread.__init__(self) self.__config = get_config("network") self.__logger = OrcLog("view")
class WidgetDefBus(object): def __init__(self): object.__init__(self) init_log() self.__logger = OrcLog("api.driver.web.widget.bus.widget_def") self.__model_widget_def = WidgetDefMod() self.__bus_widget_det = WidgetDetBus() def bus_list_add(self, p_data): """ 新增 :param p_data: :return: """ try: result = self.__model_widget_def.usr_add(p_data) except Exception: self.__logger.error("Add widget error, input: %s" % p_data) raise OrcApiModelFailException return result def bus_list_delete(self, p_list): """ 删除 :param p_list: :return: """ try: for _id in p_list: self.bus_delete(_id) except Exception: self.__logger.error("Delete widget error, input: %s" % p_list) raise OrcApiModelFailException return True def bus_list_search(self, p_cond): """ 查询 :param p_cond: :return: """ result = [] mode = p_cond["type"] if "type" in p_cond else None widget_id = p_cond["id"] if "id" in p_cond else None try: # 查询符合条件的整用例树,至根节点 if "all" == mode: result = self.__model_widget_def.usr_search_all(p_cond) # 查询节点及子节点 elif "tree" == mode: if widget_id is not None: result = self.__model_widget_def.usr_search_tree(widget_id) # 查询节点路径 elif "path" == mode: if widget_id is not None: result = self.__model_widget_def.usr_search_path(widget_id) # 其他情况只查询符合条件的数据 else: result = self.__model_widget_def.usr_search(p_cond) except Exception: self.__logger.error("Search widget error, input: %s" % p_cond) raise OrcApiModelFailException return result def bus_delete(self, p_id): """ 删除单一步骤 :param p_id: :return: """ try: # 查找 widget_det_list widget_det_list = self.__bus_widget_det.bus_list_search( dict(widget_id=p_id)) # 获取 widget_det_id_list widget_det_id_list = [ widget_det.id for widget_det in widget_det_list ] # 删除 widget_dets self.__bus_widget_det.bus_list_delete(widget_det_id_list) # 删除 widget_def self.__model_widget_def.usr_delete(p_id) except Exception: self.__logger.error("Delete widget error, input: %s" % p_id) raise OrcApiModelFailException return True def bus_update(self, p_id, p_cond): """ 更新步骤 :param p_id: :param p_cond: :return: """ cond = dict(id=p_id) cond.update(p_cond) try: self.__model_widget_def.usr_update(cond) except Exception: self.__logger.error("Update widget error, input: %s" % cond) raise OrcApiModelFailException return True def bus_search(self, p_id): """ 查询单一步骤 :param p_id: :return: """ try: result = self.__model_widget_def.usr_search(dict(id=p_id)) result = None if not result else result[0] except Exception: self.__logger.error("Search widget error, input: %s" % p_id) raise OrcApiModelFailException return result
def __init__(self): TabRunTime.__init__(self) self.__logger = OrcLog("api.run_time.mod")
def __init__(self): self.__logger = OrcLog("resource.widgets.api.det") self.__business = WidgetDetBus()
def __init__(self): self.__logger = OrcLog("resource.datas.api") self.__model = DataBus()
class ItemBus(object): def __init__(self): object.__init__(self) init_log() self.__logger = OrcLog("api.step.bus.step_def") self.__model_item = ItemMod() def bus_list_add(self, p_data): """ 新增 :param p_data: :return: """ try: result = self.__model_item.usr_add(p_data) except Exception: self.__logger.error("Add case error, input: %s" % p_data) raise OrcApiModelFailException return result def bus_list_delete(self, p_list): """ 删除 :param p_list: :return: """ try: for _id in p_list: self.bus_delete(_id) except Exception: self.__logger.error("Add case error, input: %s" % p_list) raise OrcApiModelFailException return True def bus_list_search(self, p_cond): """ 查询 :param p_cond: :return: """ try: result = self.__model_item.usr_search(p_cond) except Exception: self.__logger.error("Add case error, input: %s" % p_cond) raise OrcApiModelFailException return result def bus_delete(self, p_id): """ 删除一条 :param p_id: :return: """ try: self.__model_item.usr_delete(p_id) except Exception: self.__logger.error("Add case error, input: %s" % p_id) raise OrcApiModelFailException return True def bus_update(self, p_id, p_cond): """ 更新 :param p_id: :param p_cond: :return: """ cond = dict(id=p_id) cond.update(p_cond) try: self.__model_item.usr_update(cond) except Exception: self.__logger.error("Add case error, input: %s" % cond) raise OrcApiModelFailException return True def bus_search(self, p_id): """ 查询一条 :param p_id: :return: """ print "DDDD" print p_id print "DDD" try: result = self.__model_item.usr_search(dict(id=p_id)) result = None if not result else result[0] except Exception: self.__logger.error("Search item error, input: %s" % p_id) raise OrcApiModelFailException return result
def __init__(self): init_log() self.__logger = OrcLog("driver.api") self.__model = DriverModel()
def __init__(self): object.__init__(self) self.__logger = OrcLog("api.run.bus.run_def") self.__model_run_def = RunDefMod()
def __init__(self): self.__logger = OrcLog("resource.run.api") self.__model = RunCore()
def __init__(self): self.__logger = OrcLog("resource.driver.web.window") self.__business = WindowDefBus()
def __init__(self): self.__logger = OrcLog("resource.runs.api.det") self.__model = RunDetMod()
def __init__(self): self.__logger = OrcLog("resource.runs.api.def") self.__business = RunDefBus()
def __init__(self): # Log self.__logger = OrcLog("view.driver.web.service.page_def") self.__resource_page_def = OrcHttpNewResource("PageDef")
def __init__(self): self.__logger = OrcLog("resource.lib.dict") self.__business = DictBus()
class WindowDefMod: """ Test data management """ __session = orc_db.session __logger = OrcLog("api.driver.web.window_def") def __init__(self): pass def usr_search(self, p_cond=None): """ 查询符合条件的控件 :param p_cond: :return: """ # 判断输入参数是否为空 cond = p_cond if p_cond else dict() # 查询条件 like _like = lambda p_flag: "%%%s%%" % cond[p_flag] # db session result = self.__session.query(WebWindowDef) if 'id' in cond: # 查询支持多 id if isinstance(cond["id"], list): result = result.filter(WebWindowDef.id.in_(cond['id'])) else: result = result.filter(WebWindowDef.id == cond['id']) if 'window_mark' in cond: result = result.filter( WebWindowDef.window_mark.ilike(_like('window_mark'))) if 'window_desc' in cond: result = result.filter( WebWindowDef.window_desc.ilike(_like('window_desc'))) if 'comment' in cond: result = result.filter(WebWindowDef.comment.ilike( _like('comment'))) return result.all() def usr_add(self, p_data): """ :param p_data: :return: """ _node = WebWindowDef() # Create id _node.id = p_data['id'] # window_mark _node.window_mark = p_data[ 'window_mark'] if 'window_mark' in p_data else "" # window_desc _node.window_desc = p_data[ 'window_desc'] if 'window_desc' in p_data else "" # batch_desc, comment _node.comment = p_data['comment'] if 'comment' in p_data else "" # create_time, modify_time _node.create_time = datetime.now() _node.modify_time = datetime.now() try: self.__session.add(_node) self.__session.commit() except: self.__logger.error("") raise OrcDatabaseException return _node def usr_update(self, p_cond): for t_id in p_cond: if "id" == t_id: continue _data = None if is_null(p_cond[t_id]) else p_cond[t_id] _item = self.__session.query(WebWindowDef).filter( WebWindowDef.id == p_cond['id']) _item.update({t_id: _data}) self.__session.commit() def usr_delete(self, p_id): """ Delete :param p_id: :return: """ self.__session.query(WebWindowDef).filter( WebWindowDef.id == p_id).delete() self.__session.commit()
def __init__(self): # Log self.__logger = OrcLog("view.driver.web.service.widget_def") self.__resource_widget_def = OrcHttpNewResource("WidgetDef")
def __init__(self): self.__logger = OrcLog("resource.step.api.det") self.__business = StepDetBus()
def __init__(self): self.__logger = OrcLog("resource.report.api.det") self.__model = ReportDetModel()
def __init__(self): self.__logger = OrcLog("resource.step.api.def") self.__model = StepDefBus()
def __init__(self): TabBatchDef.__init__(self) self.__logger = OrcLog("api.batch.mod.batch_def")
class PageDefBus(object): def __init__(self): object.__init__(self) init_log() self.__logger = OrcLog("api.step.bus.step_def") self.__model_page_def = PageDefMod() self.__bus_page_det = PageDetBus() def bus_list_add(self, p_data): """ 新增 :param p_data: :return: """ try: result = self.__model_page_def.usr_add(p_data) except Exception: self.__logger.error("Add case error, input: %s" % p_data) raise OrcApiModelFailException return result def bus_list_delete(self, p_list): """ 删除 :param p_list: :return: """ try: for _id in p_list: self.bus_delete(_id) except Exception: self.__logger.error("Add case error, input: %s" % p_list) raise OrcApiModelFailException return True def bus_list_search(self, p_cond): """ 查询 :param p_cond: :return: """ try: result = self.__model_page_def.usr_search(p_cond) except Exception: self.__logger.error("Add case error, input: %s" % p_cond) raise OrcApiModelFailException return result def bus_delete(self, p_id): """ 删除单一步骤 :param p_id: :return: """ try: # 查找 page_det_list page_det_list = self.__bus_page_det.bus_list_search( dict(page_id=p_id)) # 获取 page_det_id_list page_det_id_list = [page_det.id for page_det in page_det_list] # 删除 page_dets self.__bus_page_det.bus_list_delete(page_det_id_list) # 删除 page_def self.__model_page_def.usr_delete(p_id) except Exception: self.__logger.error("Add case error, input: %s" % p_id) raise OrcApiModelFailException return True def bus_update(self, p_id, p_cond): """ 更新步骤 :param p_id: :param p_cond: :return: """ cond = dict(id=p_id) cond.update(p_cond) try: self.__model_page_def.usr_update(cond) except Exception: self.__logger.error("Add case error, input: %s" % cond) raise OrcApiModelFailException return True def bus_search(self, p_id): """ 查询单一步骤 :param p_id: :return: """ try: result = self.__model_page_def.usr_search(dict(id=p_id)) result = None if not result else result[0] except Exception: self.__logger.error("Add case error, input: %s" % p_id) raise OrcApiModelFailException return result
def __init__(self): self.__logger = OrcLog("resource.page.api.def") self.__business = PageDefBus()
# coding=utf-8 import json import requests import socket from exceptions import ValueError from functools import wraps from flask import make_response from flask import request from requests.exceptions import RequestException from requests.packages.urllib3.exceptions import HTTPError from OrcLib.LibLog import OrcLog from OrcLib import get_config from OrcApi import orc_db _logger = OrcLog("basic.lib_net") class OrcResourceBase(object): """ http 服务调用封装为资源 """ def __init__(self, p_mod): object.__init__(self) mod_list = dict(BatchDef='BATCH', BatchDet='BATCH', CaseDef='CASE', CaseDet='CASE', StepDef='CASE',
def __init__(self): self.__logger = OrcLog("resource.widget.def") self.__business = WidgetDefBus()
def __init__(self): self.__logger = OrcLog("resource.batch.api.det") self.__business = BatchDetBus()
class WidgetDetBus(object): def __init__(self): object.__init__(self) init_log() self.__logger = OrcLog("api.driver.web.widget.bus.widget_det") self.__model_widget_det = WidgetDetMod() def bus_list_add(self, p_data): """ 新增 :param p_data: :return: """ try: result = self.__model_widget_det.usr_add(p_data) except Exception: self.__logger.error("Add widget detail error, input: %s" % p_data) raise OrcApiModelFailException return result def bus_list_delete(self, p_list): """ 删除 :param p_list: :return: """ try: for _id in p_list: self.bus_delete(_id) except Exception: self.__logger.error("Delete widget detail error, input: %s" % p_list) raise OrcApiModelFailException return True def bus_list_search(self, p_cond): """ 查询 :param p_cond: :return: """ try: result = self.__model_widget_det.usr_search(p_cond) except Exception: self.__logger.error("Search widget detail error, input: %s" % p_cond) raise OrcApiModelFailException return result def bus_delete(self, p_id): """ 删除单一 item :param p_id: :return: """ try: self.__model_widget_det.usr_delete(p_id) except Exception: self.__logger.error("Delete widget detail error, input: %s" % p_id) raise OrcApiModelFailException return True def bus_update(self, p_id, p_cond): """ 更新 :param p_id: :param p_cond: :return: """ cond = dict(id=p_id) cond.update(p_cond) try: self.__model_widget_det.usr_update(cond) except Exception: self.__logger.error("Update widget detail error, input: %s" % p_cond) raise OrcApiModelFailException return True def bus_search(self, p_id): """ 查询单一条目 :param p_id: :return: """ try: result = self.__model_widget_det.usr_search(dict(id=p_id)) result = None if not result else result[0] except Exception: self.__logger.error("Search widget detail error, input: %s" % p_id) raise OrcApiModelFailException return result
def __init__(self): self.__logger = OrcLog("resource.batch.api.def") self.__model = BatchDefBus()
def __init__(self): self.__logger = OrcLog("resource.run_times.api.def") self.__model = RunTimeBus()
def __init__(self): self.__logger = OrcLog("resource.case.api.def") self.__business = CaseDefBus()