Ejemplo n.º 1
0
 def create_log(self, log_config_path=None):
     """
     创建并且返回一个具体日志实例(Class LogHandle的实例)
     :return: 成功返回(Class LogHandle的实例,失败返回None
     """
     try:
         if hasattr(self, 'console_name'):
             if self.console_name:
                 _li = HtmlHandle(
                     self.log_final_path).get_logger()  # console日志记录成html日志
                 wx.FindWindowById(10).logger = _li
             else:
                 import warnings
                 warnings.warn('console log name is None')
                 del warnings
                 return None
         else:
             _li = LoggerFromFile(log_config_path,
                                  self.log_final_path).get_logger()
         if self.log_define_type == 'run':
             wx.FindWindowById(10).logfiles.append(
                 self.log_final_path)  # 要上传的日志路径list
             DcnLog.log_list.append(_li)  # 通过类属性记录生成的loglist实例对象
         return _li
     except Exception as e:
         printResError('[异常]创建log时候遭遇异常,异常信息如下 {}'.format(e))
Ejemplo n.º 2
0
def printResInfo(msg):
    """
    打印到日志、调试窗口
    :param msg: msg
    :return: None
    """
    try:
        window = wx.FindWindowById(553)
        logger = wx.FindWindowById(10).logger
        msg = str(msg)
        if window and hasattr(window, 'WriteToText'):
            wx.CallAfter(window.WriteToText, msg + '\n')
        else:
            print(msg)
        if logger:
            for _msg in msg.split('\n'):
                logger.info(str(_msg, encoding='utf-8'))  # 此处是为了使得html日志回车换行
    except (AttributeError, Exception):
        print(msg)
    time.sleep(0.05)
Ejemplo n.º 3
0
def printResError(msg):
    """
    打印错误信息,如果有Dauto有logger(console log),则按照error级别记录log信息
    :param msg: msg
    :return: None
    """
    try:
        window = wx.FindWindowById(553)
        logger = wx.FindWindowById(10).logger
        msg = str(msg)
        if window and hasattr(window, 'WriteToText'):
            wx.CallAfter(window.WriteToText, msg + '\n')
        else:
            print(msg)
        if logger:
            for _msg in msg.split('\n'):
                logger.error(str(_msg, encoding='utf-8'))  # 此处是为了使得html日志回车换行
    except (AttributeError, Exception):
        print(msg)
    time.sleep(0.05)
Ejemplo n.º 4
0
 def set_waffirm_end(self):
     """
     更新testlink服务器上面执行状态,标记为完成
     :return: {'Status': 1 or 0, 'Message': 'XXX'}
     """
     try:
         job_type = self.tl.getJobInfo(
             self.tl.__args__['job_id'])['job_type']
         if self.tl.__args__['notes'] != 'end':
             # 如果只执行一个模块,直接将任务进度更新为完成状态
             if job_type == 'waffirm' or job_type == 'waffirm_X86':
                 self.tl.updateJobInfo(self.tl.__args__['job_id'], 2)
                 print('全部测试用例执行完毕,即将关闭确认测试用例平台')
                 main_window = wx.FindWindowById(10)
                 wx.CallAfter(main_window.OnAutoCloseWindow)
                 del self.tl.__args__['job_id']
                 return {'Status': 1, 'Message': 'Waffirm Test End'}
             else:
                 return {'Status': 0, 'Message': 'job type is not waffirm'}
         else:
             return {'Status': 0, 'Message': 'notes is end'}
     except Exception as ex:
         print('error %s' % ex)