Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
if when is not None:
cxt['when'] = util.formatInterval(when)
cxt['when_time'] = time.strftime("%H:%M:%S",
time.localtime(time.time() + when))
cxt['result_css'] = "building"
else:
cxt['result_css'] = css_classes[b.getResults()]
(start, end) = b.getTimes()
cxt['start'] = time.ctime(start)
if end:
cxt['end'] = time.ctime(end)
cxt['elapsed'] = util.formatInterval(end - start)
else:
now = util.now()
cxt['elapsed'] = util.formatInterval(now - start)
return cxt
if "show_time" in request.args:
minTime = maxTime - int(request.args["show_time"][0])
elif "first_time" in request.args:
minTime = int(request.args["first_time"][0])
else:
minTime = None
spanLength = 10 # ten-second chunks
maxPageLen = int(request.args.get("num_events", [200])[0])
# first step is to walk backwards in time, asking each column
# (commit, all builders) if they have any events there. Build up the
# array of events, and stop when we have a reasonable number.
commit_source = self.getChangemaster(request)
lastEventTime = util.now()
sources = [commit_source] + builders
changeNames = ["changes"]
builderNames = map(lambda builder: builder.getName(), builders)
sourceNames = changeNames + builderNames
sourceEvents = []
sourceGenerators = []
def get_event_from(g):
try:
while True:
e = g.next()
# e might be builder.BuildStepStatus,
# builder.BuildStatus, builder.Event,
# waterfall.Spacer(builder.Event), or changes.Change .
# The showEvents=False flag means we should hide
# builder.Event .
def buildGrid(self, request, builders):
debug = False
# XXX: see if we can use a cached copy
# first step is to walk backwards in time, asking each column
# (commit, all builders) if they have any events there. Build up the
# array of events, and stop when we have a reasonable number.
commit_source = self.changemaster
lastEventTime = util.now()
sources = [commit_source] + builders
changeNames = ["changes"]
builderNames = map(lambda builder: builder.getName(), builders)
sourceNames = changeNames + builderNames
sourceEvents = []
sourceGenerators = []
for s in sources:
gen = insertGaps(s.eventGenerator(), lastEventTime)
sourceGenerators.append(gen)
# get the first event
try:
e = gen.next()
event = interfaces.IStatusEvent(e)
if debug:
log.msg("gen %s gave1 %s" % (gen, event.getText()))
except StopIteration:
def buildGrid(self, request, builders):
debug = False
# TODO: see if we can use a cached copy
showEvents = False
if request.args.get("show_events", ["true"])[0].lower() == "true":
showEvents = True
filterBranches = [b for b in request.args.get("branch", []) if b]
filterBranches = map_branches(filterBranches)
maxTime = int(request.args.get("last_time", [util.now()])[0])
if "show_time" in request.args:
minTime = maxTime - int(request.args["show_time"][0])
elif "first_time" in request.args:
minTime = int(request.args["first_time"][0])
else:
minTime = None
spanLength = 10 # ten-second chunks
maxPageLen = int(request.args.get("num_events", [200])[0])
# first step is to walk backwards in time, asking each column
# (commit, all builders) if they have any events there. Build up the
# array of events, and stop when we have a reasonable number.
commit_source = self.getChangemaster(request)
lastEventTime = util.now()
def stepFinished(self, results):
self.finished = util.now()
self.results = results
cld = [] # deferreds for log compression
logCompressionLimit = self.master.config.logCompressionLimit
for loog in self.logs:
if not loog.isFinished():
loog.finish()
# if log compression is on, and it's a real LogFile,
# HTMLLogFiles aren't files
if logCompressionLimit is not False and \
isinstance(loog, LogFile):
if os.path.getsize(loog.getFilename()) > logCompressionLimit:
loog_deferred = loog.compressLog()
if loog_deferred:
cld.append(loog_deferred)
for r in self.updates.keys():
expectation = self.expectations[metric]
if value is not None and expectation is not None:
p = 1.0 * value / expectation
percentages.append(p)
if percentages:
avg = reduce(lambda x, y: x + y, percentages) / len(percentages)
if avg > 1.0:
# overdue
avg = 1.0
if avg < 0.0:
avg = 0.0
if percentages and self.expectedTime is not None:
return self.expectedTime - (avg * self.expectedTime)
if self.expectedTime is not None:
# fall back to pure time
return self.expectedTime - (util.now() - self.startTime)
return None # no idea
def emit_status(self, reply, which):
b = self.getBuilder(which)
str = "%s: " % which
state, builds = b.getState()
str += state
if state == "idle":
last = b.getLastFinishedBuild()
if last:
start,finished = last.getTimes()
str += ", last build %s secs ago: %s" % \
(int(util.now() - finished), " ".join(last.getText()))
if state == "building":
t = []
for build in builds:
step = build.getCurrentStep()
s = "(%s)" % " ".join(step.getText())
ETA = build.getETA()
if ETA is not None:
s += " [ETA %s]" % self.convertTime(ETA)
t.append(s)
str += ", ".join(t)
self.reply(reply, str)
def buildGrid(self, request, builders):
# summary of changes between this method and the overriden one:
# - don't show events (master started...) by default
# - only display changes related to the current module
debug = False
# TODO: see if we can use a cached copy
showEvents = False
if request.args.get("show_events", ["false"])[0].lower() == "true":
showEvents = True
filterBranches = [b for b in request.args.get("branch", []) if b]
filterBranches = map_branches(filterBranches)
maxTime = int(request.args.get("last_time", [util.now()])[0])
if "show_time" in request.args:
minTime = maxTime - int(request.args["show_time"][0])
elif "first_time" in request.args:
minTime = int(request.args["first_time"][0])
else:
minTime = None
spanLength = 10 # ten-second chunks
maxPageLen = int(request.args.get("num_events", [200])[0])
# first step is to walk backwards in time, asking each column
# (commit, all builders) if they have any events there. Build up the
# array of events, and stop when we have a reasonable number.
commit_source = self.getChangemaster(request)
lastEventTime = util.now()