(opts, args) = parser.parse_args()
-buildfarm = StormCachingBuildFarm()
+buildfarm = StormCachingBuildFarm(timeout=40.0)
smtp = smtplib.SMTP()
smtp.connect()
old_status = old.status()
if not cur_status.regressed_since(old_status):
- if opts.verbose >= 1:
- print "the build didn't get worse since %r" % old_status
+ if opts.verbose >= 3:
+ print "... hasn't regressed since %s: %s" % (old_rev, old_status)
return
recipients = set()
change_log = ""
- for rev in t.get_branch().log(from_rev=cur.rev, exclude_revs=set([old.rev])):
+ for rev in t.get_branch().log(from_rev=cur.revision, exclude_revs=set([old.revision])):
recipients.add(rev.author)
recipients.add(rev.committer)
change_log += """
The build may have been broken by one of the following commits:
%(change_log)s
- """ % {"tree": tree, "host": host, "compiler": compiler, "change_log": change_log, "scm": t.scm, "branch": t.branch,
- "cur_rev": cur_rev, "old_rev": old_rev, "cur_status": cur_status, "old_status": old_status }
+ """ % {
+ "tree": tree, "host": host, "compiler": compiler,
+ "change_log": change_log,
+ "scm": t.scm,
+ "branch": t.branch,
+ "cur_rev": cur_rev,
+ "old_rev": old_rev,
+ "cur_status": cur_status,
+ "old_status": old_status,
+ }
msg = MIMEText(body)
msg["Subject"] = "BUILD of %s:%s BROKEN on %s with %s AT REVISION %s" % (tree, t.branch, host, compiler, cur_rev)
msg["From"] = "\"Build Farm\" <build@samba.org>"
- msg["To"] = ",".join(recipients.keys())
+ msg["To"] = ",".join(recipients)
if not opts.dry_run:
- smtp.send(msg["From"], [msg["To"]], msg.as_string())
+ smtp.sendmail(msg["From"], [msg["To"]], msg.as_string())
else:
print msg.as_string()
for build in buildfarm.get_new_builds():
- if opts.verbose >= 1:
- print "Processing %s..." % build,
+ if build in buildfarm.builds:
+ continue
if not opts.dry_run:
- buildfarm.builds.upload_build(build)
+ try:
+ build = buildfarm.builds.upload_build(build)
+ except data.MissingRevisionInfo:
+ print "No revision info in %r, skipping" % build
+ continue
- (rev, rev_timestamp) = build.revision_details()
+ try:
+ (rev, rev_timestamp) = build.revision_details()
+ except data.MissingRevisionInfo:
+ print "No revision info in %r, skipping" % build
+ continue
- if opts.verbose >= 1:
+ if opts.verbose >= 2:
+ print "%s... " % build,
print str(build.status())
try:
- prev_rev = buildfarm.builds.get_previous_revision(build.tree, build.host, build.compiler, rev)
- except data.NoSuchBuildError:
- try:
+ if opts.dry_run:
# Perhaps this is a dry run and rev is not in the database yet?
prev_rev = buildfarm.builds.get_latest_revision(build.tree, build.host, build.compiler)
+ else:
+ prev_rev = buildfarm.builds.get_previous_revision(build.tree, build.host, build.compiler, rev)
+ except data.NoSuchBuildError:
+ if opts.verbose >= 1:
+ print "Unable to find previous build for %s,%s,%s" % (build.tree, build.host, build.compiler)
+ # Can't send a nastygram until there are 2 builds..
+ else:
+ try:
+ assert prev_rev is not None
+ prev_build = buildfarm.builds.get_build(build.tree, build.host, build.compiler, prev_rev)
except data.NoSuchBuildError:
if opts.verbose >= 1:
- print "Unable to find previous build for %s,%s,%s" % (build.tree, build.host, build.compiler)
- # Can't send a nastygram until there are 2 builds..
- continue
- else:
- prev_build = buildfarm.get_build(build.tree, build.host, build.compiler, prev_rev)
- check_and_send_mails(build.tree, build.host, build.compiler, build, prev_build)
+ print "Previous build %s has disappeared" % prev_build
+ else:
+ check_and_send_mails(build.tree, build.host, build.compiler, build, prev_build)
if not opts.dry_run:
- build.remove()
+ # When the new web script is introduced, kill the build here:
+ # build.remove()
buildfarm.commit()
smtp.quit()