Skip to content

Commit

Permalink
Merge pull request #9037 from gem/app-messages-dir
Browse files Browse the repository at this point in the history
Fix path of email files to work also on Windows
  • Loading branch information
ptormene authored Sep 26, 2023
2 parents 560bc91 + f62adc2 commit 6b94e8d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
3 changes: 2 additions & 1 deletion openquake/server/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import os
import socket
import getpass
import tempfile

from openquake.baselib import config
from openquake.commonlib import datastore
Expand Down Expand Up @@ -221,7 +222,7 @@
# We should redefine it to a different directory for each test,
# in order to avoid concurrency issues in case tests run in
# parallel
EMAIL_FILE_PATH = '/tmp/app-messages'
EMAIL_FILE_PATH = os.path.join(tempfile.gettempdir(), 'app-messages')

if APPLICATION_MODE.upper() in ('RESTRICTED', 'AELO'):
LOCKDOWN = True
Expand Down
4 changes: 3 additions & 1 deletion openquake/server/tests/test_aelo_mode.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,9 @@ def aelo_run_then_remove(self, params, failure_reason=None):
# # FIXME: we should use the overridden EMAIL_FILE_PATH,
# # so email_dir would contain only one file
# email_file = os.listdir(email_dir)[0]
email_files = glob.glob('/tmp/app-messages/*')
app_msgs_dir = os.path.join(tempfile.gettempdir(),
'app-messages')
email_files = glob.glob(os.path.join(app_msgs_dir, '*'))
email_file = max(email_files, key=os.path.getctime)
with open(os.path.join(email_dir, email_file), 'r') as f:
email_content = f.read()
Expand Down

0 comments on commit 6b94e8d

Please sign in to comment.