mirror of
https://github.com/sunnypilot/sunnypilot.git
synced 2026-08-21 07:03:44 +08:00
ab6d192714
* init * some fixes * move * more * old navd helpers * bring back cereal * fix linting * more * add to cereal first * sp events * lint * implement in long plan * fixme-sp * refactor state machine * wrong state * start refactor controller * some type hints * init these * enable debug print * ui? ui! * print them out * fix spinner import * fix path * let's use gps chips directly for now * service missing * publish events * no nav for now * need to sub * no car state speed yet * missed event * Car: `CarStateSP` * fix tests * bring back car state speed limit * fix * use old controller for now * fix * fix source * type hints * none for now * formatting * more * create directory if does not exist * mypy my bt * policy param catch exceptions * handle all params with exceptions * more * single method * define types in init * rename * simpler op enabled check * more mypy stuff * rename * no need for brake pressed * don't reset if gas pressed * type hint all * type hint all * back to upstream * in another pr * no longer need data type * qlog * slc in another pr * use horizontal accuracy * set core affinity for all realtime processes * unused * sort * unused * type hint and slight cleanup * from old implementation * use directly * combine pm * slight more cleanup * type hints * even more type hint * lint * more cleanup * even less * license
88 lines
2.1 KiB
Python
88 lines
2.1 KiB
Python
import os
|
|
import platform
|
|
from pathlib import Path
|
|
|
|
from openpilot.system.hardware import PC
|
|
|
|
DEFAULT_DOWNLOAD_CACHE_ROOT = "/tmp/comma_download_cache"
|
|
|
|
class Paths:
|
|
@staticmethod
|
|
def comma_home() -> str:
|
|
return os.path.join(str(Path.home()), ".comma" + os.environ.get("OPENPILOT_PREFIX", ""))
|
|
|
|
@staticmethod
|
|
def log_root() -> str:
|
|
if os.environ.get('LOG_ROOT', False):
|
|
return os.environ['LOG_ROOT']
|
|
elif PC:
|
|
return str(Path(Paths.comma_home()) / "media" / "0" / "realdata")
|
|
else:
|
|
return '/data/media/0/realdata/'
|
|
|
|
@staticmethod
|
|
def swaglog_root() -> str:
|
|
if PC:
|
|
return os.path.join(Paths.comma_home(), "log")
|
|
else:
|
|
return "/data/log/"
|
|
|
|
@staticmethod
|
|
def swaglog_ipc() -> str:
|
|
return "ipc:///tmp/logmessage" + os.environ.get("OPENPILOT_PREFIX", "")
|
|
|
|
@staticmethod
|
|
def download_cache_root() -> str:
|
|
if os.environ.get('COMMA_CACHE', False):
|
|
return os.environ['COMMA_CACHE'] + "/"
|
|
return DEFAULT_DOWNLOAD_CACHE_ROOT + os.environ.get("OPENPILOT_PREFIX", "") + "/"
|
|
|
|
@staticmethod
|
|
def persist_root() -> str:
|
|
if PC:
|
|
return os.path.join(Paths.comma_home(), "persist")
|
|
else:
|
|
return "/persist/"
|
|
|
|
@staticmethod
|
|
def stats_root() -> str:
|
|
if PC:
|
|
return str(Path(Paths.comma_home()) / "stats")
|
|
else:
|
|
return "/data/stats/"
|
|
|
|
@staticmethod
|
|
def config_root() -> str:
|
|
if PC:
|
|
return Paths.comma_home()
|
|
else:
|
|
return "/tmp/.comma"
|
|
|
|
@staticmethod
|
|
def shm_path() -> str:
|
|
if PC and platform.system() == "Darwin":
|
|
return "/tmp" # This is not really shared memory on macOS, but it's the closest we can get
|
|
return "/dev/shm"
|
|
|
|
@staticmethod
|
|
def model_root() -> str:
|
|
if PC:
|
|
return str(Path(Paths.comma_home()) / "media" / "0" / "models")
|
|
else:
|
|
return "/data/media/0/models"
|
|
|
|
@staticmethod
|
|
def crash_log_root() -> str:
|
|
if PC:
|
|
return str(Path(Paths.comma_home()) / "community" / "crashes")
|
|
else:
|
|
return "/data/community/crashes"
|
|
|
|
|
|
@staticmethod
|
|
def mapd_root() -> str:
|
|
if PC:
|
|
return str(Path(Paths.comma_home()) / "media" / "0" / "osm")
|
|
else:
|
|
return "/data/media/0/osm"
|