Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def addEvent(self, text=None):
# this adds a duration event. When it is done, the user should call
# e.finish(). They can also mangle it by modifying .text
e = Event()
e.started = util.now()
if text is None:
text = []
e.text = text
return e # they are free to mangle it further
def emit_last(self, reply, which):
last = self.getBuilder(which).getLastFinishedBuild()
if not last:
str = "(no builds run since last restart)"
else:
start,finish = last.getTimes()
str = "%s secs ago: " % (int(util.now() - finish))
str += " ".join(last.getText())
self.reply(reply, "last build [%s]: %s" % (which, str))
p['cols'] = param.cols
p['rows'] = param.rows
p['label'] = param.label
ps.append(p)
cxt['responsible_users'] = list(b.getResponsibleUsers())
(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)
has_changes = False
for ss in sourcestamps:
has_changes = has_changes or ss.changes
cxt['has_changes'] = has_changes
cxt['build_url'] = path_to_build(req, b)
cxt['authz'] = self.getAuthz(req)
template = req.site.buildbot_service.templates.get_template("build.html")
return template.render(**cxt)
import buildbot
import zope
import os
from datetime import datetime, timedelta
from twisted.python import log
class ConfigEmailLookup(buildbot.util.ComparableMixin):
"""
Email lookup implementation which searchs a user specified configuration
file to match commit authors to email addresses.
"""
# TODO: Document this class.
# Class loads llvm_authors from file and reload if the file was updated.
zope.interface.implements(buildbot.interfaces.IEmailLookup)
compare_attrs = ["author_filename", "default_address", "only_addresses"]
def __init__(self, author_filename, default_address, only_addresses = None, update_interval=timedelta(hours=1)):
from ConfigParser import ConfigParser
self.author_filename = author_filename
self.default_address = default_address
self.initialSection()
last = self.sections[-1]
# Update status if set as an argument.
if status is not None:
last['status'] = status
# Final update of text.
self.updateText()
# Add timing info.
(start, end) = self.command.step_status.getTimes()
msg = '\n\n' + '-' * 80 + '\n'
if start is None:
msg += 'Not Started\n'
else:
if end is None:
end = util.now()
msg += '\n'.join([
'started: %s' % time.ctime(start),
'ended: %s' % time.ctime(end),
'duration: %s' % util.formatInterval(end - start),
'', # So we get a final \n
])
last['log'].addStdout(msg)
# Change status (unless handling the preamble).
if len(self.sections) != 1:
last['step'].stepFinished(last['status'])
# Finish log.
last['log'].finish()
properties = yield \
pb.master.db.buildsets.getBuildsetProperties(bsid)
if not prop_match(properties):
continue
if source.changes:
for c in source.changes:
changes.append({'url': path_to_change(req, c),
'who': c.who,
'revision': c.revision,
'repo': c.repository})
cxt['pending'].append({
'when': time.strftime("%b %d %H:%M:%S",
time.localtime(submitTime)),
'delay': util.formatInterval(util.now() - submitTime),
'id': pb.brid,
'changes': changes,
'num_changes': len(changes),
'properties': properties,
})
try:
numbuilds = cxt['numbuilds'] = int(req.args.get('numbuilds', [self.numbuilds])[0])
except ValueError:
numbuilds = cxt['numbuilds'] = 10
maxsearch = int(req.args.get('maxsearch', [200])[0])
recent = cxt['recent'] = []
for build in b.generateFinishedBuilds(
num_builds=int(numbuilds),
max_search=maxsearch,
filter_fn=lambda b: prop_match(b.getProperties())):
def setup(self, check_version=True, verbose=True):
db_url = self.configured_url = self.master.config.db['db_url']
log.msg("Setting up database with URL %r"
% util.stripUrlPassword(db_url))
# set up the engine and pool
self._engine = enginestrategy.create_engine(db_url,
basedir=self.basedir)
self.pool = pool.DBThreadPool(
self._engine, reactor=self.master.reactor, verbose=verbose)
# make sure the db is up to date, unless specifically asked not to
if check_version:
if db_url == 'sqlite://':
# Using in-memory database. Since it is reset after each process
# restart, `buildbot upgrade-master` cannot be used (data is not
# persistent). Upgrade model here to allow startup to continue.
self.model.upgrade()
current = yield self.model.is_current()
if not current:
def emit_last(which):
last = self.getBuilder(which).getLastFinishedBuild()
if not last:
str = "(no builds run since last restart)"
else:
start,finish = last.getTimes()
str = "%s ago: " % (self.convertTime(int(util.now() - finish)))
str += " ".join(last.getText())
self.send("last build [%s]: %s" % (which, str))
def emit_last(self, reply, which):
last = self.getBuilder(which).getLastFinishedBuild()
if not last:
str = "(no builds run since last restart)"
else:
start,finish = last.getTimes()
str = "%s secs ago: " % (int(util.now() - finish))
str += " ".join(last.getText())
self.reply(reply, "last build [%s]: %s" % (which, str))
@classmethod
def getName(cls, *args, **kwargs):
_hash = hashlib.sha1()
for arg in args:
arg = unicode2bytes(str(arg))
_hash.update(arg)
for k, v in sorted(kwargs.items()):
k = unicode2bytes(str(k))
v = unicode2bytes(str(v))
_hash.update(k)
_hash.update(v)
return cls.__name__ + "_" + _hash.hexdigest()
class BuildbotService(AsyncMultiService, config.ConfiguredMixin, util.ComparableMixin,
ReconfigurableServiceMixin):
compare_attrs = ('name', '_config_args', '_config_kwargs')
name = None
configured = False
objectid = None
def __init__(self, *args, **kwargs):
name = kwargs.pop("name", None)
if name is not None:
self.name = bytes2unicode(name)
self.checkConfig(*args, **kwargs)
if self.name is None:
raise ValueError(
"%s: must pass a name to constructor" % type(self))
self._config_args = args
self._config_kwargs = kwargs