Skip to content

Commit

Permalink
log error and use default if template for mail is not found
Browse files Browse the repository at this point in the history
  • Loading branch information
osallou committed Jun 26, 2020
1 parent acf9456 commit 98689f9
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 6 deletions.
3 changes: 2 additions & 1 deletion CHANGES.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
3.1.18 [UNRELEASED]:
3.1.18:
If multiple files match release.file, take most recent one
If mail template not found, log and use default
3.1.17:
Fix regression when saving file with a differe,t structure such as xxx/(FASTA)/(file.txt) to save under FASTA/file.txt
Send removal mail for --remove-all option
Expand Down
14 changes: 10 additions & 4 deletions biomaj/notify.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,11 @@ def notifyBankAction(bank, with_log=True, with_msg=''):
'remove': bank.session.get('remove')
}

if bank.config.get('mail.template.subject', default=None):
template_file = bank.config.get('mail.template.subject')
template_file = bank.config.get('mail.template.subject', default=None)
if template_file and not os.path.exists(template_file):
logging.error('Template file not found: %s' % template_file)
template_file = None
if template_file:
template = None
with open(template_file) as file_:
template = Template(file_.read())
Expand All @@ -108,8 +111,11 @@ def notifyBankAction(bank, with_log=True, with_msg=''):
else:
msg['Subject'] = 'BANK[' + bank.name + '] - STATUS[' + str(bank.session.get_status(Workflow.FLOW_OVER)) + '] - UPDATE[' + str(bank.session.get('update')) + '] - REMOVE[' + str(bank.session.get('remove')) + ']' + ' - RELEASE[' + str(bank.session.get('release')) + ']'

if bank.config.get('mail.template.body', default=None):
template_file = bank.config.get('mail.template.body')
template_file = bank.config.get('mail.template.body', None)
if template_file and not os.path.exists(template_file):
logging.error('Template file not found: %s' % template_file)
template_file = None
if template_file:
template = None
with open(template_file) as file_:
template = Template(file_.read())
Expand Down
3 changes: 2 additions & 1 deletion biomaj/workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -753,6 +753,7 @@ def wf_release(self):
return False

release_downloader.match([cf.get('release.file')], file_list, dir_list)

if len(release_downloader.files_to_download) == 0:
logging.error('release.file defined but does not match any file')
self._close_download_service(dserv)
Expand All @@ -768,7 +769,7 @@ def wf_release(self):
else:
rel = re.search(cf.get('release.file'), release_downloader.files_to_download[0]['name'])
if rel is None:
logging.error('release.file defined but does not match any file')
logging.error('release.file defined but could not match any file')
self._close_download_service(dserv)
return False
release = rel.group(1)
Expand Down

0 comments on commit 98689f9

Please sign in to comment.