def execute_shell(url, data): ws = create_connection(url) ws.send(json.dumps(data)) # 获取连接状态 Logger().get_log().info("获取连接状态:%s" % ws.getstatus()) # 获取返回结果 result = ws.recv() print("接收结果:", result)
import random from basic_info.setting import Dsp_MySQL_CONFIG from util.Open_DB import MYSQL from util.logs import Logger ms = MYSQL(Dsp_MySQL_CONFIG["HOST"], Dsp_MySQL_CONFIG["USER"], Dsp_MySQL_CONFIG["PASSWORD"], Dsp_MySQL_CONFIG["DB"], Dsp_MySQL_CONFIG["PORT"]) log = Logger().get_log() def deal_parameters(data): try: if data: if '随机数' in data: data = data.replace('随机数', str(random.randint(0, 999))) return deal_parameters(data) if 'select id from' in data: data_select_result = ms.ExecuQuery(data.encode('utf-8')) new_data = [] if data_select_result: if len(data_select_result) > 1: for i in range(len(data_select_result)): new_data.append(data_select_result[i]["id"]) if "select id from merce_dss" in data: return new_data elif "select id from merce_schema" in data: return new_data elif "select id from merce_role" in data: return new_data elif "select id from merce_user" in data:
# coding:utf-8 from util.send_mail import dsp_main3 import datetime from new_api_cases.execute_dsp_cases import deal_request_method from new_api_cases.execute_dsp_cases import CheckResult from basic_info.setting import dsp_host from basic_info.setting import receivers_list from util.logs import Logger log = Logger().get_log() log.info("--------开始执行用例-------") start_time = datetime.datetime.now() log.info("开始时间:%s" % start_time) log.info("--------开始执行api case-------") # 执行API用例并对比结果 deal_request_method() CheckResult().deal_result() stop_time = datetime.datetime.now() log.info("结束时间:%s" % stop_time) log.info("耗时:%s" % (stop_time - start_time)) # 发送邮件 dsp_main3(dsp_host, receivers_list)