Skip to content
This repository has been archived by the owner on Jun 11, 2019. It is now read-only.

Commit

Permalink
merge from default -> production-0.8
Browse files Browse the repository at this point in the history
--HG--
branch : production-0.8
  • Loading branch information
lsblakk committed Jun 13, 2011
2 parents ad54840 + 239e96d commit 838cc6a
Showing 1 changed file with 37 additions and 11 deletions.
48 changes: 37 additions & 11 deletions bin/try_mailer.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.