Skip to content

Commit b9ce223

Browse files
authored
Add try-except propagation status fails (#308)
* Add try-except propagation status fails * Add details to subject * Fix recipient for postrun failure * Add node_hostname to subject
1 parent 18d6d35 commit b9ce223

File tree

1 file changed

+19
-2
lines changed

1 file changed

+19
-2
lines changed

BBS-make-PROPAGATION_STATUS_DB.py

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
import time
1313
import subprocess
1414

15+
import bbs.notify
16+
1517
import BBSutils
1618
import BBSvars
1719
import BBSbase
@@ -30,8 +32,23 @@ def make_PROPAGATION_STATUS_DB(final_repo):
3032
## subprocess.run() if this code is runned by the Task Scheduler
3133
## on Windows (the child process tends to almost always return an
3234
## error). Apparently using 'stderr=subprocess.STDOUT' fixes this pb.
33-
subprocess.run(cmd, stdout=None, stderr=subprocess.STDOUT, shell=True,
34-
check=True)
35+
try:
36+
subprocess.run(cmd, stdout=None, stderr=subprocess.STDOUT, shell=True,
37+
check=True)
38+
except subprocess.CalledProcessError as e:
39+
subject = (f"[BBS] Postrun failure on {BBSvars.node_hostname} for "
40+
f"{BBSvars.bioc_version} {BBSvars.buildtype} builds")
41+
msg_body = f"""\
42+
Postrun failed on {BBSvars.node_hostname} for the {BBSvars.bioc_version}
43+
{BBSvars.buildtype} builds with the following error:
44+
45+
Error: {e}"""
46+
bbs.notify.mode = "do-it"
47+
bbs.notify.sendtextmail("[email protected]",
48+
49+
subject,
50+
msg_body)
51+
raise e
3552
return
3653

3754
##############################################################################

0 commit comments

Comments
 (0)