"""
utility functions for garmindb-mtb-dashboard
"""

import os
import sys

from pathlib import Path

def is_running_in_docker():
    """
    Checks if the current process is running inside a Docker container.
    """
    cgroup = Path('/proc/self/cgroup')
    return Path('/.dockerenv').is_file() or cgroup.is_file() and 'docker' in cgroup.read_text()

def get_correct_csv_file():
    if is_running_in_docker():
        sys.stderr.write("Running in a Docker container\n")
        return('/root/HealthData/garmin_bike.csv')
    else:
        sys.stderr.write("NOT Running in a Docker container\n" + os.getcwd() + "\n")
        return('./HealthData/garmin_bike.csv')
