add 'tail' capability to 'attach_mail_file' function, shortened 'alloy_build_log.log' being sent to 100 lines in case of success and 400 in case of failure
This commit is contained in:
26
alloy.py
26
alloy.py
@@ -33,9 +33,22 @@
|
|||||||
|
|
||||||
# // Author: Filippov Ilia
|
# // Author: Filippov Ilia
|
||||||
|
|
||||||
def attach_mail_file(msg, filename, name):
|
def tail_and_save(file_in, file_out, tail = 100):
|
||||||
|
with open(file_in, 'r') as f_in:
|
||||||
|
lines = f_in.readlines()[-tail:]
|
||||||
|
|
||||||
|
with open(file_out, 'w') as f_out:
|
||||||
|
f_out.writelines(lines)
|
||||||
|
|
||||||
|
|
||||||
|
def attach_mail_file(msg, filename, name, tail = -1):
|
||||||
if os.path.exists(filename):
|
if os.path.exists(filename):
|
||||||
fp = open(filename, "rb")
|
if tail > 0:
|
||||||
|
tail_and_save(filename, filename + '.tail', tail)
|
||||||
|
fp = open(filename + '.tail', "rb")
|
||||||
|
else:
|
||||||
|
fp = open(filename, "rb")
|
||||||
|
|
||||||
to_attach = MIMEBase("application", "octet-stream")
|
to_attach = MIMEBase("application", "octet-stream")
|
||||||
to_attach.set_payload(fp.read())
|
to_attach.set_payload(fp.read())
|
||||||
encode_base64(to_attach)
|
encode_base64(to_attach)
|
||||||
@@ -43,6 +56,7 @@ def attach_mail_file(msg, filename, name):
|
|||||||
fp.close()
|
fp.close()
|
||||||
msg.attach(to_attach)
|
msg.attach(to_attach)
|
||||||
|
|
||||||
|
|
||||||
def setting_paths(llvm, ispc, sde):
|
def setting_paths(llvm, ispc, sde):
|
||||||
if llvm != "":
|
if llvm != "":
|
||||||
os.environ["LLVM_HOME"]=llvm
|
os.environ["LLVM_HOME"]=llvm
|
||||||
@@ -74,8 +88,10 @@ def try_do_LLVM(text, command, from_validation):
|
|||||||
print_debug("ERROR.\n", from_validation, alloy_build)
|
print_debug("ERROR.\n", from_validation, alloy_build)
|
||||||
if options.notify != "":
|
if options.notify != "":
|
||||||
msg = MIMEMultipart()
|
msg = MIMEMultipart()
|
||||||
attach_mail_file(msg, alloy_build, "alloy_build.log")
|
attach_mail_file(msg, alloy_build, "alloy_build.log", 400)
|
||||||
send_mail("Unable to build or download something. See logs for more information.", msg)
|
attach_mail_file(msg, stability_log, "stability.log")
|
||||||
|
attach_mail_file(msg, stability.in_file, "run_tests_log.log")
|
||||||
|
send_mail("Error while executing " + command + ". Examine 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)
|
||||||
|
|
||||||
@@ -620,7 +636,7 @@ 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)):
|
||||||
body = body + f_lines[i][:-1]
|
body = body + f_lines[i][:-1]
|
||||||
body = body + ' \n'
|
body = body + ' \n'
|
||||||
attach_mail_file(msg, alloy_build, "alloy_build.log")
|
attach_mail_file(msg, alloy_build, "alloy_build.log", 100)
|
||||||
send_mail(body, msg)
|
send_mail(body, msg)
|
||||||
|
|
||||||
def send_mail(body, msg):
|
def send_mail(body, msg):
|
||||||
|
|||||||
Reference in New Issue
Block a user