Unique way to send e-mail
This commit is contained in:
31
alloy.py
31
alloy.py
@@ -72,9 +72,11 @@ def try_do_LLVM(text, command, from_validation):
|
|||||||
postfix = " >> " + alloy_build + " 2>> " + alloy_build
|
postfix = " >> " + alloy_build + " 2>> " + alloy_build
|
||||||
if os.system(command + postfix) != 0:
|
if os.system(command + postfix) != 0:
|
||||||
print_debug("ERROR.\n", from_validation, alloy_build)
|
print_debug("ERROR.\n", from_validation, alloy_build)
|
||||||
send_mail("ISPC test system download/build fail", "ISPC_test_system", options.notify,\
|
if options.notify != "":
|
||||||
"Unable to build or download something. See logs for more information.", \
|
msg = MIMEMultipart()
|
||||||
alloy_build, "alloy_build.log")
|
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)
|
error("can't " + text, 1)
|
||||||
print_debug("DONE.\n", from_validation, alloy_build)
|
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"]
|
os.environ["PATH"] = os.environ["ISPC_HOME"] + ":" + os.environ["PATH"]
|
||||||
if options.notify != "":
|
if options.notify != "":
|
||||||
common.remove_if_exists(os.environ["ISPC_HOME"] + os.sep + "notify_log.log")
|
common.remove_if_exists(os.environ["ISPC_HOME"] + os.sep + "notify_log.log")
|
||||||
smtp_server = os.environ["SMTP_ISPC"]
|
|
||||||
msg = MIMEMultipart()
|
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("Command: " + ' '.join(sys.argv) + "\n", False, "")
|
||||||
print_debug("Folder: " + os.environ["ISPC_HOME"] + "\n", False, "")
|
print_debug("Folder: " + os.environ["ISPC_HOME"] + "\n", False, "")
|
||||||
date = datetime.datetime.now()
|
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)):
|
for i in range(0,len(f_lines)):
|
||||||
line = line + f_lines[i][:-1]
|
line = line + f_lines[i][:-1]
|
||||||
line = line + ' \n'
|
line = line + ' \n'
|
||||||
text = MIMEText(line, "", "KOI-8")
|
|
||||||
msg.attach(text)
|
|
||||||
attach_mail_file(msg, alloy_build, "alloy_build.log")
|
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
|
def send_mail(subject, from_field, to, line, msg):
|
||||||
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):
|
|
||||||
smtp_server = os.environ["SMTP_ISPC"]
|
smtp_server = os.environ["SMTP_ISPC"]
|
||||||
msg = MIMEMultipart()
|
|
||||||
msg['Subject'] = subject
|
msg['Subject'] = subject
|
||||||
msg['From'] = _from
|
msg['From'] = from_field
|
||||||
msg['To'] = to
|
msg['To'] = to
|
||||||
text = MIMEText(line, "", "KOI-8")
|
text = MIMEText(line, "", "KOI-8")
|
||||||
msg.attach(text)
|
msg.attach(text)
|
||||||
attach_mail_file(msg, attach_filename, attach_name)
|
|
||||||
s = smtplib.SMTP(smtp_server)
|
s = smtplib.SMTP(smtp_server)
|
||||||
for name in options.notify.split(" "):
|
s.sendmail(from_field, options.notify.split(" "), msg.as_string())
|
||||||
s.sendmail(_from, name, msg.as_string())
|
|
||||||
s.quit()
|
s.quit()
|
||||||
|
|
||||||
def Main():
|
def Main():
|
||||||
|
|||||||
Reference in New Issue
Block a user