From f62adc230ba3f7ce3071edc1d190bde3c42c38eb Mon Sep 17 00:00:00 2001 From: Paolo Tormene Date: Tue, 26 Sep 2023 10:43:27 +0200 Subject: [PATCH] Fix path of email files to work also on Windows --- openquake/server/settings.py | 3 ++- openquake/server/tests/test_aelo_mode.py | 4 +++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/openquake/server/settings.py b/openquake/server/settings.py index b2ed55908cb7..b7fe1c42edc6 100644 --- a/openquake/server/settings.py +++ b/openquake/server/settings.py @@ -20,6 +20,7 @@ import os import socket import getpass +import tempfile from openquake.baselib import config from openquake.commonlib import datastore @@ -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 diff --git a/openquake/server/tests/test_aelo_mode.py b/openquake/server/tests/test_aelo_mode.py index 317ea5df3c04..31255cfac88f 100644 --- a/openquake/server/tests/test_aelo_mode.py +++ b/openquake/server/tests/test_aelo_mode.py @@ -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()