2025-01-02 15:05:06 +00:00
|
|
|
# © Crown-owned copyright 2025, Defence Science and Technology Laboratory UK
|
2023-06-30 09:08:13 +01:00
|
|
|
import tempfile
|
|
|
|
|
from datetime import datetime
|
|
|
|
|
from pathlib import Path
|
2023-07-06 11:35:44 +01:00
|
|
|
from uuid import uuid4
|
2023-06-30 09:08:13 +01:00
|
|
|
|
|
|
|
|
from primaite import getLogger
|
|
|
|
|
|
|
|
|
|
_LOGGER = getLogger(__name__)
|
|
|
|
|
|
|
|
|
|
|
2023-11-16 15:11:03 +00:00
|
|
|
def temp_user_sessions_path() -> Path:
|
2023-06-30 09:08:13 +01:00
|
|
|
"""
|
|
|
|
|
Get a temp directory session path the test session will output to.
|
|
|
|
|
|
|
|
|
|
:param session_timestamp: This is the datetime that the session started.
|
|
|
|
|
:return: The session directory path.
|
|
|
|
|
"""
|
2023-07-06 11:35:44 +01:00
|
|
|
session_path = Path(tempfile.gettempdir()) / "primaite" / str(uuid4())
|
2023-06-30 09:08:13 +01:00
|
|
|
session_path.mkdir(exist_ok=True, parents=True)
|
|
|
|
|
_LOGGER.debug(f"Created temp session directory: {session_path}")
|
|
|
|
|
return session_path
|