Skip to content
Snippets Groups Projects
Commit 073718ba authored by Jorrit Schaap's avatar Jorrit Schaap
Browse files

Task #11385: mail to seperate to/bcc adresses. only mention 'could not find...

Task #11385: mail to seperate to/bcc adresses. only mention 'could not find mail adresses' remark in successful mails
parent 8a661658
No related branches found
No related tags found
No related merge requests found
...@@ -24,7 +24,7 @@ from lofar.lta.ingest.common.job import * ...@@ -24,7 +24,7 @@ from lofar.lta.ingest.common.job import *
from lofar.lta.ingest.common.config import DEFAULT_INGEST_NOTIFICATION_BUSNAME, DEFAULT_INGEST_NOTIFICATION_PREFIX from lofar.lta.ingest.common.config import DEFAULT_INGEST_NOTIFICATION_BUSNAME, DEFAULT_INGEST_NOTIFICATION_PREFIX
from lofar.lta.ingest.server.config import DEFAULT_INGEST_BUSNAME, DEFAULT_INGEST_SERVICENAME from lofar.lta.ingest.server.config import DEFAULT_INGEST_BUSNAME, DEFAULT_INGEST_SERVICENAME
from lofar.lta.ingest.common.config import DEFAULT_BROKER from lofar.lta.ingest.common.config import DEFAULT_BROKER
from lofar.lta.ingest.server.config import JOBS_DIR, MAX_NR_OF_RETRIES, FINISHED_NOTIFICATION_MAILING_LIST, DEFAULT_JOB_PRIORITY from lofar.lta.ingest.server.config import JOBS_DIR, MAX_NR_OF_RETRIES, FINISHED_NOTIFICATION_MAILING_LIST, FINISHED_NOTIFICATION_BCC_MAILING_LIST, DEFAULT_JOB_PRIORITY
from lofar.lta.ingest.server.config import DEFAULT_JOBMANAGER_NOTIFICATION_QUEUENAME from lofar.lta.ingest.server.config import DEFAULT_JOBMANAGER_NOTIFICATION_QUEUENAME
from lofar.lta.ingest.server.config import DEFAULT_INGEST_JOBS_QUEUENAME, DEFAULT_INGEST_JOBS_FOR_TRANSER_QUEUENAME from lofar.lta.ingest.server.config import DEFAULT_INGEST_JOBS_QUEUENAME, DEFAULT_INGEST_JOBS_FOR_TRANSER_QUEUENAME
from lofar.messaging import CommandMessage, EventMessage, FromBus, ToBus from lofar.messaging import CommandMessage, EventMessage, FromBus, ToBus
...@@ -1082,8 +1082,8 @@ Total Files: %(total)i ...@@ -1082,8 +1082,8 @@ Total Files: %(total)i
if project_details and 'author_email' in project_details: if project_details and 'author_email' in project_details:
extra_mail_addresses.append(project_details['author_email']) extra_mail_addresses.append(project_details['author_email'])
if not extra_mail_addresses: if not extra_mail_addresses:
report += '\n\nCould not find any PI\'s/Contact-author\'s email address in MoM to sent this email to.' report += '\n\nCould not find any PI\'s/Contact-author\'s email address in MoM to sent this email to.'
except Exception as e: except Exception as e:
msg = 'error while trying to get PI\'s/Contact-author\'s email address for %s: %s' % (job_group_id, e) msg = 'error while trying to get PI\'s/Contact-author\'s email address for %s: %s' % (job_group_id, e)
...@@ -1100,7 +1100,8 @@ Total Files: %(total)i ...@@ -1100,7 +1100,8 @@ Total Files: %(total)i
mailing_list += submitters + extra_mail_addresses mailing_list += submitters + extra_mail_addresses
if mailing_list: if mailing_list:
# make it a csv list of addresses # make it a csv list of addresses
mailing_list = ','.join(mailing_list) mailing_list_csv = ','.join(mailing_list)
bcc_mailing_list_csv = ','.join(FINISHED_NOTIFICATION_BCC_MAILING_LIST)
projects = set([j['Project'] for j in done_group_jobs if 'Project' in j]) projects = set([j['Project'] for j in done_group_jobs if 'Project' in j])
subject = "Ingest Export job %s of project %s " % (job_group_id, '/'.join(projects)) subject = "Ingest Export job %s of project %s " % (job_group_id, '/'.join(projects))
...@@ -1116,7 +1117,10 @@ Total Files: %(total)i ...@@ -1116,7 +1117,10 @@ Total Files: %(total)i
len(done_group_jads), len(done_group_jads),
100.0 * len(unfinished_group_jads) / len(done_group_jads)) 100.0 * len(unfinished_group_jads) / len(done_group_jads))
if os.system('echo "%s"|mailx -s "%s" %s' % (report, subject, mailing_list)) == 0: if os.system('echo "%s"|mailx -s "%s" %s %s' % (report,
subject,
'-b ' + bcc_mailing_list_csv if bcc_mailing_list_csv else '',
mailing_list_csv)) == 0:
logger.info('sent notification email for export job %s to %s', job_group_id, mailing_list) logger.info('sent notification email for export job %s to %s', job_group_id, mailing_list)
else: else:
logger.error('failed sending a notification email for export job %s to %s', job_group_id, mailing_list) logger.error('failed sending a notification email for export job %s to %s', job_group_id, mailing_list)
......
...@@ -32,7 +32,11 @@ GLOBUS_TIMEOUT = 1800 ...@@ -32,7 +32,11 @@ GLOBUS_TIMEOUT = 1800
TRANSFER_TIMEOUT = 300 TRANSFER_TIMEOUT = 300
FINISHED_NOTIFICATION_MAILING_LIST=['schaap@astron.nl','softwaresupport@astron.nl'] FINISHED_NOTIFICATION_MAILING_LIST = []
if isProductionEnvironment(): if isProductionEnvironment():
FINISHED_NOTIFICATION_MAILING_LIST += ['observer@astron.nl','sos@astron.nl'] FINISHED_NOTIFICATION_MAILING_LIST += ['sos@astron.nl']
FINISHED_NOTIFICATION_BCC_MAILING_LIST=['schaap@astron.nl','softwaresupport@astron.nl']
if isProductionEnvironment():
FINISHED_NOTIFICATION_BCC_MAILING_LIST += ['observer@astron.nl']
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment