- msg["To"] = recipients
- smtp.send(msg["From"], [msg["To"]], msg.as_string())
-
-
-for host in hosts:
- for tree in trees:
- for compiler in compilers:
- retry = 0
- if opts.verbose >= 2:
- print "Looking for a log file for %s %s %s..." % (host, compiler, tree)
-
- # By building the log file name this way, using only the list of
- # hosts, trees and compilers as input, we ensure we
- # control the inputs
- try:
- build = db.get_build(host, tree, compiler)
- except data.NoSuchBuildError:
- continue
-
- if opts.verbose >= 2:
- print "Processing %s..." % build
-
- db.upload_build(build)
-
- (rev, commit_rev, rev_timestamp) = db.revision_details()
-
- try:
- prev_rev = db.get_previous_revision(tree, host, compiler, rev)
- except hostdb.NoSuchBuild:
- # Can't send a nastygram until there are 2 builds..
- continue
- else:
- prev_build = db.get_build(tree, host, compiler, prev_rev)
- check_and_send_mails(tree, host, compiler, build.status(), prev_build.status())
+ msg["To"] = ",".join(recipients)
+ if not opts.dry_run:
+ smtp.sendmail(msg["From"], [msg["To"]], msg.as_string())
+ else:
+ print msg.as_string()
+
+
+for build in buildfarm.get_new_builds():
+ if build in buildfarm.builds:
+ continue
+
+ if not opts.dry_run:
+ old_build = build
+ try:
+ build = buildfarm.builds.upload_build(old_build)
+ except MissingRevisionInfo:
+ print "No revision info in %r, skipping" % build
+ continue
+
+ try:
+ rev = build.revision_details()
+ except MissingRevisionInfo:
+ print "No revision info in %r, skipping" % build
+ continue
+
+ if opts.verbose >= 2:
+ print "%s... " % build,
+ print str(build.status())
+
+ try:
+ if opts.dry_run:
+ # Perhaps this is a dry run and rev is not in the database yet?
+ prev_build = buildfarm.builds.get_latest_build(build.tree, build.host, build.compiler)
+ else:
+ prev_build = buildfarm.builds.get_previous_build(build.tree, build.host, build.compiler, rev)
+ except 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:
+ check_and_send_mails(build, prev_build)