Commit 378243f167f94ad398af34bf4e345566c0d3f771

Authored by wenleiming
2 parents 0a5e141a 3c0853f3

Merge remote-tracking branch 'origin/master'

commons/MySession.py
@@ -108,9 +108,9 @@ class mysession(): @@ -108,9 +108,9 @@ class mysession():
108 self.re = self.se.post(url=self.url_client, headers=self.header_client, json=self.body_client, proxies=self.proxies, **kwargs) 108 self.re = self.se.post(url=self.url_client, headers=self.header_client, json=self.body_client, proxies=self.proxies, **kwargs)
109 #组装请求的cookie 109 #组装请求的cookie
110 co = requests.cookies.RequestsCookieJar() 110 co = requests.cookies.RequestsCookieJar()
111 - co.set("UAP_firmId", str(self.re.json()["data"]["user"]["firmId"]))  
112 - co.set("UAP_accessToken", self.re.json()["data"]["accessToken"])  
113 - co.set("UAP_refreshToken", self.re.json()["data"]["refreshToken"]) 111 + co.set("UAP_firmId", str(self.re.json()["data"]["user"]["firmId"]),domain=".diligrp.com")
  112 + co.set("UAP_accessToken", self.re.json()["data"]["accessToken"],domain=".diligrp.com")
  113 + co.set("UAP_refreshToken", self.re.json()["data"]["refreshToken"],domain=".diligrp.com")
114 self.se.cookies.update(co) 114 self.se.cookies.update(co)
115 # 返回session对象,供其他接口使用 115 # 返回session对象,供其他接口使用
116 return self.se 116 return self.se
@@ -282,12 +282,10 @@ class mysession(): @@ -282,12 +282,10 @@ class mysession():
282 my = mysession() 282 my = mysession()
283 my.set_mark() 283 my.set_mark()
284 my.cliLogin() 284 my.cliLogin()
285 -# s1 = my.get_session_client("sy_user01")  
286 -s1 = my.get_session("sy_user01")  
287 -s2 = my.get_session_client("sy_user01")  
288 -# s3 = my.get_session_client("sy_user03")  
289 -# s3= my.get_session_client("sg_user02")  
290 -# sg01=my.get_session_client("sg_user01")  
291 -# sg02=my.get_session_client("sg_user02")  
292 -# sy=my.get_session_client("sy_user01") 285 +sy1 = my.get_session_client("sy_user01")
  286 +sy2 = my.get_session_client("sy_user02")
  287 +# heb1 = my.get_session_client("heb_user01")
  288 +# gy1=my.get_session_client("gy_user01")
  289 +# sg1=my.get_session_client("sg_user01")
  290 +# hs1=my.get_session_client("hs_user01")
293 291
commons/api/duplicateToken.py
@@ -2,10 +2,7 @@ @@ -2,10 +2,7 @@
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,s2  
6 -import requests  
7 -from requests.cookies import remove_cookie_by_name  
8 - 5 +from commons.MySession import my,sy1,sy2
9 urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning) 6 urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
10 7
11 8
@@ -21,25 +18,16 @@ class duplicateToken(): @@ -21,25 +18,16 @@ class duplicateToken():
21 def __init__(self): 18 def __init__(self):
22 self.url = duplicateToken.url.replace("http://test.", com.get_global_config("global_data", "environment", "en")) 19 self.url = duplicateToken.url.replace("http://test.", com.get_global_config("global_data", "environment", "en"))
23 self.header = duplicateToken.header 20 self.header = duplicateToken.header
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"] 21 + self.header["UAP_accessToken"] = sy1.cookies["UAP_accessToken"]
  22 + self.header["UAP_refreshToken"] = sy1.cookies["UAP_refreshToken"]
  23 + self.header["UAP_firmId"] = sy1.cookies["UAP_firmId"]
27 self.header["Host"] = com.get_global_config("global_data", "host", "gateway") 24 self.header["Host"] = com.get_global_config("global_data", "host", "gateway")
28 25
29 def jmsf_duplicate_commit_token(self): 26 def jmsf_duplicate_commit_token(self):
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) 27 + re = sy1.get(url=self.url, headers=self.header,proxies=my.myproxies)
37 return re.json()["data"] 28 return re.json()["data"]
38 29
39 30
40 -# print(s1.headers)  
41 -du=duplicateToken()  
42 -du.jmsf_duplicate_commit_token() 31 +# du=duplicateToken()
  32 +# du.jmsf_duplicate_commit_token()
43 # print(du.jmsf_duplicate_commit_token()) 33 # print(du.jmsf_duplicate_commit_token())
44 -# print(re.json())  
45 -# print(re.headers)  
46 \ No newline at end of file 34 \ No newline at end of file
commons/api/weighingServiceSave.py
@@ -2,7 +2,7 @@ @@ -2,7 +2,7 @@
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,sy1,sy2
6 from commons.api.duplicateToken import duplicateToken 6 from commons.api.duplicateToken import duplicateToken
7 urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning) 7 urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
8 du=duplicateToken() 8 du=duplicateToken()
@@ -46,13 +46,13 @@ class weighingServiceSave(): @@ -46,13 +46,13 @@ class weighingServiceSave():
46 self.url = weighingServiceSave.url.replace("http://test.", com.get_global_config("global_data", "environment", "en")) 46 self.url = weighingServiceSave.url.replace("http://test.", com.get_global_config("global_data", "environment", "en"))
47 self.header = weighingServiceSave.header 47 self.header = weighingServiceSave.header
48 self.header["jmsf_duplicate_commit_token"] = du.jmsf_duplicate_commit_token() 48 self.header["jmsf_duplicate_commit_token"] = du.jmsf_duplicate_commit_token()
49 - self.header["UAP_accessToken"] = s1.cookies["UAP_accessToken"]  
50 - self.header["UAP_refreshToken"] = s1.cookies["UAP_refreshToken"]  
51 - self.header["UAP_firmId"] = s1.cookies["UAP_firmId"] 49 + self.header["UAP_accessToken"] = sy1.cookies["UAP_accessToken"]
  50 + self.header["UAP_refreshToken"] = sy1.cookies["UAP_refreshToken"]
  51 + self.header["UAP_firmId"] = sy1.cookies["UAP_firmId"]
52 self.header["Host"] = com.get_global_config("global_data", "host", "gateway") 52 self.header["Host"] = com.get_global_config("global_data", "host", "gateway")
53 53
54 54
55 55
56 # tt=weighingServiceSave() 56 # tt=weighingServiceSave()
57 -# re=s1.post(url=tt.url,headers=tt.header,json=tt.body,proxies=my.myproxies)  
58 -# print(re.json())  
59 \ No newline at end of file 57 \ No newline at end of file
  58 +# re=sy1.post(url=tt.url,headers=tt.header,json=tt.body,proxies=my.myproxies)
  59 +# # print(re.json())
60 \ No newline at end of file 60 \ No newline at end of file