-
Notifications
You must be signed in to change notification settings - Fork 1
/
run.py
65 lines (56 loc) · 1.3 KB
/
run.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#coding=utf-8
'''
需要安装的软件:
1. mysql
2. pip
需要安装的python插件
1. PyMySQL
2. beautifulsoup4
3. html5lib
4. lxml
5. pycrypto
'''
'''
#运行
1. 修改Config.sample.py
2. 执行python run.py
'''
from src.utils import Log
import sys, os
#清空数据库中的表
def dropAllTables():
from src.db import Db
Db.instance.executeSql('''show tables;''');
ret = Db.instance.fetchAll();
for item in ret:
for k, v in item.items():
Db.instance.executeSql('''drop table if exists {};'''.format(v));
Log.D("droping table " + str(v));
Log.D("droped all tables finished");
def test():
Log.D("--test--");
dropAllTables();
sys.exit(0)
# 将Config.sample.py复制出一个Config.py文件
def createConfigFile():
if not os.path.exists("Config.py"):
fd = open("Config.sample.py", "r");
content = fd.read();
fd.close();
wfd = open("Config.py", "w");
wfd.write(content);
wfd.flush();
wfd.close();
if __name__ == '__main__':
createConfigFile();
# test();
try:
from src.Prepare import Prepare
Prepare();
except Exception, e:
Log.E("--------异常退出--------");
Log.Exc(e);
Log.V(Log.traceback());
sys.exit(0);
else:
Log.E("-错误")