Skip to content

Commit

Permalink
version 0.5.5
Browse files Browse the repository at this point in the history
catch error if email fails (eg internet disconnected) and write to log
  • Loading branch information
elesiuta committed Feb 3, 2021
1 parent 0ddf931 commit e8a451d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
7 changes: 6 additions & 1 deletion baka.py
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,12 @@ def main() -> int:
if args.job:
command_output = "\n".join(command_output)
if "email" in config.jobs[args.job] and config.jobs[args.job]["email"] and config.jobs[args.job]["email"]["to"]:
send_email(config.email, config.jobs[args.job]["email"], command_output)
try:
send_email(config.email, config.jobs[args.job]["email"], command_output)
except Exception as e:
error_email = "--- %s ---\nEmail Error: %s %s\nMessage:\n%s" % (time.ctime(), type(e).__name__, e.args, command_output)
with open(os.path.expanduser("~/.baka/error.log"), "a", encoding="utf-8", errors="surrogateescape") as log_file:
log_file.write(error_email + "\n")
if "write" in config.jobs[args.job] and config.jobs[args.job]["write"]:
file_path = os.path.abspath(datetime.datetime.now().strftime(config.jobs[args.job]["write"]))
os.makedirs(os.path.dirname(file_path), exist_ok=True)
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

setuptools.setup(
name="bakabakabaka",
version="0.5.4",
version="0.5.5",
description="Baka Admin's Kludge Assistant",
long_description=long_description,
long_description_content_type="text/markdown",
Expand Down

0 comments on commit e8a451d

Please sign in to comment.