From: Andreas Schneider Date: Wed, 25 Jan 2023 16:08:58 +0000 (+0100) Subject: script:autobuild: Make sure we can send a failure mail X-Git-Tag: tevent-0.14.1~28 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f6712c709868bf87dfd3d92bec1f306d2a98116e;p=thirdparty%2Fsamba.git script:autobuild: Make sure we can send a failure mail We should not run into an exception if the file doesn't exist. Traceback (most recent call last): File "script/autobuild.py", line 1781, in email_failure(-1, 'rebase', 'rebase', 'rebase', File "script/autobuild.py", line 1677, in email_failure f = open("%s/%s.stdout" % (gitroot, failed_tag), 'r') FileNotFoundError: [Errno 2] No such file or directory: 'samba-autobuild/rebase.stdout' Signed-off-by: Andreas Schneider Reviewed-by: Andrew Bartlett Autobuild-User(master): Andrew Bartlett Autobuild-Date(master): Mon Jan 30 10:00:27 UTC 2023 on atb-devel-224 --- diff --git a/script/autobuild.py b/script/autobuild.py index afa757491e0..492085a5bbb 100755 --- a/script/autobuild.py +++ b/script/autobuild.py @@ -1673,14 +1673,16 @@ The top commit for the tree that was built was: ''' % (log_base, failed_tag, log_base, failed_tag, log_base, top_commit_msg) - if add_log_tail: - f = open("%s/%s.stdout" % (gitroot, failed_tag), 'r') + log_stdout = "%s/%s.stdout" % (gitroot, failed_tag) + if add_log_tail and os.access(log_stdout, os.R_OK): + f = open(log_stdout, 'r') lines = f.readlines() log_tail = "".join(lines[-50:]) num_lines = len(lines) - if num_lines < 50: + log_stderr = "%s/%s.stderr" % (gitroot, failed_tag) + if num_lines < 50 and os.access(log_stderr, os.R_OK): # Also include stderr (compile failures) if < 50 lines of stdout - f = open("%s/%s.stderr" % (gitroot, failed_tag), 'r') + f = open(log_stderr, 'r') log_tail += "".join(f.readlines()[-(50 - num_lines):]) text += '''