Skip to content

Send email on CalledProcessError #171

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions bbs/jobs.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
import datetime
import time
import socket
import bbs.notify

if sys.platform == "win32":
import psutil
#import win32api
Expand Down Expand Up @@ -87,6 +89,14 @@ def call(cmd, check=False):
# Apparently using "stderr=subprocess.STDOUT" fixes this pb.
retcode = subprocess.call(cmd, stderr=subprocess.STDOUT, shell=True)
if check and retcode != 0:
subject = '[BBS] {}'.format(retcode)
bbs.notify.mode = 'do-it'
# TODO: Get notification email from config
bbs.notify.sendtextmail('[email protected]',
['[email protected]'],
subject,
'{}'.format(cmd))
print("Attempted to send notification")
raise subprocess.CalledProcessError(retcode, cmd)
return retcode

Expand Down