mirror of
https://github.com/sunnypilot/sunnypilot.git
synced 2026-07-23 01:22:04 +08:00
a43fc920b5
# Conflicts: # .github/workflows/prebuilt.yaml # common/api.py # common/params_keys.h # opendbc_repo # selfdrive/controls/controlsd.py # selfdrive/controls/lib/desire_helper.py # selfdrive/modeld/modeld.py # selfdrive/ui/mici/layouts/settings/device.py # selfdrive/ui/soundd.py # system/athena/athenad.py # system/athena/registration.py # system/hardware/hardwared.py # system/loggerd/deleter.py # system/manager/manager.py # system/manager/process_config.py # system/sentry.py # system/updated/updated.py # tinygrad_repo # tools/scripts/uiview.py
35 lines
827 B
Python
35 lines
827 B
Python
import os
|
|
from openpilot.common.hardware.hw import Paths
|
|
|
|
|
|
CAMERA_FPS = 20
|
|
SEGMENT_LENGTH = 60
|
|
|
|
STATS_DIR_FILE_LIMIT = 10000
|
|
STATS_SOCKET = "ipc:///tmp/stats"
|
|
STATS_FLUSH_TIME_S = 60
|
|
|
|
PATH_DICT = {
|
|
"internal": Paths.log_root(),
|
|
"external": Paths.log_root_external()
|
|
}
|
|
|
|
def get_available_percent(default: float, path_type="internal") -> float:
|
|
try:
|
|
statvfs = os.statvfs(PATH_DICT[path_type])
|
|
available_percent = 100.0 * statvfs.f_bavail / statvfs.f_blocks
|
|
except (OSError, KeyError):
|
|
available_percent = default
|
|
|
|
return available_percent
|
|
|
|
|
|
def get_available_bytes(default: int, path_type="internal") -> int:
|
|
try:
|
|
statvfs = os.statvfs(PATH_DICT[path_type])
|
|
available_bytes = statvfs.f_bavail * statvfs.f_frsize
|
|
except (OSError, KeyError):
|
|
available_bytes = default
|
|
|
|
return available_bytes
|