Commit 9d230e7d407f53124df8fb93793374f0e1174261

Authored by lixi
1 parent 4242e002

更新进门称重的方法

commons/ConfigDB.py
@@ -2,11 +2,9 @@ @@ -2,11 +2,9 @@
2 # -*- coding: UTF-8 -*- 2 # -*- coding: UTF-8 -*-
3 import pymysql 3 import pymysql
4 import time 4 import time
5 -import commons.common as ca  
6 import json 5 import json
7 -from commons.Logging import Logger  
8 -# import chardet  
9 -log=Logger() 6 +import commons.common as ca
  7 +from commons.Logging import log
10 8
11 9
12 dbhost=ca.get_global_config('global_data','Database','dbhost') 10 dbhost=ca.get_global_config('global_data','Database','dbhost')
commons/Logging.py
@@ -55,3 +55,6 @@ class Logger(): @@ -55,3 +55,6 @@ class Logger():
55 def critical(self,message): 55 def critical(self,message):
56 56
57 self.logger.critical(message) 57 self.logger.critical(message)
  58 +
  59 +
  60 +log=Logger()
58 \ No newline at end of file 61 \ No newline at end of file
commons/MySession.py
@@ -2,10 +2,10 @@ @@ -2,10 +2,10 @@
2 # -*- coding: UTF-8 -*- 2 # -*- coding: UTF-8 -*-
3 import requests 3 import requests
4 from commons import common as com 4 from commons import common as com
5 -from commons.Logging import Logger 5 +from commons.Logging import log
6 from commons.clientSession import cliSession 6 from commons.clientSession import cliSession
7 from commons.scripts.pwdCry import pwdCry 7 from commons.scripts.pwdCry import pwdCry
8 -log=Logger() 8 +
9 9
10 class mysession(requests.Session): 10 class mysession(requests.Session):
11 "封装了requests的基类,以供后期统一使用" 11 "封装了requests的基类,以供后期统一使用"
@@ -127,7 +127,7 @@ class mysession(requests.Session): @@ -127,7 +127,7 @@ class mysession(requests.Session):
127 com.get_global_config("global_data", "account", account).split("&")[0]) 127 com.get_global_config("global_data", "account", account).split("&")[0])
128 self.body = self.body.replace("111111", com.get_global_config("global_data", "account", account).split("&")[1]) 128 self.body = self.body.replace("111111", com.get_global_config("global_data", "account", account).split("&")[1])
129 # POST请求, 129 # POST请求,
130 - re = self.se.post(url=self.url, headers=self.header, data=self.body, proxies=self.proxies, 130 + re = super().post(url=self.url, headers=self.header, data=self.body,
131 allow_redirects=False, **kwargs) 131 allow_redirects=False, **kwargs)
132 # 判断请求 132 # 判断请求
133 assert "UAP_accessToken" in re.headers["Set-Cookie"] 133 assert "UAP_accessToken" in re.headers["Set-Cookie"]
@@ -178,9 +178,6 @@ class mysession(requests.Session): @@ -178,9 +178,6 @@ class mysession(requests.Session):
178 :param \*\*kwargs: Optional arguments that ``request`` takes. 178 :param \*\*kwargs: Optional arguments that ``request`` takes.
179 :rtype: requests.Response 179 :rtype: requests.Response
180 """ 180 """
181 - # 记录日志  
182 - log.info("{0:=^86}".format(''))  
183 - log.info("{}\n{}\n".format(url, kwargs))  
184 # 进行请求 181 # 进行请求
185 re = super().get(url, **kwargs) 182 re = super().get(url, **kwargs)
186 return re 183 return re
@@ -194,9 +191,6 @@ class mysession(requests.Session): @@ -194,9 +191,6 @@ class mysession(requests.Session):
194 :param \*\*kwargs: Optional arguments that ``request`` takes. 191 :param \*\*kwargs: Optional arguments that ``request`` takes.
195 :rtype: requests.Response 192 :rtype: requests.Response
196 """ 193 """
197 - # 记录日志  
198 - log.info("{0:=^86}".format(''))  
199 - log.info("{}\n{}\n{}\n{}".format(url, data, json, kwargs))  
200 # 进行请求 194 # 进行请求
201 re = super().post(url, data=data, json=json, **kwargs) 195 re = super().post(url, data=data, json=json, **kwargs)
202 return re 196 return re
commons/SendEmail.py
@@ -7,8 +7,7 @@ from email.header import Header @@ -7,8 +7,7 @@ from email.header import Header
7 from email.mime.text import MIMEText 7 from email.mime.text import MIMEText
8 from email.mime.image import MIMEImage 8 from email.mime.image import MIMEImage
9 from email.mime.application import MIMEApplication 9 from email.mime.application import MIMEApplication
10 -from commons.Logging import Logger  
11 -log=Logger() 10 +from commons.Logging import log
12 11
13 def send_email_text(): 12 def send_email_text():
14 # 1. 编写邮件内容(Email邮件需要专门的MIME格式) 13 # 1. 编写邮件内容(Email邮件需要专门的MIME格式)
commons/common.py
@@ -4,8 +4,7 @@ import os @@ -4,8 +4,7 @@ import os
4 import configparser 4 import configparser
5 import unittest 5 import unittest
6 from discover import DiscoveringTestLoader 6 from discover import DiscoveringTestLoader
7 -from commons.Logging import Logger  
8 -log=Logger() 7 +from commons.Logging import log
9 8
10 9
11 def get_global_config(file,section, key): 10 def get_global_config(file,section, key):
testcase/weightBizBill/test_weighingServiceSave.py
@@ -23,7 +23,7 @@ class test_weighingServiceSave(unittest.TestCase): @@ -23,7 +23,7 @@ class test_weighingServiceSave(unittest.TestCase):
23 def setUp(self) : 23 def setUp(self) :
24 pass 24 pass
25 25
26 - @com.mylog 26 + # @com.mylog
27 @unittest.case_mark(my.mark()) 27 @unittest.case_mark(my.mark())
28 def test_weighingServiceSave_01(self): 28 def test_weighingServiceSave_01(self):
29 "称重服务:成功新增一条称重服务单" 29 "称重服务:成功新增一条称重服务单"