Commit a4a746814d29f31724b58db2ab9f146e58de3dea

Authored by lixi
1 parent f8af1ae7

更新进门称重的方法

commons/MySession.py
@@ -111,7 +111,6 @@ class mysession(): @@ -111,7 +111,6 @@ class mysession():
111 co.set("UAP_firmId", str(self.re.json()["data"]["user"]["firmId"])) 111 co.set("UAP_firmId", str(self.re.json()["data"]["user"]["firmId"]))
112 co.set("UAP_accessToken", self.re.json()["data"]["accessToken"]) 112 co.set("UAP_accessToken", self.re.json()["data"]["accessToken"])
113 co.set("UAP_refreshToken", self.re.json()["data"]["refreshToken"]) 113 co.set("UAP_refreshToken", self.re.json()["data"]["refreshToken"])
114 - print(dir(co))  
115 self.se.cookies.update(co) 114 self.se.cookies.update(co)
116 # 返回session对象,供其他接口使用 115 # 返回session对象,供其他接口使用
117 return self.se 116 return self.se
commons/api/duplicateToken.py
@@ -2,8 +2,9 @@ @@ -2,8 +2,9 @@
2 # -*- coding: UTF-8 -*- 2 # -*- coding: UTF-8 -*-
3 import urllib3 3 import urllib3
4 from commons import common as com 4 from commons import common as com
5 -from commons.MySession import my,s1 5 +from commons.MySession import my,s1,s2
6 import requests 6 import requests
  7 +from requests.cookies import remove_cookie_by_name
7 8
8 urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning) 9 urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
9 10
@@ -20,18 +21,25 @@ class duplicateToken(): @@ -20,18 +21,25 @@ class duplicateToken():
20 def __init__(self): 21 def __init__(self):
21 self.url = duplicateToken.url.replace("http://test.", com.get_global_config("global_data", "environment", "en")) 22 self.url = duplicateToken.url.replace("http://test.", com.get_global_config("global_data", "environment", "en"))
22 self.header = duplicateToken.header 23 self.header = duplicateToken.header
23 - self.header["UAP_accessToken"] = s1.cookies["UAP_accessToken"]  
24 - self.header["UAP_refreshToken"] = s1.cookies["UAP_refreshToken"]  
25 - self.header["UAP_firmId"] = s1.cookies["UAP_firmId"] 24 + self.header["UAP_accessToken"] = s2.cookies["UAP_accessToken"]
  25 + self.header["UAP_refreshToken"] = s2.cookies["UAP_refreshToken"]
  26 + self.header["UAP_firmId"] = s2.cookies["UAP_firmId"]
26 self.header["Host"] = com.get_global_config("global_data", "host", "gateway") 27 self.header["Host"] = com.get_global_config("global_data", "host", "gateway")
27 28
28 def jmsf_duplicate_commit_token(self): 29 def jmsf_duplicate_commit_token(self):
29 - re = s1.get(url=self.url, headers=self.header) 30 + re = s2.get(url=self.url, headers=self.header)
  31 + print(s2.cookies)
  32 + print(s2.cookies.list_domains())
  33 + print(s2.cookies.list_paths())
  34 + # remove_cookie_by_name(s2.cookies,domain="",name="UAP_accessToken")
  35 + # remove_cookie_by_name(s2.cookies,domain="",name="UAP_refreshToken")
  36 + # print(s2.cookies)
30 return re.json()["data"] 37 return re.json()["data"]
31 38
32 39
33 # print(s1.headers) 40 # print(s1.headers)
34 -# du=duplicateToken() 41 +du=duplicateToken()
  42 +du.jmsf_duplicate_commit_token()
35 # print(du.jmsf_duplicate_commit_token()) 43 # print(du.jmsf_duplicate_commit_token())
36 # print(re.json()) 44 # print(re.json())
37 # print(re.headers) 45 # print(re.headers)
38 \ No newline at end of file 46 \ No newline at end of file