Skip to content

Commit 59be3f5

Browse files
committed
修改文件上传:支持多种浏览器上传
修改日志类:修改无法根据config中级别输出日志 修改发送邮件:支持多个附件
1 parent c310b44 commit 59be3f5

17 files changed

+246
-133
lines changed

config/config.ini

Lines changed: 23 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -3,30 +3,30 @@
33
; Database configuration.
44
; Path of all layers.
55
; Email configuration.
6-
; Encrypt configuration.
6+
; Logging configuration.
77
;
88

99

1010
[db]
11-
; Required if you want to connect to database.
12-
; -args:
11+
; Required.AutoTestFramework Database.
12+
; -options:
1313
; driver : Database type.For now, support mysql and oracle.
1414
; host : Database IP.
1515
; port : Database port.
1616
; user : Connect user.
1717
; pwd : Password.
1818
; db_name : Database name.
19-
driver = oracle
20-
host = 192.168.7.226
21-
port = 1521
22-
user = zhigouceshi
23-
pwd = zhigouceshi
24-
db_name = ZHIGOU
19+
driver = mysql
20+
host = localhost
21+
port = 3306
22+
user = root
23+
pwd = 123456
24+
db_name = autotest
2525

2626

2727
[path]
2828
; Required.
29-
; -args:
29+
; -options:
3030
; base : Absolute path of the project. Required.
3131
; log : Path of logfiles. Not required. Default: %(base)s\log\.
3232
; report : Path of reports. Not required. Default: %(base)s\report\.
@@ -42,29 +42,28 @@ url_xml = %(data)s\zhigou.xml
4242

4343
[email]
4444
; Not required.If you want to send report email to somebody, you'll need to configure this.
45-
; -args:
45+
; -options:
4646
; server : Email server,for example: smtp.126.com.
4747
; from : Eamil which uses to send reports.
4848
; pass : Password of the from email.
4949
; to : Who will receive the reports.Use ';' to seperate a list of receivers.
50-
server = smtp.126.com
51-
from = womende218@126.com
52-
pass = kaixinzhima123?
50+
server = smtp.boce.cn
51+
from = zhangxin@boce.cn
52+
pass = ????
5353
to = 396214358@qq.com
5454

5555

56-
[encrypt]
57-
; Not required.If your project interface need to encrypt, then you need to give the private key and the salt.
58-
; -args:
59-
; priv_key: Private key of the interface.
60-
; pwd_key : Salt which encrypt all passwords of interface.
61-
priv_key = 84b0d211449da13fc9db1c1555e3ef00
62-
pwd_key = 5gN^zqGb#Szht&NYwv^p7b*Qq3Y$YF!3
63-
64-
6556
[logging]
57+
; Required.
58+
; -options:
59+
; backup_count : log files count to keep.
60+
; console_output_level
61+
; file_output_level
62+
; log_file_name
63+
; console_output : output log if set 1, else not.
64+
; file_output : output log if set 1, else not.
6665
backup_count = 10
67-
console_output_level = ERROR
66+
console_output_level = WARNING
6867
file_output_level = DEBUG
6968
log_file_name = test.log
7069
console_output = 1

config/config_zhigou.ini

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
; Project configuration.
2+
3+
[db]
4+
; Required if you want to connect to database.
5+
; -args:
6+
; driver : Database type.For now, support mysql and oracle.
7+
; host : Database IP.
8+
; port : Database port.
9+
; user : Connect user.
10+
; pwd : Password.
11+
; db_name : Database name.
12+
driver = oracle
13+
host = 192.168.7.226
14+
port = 1521
15+
user = zhigouceshi
16+
pwd = zhigouceshi
17+
db_name = ZHIGOU
18+
19+
20+
[encrypt]
21+
; Not required.If your project interface need to encrypt, then you need to give private key and salt.
22+
; -args:
23+
; priv_key: Private key of the interface.
24+
; pwd_key : Salt which encrypt all passwords of interface.
25+
private_key = 84b0d211449da13fc9db1c1555e3ef00
26+
salt = 5gN^zqGb#Szht&NYwv^p7b*Qq3Y$YF!3

config/log.conf

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
# Configuration for log output
2-
31
[loggers]
42
keys = root
53

@@ -11,15 +9,24 @@ keys = simpleFmt
119

1210
[logger_root]
1311
level = DEBUG
14-
handlers = consoleHandler
15-
# handlers = fileHandler
12+
handlers = consoleHandler,fileHandler
1613

1714
[handler_consoleHandler]
1815
class = StreamHandler
1916
level = DEBUG
2017
formatter = simpleFmt
2118
args = (sys.stdout,)
2219

