ATLAS Offline Software
Loading...
Searching...
No Matches
TRTCalibrationMessage.py
Go to the documentation of this file.
1"""
2Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3"""
4import sys, os, smtplib
5
6def EmailNotification(jobStatus):
7
8 AtlasBuildBranch=os.environ.get("AtlasBuildBranch" , "UNDEFINED")
9 AthenaPlatform =os.environ.get("Athena_PLATFORM" , "UNDEFINED")
10 AtlasRelease =os.environ.get("ATLAS_RELEASE_BASE", "UNDEFINED")
11 Atlasbuild =os.environ.get("AtlasBuildStamp" , "UNDEFINED")
12
13 if AtlasBuildBranch != "24.0" and AtlasBuildBranch != "main":
14 print("AtlasBuildBranch not 24.0 or main. Exiting.")
15 sys.exit(0)
16
17
18 mserver = "cernmx.cern.ch"
19 mfrom = "no-reply@cern.ch"
20 mto = ["atlas-trt-offline-shifts@cern.ch","atlas-trt-expert-shifters@cern.ch"]
21 msubject = "ART test notification: TRT calibration Workflow for %s" % (AtlasBuildBranch)
22
23 status="*SUCCEEDED*"
24 if jobStatus.ACCU != 0 or jobStatus.MERGE != 0:
25 status = "*FAILED*\n"
26 status += "\t- The TRT ACCU transform %s.\n" % ("*is broken*" if jobStatus.ACCU else "works")
27 status += "\t- The TRT MERGE transform %s." % ("*is broken*" if jobStatus.MERGE else "works")
28
29 # assemble mail body
30 mbody = "Dear TRT expert/shifter\n\n"
31 mbody += " This email is generated by the ART test InnerDetector/InDetCalibAlgs/TRT_CalibAlgs/test/test_TRTCalibration.sh \n\n"
32 mbody += " The test has %s\n\n" % (status)
33 mbody += " For %s\n\n" % (AtlasRelease)
34 mbody += f" You can check the results in https://bigpanda.cern.ch/art/overview/?branch={AtlasBuildBranch}/Athena/{AthenaPlatform}&nlastnightlies=7&view=packages&test_type=local\n"
35 mbody += f" Outputs are in /eos/atlas/atlascerngroupdisk/data-art/local-output/{AtlasBuildBranch}/Athena/{AthenaPlatform}/{Atlasbuild}/\n\n"
36 mbody += "Cheers\n"
37 mbody += "\tYour amazing TRT Calibration test"
38
39 fullmsg = "To: %s\nSubject: %s\n\n%s" % ("".join(("%s," % str(_mto_)) for _mto_ in mto ), msubject, mbody)
40
41 print("Email body:\n")
42 print(fullmsg)
43 print("Email sent to:")
44
45 try :
46 con = smtplib.SMTP(mserver)
47 print("\t- %s"% (mto))
48 con.sendmail(mfrom, mto, fullmsg)
49 con.quit()
50 except OSError as e:
51 print("ERROR: Failed sending email notification\n",e)
52 exit(e.errno)
53
54
55
56if __name__ == '__main__':
57
58 import argparse
59 parser = argparse.ArgumentParser(prog='python -m TRT_CalibAlgs.TRTCalibrationMessage',
60 description="""Email notification for ART test - R-t TRT calibration.\n\n
61 Example: python -m TRT_CalibAlgs.TRTCalibrationMessage --ACCU [status]...""")
62
63 parser.add_argument('--ACCU' ,type=int, help="Stores the status of the job")
64 parser.add_argument('--MERGE' ,type=int, help="Stores the status of the job")
65 args = parser.parse_args()
66
68
69 sys.exit(0)
70
void print(char *figname, TCanvas *c1)