2 Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
4 import sys, os, smtplib
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")
13 if AtlasBuildBranch !=
"24.0" and AtlasBuildBranch !=
"main":
14 print(
"AtlasBuildBranch not 24.0 or main. Exiting.")
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)
24 if jobStatus.ACCU != 0
or jobStatus.MERGE != 0:
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")
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 +=
" You can check the results in https://atlas-art-data.web.cern.ch/atlas-art-data/local-output/\n"
35 mbody +=
" Outputs are in /eos/atlas/atlascerngroupdisk/data-art/local-output/%s/Athena/%s/%s/\n\n" % (AtlasBuildBranch,AthenaPlatform,Atlasbuild)
37 mbody +=
"\tYour amazing TRT Calibration test"
39 fullmsg =
"To: %s\nSubject: %s\n\n%s" % (
"".
join((
"%s," %
str(_mto_))
for _mto_
in mto ), msubject, mbody)
41 print(
"Email body:\n")
43 print(
"Email sent to:")
46 con = smtplib.SMTP(mserver)
47 print(
"\t- %s"% (mto))
48 con.sendmail(mfrom, mto, fullmsg)
51 print(
"ERROR: Failed sending email notification\n",e)
56 if __name__ ==
'__main__':
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]...""")
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()