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

Side by Side Diff: third_party/buildbot_8_4p1/buildbot/status/web/status_json.py

Issue 392223002: Added logging to the status_json.py (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/build
Patch Set: Updated README.chromium Created 6 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « third_party/buildbot_8_4p1/README.chromium ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # This file is part of Buildbot. Buildbot is free software: you can 1 # This file is part of Buildbot. Buildbot is free software: you can
2 # redistribute it and/or modify it under the terms of the GNU General Public 2 # redistribute it and/or modify it under the terms of the GNU General Public
3 # License as published by the Free Software Foundation, version 2. 3 # License as published by the Free Software Foundation, version 2.
4 # 4 #
5 # This program is distributed in the hope that it will be useful, but WITHOUT 5 # This program is distributed in the hope that it will be useful, but WITHOUT
6 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 6 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
7 # FOR A PARTICULAR PURPOSE. See the GNU General Public License for more 7 # FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
8 # details. 8 # details.
9 # 9 #
10 # You should have received a copy of the GNU General Public License along with 10 # You should have received a copy of the GNU General Public License along with
11 # this program; if not, write to the Free Software Foundation, Inc., 51 11 # this program; if not, write to the Free Software Foundation, Inc., 51
12 # Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 12 # Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
13 # 13 #
14 # Portions Copyright Buildbot Team Members 14 # Portions Copyright Buildbot Team Members
15 # Original Copyright (c) 2010 The Chromium Authors. 15 # Original Copyright (c) 2010 The Chromium Authors.
16 16
17 """Simple JSON exporter.""" 17 """Simple JSON exporter."""
18 18
19 import collections 19 import collections
20 import datetime 20 import datetime
21 import os 21 import os
22 import re 22 import re
23 23
24 from twisted.internet import defer 24 from twisted.internet import defer
25 from twisted.python import log as twlog
25 from twisted.web import html, resource, server 26 from twisted.web import html, resource, server
26 27
27 from buildbot.status.web.base import HtmlResource 28 from buildbot.status.web.base import HtmlResource
28 from buildbot.util import json 29 from buildbot.util import json
29 30
30 31
31 _IS_INT = re.compile('^[-+]?\d+$') 32 _IS_INT = re.compile('^[-+]?\d+$')
32 33
33 34
34 FLAGS = """\ 35 FLAGS = """\
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
155 def RecurseFix(res, level): 156 def RecurseFix(res, level):
156 res.level = level + 1 157 res.level = level + 1
157 for c in res.children.itervalues(): 158 for c in res.children.itervalues():
158 RecurseFix(c, res.level) 159 RecurseFix(c, res.level)
159 160
160 RecurseFix(res, self.level) 161 RecurseFix(res, self.level)
161 resource.Resource.putChild(self, name, res) 162 resource.Resource.putChild(self, name, res)
162 163
163 def render_GET(self, request): 164 def render_GET(self, request):
164 """Renders a HTTP GET at the http request level.""" 165 """Renders a HTTP GET at the http request level."""
166 userAgent = request.requestHeaders.getRawHeaders(
167 'user-agent', ['unknown'])[0]
168 twlog.msg('Received request for %s from %s, id: %s' %
169 (request.uri, userAgent, id(request)))
165 d = defer.maybeDeferred(lambda : self.content(request)) 170 d = defer.maybeDeferred(lambda : self.content(request))
166 def handle(data): 171 def handle(data):
167 if isinstance(data, unicode): 172 if isinstance(data, unicode):
168 data = data.encode("utf-8") 173 data = data.encode("utf-8")
169 request.setHeader("Access-Control-Allow-Origin", "*") 174 request.setHeader("Access-Control-Allow-Origin", "*")
170 if RequestArgToBool(request, 'as_text', False): 175 if RequestArgToBool(request, 'as_text', False):
171 request.setHeader("content-type", 'text/plain') 176 request.setHeader("content-type", 'text/plain')
172 else: 177 else:
173 request.setHeader("content-type", self.contentType) 178 request.setHeader("content-type", self.contentType)
174 request.setHeader("content-disposition", 179 request.setHeader("content-disposition",
175 "attachment; filename=\"%s.json\"" % request.pat h) 180 "attachment; filename=\"%s.json\"" % request.pat h)
176 # Make sure we get fresh pages. 181 # Make sure we get fresh pages.
177 if self.cache_seconds: 182 if self.cache_seconds:
178 now = datetime.datetime.utcnow() 183 now = datetime.datetime.utcnow()
179 expires = now + datetime.timedelta(seconds=self.cache_seconds) 184 expires = now + datetime.timedelta(seconds=self.cache_seconds)
180 request.setHeader("Expires", 185 request.setHeader("Expires",
181 expires.strftime("%a, %d %b %Y %H:%M:%S GMT")) 186 expires.strftime("%a, %d %b %Y %H:%M:%S GMT"))
182 request.setHeader("Pragma", "no-cache") 187 request.setHeader("Pragma", "no-cache")
183 return data 188 return data
184 d.addCallback(handle) 189 d.addCallback(handle)
185 def ok(data): 190 def ok(data):
191 twlog.msg('Finished processing request with id: %s' % id(request))
186 request.write(data) 192 request.write(data)
187 request.finish() 193 request.finish()
188 def fail(f): 194 def fail(f):
189 request.processingFailed(f) 195 request.processingFailed(f)
190 return None # processingFailed will log this for us 196 return None # processingFailed will log this for us
191 d.addCallbacks(ok, fail) 197 d.addCallbacks(ok, fail)
192 return server.NOT_DONE_YET 198 return server.NOT_DONE_YET
193 199
194 @defer.deferredGenerator 200 @defer.deferredGenerator
195 def content(self, request): 201 def content(self, request):
(...skipping 563 matching lines...) Expand 10 before | Expand all | Expand 10 after
759 if not builder: 765 if not builder:
760 return 766 return
761 EXAMPLES = EXAMPLES.replace('<A_BUILDER>', builder.getName()) 767 EXAMPLES = EXAMPLES.replace('<A_BUILDER>', builder.getName())
762 build = builder.getBuild(-1) 768 build = builder.getBuild(-1)
763 if build: 769 if build:
764 EXAMPLES = EXAMPLES.replace('<A_BUILD>', str(build.getNumber())) 770 EXAMPLES = EXAMPLES.replace('<A_BUILD>', str(build.getNumber()))
765 if builder.slavenames: 771 if builder.slavenames:
766 EXAMPLES = EXAMPLES.replace('<A_SLAVE>', builder.slavenames[0]) 772 EXAMPLES = EXAMPLES.replace('<A_SLAVE>', builder.slavenames[0])
767 773
768 # vim: set ts=4 sts=4 sw=4 et: 774 # vim: set ts=4 sts=4 sw=4 et:
OLDNEW
« no previous file with comments | « third_party/buildbot_8_4p1/README.chromium ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698