mirror of
https://github.com/sunnypilot/sunnypilot.git
synced 2026-02-20 00:03:54 +08:00
* device side of statsd * need to start it * enable in manager * add sleep * cleanup * remove aggregates for now and standardize on industry terms * manager needs main * need to have a try/except * atomic_write_on_fs_tmp does not work * cleaner * use dump Co-authored-by: Willem Melching <willem.melching@gmail.com> * one file at a time * limit amount of files * move to influx line protocol and cleanup * needs to be a list * fix timezone bug * actually rate limit * add to release * normalized origin * also log deviceType * more stats Co-authored-by: Willem Melching <willem.melching@gmail.com>
42 lines
935 B
Python
42 lines
935 B
Python
import os
|
|
from pathlib import Path
|
|
from selfdrive.hardware import PC
|
|
|
|
if os.environ.get('LOG_ROOT', False):
|
|
ROOT = os.environ['LOG_ROOT']
|
|
elif PC:
|
|
ROOT = os.path.join(str(Path.home()), ".comma", "media", "0", "realdata")
|
|
else:
|
|
ROOT = '/data/media/0/realdata/'
|
|
|
|
|
|
CAMERA_FPS = 20
|
|
SEGMENT_LENGTH = 60
|
|
|
|
STATS_DIR_FILE_LIMIT = 10000
|
|
STATS_SOCKET = "ipc:///tmp/stats"
|
|
if PC:
|
|
STATS_DIR = os.path.join(str(Path.home()), ".comma", "stats")
|
|
else:
|
|
STATS_DIR = "/data/stats/"
|
|
STATS_FLUSH_TIME_S = 60
|
|
|
|
def get_available_percent(default=None):
|
|
try:
|
|
statvfs = os.statvfs(ROOT)
|
|
available_percent = 100.0 * statvfs.f_bavail / statvfs.f_blocks
|
|
except OSError:
|
|
available_percent = default
|
|
|
|
return available_percent
|
|
|
|
|
|
def get_available_bytes(default=None):
|
|
try:
|
|
statvfs = os.statvfs(ROOT)
|
|
available_bytes = statvfs.f_bavail * statvfs.f_frsize
|
|
except OSError:
|
|
available_bytes = default
|
|
|
|
return available_bytes
|