Permalink
Browse files

merge from default -> production-0.8

--HG--
branch : production-0.8
  • Loading branch information...
2 parents ad54840 + 239e96d commit 838cc6a6fadfc621a66341748e80f97b87b10d81 @lsblakk lsblakk committed Jun 13, 2011
Showing with 37 additions and 11 deletions.
  1. +37 −11 bin/try_mailer.py
View
@@ -162,21 +162,47 @@ def formatMessage(msgdict, from_, to):
log_url, exit_code = uploadLog(args)
print
- builder_path, build_number = sys.argv[-2:]
+ tm_parser = ArgumentParser()
+ tm_parser.add_argument("-e", "--all-emails", dest="all_emails", help="request all emails", action="store_true")
+ tm_parser.add_argument("-n", "--no-emails", dest="silence", help="request no emails at all", action="store_true")
+ tm_parser.set_defaults(
+ all_emails=False,
+ silence=False,
+ )
+
+ builder_path, build_number = args[-2:]
build = getBuild(builder_path, build_number)
- # Generate the message
- msgdict = makeTryMessage(build, log_url)
+ # check the commit message for syntax regarding email prefs
+ match = re.search("try: ", build.source.changes[-1].comments)
+ comment_args = ""
+ if match:
+ comment_args = build.source.changes[-1].comments.split("try: ")[1].split()
+ tm_options, args = tm_parser.parse_known_args(comment_args)
- if options.to_author:
- options.to.append(msgdict['author'])
+ # Let's check the results to see if we need the message
+ result = build.getResults()
+ # if silence, never make the message
+ # if all emails, alway make the message
+ # else default is failures only
+ msgdict = None
+ # Generate the message
+ if not tm_options.silence:
+ if tm_options.all_emails:
+ msgdict = makeTryMessage(build, log_url)
+ else:
+ if result != SUCCESS:
+ msgdict = makeTryMessage(build, log_url)
# Send it!
- msg = formatMessage(msgdict, options.from_, options.to)
- print msg
-
- s = SMTP()
- s.connect()
- s.sendmail(options.from_, options.to, msg.as_string())
+ if msgdict != None:
+ if options.to_author:
+ options.to.append(msgdict['author'])
+ msg = formatMessage(msgdict, options.from_, options.to)
+ print msg
+
+ s = SMTP()
+ s.connect()
+ s.sendmail(options.from_, options.to, msg.as_string())
sys.exit(exit_code)

0 comments on commit 838cc6a

Please sign in to comment.