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

Unified 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, 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « command_wrapper/bin/command_wrapper.py ('k') | command_wrapper/index.yaml » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: command_wrapper/command_wrapper_web.py
===================================================================
--- command_wrapper/command_wrapper_web.py (revision 0)
+++ command_wrapper/command_wrapper_web.py (revision 0)
@@ -0,0 +1,90 @@
+# Copyright (c) 2010 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+import os
+from google.appengine.api import users
+from google.appengine.ext import db
+from google.appengine.ext import webapp
+from google.appengine.ext.webapp import template
+from google.appengine.ext.webapp.util import run_wsgi_app
+
+
+class CommandInvocation(db.Model):
+ command_id = db.StringProperty()
+ remote_addr = db.StringProperty()
+ attempt = db.IntegerProperty()
+ retries = db.IntegerProperty()
+ cwd = db.StringProperty()
+ command = db.StringProperty()
+ returncode = db.IntegerProperty()
+ stdout = db.StringProperty(multiline=True)
+ stderr = db.StringProperty(multiline=True)
+ runtime = db.FloatProperty()
+ timestamp = db.DateTimeProperty(auto_now_add=True)
+ uname_sysname = db.StringProperty()
+ uname_nodename = db.StringProperty()
+ uname_release = db.StringProperty()
+ uname_version = db.StringProperty()
+ uname_machine = db.StringProperty()
+ uname_machine = db.StringProperty()
+
+
+class LogHandler(webapp.RequestHandler):
+ """Handle requests to log events."""
+
+ def post(self):
+ ci = CommandInvocation()
+ ci.remote_addr = self.request.remote_addr
+ ci.command_id = str(self.request.get('command_id'))
+ ci.attempt = int(self.request.get('attempt'))
+ ci.retries = int(self.request.get('retries'))
+ ci.cwd = str(self.request.get('cwd'))
+ ci.command = str(self.request.get('command'))
+ ci.returncode = int(self.request.get('returncode'))
+ ci.stdout = str(self.request.get('stdout'))
+ ci.stderr = str(self.request.get('stderr'))
+ ci.runtime = float(self.request.get('runtime'))
+ ci.uname_sysname = str(self.request.get('uname_sysname'))
+ ci.uname_nodename = str(self.request.get('uname_nodename'))
+ ci.uname_release = str(self.request.get('uname_release'))
+ ci.uname_version = str(self.request.get('uname_version'))
+ ci.uname_machine = str(self.request.get('uname_machine'))
+ ci.put()
+
+
+class ViewerHandler(webapp.RequestHandler):
+ """View log info."""
+
+ def get(self):
+ user = users.get_current_user()
+ if not user:
+ uri = self.request.uri
+ if uri.startswith('http:'):
+ uri = 'https:' + uri[5:]
+ self.redirect(users.create_login_url(uri))
+ return
+ # Only allow @google.com folks to look.
+ if not user.email().endswith('@google.com'):
+ return
+ items = db.GqlQuery('SELECT * FROM CommandInvocation '
+ 'ORDER BY timestamp DESC LIMIT 100')
+ template_values = {
+ 'items': items,
+ }
+ path = os.path.join(os.path.dirname(__file__), 'viewer.html')
+ self.response.out.write(template.render(path, template_values))
+
+
+APPLICATION = webapp.WSGIApplication([
+ ('/log', LogHandler),
+ ('/', ViewerHandler),
+], debug=False)
+
+
+def main():
+ run_wsgi_app(APPLICATION)
+
+
+if __name__ == '__main__':
+ main()
Property changes on: command_wrapper/command_wrapper_web.py
___________________________________________________________________
Added: svn:eol
+ LF
« 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