Skip to content

Commit

Permalink
Merge pull request #208 from wwade/mail-decode-binary-handling
Browse files Browse the repository at this point in the history
mail: handle autoDecode failure for job logs with binary data
  • Loading branch information
wwade committed Sep 10, 2022
2 parents cf04ec2 + aeca486 commit c458fe4
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
8 changes: 7 additions & 1 deletion jobrunner/main.py
Expand Up @@ -799,7 +799,13 @@ def extendMailOrNotifyCmdLockRequired(
safeWrite(tmp, depJob.detail(False))
safeWrite(tmp, "\n" + SPACER_EACH + "\n")
assert depJob.logfile
lines = autoDecode(check_output(["tail", "-n20", depJob.logfile]))
out = check_output(["tail", "-n20", depJob.logfile])
try:
lines = autoDecode(out)
except ValueError as err:
LOG.debug("error decoding output from log file %r for %s: %s",
depJob.logfile, depJob, err)
lines = f"{out[:50]}\n"
safeWrite(tmp, lines)
safeWrite(tmp, SPACER_EACH + "\n")
safeWrite(tmp, "\n")
Expand Down
2 changes: 1 addition & 1 deletion jobrunner/utils.py
Expand Up @@ -348,7 +348,7 @@ def sudoKillProcGroup(pgrp):
try:
subprocess.check_call(cmd)
except subprocess.CalledProcessError as error:
LOG("cmd %r => error=%s", cmd, error, exc_info=True)
LOG.debug("cmd %r => error=%s", cmd, error, exc_info=True)
return error.output
return None

Expand Down

0 comments on commit c458fe4

Please sign in to comment.