From 5512fb6275ade520b17cefcb2bc53fbd4be41d5e Mon Sep 17 00:00:00 2001 From: Vsevolod Livinskiy Date: Tue, 8 Jul 2014 12:58:21 +0400 Subject: [PATCH 1/4] alloy.py finds out revision of llvm --- alloy.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/alloy.py b/alloy.py index 1fd9bd14..989058c7 100755 --- a/alloy.py +++ b/alloy.py @@ -296,6 +296,17 @@ 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: @@ -703,6 +714,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 From 97057ed7a1bf286a790290a1c80a2dd98f422874 Mon Sep 17 00:00:00 2001 From: Vsevolod Livinskiy Date: Tue, 8 Jul 2014 15:51:14 +0400 Subject: [PATCH 2/4] Send mail with build error. --- alloy.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/alloy.py b/alloy.py index 989058c7..f4c1c411 100755 --- a/alloy.py +++ b/alloy.py @@ -72,6 +72,9 @@ 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) + send_mail("ISPC test system download/build fail", "ISPC_test_system", options.notify,\ + "Unable to build or download something. See logs for more information.", \ + alloy_build, "alloy_build.log") error("can't " + text, 1) print_debug("DONE.\n", from_validation, alloy_build) @@ -296,6 +299,7 @@ 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 @@ -630,6 +634,20 @@ def validation_run(only, only_targets, reference_branch, number, notify, update, s.sendmail('ISPC_test_system', name, msg.as_string()) s.quit() +def send_mail(subject, _from, to, line, attach_filename, attach_name): + smtp_server = os.environ["SMTP_ISPC"] + msg = MIMEMultipart() + msg['Subject'] = subject + msg['From'] = _from + msg['To'] = to + text = MIMEText(line, "", "KOI-8") + msg.attach(text) + attach_mail_file(msg, attach_filename, attach_name) + s = smtplib.SMTP(smtp_server) + for name in options.notify.split(" "): + s.sendmail(_from, name, msg.as_string()) + s.quit() + def Main(): global current_OS global current_OS_version From d890ccc92cb93a9eee169a5cfc03a4e04b66690f Mon Sep 17 00:00:00 2001 From: Vsevolod Livinskiy Date: Tue, 8 Jul 2014 16:56:15 +0400 Subject: [PATCH 3/4] Unique way to send e-mail --- alloy.py | 31 +++++++++---------------------- 1 file changed, 9 insertions(+), 22 deletions(-) diff --git a/alloy.py b/alloy.py index f4c1c411..ad08fed8 100755 --- a/alloy.py +++ b/alloy.py @@ -72,9 +72,11 @@ 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) - send_mail("ISPC test system download/build fail", "ISPC_test_system", options.notify,\ - "Unable to build or download something. See logs for more information.", \ - alloy_build, "alloy_build.log") + if options.notify != "": + msg = MIMEMultipart() + attach_mail_file(msg, alloy_build, "alloy_build.log") + send_mail("ISPC test system download/build fail", "ISPC_test_system", options.notify,\ + "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) @@ -375,11 +377,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() @@ -623,29 +621,18 @@ def validation_run(only, only_targets, reference_branch, number, notify, update, 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) attach_mail_file(msg, alloy_build, "alloy_build.log") - s = smtplib.SMTP(smtp_server) + send_mail("ISPC test system results", "ISPC_test_system", options.notify, line, 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()) - s.quit() - -def send_mail(subject, _from, to, line, attach_filename, attach_name): +def send_mail(subject, from_field, to, line, msg): smtp_server = os.environ["SMTP_ISPC"] - msg = MIMEMultipart() msg['Subject'] = subject - msg['From'] = _from + msg['From'] = from_field msg['To'] = to text = MIMEText(line, "", "KOI-8") msg.attach(text) - attach_mail_file(msg, attach_filename, attach_name) s = smtplib.SMTP(smtp_server) - for name in options.notify.split(" "): - s.sendmail(_from, name, msg.as_string()) + s.sendmail(from_field, options.notify.split(" "), msg.as_string()) s.quit() def Main(): From 7ecc9e07698aee00628534c364e4eaccc3ff1560 Mon Sep 17 00:00:00 2001 From: Vsevolod Livinskiy Date: Tue, 8 Jul 2014 18:03:01 +0400 Subject: [PATCH 4/4] Some fixes in send function --- alloy.py | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/alloy.py b/alloy.py index ad08fed8..8bed9381 100755 --- a/alloy.py +++ b/alloy.py @@ -75,8 +75,7 @@ def try_do_LLVM(text, command, from_validation): if options.notify != "": msg = MIMEMultipart() attach_mail_file(msg, alloy_build, "alloy_build.log") - send_mail("ISPC test system download/build fail", "ISPC_test_system", options.notify,\ - "Unable to build or download something. See logs for more information.", msg) + 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) @@ -615,24 +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' + body = body + f_lines[i][:-1] + body = body + ' \n' attach_mail_file(msg, alloy_build, "alloy_build.log") - send_mail("ISPC test system results", "ISPC_test_system", options.notify, line, msg) + send_mail(body, msg) -def send_mail(subject, from_field, to, line, msg): +def send_mail(body, msg): smtp_server = os.environ["SMTP_ISPC"] - msg['Subject'] = subject - msg['From'] = from_field - msg['To'] = to - text = MIMEText(line, "", "KOI-8") + 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(from_field, options.notify.split(" "), msg.as_string()) + s.sendmail(options.notify, options.notify.split(" "), msg.as_string()) s.quit() def Main():