20+
[handler_fileHandler]
21+
class = handlers.TimedRotatingFileHandler
22+
level = ERROR
23+
formatter = simpleFmt
24+
args = ('test.log', 'D', 1, 10)
25+
2326
[formatter_simpleFmt]
24-
format = %(asctime)s - %(name)s - %(levelname)s - %(message)s - [%(filename)s:%(lineno)s]
25-
datefmt = %Y-%m-%d %H:%M:%S
27+
format = %(asctime)s - %(name)s - %(levelname)s - %(message)s
28+
datefmt = %Y-%m-%d %H:%M:%S
29+
30+
31+
32+

src/others/filesupload.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
time.sleep(1)
1515

1616
# win32gui
17-
dialog = win32gui.FindWindow('#32770', None)
17+
dialog = win32gui.FindWindow('#32770', u'文件上传')
1818
ComboBoxEx32 = win32gui.FindWindowEx(dialog, 0, 'ComboBoxEx32', None)
1919
ComboBox = win32gui.FindWindowEx(ComboBoxEx32, 0, 'ComboBox', None)
2020
Edit = win32gui.FindWindowEx(ComboBox, 0, 'Edit', None)
@@ -23,6 +23,9 @@
2323
win32gui.SendMessage(Edit, win32con.WM_SETTEXT, 0, '"d:\\baidu.py" "d:\\upload.py" "d:\\1.html"')
2424
win32gui.SendMessage(dialog, win32con.WM_COMMAND, 1, button)
2525

26+
print dialog
27+
print Edit
28+
print button
2629

2730
print dr.find_element_by_id('status_info').text
2831
dr.quit()

src/others/trylogging.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# -*- coding: utf-8 -*-
2+
3+
import logging
4+
import logging.config
5+
from src.utils.config import DefaultConfig
6+
7+
# log_path = DefaultConfig().base_path + '\config\log.conf'
8+
# print log_path
9+
# logging.config.fileConfig(log_path)
10+
11+
# logging.basicConfig(level=logging.NOTSET)
12+
log = logging.getLogger('s')
13+
logging.root.setLevel(logging.NOTSET)
14+
15+
console = logging.StreamHandler()
16+
console.setLevel(logging.INFO)
17+
console.setFormatter(logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s'))
18+
19+
log.addHandler(console)
20+
print log.getEffectiveLevel()
21+
22+
# log.debug('debug message')
23+
log.info('info message')
24+
# log.error('error message')
25+
# log.critical('critical message')
26+
27+
print log.handlers
28+
print logging.root.handlers

src/resource/__init__.py

Whitespace-only changes.

src/resource/upfile_autoit_chrome.exe

839 KB
Binary file not shown.

src/resource/upfile_autoit_ie.exe

839 KB
Binary file not shown.

src/utils/config.py

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,6 @@
2424
from src.utils.utils_exception import ConfigFileException, ConfigError
2525

2626

27-
# todo(396214358@qq.com): log when log module finished.
28-
29-
3027
# 获取当前文件绝对路径,从而获得config层路径
3128
UTILS_PATH = os.path.split(os.path.realpath(__file__))[0]
3229
CONFIG_PATH = UTILS_PATH + '\\..\\..\\config\\' # config层
@@ -41,20 +38,6 @@ def __init__(self, filename='config.ini'):
4138
else:
4239
raise ConfigFileException('Config file not exists or not available.Please check {}.'.format(self.path))
4340

44-
45-
class DefaultConfig(Config):
46-
"""
47-
-properties:
48-
db_connect : Return database string which can use to connect to database.
49-
base_path : Return [path].base value.
50-
log_path : Return [path].log value or default log path.
51-
report_path : Return [path].report value or default report path.
52-
data_path : Return [path].data value or default data path.
53-
driver_path : Return default driver path.
54-
"""
55-
def __init__(self):
56-
Config.__init__(self)
57-
5841
def _mysql_connect(self):
5942
"""Get sqlalchemy database connection string."""
6043
return 'mysql+{0}://{1}:{2}@{3}:{4}/{5}?charset=utf8'.format(
@@ -88,6 +71,20 @@ def db_connect(self):
8871
raise ConfigError('[db] section is required. And [db] section must have these options:'
8972
'"driver", "user", "pwd", "host", "port", "db_name"')
9073

74+
75+
class DefaultConfig(Config):
76+
"""
77+
-properties:
78+
db_connect : Return database string which can use to connect to database.
79+
base_path : Return [path].base value.
80+
log_path : Return [path].log value or default log path.
81+
report_path : Return [path].report value or default report path.
82+
data_path : Return [path].data value or default data path.
83+
driver_path : Return default driver path.
84+
"""
85+
def __init__(self):
86+
Config.__init__(self)
87+
9188
@property
9289
def base_path(self):
9390
try:

0 commit comments

Comments
 (0)