Merge branch 'develop' of https://git.mesalab.cn/dongxiaoyan/tsg_autotest.git into develop
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -180,9 +180,10 @@ class Order:
|
|||||||
Order.UpdateAllvalues(self,chdict, key, value)
|
Order.UpdateAllvalues(self,chdict, key, value)
|
||||||
element[k] = chdict
|
element[k] = chdict
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#递归提取json中符合要求键的值
|
#递归提取json中符合要求键的值
|
||||||
import json
|
import json
|
||||||
|
|
||||||
def get_dict_allkeys(self,dict_a):
|
def get_dict_allkeys(self,dict_a):
|
||||||
"""
|
"""
|
||||||
遍历嵌套字典,获取json返回结果的所有key值
|
遍历嵌套字典,获取json返回结果的所有key值
|
||||||
@@ -217,59 +218,17 @@ class Order:
|
|||||||
print(type(datas))
|
print(type(datas))
|
||||||
lists=lists.split(",")
|
lists=lists.split(",")
|
||||||
print(type(lists))
|
print(type(lists))
|
||||||
|
print("gsd")
|
||||||
|
datas2=list(map(str,datas))
|
||||||
|
print(datas2)
|
||||||
print(datas)
|
print(datas)
|
||||||
print(lists)
|
print(lists)
|
||||||
|
|
||||||
if set(datas) > set(lists):
|
if set(datas2) > set(lists):
|
||||||
return "ture"
|
return "true"
|
||||||
else:
|
else:
|
||||||
return "flase"
|
return "flase"
|
||||||
# 获取单层列表索引
|
|
||||||
def Index(self,list,value):
|
|
||||||
n = 0
|
|
||||||
for a in list:
|
|
||||||
if a!=value:
|
|
||||||
n+=1
|
|
||||||
else:
|
|
||||||
return n
|
|
||||||
def Interface_data(ipstart,ipend):
|
|
||||||
list1 = []
|
|
||||||
while ipstart<=ipend:
|
|
||||||
url = "http://192.168.44.17/v1/policy/object"
|
|
||||||
false = False
|
|
||||||
true = True
|
|
||||||
ip = "192.168.2."+str(ipstart)
|
|
||||||
data = {"opAction":"add","returnData":1,"objectList":{"objectType":"ip","objectSubType":"endpoint","isValid":1,"isInitialize":0,"isExclusion":0,"objectName":str(ip),"objectDesc":"","subObjectIds":[],"addItemList":[{"ip":ip,"ipIf":false,"portIf":false,"port":"0-65535","itemId":"","clientIp1":ip,"clientIp2":ip,"clientPort1":"0","clientPort2":"65535","clientIpFormat":"range","clientPortFormat":"range","addrType":4,"direction":0,"temporaryItemId":1599893528}],"updateItemList":[],"deleteItemIds":[],"iconColor":"#31739C"}}
|
|
||||||
headers = {
|
|
||||||
'Content-Type': "application/json",
|
|
||||||
'Authorization': "1520b640-fa0f-4ed4-b972-7e0b75ecec40&103&"
|
|
||||||
}
|
|
||||||
# r = requests.post(url,data1,headers=headers)
|
|
||||||
result = requests.post(url=url, data=json.dumps(data), headers=headers).json()
|
|
||||||
res = json.dumps(result, ensure_ascii=False, sort_keys=True, indent=2)
|
|
||||||
a = result["data"]["objectList"][0]["objectId"]
|
|
||||||
list1.append(a)
|
|
||||||
# sleep(1)
|
|
||||||
# print(res)
|
|
||||||
# print("**************")
|
|
||||||
# print(result["data"]["objectList"][0]["objectId"])
|
|
||||||
|
|
||||||
# print(ip)
|
|
||||||
ipstart+=1
|
|
||||||
url = "http://192.168.44.17/v1/policy/object"
|
|
||||||
false = False
|
|
||||||
true = True
|
|
||||||
data = {"opAction":"add","returnData":1,"objectList":{"objectType":"ip","objectSubType":"endpoint","isValid":1,"isInitialize":0,"isExclusion":0,"objectName":"192.168.2."+str(ipstart)+"~"+str(ipend)+"集合","objectDesc":"","subObjectIds":list1,"addItemList":[],"updateItemList":[],"deleteItemIds":[],"iconColor":"#31739C"}}
|
|
||||||
headers = {
|
|
||||||
'Content-Type': "application/json",
|
|
||||||
'Authorization': "1520b640-fa0f-4ed4-b972-7e0b75ecec40&103&"
|
|
||||||
}
|
|
||||||
# r = requests.post(url,data1,headers=headers)
|
|
||||||
result1 = requests.post(url=url, data=json.dumps(data), headers=headers).json()
|
|
||||||
res = json.dumps(result1, ensure_ascii=False, sort_keys=True, indent=2)
|
|
||||||
# a = result["data"]["objectList"][0]["objectId"]
|
|
||||||
|
|
||||||
return result1
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
# datas = {"url":['https://www.baidu.com'],
|
# datas = {"url":['https://www.baidu.com'],
|
||||||
@@ -322,3 +281,10 @@ if __name__ == '__main__':
|
|||||||
b = a.Jsoneditmanu(jsons,datas)
|
b = a.Jsoneditmanu(jsons,datas)
|
||||||
# print("替换前:\n %s" % jsons)
|
# print("替换前:\n %s" % jsons)
|
||||||
print("替换后:\n %s" % b)
|
print("替换后:\n %s" % b)
|
||||||
|
|
||||||
|
data = {"aid":[{'bid':2},{'cid':3}]}
|
||||||
|
print(type(data))
|
||||||
|
# data="""{}"""
|
||||||
|
# data1 = json.loads(data)
|
||||||
|
get_keys = get_dict_allkeys(data)
|
||||||
|
print(get_keys)
|
||||||
|
|||||||
Reference in New Issue
Block a user