System: cleanup paths to use a common class (#29816)
* use OP prefix for logmessage
* cleanup paths too
* cleanup the paths too
* add hw.py to release
* fix those issues
* fix unittests
* fix unittests
* fix unittests
* do swaglog_ipc properly across all the files
* fix that
* fix swaglog in c++
* review suggestions
old-commit-hash: bfe990b112
test-msgs
parent
2716ef3a23
commit
c7029ea15a
25 changed files with 129 additions and 118 deletions
@ -0,0 +1,29 @@ |
|||||||
|
import os |
||||||
|
from pathlib import Path |
||||||
|
|
||||||
|
from openpilot.selfdrive.hardware import PC |
||||||
|
|
||||||
|
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", "") |
@ -1,8 +1,8 @@ |
|||||||
import os |
import os |
||||||
|
from openpilot.system.hardware.hw import Paths |
||||||
from openpilot.system.loggerd.uploader import UPLOAD_ATTR_NAME, UPLOAD_ATTR_VALUE |
from openpilot.system.loggerd.uploader import UPLOAD_ATTR_NAME, UPLOAD_ATTR_VALUE |
||||||
|
|
||||||
from openpilot.system.loggerd.config import ROOT |
for folder in os.walk(Paths.log_root()): |
||||||
for folder in os.walk(ROOT): |
|
||||||
for file1 in folder[2]: |
for file1 in folder[2]: |
||||||
full_path = os.path.join(folder[0], file1) |
full_path = os.path.join(folder[0], file1) |
||||||
os.setxattr(full_path, UPLOAD_ATTR_NAME, UPLOAD_ATTR_VALUE) |
os.setxattr(full_path, UPLOAD_ATTR_NAME, UPLOAD_ATTR_VALUE) |
||||||
|
Loading…
Reference in new issue