CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
webApp.py
Go to the documentation of this file.
1 import os
2 import cherrypy
3 import web_results_display
4 import service
5 
6 sessionsDirectory = os.path.join(service.settings['rootDirectory'], 'sessions')
7 
8 class Server:
9 
10  def ShowTable(self, curs, label):
11  res1 = web_results_display.GetRunResults(curs[0])
12  # only
13  for rows in res1:
14  res2, stCount = web_results_display.GetResultsList(rows[0])
15  break
16  #print stCount
17  Code ="""
18  <table id="header" bgcolor="#D8D8D8">
19  <tr>
20  <td colspan = "2">Test Sequence:
21  <b>"""+str(curs[2])+"""</b>&nbsp&nbsp&nbsp&nbsp
22  RunID:
23  """+str(curs[0])+"""&nbsp&nbsp&nbsp&nbsp
24  Time:
25  """+str(curs[1])+"""
26  </td>
27  <tr>
28  <td>
29  Candidate:
30  <b>"""+str(curs[3])+"""</b>&nbsp&nbsp&nbsp&nbsp
31  Architecture:
32  <b>"""+str(curs[4])+"""</b>
33  </td>
34  <td class="links"><a href="showLogs?runID="""+str(curs[0])+"""&label="""+label+"""">&gt&gt Logfile</a></td>
35  </tr>
36  </table>
37  <table id="status">
38  """
39  Code +="""
40  <tr>
41  <!--<th rowspan="2" colspan = "2">Reference releases</th>-->
42  <th>Reference release</th>
43  <th>Reference architecture</th>
44 
45  """
46  for i in range (0, stCount):
47  Code += """<th>"""+str(res2[i][2])+"""</th>
48  """
49  Code +="""</tr>"""
50  for rows in res1:
51  res2, stCount = web_results_display.GetResultsList(rows[0])
52  Code += """<tr>
53  <td align="left" >"""+str(rows[1])+"""</td>
54  <td>"""+str(rows[2])+"""</td>
55  """
56  for i in range (0, stCount):
57  if(res2[i][1] == 0):
58  Code +="""<td align="center" bgcolor ="#A7C942"><b>OK</b></td>
59  """
60  else:
61  Code +="""<td align="center" bgcolor ="#FF0000"><b>Failure</b></td>
62  """
63  Code += """</tr></tr>
64  """
65  Code += """</table><hr>
66  """
67  Code += """
68  </body>
69  </html>
70  """
71  return Code
72  def index(self, **args):
73  print "Arguments :"
74  print args
75  selectRel = False
76  if 'reset' in args.keys():
77  cherrypy.session.clear()
78  it = 0
79  for row in web_results_display.GetLabels():
80  if not 'label' in cherrypy.session.keys():
81  cherrypy.session['label'] = row[0]
82  break
83  if 'submit' in args.keys():
84  cherrypy.session['submit'] = args['submit']
85  cherrypy.session['label'] = args['label']
86  if 'release' in args.keys() and args['release'] != '':
87  cherrypy.session['release'] = args['release']
88  if 'release' in cherrypy.session.keys() and args['release'] != cherrypy.session['release']:
89  cherrypy.session['release'] = args['release']
90  if 'arch' in args.keys() and args['arch'] != '':
91  cherrypy.session['arch'] = args['arch']
92  if 'arch' in cherrypy.session.keys() and args['arch'] != cherrypy.session['arch']:
93  cherrypy.session['arch'] = args['arch']
94  if 'count' in args.keys() and args['count'].isdigit():
95  cherrypy.session['count'] = args['count']
96  print "Session :"
97  print cherrypy.session
98  if 'arch' in cherrypy.session.keys() and cherrypy.session['arch'] != '' or 'release' in cherrypy.session.keys() and cherrypy.session['release'] != '':
99  selectRel = True
100  if 'count' in cherrypy.session.keys() and cherrypy.session['count'].isdigit():
101  stCount = int(cherrypy.session['count'])
102  else:
103  stCount = 2;
104 
105  htmlCode = """
106  <html>
107  <META HTTP-EQUIV="REFRESH" CONTENT="60">
108  <head>
109  <style type="text/css">
110  button,
111  input,
112  select,
113  textarea {
114  font-size: 100%;
115  margin: 0;
116  vertical-align: baseline;
117  *vertical-align: middle;
118  }
119  button, input {
120  line-height: normal;
121  *overflow: visible;
122  }
123  button::-moz-focus-inner, input::-moz-focus-inner {
124  border: 0;
125  padding: 0;
126  }
127  select {
128  }
129  button,
130  input[type="submit"] {
131  cursor: pointer;
132  -webkit-appearance: button;
133  }
134  input[type="search"] {
135  -webkit-appearance: textfield;
136  -webkit-box-sizing: content-box;
137  -moz-box-sizing: content-box;
138  box-sizing: content-box;
139  }
140  a {
141  color: #bfbfbf;
142  text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.25);
143  text-decoration:none;
144  }
145  a:hover, .active a {
146  color: #ffffff;
147  text-decoration: none;
148  }
149  .links {
150  background-color: #222;
151  background-color: #222222;
152  background-repeat: repeat-x;
153  background-image: -khtml-gradient(linear, left top, left bottom, from(#333333), to(#222222));
154  background-image: -moz-linear-gradient(top, #333333, #222222);
155  background-image: -ms-linear-gradient(top, #333333, #222222);
156  background-image: -webkit-gradient(linear, left top, left bottom, color-stop(0%, #333333), color-stop(100%, #222222));
157  background-image: -webkit-linear-gradient(top, #333333, #222222);
158  background-image: -o-linear-gradient(top, #333333, #222222);
159  background-image: linear-gradient(top, #333333, #222222);
160  filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#333333', endColorstr='#222222', GradientType=0);
161  -webkit-box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25), inset 0 -1px 0 rgba(0, 0, 0, 0.1);
162  -moz-box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25), inset 0 -1px 0 rgba(0, 0, 0, 0.1);
163  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25), inset 0 -1px 0 rgba(0, 0, 0, 0.1);
164  }
165  #status, #header
166  {
167  font-family:"Trebuchet MS", Arial, Helvetica, sans-serif;
168  width:100%;
169  border-collapse:collapse;
170  }
171  #header td
172  {
173  font-size:1em;
174  border:1px solid #67645B;
175  padding:3px 7px 2px 7px;
176  text-align:left;
177  }
178  #status td
179  {
180  font-size:1em;
181  border:1px solid #67645B;
182  padding:3px 7px 2px 7px;
183  }
184  #status th
185  {
186  border:1px solid #67645B;
187  font-size:1.1em;
188  text-align:center;
189  padding-top:5px;
190  padding-bottom:4px;
191  background-color:#ECAE12;
192  color:#ffffff;
193  }
194  #controls
195  {
196  font-family:"Trebuchet MS", Arial, Helvetica, sans-serif;
197  width:100%;
198  border-collapse:collapse;
199  }
200  #controls td
201  {
202  font-size:1.1em;
203  border:none;
204  padding-top:5px;
205  padding-bottom:4px;
206  text-align:left;
207  background-color:#393333;
208  color:#ffffff;
209 
210  }
211  .topbar {
212  height: 40px;
213  position: fixed;
214  top: 0;
215  left: 0;
216  right: 0;
217  z-index: 10000;
218  overflow: visible;
219  color: #ffffff;
220  width: 100%;
221  }
222  .topbar form {
223  float: left;
224  margin: 5px 0 0 0;
225  position: relative;
226  filter: alpha(opacity=100);
227  -khtml-opacity: 1;
228  -moz-opacity: 1;
229  opacity: 1;
230  }
231  .topbar input {
232  background-color: #444;
233  background-color: rgba(255, 255, 255, 0.3);
234  font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
235  font-size: 80%;
236  font-weight: 13px;
237  line-height: 1;
238  padding: 4px 9px;
239  color: #fff;
240  color: rgba(255, 255, 255, 0.75);
241  border: 1px solid #111;
242  -webkit-border-radius: 4px;
243  -moz-border-radius: 4px;
244  border-radius: 4px;
245  -webkit-box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.1), 0 1px 0px rgba(255, 255, 255, 0.25);
246  -moz-box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.1), 0 1px 0px rgba(255, 255, 255, 0.25);
247  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.1), 0 1px 0px rgba(255, 255, 255, 0.25);
248  -webkit-transition: none;
249  -moz-transition: none;
250  transition: none;
251  }
252  .topbar input:-moz-placeholder {
253  color: #e6e6e6;
254  }
255  .topbar input::-webkit-input-placeholder {
256  color: #e6e6e6;
257  }
258  .topbar input:hover {
259  background-color: #bfbfbf;
260  background-color: rgba(255, 255, 255, 0.5);
261  color: #fff;
262  }
263  .topbar input:focus, .topbar input.focused {
264  outline: none;
265  background-color: #fff;
266  color: #404040;
267  text-shadow: 0 1px 0 #fff;
268  border: 0;
269  padding: 5px 10px;
270  -webkit-box-shadow: 0 0 3px rgba(0, 0, 0, 0.15);
271  -moz-box-shadow: 0 0 3px rgba(0, 0, 0, 0.15);
272  box-shadow: 0 0 3px rgba(0, 0, 0, 0.15);
273  }
274  .topbar-inner, .topbar .fill {
275  background-color: #222;
276  background-color: #222222;
277  background-repeat: repeat-x;
278  background-image: -khtml-gradient(linear, left top, left bottom, from(#333333), to(#222222));
279  background-image: -moz-linear-gradient(top, #333333, #222222);
280  background-image: -ms-linear-gradient(top, #333333, #222222);
281  background-image: -webkit-gradient(linear, left top, left bottom, color-stop(0%, #333333), color-stop(100%, #222222));
282  background-image: -webkit-linear-gradient(top, #333333, #222222);
283  background-image: -o-linear-gradient(top, #333333, #222222);
284  background-image: linear-gradient(top, #333333, #222222);
285  filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#333333', endColorstr='#222222', GradientType=0);
286  -webkit-box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25), inset 0 -1px 0 rgba(0, 0, 0, 0.1);
287  -moz-box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25), inset 0 -1px 0 rgba(0, 0, 0, 0.1);
288  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25), inset 0 -1px 0 rgba(0, 0, 0, 0.1);
289  }
290  .buts {
291  float: right;
292  }
293  </style>
294  </head>
295  <body>
296  <form method="post" action="index" >
297  <div class="topbar">
298  <div class="fill">
299  <div class="container">
300  <select name = "label">"""
302  for row in curs:
303  if str(row[0]) == cherrypy.session['label']:
304  htmlCode += """<option value = """+str(row[0])+""" selected = "selected">"""+str(row[0])+"""</option>
305  """
306  else:
307  htmlCode += """<option value = """+str(row[0])+""">"""+str(row[0])+"""</option>
308  """
309  htmlCode+="""</select>
310  """
311  if 'release' in cherrypy.session.keys():
312  htmlCode += """Candidate Release:<input type="text" name="release" size="30" maxlength="50" value=\""""+str(cherrypy.session['release'])+""""\"/>
313  """
314  else:
315  htmlCode += """Candidate Release:<input type="text" name="release" size="30" maxlength="50"/>
316  """
317  if 'arch' in cherrypy.session.keys():
318  htmlCode += """Candidate Architecture:<input type="text" name="arch" size="15" maxlength="30" value=\""""+cherrypy.session['arch']+""""\"/>
319  """
320  else:
321  htmlCode += """Candidate Architecture:<input type="text" name="arch" size="15" maxlength="30" />
322  """
323  if 'count' in cherrypy.session.keys():
324  htmlCode += """Number of results:<input type="text" name="count" size="1" maxlength="4" value=\""""+cherrypy.session['count']+""""\"/>
325  """
326  else:
327  htmlCode += """Number of results:<input type="text" name="count" size="4" maxlength="4" />
328  """
329  htmlCode +="""<div class = "buts"><input type="submit" name="submit" value="Refresh"/>
330  <input type="submit" name="reset" value="Reset"/>
331  </div></div></div></div>
332  <br>
333  </form>
334  """
335  if(selectRel == True):
336  if 'arch' in cherrypy.session.keys() and 'release' in cherrypy.session.keys():
337  DBdata = web_results_display.GetReleasesHeaders(cherrypy.session['label'], cherrypy.session['release'], cherrypy.session['arch'])
338  elif 'release' in cherrypy.session.keys():
339  DBdata = web_results_display.GetReleasesHeaders(cherrypy.session['label'], cherrypy.session['release'])
340  elif 'arch' in cherrypy.session.keys():
341  DBdata = web_results_display.GetReleasesHeaders(cherrypy.session['label'], "", cherrypy.session['arch'])
342  counter =0
343  for data in DBdata:
344  counter += 1
345  if stCount != 0:
346  htmlCode += self.ShowTable( data, cherrypy.session['label'])
347  stCount = stCount -1
348  if (counter == 0):
349  htmlCode += """<h3> No entries found </h3>"""
350  else:
351  DBdata = web_results_display.GetResultHeaders(cherrypy.session['label'])
352  for data in DBdata:
353  if stCount != 0:
354  htmlCode += self.ShowTable(data, cherrypy.session['label'])
355  stCount = stCount -1
356  return htmlCode
357 
358  index.exposed = True
359  def showLogs(self, **args):
360  runID = int(args['runID'])
361  label = args['label']
362 
363  logInfo = "<html><head></head><body><pre>\n"
364  logInfo += web_results_display.GetReadLogStatus(label, runID)
365  logInfo += '\n</pre></body></html>'
366  return logInfo
367 
368  showLogs.exposed = True
369 
370 def main():
371  service.start(Server())
372 
373 
374 if __name__ == '__main__':
375  main()
376 
377 
def index
Definition: webApp.py:72
def ShowTable
Definition: webApp.py:10
def showLogs
Definition: webApp.py:359
perl if(1 lt scalar(@::datatypes))
Definition: edlooper.cc:31
def main
Definition: webApp.py:370