-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.py
151 lines (128 loc) · 4.04 KB
/
test.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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
#!/usr/bin/python
import sys
import logHelper
import component
import logFile
import module
default_encoding = 'utf-8'
if sys.getdefaultencoding() != default_encoding:
reload(sys)
sys.setdefaultencoding(default_encoding)
try:
import web
except ImportError:
sys.path.append("/home/edrop/opt/python/lib/python2.4/site-packages")
import web
from web import form
urls = (
'/', 'index',
'/metaserver', 'log',
'/mas', 'log',
'/portal', 'log',
'/web', 'log',
'/test', 'log'
'/deploy', 'deploy'
)
render = web.template.render('templates/')
web.config.debug = True
config = web.storage(
email='aa.com',
site_name='V1.0',
site_desc='',
static='/static',
)
web.template.Template.globals['config'] = config
web.template.Template.globals['render'] = render
class index:
def GET(self):
global render
init()
f = genForm()
datas = []
return render.log(f, datas, urls)
def genComponets():
component.components=[]
component.components.append(component.keyFilter('userid'))
component.components.append(component.keyFilter('task'))
component.components.append(component.srcFilter())
def genModules():
module.modules=[]
module.modules.append(module.metaserver())
module.modules.append(module.mas())
module.modules.append(module.test())
for module1 in module.modules:
module.moduleDict[module1.name] = module1
def genForm():
log_form = form.Form()
inputs = []
for component1 in component.components:
inputs.append(component1.layout())
inputs.append(form.Button("submit", type="submit", description="search"))
log_form.inputs = inputs
return log_form
def parseInput(stor):
for component1 in component.components:
value = stor.get(component1.key)
print component1.key, value
if value != '':
component1.data = value
def init():
genComponets()
genModules()
class log:
def GET(self):
global render
f = genForm()
datas = []
return render.log(f, datas, urls)
def POST(self):
global render
f = genForm()
stor = web.input(src='all', userid='', trace='')
print stor
filters = []
parseInput(stor)
if stor.trace != '':
logItem = logHelper.parseLogItem(stor.trace)
modules1 = module.findRelationModules(logItem.server)
datas = []
before = True
for module1 in modules1:
print logItem.server, module1.name
if logItem.server == module1.name:
datas.append(stor.trace.replace('<br>', '<br/>'))
before = False
continue
if before:
time = component.beforeTime(module1)
else:
time = component.afterTime(module1)
time.starTime = logItem.startTime
time.endTime = logItem.endTime
logs = logFile.getLogs(module1);
print logs[-1].name
components = []
components.append(time)
components.extend(component.components)
content = logHelper.findInLastlog(logs[-1].name, logItem.keyId, module1, components)
datas.extend(content.datas)
return render.log(f, datas, urls)
uri = web.ctx.env.get("REQUEST_URI")[1:]
module1 = None
if uri != '':
for oneModule in module.modules:
if oneModule.name == uri:
module1 = oneModule
if module1 != None and stor.userid != '':
logs = logFile.getLogs(module1);
print logs[-1].name
content = logHelper.findInLastlog(logs[-1].name, stor.userid, module1, component.components)
datas = content.datas
else:
datas = []
return render.log(f, datas, urls)
if __name__ == "__main__":
app = web.application(urls, globals())
init()
print 'http://127.0.0.1:8080/'
app.run()