def emit(self, record): """ 日志记录器日志发送函数 record 日志记录 MakeRecord() """ # print "emit", record.levelname ts = CoTimeM.get_ts() try: # 根据格式字符串生成消息文本 msg = self.format(record) msg = "[ts:\"" + str(ts) + "\"]" + \ "[level:\"" + record.levelname + "\"]" + \ "[filepath:\"" + self.filepath + "\"]" + \ "[msg:\"" + msg.replace('"', "\\\"") + "\"];" msg = self.appid + ":" + msg + "\n" #print msg # socket # stream = self.stream # 使用socket的发送方法来发送日志 sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) sock.connect((self.agent_ip, self.agent_port)) sock.send(msg) sock.close() self.flush() except (KeyboardInterrupt, SystemExit): raise except Exception, exc: self.handle_exc(Exception, exc) self.handleError(record)
suite_opt = options.suite app_loc = CoFileM.get_app_loc() app_cfg = CoConfM.get_cfg_type() app_gbl_cfg_file = CoConfM.get_cfg_type_path() if not suite_opt: suite_config = "suites.json" else: # 到指定的目录获取对应的测试集配置 suite_config = app_loc + "config" + os.sep + app_cfg + os.sep + suite_opt + ".json" # 获取当前时间 date = cofTime.get_date_ymd() # 日期【20150213】 timestamp = str(cofTime.get_ts()) # 时间戳【1423813170】 # 当前路径 path = os.path.abspath(__file__) path = os.path.dirname(path) argvs = sys.argv if len(argvs) <= 2: ip = '172.24.128.14' else: ip = argvs[2] if len(argvs) <= 3: port = '5816' else: port = argvs[3]
suite_opt = options.suite app_loc = CoFileM.get_app_loc() app_cfg = CoConfM.get_cfg_type() app_gbl_cfg_file = CoConfM.get_cfg_type_path() if not suite_opt: suite_config = "suites.json" else: # 到指定的目录获取对应的测试集配置 suite_config = app_loc + "config" + os.sep + app_cfg + os.sep + suite_opt + ".json" # 获取当前时间 date = cofTime.get_date_ymd() # 日期【20150213】 timestamp = str(cofTime.get_ts()) # 时间戳【1423813170】 # 当前路径 path = os.path.abspath(__file__) path = os.path.dirname(path) def set_case_list(): """ 从命令行读取需要运行的测试集,返回测试集列表 """ argvs = sys.argv #argvs = ['runner.py', 'case_test'] if len(argvs) <= 1: # 没有指定测试用例集,默认运行所有测试用例(nose自动识别) print "no specified cases, could run all cases"