|
@@ -2,7 +2,8 @@
|
|
|
utility functions for garmindb-mtb-dashboard
|
|
utility functions for garmindb-mtb-dashboard
|
|
|
"""
|
|
"""
|
|
|
|
|
|
|
|
-# import sys
|
|
|
|
|
|
|
+import os
|
|
|
|
|
+import sys
|
|
|
|
|
|
|
|
from pathlib import Path
|
|
from pathlib import Path
|
|
|
|
|
|
|
@@ -13,20 +14,10 @@ def is_running_in_docker():
|
|
|
cgroup = Path('/proc/self/cgroup')
|
|
cgroup = Path('/proc/self/cgroup')
|
|
|
return Path('/.dockerenv').is_file() or cgroup.is_file() and 'docker' in cgroup.read_text()
|
|
return Path('/.dockerenv').is_file() or cgroup.is_file() and 'docker' in cgroup.read_text()
|
|
|
|
|
|
|
|
-# def is_running_in_docker():
|
|
|
|
|
-# """
|
|
|
|
|
-# Checks if the current process is running inside a Docker container.
|
|
|
|
|
-# """
|
|
|
|
|
-# try:
|
|
|
|
|
-# with open('/proc/1/cgroup', 'r') as f:
|
|
|
|
|
-# cgroup = f.read()
|
|
|
|
|
-# return 'docker' in cgroup
|
|
|
|
|
-# except FileNotFoundError:
|
|
|
|
|
-# return False
|
|
|
|
|
-
|
|
|
|
|
- # if is_running_in_docker():
|
|
|
|
|
- # sys.stderr.write("Running in a Docker container\n")
|
|
|
|
|
- # csv_file = '/root/HealthData/garmin_bike.csv'
|
|
|
|
|
- # else:
|
|
|
|
|
- # sys.stderr.write("NOT Running in a Docker container\n" + os.getcwd() + "\n")
|
|
|
|
|
- # csv_file = './HealthData/garmin_bike.csv'
|
|
|
|
|
|
|
+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')
|