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

Side by Side Diff: third_party/buildbot_8_4p1/README.chromium

Issue 13619004: Only calculate slave->build mapping once in json output. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/build
Patch Set: Rename to custom_data. Created 7 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 | « no previous file | third_party/buildbot_8_4p1/buildbot/status/web/status_json.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 URL: http://buildbot.net/trac 1 URL: http://buildbot.net/trac
2 Version: 0.8.4p1 2 Version: 0.8.4p1
3 License: GNU General Public License (GPL) Version 2 3 License: GNU General Public License (GPL) Version 2
4 4
5 This is a forked copy of buildbot v0.8.4p1. 5 This is a forked copy of buildbot v0.8.4p1.
6 6
7 Make hidden steps stay hidden even if not finished, add brDoStepIf 7 Make hidden steps stay hidden even if not finished, add brDoStepIf
8 to support buildrunner. 8 to support buildrunner.
9 9
10 10
(...skipping 2929 matching lines...) Expand 10 before | Expand all | Expand 10 after
2940 doStepIf = True 2940 doStepIf = True
2941 hideStepIf = False 2941 hideStepIf = False
2942 # like doStepIf, but evaluated at runtime if executing under runbuild.py 2942 # like doStepIf, but evaluated at runtime if executing under runbuild.py
2943 - # we also overload 'False' to signify this isn't a buildrunner step 2943 - # we also overload 'False' to signify this isn't a buildrunner step
2944 - brDoStepIf = False 2944 - brDoStepIf = False
2945 + # We use None to signify that a step is not a buildrunner step. 2945 + # We use None to signify that a step is not a buildrunner step.
2946 + brDoStepIf = None 2946 + brDoStepIf = None
2947 2947
2948 def __init__(self, **kwargs): 2948 def __init__(self, **kwargs):
2949 self.factory = (self.__class__, dict(kwargs)) 2949 self.factory = (self.__class__, dict(kwargs))
2950
2951
2952 diff --git a/third_party/buildbot_8_4p1/buildbot/status/web/status_json.py b/thi rd_party/buildbot_8_4p1/buildbot/status/web/status_json.py
2953 index b656563..e48542d 100644
2954 --- a/third_party/buildbot_8_4p1/buildbot/status/web/status_json.py
2955 +++ b/third_party/buildbot_8_4p1/buildbot/status/web/status_json.py
2956 @@ -16,6 +16,7 @@
2957
2958 """Simple JSON exporter."""
2959
2960 +import collections
2961 import datetime
2962 import os
2963 import re
2964 @@ -635,21 +636,38 @@ class SlaveJsonResource(JsonResource):
2965 self.builders.append(builderName)
2966 return self.builders
2967
2968 + def getSlaveBuildMap(self, buildcache, buildercache):
2969 + for builderName in self.getBuilders():
2970 + if builderName not in buildercache:
2971 + buildercache.add(builderName)
2972 + builder_status = self.status.getBuilder(builderName)
2973 + for i in range(1, builder_status.buildCacheSize - 1):
2974 + build_status = builder_status.getBuild(-i)
2975 + if not build_status or not build_status.isFinished():
2976 + # If not finished, it will appear in runningBuilds.
2977 + break
2978 + slave = buildcache[build_status.getSlavename()]
2979 + slave.setdefault(builderName, []).append(
2980 + build_status.getNumber())
2981 + return buildcache[self.name]
2982 +
2983 def asDict(self, request):
2984 + if not hasattr(request, 'custom_data'):
2985 + request.custom_data = {}
2986 + if 'buildcache' not in request.custom_data:
2987 + # buildcache is used to cache build information across multiple
2988 + # invocations of SlaveJsonResource. It should be set to an empty
2989 + # collections.defaultdict(dict).
2990 + request.custom_data['buildcache'] = collections.defaultdict(dict)
2991 +
2992 + # Tracks which builders have been stored in the buildcache.
2993 + request.custom_data['buildercache'] = set()
2994 +
2995 results = self.slave_status.asDict()
2996 - # Enhance it by adding more informations.
2997 - results['builders'] = {}
2998 - for builderName in self.getBuilders():
2999 - builds = []
3000 - builder_status = self.status.getBuilder(builderName)
3001 - for i in range(1, builder_status.buildCacheSize - 1):
3002 - build_status = builder_status.getBuild(-i)
3003 - if not build_status or not build_status.isFinished():
3004 - # If not finished, it will appear in runningBuilds.
3005 - break
3006 - if build_status.getSlavename() == self.name:
3007 - builds.append(build_status.getNumber())
3008 - results['builders'][builderName] = builds
3009 + # Enhance it by adding more information.
3010 + results['builders'] = self.getSlaveBuildMap(
3011 + request.custom_data['buildcache'],
3012 + request.custom_data['buildercache'])
3013 return results
3014
3015
OLDNEW
« no previous file with comments | « no previous file | third_party/buildbot_8_4p1/buildbot/status/web/status_json.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698