about summary refs log tree commit diff
path: root/src/ci/scripts/free_disk_space_windows_util.py
blob: 488187864c2f81486136a21d121e3ddbf72e1301 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
"""
Utilities for Windows disk space cleanup scripts.
"""

import os
from pathlib import Path
import sys


def get_temp_dir() -> Path:
    """Get the temporary directory set by GitHub Actions."""
    return Path(os.environ.get("RUNNER_TEMP"))


def get_pid_file() -> Path:
    return get_temp_dir() / "free-disk-space.pid"


def get_log_file() -> Path:
    return get_temp_dir() / "free-disk-space.log"


def run_main(main_fn):
    exit_code = 1
    try:
        exit_code = main_fn()
    except Exception as e:
        print(f"::error::{e}")
    sys.exit(exit_code)