Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(173)

Side by Side Diff: command_wrapper/command_wrapper_web.py

Issue 3036026: Adding a retry and logging utility + appengine backend.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/tools/
Patch Set: '' Created 10 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « command_wrapper/bin/command_wrapper.py ('k') | command_wrapper/index.yaml » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Property Changes:
Added: svn:eol
+ LF
OLDNEW
(Empty)
1 # Copyright (c) 2010 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file.
4
5 import os
6 from google.appengine.api import users
7 from google.appengine.ext import db
8 from google.appengine.ext import webapp
9 from google.appengine.ext.webapp import template
10 from google.appengine.ext.webapp.util import run_wsgi_app
11
12
13 class CommandInvocation(db.Model):
14 command_id = db.StringProperty()
15 remote_addr = db.StringProperty()
16 attempt = db.IntegerProperty()
17 retries = db.IntegerProperty()
18 cwd = db.StringProperty()
19 command = db.StringProperty()
20 returncode = db.IntegerProperty()
21 stdout = db.StringProperty(multiline=True)
22 stderr = db.StringProperty(multiline=True)
23 runtime = db.FloatProperty()
24 timestamp = db.DateTimeProperty(auto_now_add=True)
25 uname_sysname = db.StringProperty()
26 uname_nodename = db.StringProperty()
27 uname_release = db.StringProperty()
28 uname_version = db.StringProperty()
29 uname_machine = db.StringProperty()
30 uname_machine = db.StringProperty()
31
32
33 class LogHandler(webapp.RequestHandler):
34 """Handle requests to log events."""
35
36 def post(self):
37 ci = CommandInvocation()
38 ci.remote_addr = self.request.remote_addr
39 ci.command_id = str(self.request.get('command_id'))
40 ci.attempt = int(self.request.get('attempt'))
41 ci.retries = int(self.request.get('retries'))
42 ci.cwd = str(self.request.get('cwd'))
43 ci.command = str(self.request.get('command'))
44 ci.returncode = int(self.request.get('returncode'))
45 ci.stdout = str(self.request.get('stdout'))
46 ci.stderr = str(self.request.get('stderr'))
47 ci.runtime = float(self.request.get('runtime'))
48 ci.uname_sysname = str(self.request.get('uname_sysname'))
49 ci.uname_nodename = str(self.request.get('uname_nodename'))
50 ci.uname_release = str(self.request.get('uname_release'))
51 ci.uname_version = str(self.request.get('uname_version'))
52 ci.uname_machine = str(self.request.get('uname_machine'))
53 ci.put()
54
55
56 class ViewerHandler(webapp.RequestHandler):
57 """View log info."""
58
59 def get(self):
60 user = users.get_current_user()
61 if not user:
62 uri = self.request.uri
63 if uri.startswith('http:'):
64 uri = 'https:' + uri[5:]
65 self.redirect(users.create_login_url(uri))
66 return
67 # Only allow @google.com folks to look.
68 if not user.email().endswith('@google.com'):
69 return
70 items = db.GqlQuery('SELECT * FROM CommandInvocation '
71 'ORDER BY timestamp DESC LIMIT 100')
72 template_values = {
73 'items': items,
74 }
75 path = os.path.join(os.path.dirname(__file__), 'viewer.html')
76 self.response.out.write(template.render(path, template_values))
77
78
79 APPLICATION = webapp.WSGIApplication([
80 ('/log', LogHandler),
81 ('/', ViewerHandler),
82 ], debug=False)
83
84
85 def main():
86 run_wsgi_app(APPLICATION)
87
88
89 if __name__ == '__main__':
90 main()
OLDNEW
« no previous file with comments | « command_wrapper/bin/command_wrapper.py ('k') | command_wrapper/index.yaml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698