diff --git a/alloy.py b/alloy.py index 8bed9381..40f0e2d3 100755 --- a/alloy.py +++ b/alloy.py @@ -33,9 +33,22 @@ # // 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): - 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.set_payload(fp.read()) encode_base64(to_attach) @@ -43,6 +56,7 @@ def attach_mail_file(msg, filename, name): fp.close() msg.attach(to_attach) + def setting_paths(llvm, ispc, sde): if 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) 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) + attach_mail_file(msg, alloy_build, "alloy_build.log", 400) + 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) 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)): body = body + f_lines[i][:-1] 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) def send_mail(body, msg):