diff --git a/alloy.py b/alloy.py index 1fd9bd14..8bed9381 100755 --- a/alloy.py +++ b/alloy.py @@ -72,6 +72,10 @@ def try_do_LLVM(text, command, from_validation): postfix = " >> " + alloy_build + " 2>> " + alloy_build if os.system(command + postfix) != 0: print_debug("ERROR.\n", from_validation, alloy_build) + if options.notify != "": + msg = MIMEMultipart() + attach_mail_file(msg, alloy_build, "alloy_build.log") + send_mail("Unable to build or download something. See logs for more information.", msg) error("can't " + text, 1) print_debug("DONE.\n", from_validation, alloy_build) @@ -296,6 +300,18 @@ def build_ispc(version_LLVM, make): p_temp = os.getenv("PATH") os.environ["PATH"] = os.environ["LLVM_HOME"] + "/bin-" + version_LLVM + "/bin:" + os.environ["PATH"] try_do_LLVM("clean ISPC for building", "make clean", True) + + folder = os.environ["LLVM_HOME"] + os.sep + "llvm-" + if options.folder == "": + folder += version_LLVM + if options.debug == True: + folder += "dbg" + + p = subprocess.Popen("svnversion " + folder, shell=True, \ + stdout=subprocess.PIPE, stderr=subprocess.PIPE) + (revision_llvm, err) = p.communicate() + + try_do_LLVM("recognize LLVM revision", "svn info " + folder, True) try_do_LLVM("build ISPC with LLVM version " + version_LLVM + " ", make, True) os.environ["PATH"] = p_temp else: @@ -360,11 +376,7 @@ def validation_run(only, only_targets, reference_branch, number, notify, update, os.environ["PATH"] = os.environ["ISPC_HOME"] + ":" + os.environ["PATH"] if options.notify != "": common.remove_if_exists(os.environ["ISPC_HOME"] + os.sep + "notify_log.log") - smtp_server = os.environ["SMTP_ISPC"] msg = MIMEMultipart() - msg['Subject'] = 'ISPC test system results' - msg['From'] = 'ISPC_test_system' - msg['To'] = options.notify print_debug("Command: " + ' '.join(sys.argv) + "\n", False, "") print_debug("Folder: " + os.environ["ISPC_HOME"] + "\n", False, "") date = datetime.datetime.now() @@ -602,21 +614,24 @@ def validation_run(only, only_targets, reference_branch, number, notify, update, fp = open(os.environ["ISPC_HOME"] + os.sep + "notify_log.log", 'rb') f_lines = fp.readlines() fp.close() - line = "" + body = "" if not sys.exc_info()[0] == None: - line = line + "Last exception: " + str(sys.exc_info()) + '\n' + body = body + "Last exception: " + str(sys.exc_info()) + '\n' for i in range(0,len(f_lines)): - line = line + f_lines[i][:-1] - line = line + ' \n' - text = MIMEText(line, "", "KOI-8") - msg.attach(text) + body = body + f_lines[i][:-1] + body = body + ' \n' attach_mail_file(msg, alloy_build, "alloy_build.log") - s = smtplib.SMTP(smtp_server) + send_mail(body, msg) - print "Sending an e-mail with logs:", options.notify - for name in options.notify.split(" "): - print "Sending to: ", name - s.sendmail('ISPC_test_system', name, msg.as_string()) +def send_mail(body, msg): + smtp_server = os.environ["SMTP_ISPC"] + msg['Subject'] = "ISPC test system results" + msg['From'] = "ISPC_test_system" + msg['To'] = options.notify + text = MIMEText(body, "", "KOI-8") + msg.attach(text) + s = smtplib.SMTP(smtp_server) + s.sendmail(options.notify, options.notify.split(" "), msg.as_string()) s.quit() def Main(): @@ -703,6 +718,7 @@ import smtplib import datetime import copy import multiprocessing +import subprocess from email.MIMEMultipart import MIMEMultipart from email.MIMEBase import MIMEBase from email.mime.text import MIMEText