Compare commits

..

165 Commits

Author SHA1 Message Date
royjr
e135051ca8 Merge branch 'master' into ccnc-port 2026-06-13 22:38:22 -04:00
royjr
12bef55d8a Update opendbc_repo 2026-06-13 22:12:00 -04:00
royjr
2f7a45e6c8 Merge branch 'master' into ccnc-port 2026-06-08 22:01:57 -04:00
royjr
936ebfc12b Update opendbc_repo 2026-06-08 22:01:44 -04:00
royjr
aa0c9dc0eb Merge branch 'master' into ccnc-port 2026-06-04 09:52:35 -04:00
royjr
7476a866e7 Update opendbc_repo 2026-06-04 09:52:06 -04:00
royjr
610d857e33 Merge branch 'master' into ccnc-port 2026-05-28 08:30:40 -04:00
royjr
d2f47407d0 Update opendbc_repo 2026-05-12 21:03:18 -04:00
royjr
db75ec76ea Merge branch 'master' into ccnc-port 2026-05-12 20:44:57 -04:00
royjr
24066465d7 Update opendbc_repo 2026-05-12 20:44:48 -04:00
royjr
a7abbd6e25 Update opendbc_repo 2026-04-20 18:22:12 -04:00
royjr
878982447c Merge branch 'master' into ccnc-port 2026-04-19 12:06:46 -04:00
royjr
576527a36b Merge branch 'master' into ccnc-port 2026-04-17 05:42:35 -04:00
royjr
ef8c35da24 Update opendbc_repo 2026-04-17 05:41:21 -04:00
royjr
85688b1040 Merge branch 'master' into ccnc-port 2026-04-16 19:48:39 -04:00
royjr
0fb2199130 Update opendbc_repo 2026-04-16 19:47:57 -04:00
royjr
d48d756c1d Update opendbc_repo 2026-04-08 00:56:54 -04:00
royjr
2ed298a0c9 Merge branch 'master' into ccnc-port 2026-04-08 00:51:13 -04:00
royjr
d68f038949 Update opendbc_repo 2026-04-08 00:51:11 -04:00
royjr
7231571e57 Merge branch 'master' into ccnc-port 2026-04-03 23:34:00 -04:00
royjr
b37f1419d3 Update opendbc_repo 2026-04-03 23:33:19 -04:00
royjr
cd85a66790 Merge branch 'master' into ccnc-port 2026-03-26 00:53:07 -04:00
royjr
305ea87daf Update opendbc_repo 2026-03-26 00:52:44 -04:00
royjr
4bbfc793e0 Merge branch 'master' into ccnc-port 2026-03-15 15:44:59 -04:00
royjr
d5d983676e Update opendbc_repo 2026-03-13 16:41:05 -04:00
royjr
de8a96a398 Merge branch 'master' into ccnc-port 2026-03-13 16:41:00 -04:00
royjr
0cbf45f699 Merge branch 'master' into ccnc-port 2026-03-11 23:28:59 -04:00
royjr
0d68a3a2ab Merge branch 'master' into ccnc-port 2026-03-09 19:58:32 -04:00
royjr
9e85a85059 Update opendbc_repo 2026-03-09 19:58:18 -04:00
royjr
0373c327c0 Update opendbc_repo 2026-03-02 10:10:38 -05:00
royjr
efe9e5c200 Update opendbc_repo 2026-03-02 02:15:05 -05:00
royjr
8a249a45dc Update opendbc_repo 2026-03-02 02:06:16 -05:00
royjr
bdbefe67f6 Update opendbc_repo 2026-03-02 01:40:31 -05:00
royjr
675bb166ad Merge branch 'master' into ccnc-port 2026-03-01 17:18:11 -05:00
royjr
1b717a7e88 Merge branch 'master' into ccnc-port 2026-03-01 13:23:30 -05:00
royjr
86f55a8ba9 Update opendbc_repo 2026-03-01 13:23:24 -05:00
royjr
629392d2f7 Update opendbc_repo 2026-02-27 16:31:59 -05:00
royjr
bc414bdc8b Update opendbc_repo 2026-02-26 23:53:26 -05:00
royjr
7ca5649f2c Merge branch 'master' into ccnc-port 2026-02-26 23:52:46 -05:00
royjr
641ee8fa87 Update opendbc_repo 2026-02-26 23:52:27 -05:00
royjr
56c276158c Merge branch 'master' into ccnc-port 2026-02-24 14:12:12 -05:00
royjr
c65308a8bd Update opendbc_repo 2026-02-24 14:12:01 -05:00
royjr
994e526460 Merge branch 'master' into ccnc-port 2026-02-18 12:06:05 -05:00
royjr
1defae36b7 Update opendbc_repo 2026-02-18 12:05:53 -05:00
royjr
8f029fd0ef Merge branch 'master' into ccnc-port 2026-02-13 23:01:41 -05:00
royjr
ddb46284dc Update opendbc_repo 2026-02-13 23:01:16 -05:00
royjr
9effc754d9 Merge branch 'master' into ccnc-port 2026-02-06 01:16:06 -05:00
royjr
e49ffc2a2d Update opendbc_repo 2026-02-06 01:15:59 -05:00
royjr
2cacd0b3e5 Merge branch 'master' into ccnc-port 2026-01-24 12:50:18 -05:00
royjr
c4b8859dff Update opendbc_repo 2026-01-24 12:50:11 -05:00
royjr
8fb0953205 Merge branch 'master' into ccnc-port 2026-01-11 22:17:38 -05:00
royjr
63d1c8835f Merge branch 'master' into ccnc-port 2026-01-10 13:03:48 -05:00
royjr
17a185606d Merge branch 'master' into ccnc-port 2026-01-09 16:40:32 -05:00
royjr
da10131392 Merge branch 'master' into ccnc-port 2025-12-28 17:18:51 -05:00
royjr
7107c2ba14 Merge branch 'master' into ccnc-port 2025-12-23 12:13:48 -05:00
royjr
95b6e877ac Update opendbc_repo 2025-12-23 12:13:29 -05:00
royjr
eb02c6570e Update opendbc_repo 2025-12-21 15:43:04 -05:00
royjr
1be8ae31c4 Merge branch 'master' into ccnc-port 2025-12-19 01:04:42 -05:00
royjr
04dcd38856 Update opendbc_repo 2025-12-19 01:04:30 -05:00
royjr
22ccf0d72f Merge branch 'master' into ccnc-port 2025-12-15 17:02:50 -05:00
royjr
3c969bb627 Merge branch 'master' into ccnc-port 2025-12-13 23:22:22 -05:00
royjr
20f8011feb Update opendbc_repo 2025-12-13 23:22:11 -05:00
royjr
9cf17e74a1 Merge branch 'master' into ccnc-port 2025-12-12 23:19:56 -05:00
royjr
2c4efdf557 Merge branch 'master' into ccnc-port 2025-12-07 13:29:48 -05:00
royjr
4cd3d3c16c Merge branch 'master' into ccnc-port 2025-12-02 12:56:21 -05:00
royjr
637f3ae9c8 Merge branch 'master' into ccnc-port 2025-12-01 14:41:03 -05:00
royjr
464ee80f71 Merge branch 'master' into ccnc-port 2025-11-26 00:27:53 -05:00
royjr
2743a04613 Merge branch 'master' into ccnc-port 2025-11-24 18:44:13 -05:00
royjr
7f9978d001 Merge branch 'master' into ccnc-port 2025-11-22 00:21:15 -05:00
royjr
4b83961c67 Merge branch 'master' into ccnc-port 2025-11-21 16:23:22 -05:00
royjr
c00eaf428a Update opendbc_repo 2025-11-21 16:23:01 -05:00
royjr
0a9993e8d4 Merge branch 'master' into ccnc-port 2025-11-19 16:49:59 -05:00
royjr
0af214a985 Update opendbc_repo 2025-11-19 16:49:51 -05:00
royjr
af43385e3a Merge branch 'master' into ccnc-port 2025-11-11 10:19:51 -05:00
royjr
0ab2b8c590 Update opendbc_repo 2025-11-07 19:59:50 -05:00
royjr
67ab18a0de Merge branch 'master' into ccnc-port 2025-11-07 19:23:51 -05:00
royjr
e87dc15b30 Update opendbc_repo 2025-11-07 19:23:37 -05:00
royjr
192d08516c Merge branch 'master' into ccnc-port 2025-11-02 19:23:00 -05:00
royjr
3cf001c59c Update opendbc_repo 2025-11-02 19:22:49 -05:00
royjr
f2ccd021da Merge branch 'master' into ccnc-port 2025-11-02 14:07:54 -05:00
royjr
c9fc900f64 Update opendbc_repo 2025-11-02 14:07:44 -05:00
royjr
3c37c5ce5d Update opendbc_repo 2025-10-30 11:28:49 -04:00
royjr
7c45889e4e Merge branch 'master' into ccnc-port 2025-10-30 11:27:50 -04:00
royjr
2aabb7aee8 Merge branch 'master' into ccnc-port 2025-10-24 14:16:09 -04:00
royjr
3859e9962f Update opendbc_repo 2025-10-24 14:15:51 -04:00
royjr
810efbab72 Merge branch 'master' into ccnc-port 2025-10-18 07:33:11 -04:00
royjr
ec27bec326 Update opendbc_repo 2025-10-18 07:32:33 -04:00
royjr
250d553157 Merge branch 'master' into ccnc-port 2025-10-14 21:57:32 -04:00
royjr
cea54a0ca8 Update opendbc_repo 2025-10-14 21:57:26 -04:00
royjr
8e72d783bd Update opendbc_repo 2025-10-13 22:41:21 -04:00
royjr
1b0dc103dc Merge branch 'master' into ccnc-port 2025-10-11 23:51:46 -04:00
royjr
6c364d292b Update opendbc_repo 2025-10-11 23:51:31 -04:00
royjr
bcdec2ce84 Merge branch 'master' into ccnc-port 2025-10-10 17:29:05 -04:00
royjr
3deaeb3759 Merge branch 'master' into ccnc-port 2025-10-10 15:02:32 -04:00
royjr
c669f0984a Update opendbc_repo 2025-10-10 15:02:17 -04:00
royjr
46dd946740 Merge branch 'master' into ccnc-port 2025-10-07 01:36:06 -04:00
royjr
9da4b3653e Update opendbc_repo 2025-10-07 01:35:58 -04:00
royjr
4e21ae7c50 Update opendbc_repo 2025-10-05 06:21:56 -04:00
royjr
bb91e92237 Update opendbc_repo 2025-10-05 06:01:15 -04:00
royjr
14b4c4f85b Update opendbc_repo 2025-10-02 09:20:32 -04:00
royjr
0660b542c3 Merge branch 'master' into ccnc-port 2025-10-01 16:01:32 -04:00
royjr
2b893b90c9 Update opendbc_repo 2025-10-01 16:01:26 -04:00
royjr
f5139178ed Merge branch 'master' into ccnc-port 2025-09-30 14:39:57 -04:00
royjr
fb43b755f2 Update opendbc_repo 2025-09-30 14:39:50 -04:00
royjr
07f5b967d8 Merge branch 'master' into ccnc-port 2025-09-24 21:30:29 -04:00
royjr
ea19c7d3bb Update opendbc_repo 2025-09-24 21:30:17 -04:00
royjr
e461842cbb Merge branch 'master' into ccnc-port 2025-09-23 05:55:02 -04:00
royjr
a73c9659d5 Update opendbc_repo 2025-09-23 05:54:50 -04:00
royjr
cb796fbc76 Merge branch 'master' into ccnc-port 2025-09-18 20:10:43 -04:00
royjr
6bf75fc557 Update opendbc_repo 2025-09-18 20:10:37 -04:00
royjr
9a1fc28819 Merge branch 'master' into ccnc-port 2025-09-18 13:54:36 -04:00
royjr
0741d05e92 Update opendbc_repo 2025-09-18 13:54:23 -04:00
royjr
1ad008107d Merge branch 'master' into ccnc-port 2025-09-15 01:40:27 -04:00
royjr
feebd9df93 Reapply "UI: Developer UI (#1233)"
This reverts commit 15e5d2efb9.
2025-09-15 01:40:21 -04:00
royjr
c2e5ced3e5 Update opendbc_repo 2025-09-15 01:39:51 -04:00
royjr
15e5d2efb9 Revert "UI: Developer UI (#1233)"
This reverts commit 1bb4ca2547.
2025-09-12 02:10:29 -04:00
royjr
a3929d0b54 Merge branch 'master' into ccnc-port 2025-09-12 01:40:29 -04:00
royjr
794f8f9991 Update opendbc_repo 2025-09-08 09:27:31 -04:00
royjr
68fa5e3f21 Merge branch 'master' into ccnc-port 2025-09-07 13:13:37 -04:00
royjr
86c6cc1f48 Merge branch 'master' into ccnc-port 2025-09-03 22:22:12 -04:00
royjr
eb7ffbf093 Update opendbc_repo 2025-09-03 10:14:58 -04:00
royjr
3919095752 Update opendbc_repo 2025-09-03 10:05:35 -04:00
royjr
74d63be1c3 Merge branch 'master' into ccnc-port 2025-09-03 09:50:55 -04:00
royjr
8894486a1a Update opendbc_repo 2025-09-03 09:50:49 -04:00
royjr
810599315d Merge branch 'master' into ccnc-port 2025-08-31 16:53:30 -04:00
royjr
6f3ab810c8 Update opendbc_repo 2025-08-31 16:53:24 -04:00
royjr
230f78b8d3 Merge branch 'master' into ccnc-port 2025-08-26 12:14:46 -04:00
royjr
f1affec088 Update opendbc_repo 2025-08-26 12:14:22 -04:00
royjr
97d8ef242c Merge branch 'master' into ccnc-port 2025-08-24 15:12:57 -04:00
royjr
a63fff9b45 Update opendbc_repo 2025-08-24 15:12:46 -04:00
royjr
cb3893daaa Merge branch 'master' into ccnc-port 2025-08-23 10:33:24 -04:00
royjr
29f60df74b Merge branch 'master' into ccnc-port 2025-08-22 11:18:27 -04:00
royjr
c6c072e1f4 Update opendbc_repo 2025-08-22 11:18:18 -04:00
royjr
d101cbb83e Update opendbc_repo 2025-08-13 16:00:04 -04:00
royjr
1536d59633 Update opendbc_repo 2025-08-13 15:28:37 -04:00
royjr
dc99b865ae Merge branch 'master' into ccnc-port 2025-08-13 12:31:14 -04:00
royjr
e59bc027ff Merge branch 'master' into ccnc-port 2025-08-13 11:58:05 -04:00
royjr
cf7e5efaca Update opendbc_repo 2025-08-13 11:57:57 -04:00
royjr
4b44f2eb31 Merge branch 'master' into ccnc-port 2025-08-10 09:18:24 -04:00
royjr
107d2ab400 Update opendbc_repo 2025-08-10 09:18:15 -04:00
royjr
5432d9062c Merge branch 'master' into ccnc-port 2025-08-04 11:52:29 -04:00
royjr
f533f6c843 Merge branch 'master' into ccnc-port 2025-08-02 06:53:54 -04:00
royjr
58e9ac763c Update opendbc_repo 2025-08-02 06:53:43 -04:00
royjr
cb50d54169 Merge branch 'master-new' into ccnc-port 2025-07-24 20:23:46 -04:00
royjr
bd5de4ed0a Merge branch 'master-new' into ccnc-port 2025-07-20 23:49:36 -04:00
royjr
0d4073fadb Merge branch 'master-new' into ccnc-port 2025-07-19 23:18:26 -04:00
royjr
ebc70dcb52 Merge branch 'master-new' into ccnc-port 2025-07-19 14:37:17 -04:00
royjr
4d0426999e Update opendbc_repo 2025-07-19 14:36:59 -04:00
royjr
286da42573 Merge branch 'master-new' into ccnc-port 2025-07-16 23:48:23 -04:00
royjr
8a836710a9 Update opendbc_repo 2025-07-16 23:48:06 -04:00
royjr
5d515bcf33 Merge branch 'master-new' into ccnc-port 2025-07-07 05:35:55 -04:00
royjr
1c7f6d5133 Update opendbc_repo 2025-07-03 21:24:01 -04:00
royjr
05d57c7aeb Update opendbc_repo 2025-07-01 18:30:32 -04:00
royjr
e4b0eaf352 Update opendbc_repo 2025-06-28 19:30:28 -04:00
royjr
a710276472 Merge branch 'master-new' into ccnc-port 2025-06-28 19:22:59 -04:00
royjr
af086db671 Merge branch 'master-new' into ccnc-port 2025-06-28 12:13:26 -04:00
royjr
0d9eb0e25e Update opendbc_repo submodule to latest commit
Advanced the opendbc_repo submodule to commit d309f7ec96e37267c94d12fc4bfe2672ad505b06. This pulls in the latest changes from the opendbc repository.
2025-06-26 14:03:56 -04:00
royjr
0616caed6d Merge branch 'master-new' into ccnc-port 2025-06-25 19:33:53 -04:00
royjr
095337b3c1 Update opendbc_repo 2025-06-25 19:33:38 -04:00
royjr
1edec2d22c Update opendbc_repo 2025-06-14 16:14:02 -04:00
royjr
affabb9ee0 Update opendbc_repo 2025-06-14 15:55:07 -04:00
royjr
dc27e8711c Update opendbc_repo 2025-06-14 14:54:32 -04:00
royjr
cf7329a264 Merge branch 'master-new' into ccnc-port 2025-06-11 21:36:06 -04:00
royjr
5ee5ecd820 Merge branch 'master-new' into ccnc-port 2025-06-08 23:25:13 -04:00
royjr
b064f730dd Update opendbc_repo 2025-06-08 17:54:43 -04:00
3 changed files with 2 additions and 268 deletions

View File

@@ -20,7 +20,6 @@ from openpilot.system.ui.widgets.list_view import button_item
from openpilot.system.ui.sunnypilot.widgets.html_render import HtmlModalSP
from openpilot.system.ui.sunnypilot.widgets.list_view import toggle_item_sp
from openpilot.selfdrive.ui.sunnypilot.layouts.settings.external_storage import external_storage_item
PREBUILT_PATH = os.path.join(Paths.comma_home(), "prebuilt") if PC else "/data/openpilot/prebuilt"
@@ -53,11 +52,7 @@ class DeveloperLayoutSP(DeveloperLayout):
self.error_log_btn = button_item(tr("Error Log"), tr("VIEW"), tr("View the error log for sunnypilot crashes."), callback=self._on_error_log_clicked)
self.external_storage = external_storage_item(tr("External Storage"), description=tr("Extend your comma device's storage by inserting a USB drive " +
"into the aux port."))
self.items: list = [self.show_advanced_controls, self.enable_github_runner_toggle, self.enable_copyparty_toggle, self.prebuilt_toggle,
self.external_storage, self.error_log_btn,]
self.items: list = [self.show_advanced_controls, self.enable_github_runner_toggle, self.enable_copyparty_toggle, self.prebuilt_toggle, self.error_log_btn,]
@staticmethod
def _on_prebuilt_toggled(state):

View File

@@ -1,261 +0,0 @@
"""
Copyright (c) 2021-, Haibin Wen, sunnypilot, and a number of other contributors.
This file is part of sunnypilot and is licensed under the MIT License.
See the LICENSE.md file in the root directory for more details.
"""
import pyray as rl
import threading
import subprocess
import copy
from enum import Enum
from collections.abc import Callable
from openpilot.common.params import Params
from openpilot.system.hardware import PC
from openpilot.system.ui.lib.application import gui_app, FontWeight
from openpilot.system.ui.lib.text_measure import measure_text_cached
from openpilot.system.ui.lib.multilang import tr, tr_noop
from openpilot.system.ui.widgets import DialogResult
from openpilot.system.ui.widgets.button import Button, ButtonStyle
from openpilot.system.ui.widgets.confirm_dialog import alert_dialog, ConfirmDialog
from openpilot.system.ui.widgets.list_view import (
ItemAction,
ListItem,
BUTTON_HEIGHT,
BUTTON_BORDER_RADIUS,
BUTTON_FONT_SIZE,
BUTTON_WIDTH,
)
VALUE_FONT_SIZE = 48
class ExternalStorageState(Enum):
DISABLED = tr_noop("DISABLED")
LOADING = tr_noop("LOADING")
CHECK = tr_noop("CHECK")
MOUNT = tr_noop("MOUNT")
UNMOUNT = tr_noop("UNMOUNT")
FORMAT = tr_noop("FORMAT")
class ExternalStorageAction(ItemAction):
MAX_WIDTH = 500
def __init__(self):
super().__init__(self.MAX_WIDTH, True)
self._params = Params()
self._error_message = ""
self._text_font = gui_app.font(FontWeight.NORMAL)
self._button = Button(
"",
click_callback=self._handle_button_click,
button_style=ButtonStyle.LIST_ACTION,
border_radius=BUTTON_BORDER_RADIUS,
font_size=BUTTON_FONT_SIZE,
)
self._value_text = ""
self._formatting = False
self._refresh_pending = False
self._state = ExternalStorageState.CHECK
self._refresh_state()
self.refresh()
def set_touch_valid_callback(self, callback):
def wrapped():
if self._state == ExternalStorageState.DISABLED:
return False
return callback()
super().set_touch_valid_callback(wrapped)
self._button.set_touch_valid_callback(wrapped)
def _run(self, cmd: str) -> bool:
return subprocess.call(["sh", "-c", cmd]) == 0
def _run_output(self, cmd: str) -> str:
try:
out = subprocess.check_output(["sh", "-c", cmd], universal_newlines=True)
return out.strip()
except Exception:
return ""
def _render(self, rect: rl.Rectangle) -> bool:
if self._error_message:
msg = copy.copy(self._error_message)
gui_app.set_modal_overlay(alert_dialog(msg))
self._error_message = ""
if self._value_text:
text_size = measure_text_cached(self._text_font, self._value_text, VALUE_FONT_SIZE)
rl.draw_text_ex(
self._text_font,
self._value_text,
(rect.x + rect.width - BUTTON_WIDTH - text_size.x - 30,
rect.y + (rect.height - text_size.y) / 2),
VALUE_FONT_SIZE,
1.0,
rl.Color(170, 170, 170, 255),
)
button_rect = rl.Rectangle(
rect.x + rect.width - BUTTON_WIDTH,
rect.y + (rect.height - BUTTON_HEIGHT) / 2,
BUTTON_WIDTH,
BUTTON_HEIGHT
)
self._button.set_rect(button_rect)
self._button.set_text(tr(self._state.value))
self._button.set_enabled(self._state not in (ExternalStorageState.LOADING,
ExternalStorageState.DISABLED))
self._button.render(button_rect)
return False
def _refresh_state(self):
if PC:
self._state = ExternalStorageState.DISABLED
self._button.set_enabled(False)
self._value_text = ""
def debounced_refresh(self):
if self._refresh_pending:
return
self._refresh_pending = True
def _timer():
import time
time.sleep(0.25)
self._refresh_pending = False
self.refresh()
threading.Thread(target=_timer, daemon=True).start()
def refresh(self):
def _work():
is_mounted = self._run("findmnt -n /mnt/external_realdata")
has_drive = self._run("lsblk -f /dev/sdg")
has_fs = self._run("lsblk -f /dev/sdg1 | grep -q ext4")
has_label = self._run("blkid /dev/sdg1 | grep -q 'LABEL=\"openpilot\"'")
info = ""
if is_mounted and has_label:
info = self._run_output(
"df -h /mnt/external_realdata | awk 'NR==2 {print $3 \"/\" $2}'"
)
def apply():
if self._formatting:
self._value_text = tr("formatting")
self._state = ExternalStorageState.FORMAT
return
if not has_drive:
self._value_text = tr("insert drive")
self._state = ExternalStorageState.CHECK
elif not has_fs or not has_label:
self._value_text = tr("needs format")
self._state = ExternalStorageState.FORMAT
elif is_mounted:
self._value_text = info
self._state = ExternalStorageState.UNMOUNT
else:
self._value_text = tr("drive detected")
self._state = ExternalStorageState.MOUNT
apply()
threading.Thread(target=_work, daemon=True).start()
def _handle_button_click(self):
st = self._state
if st == ExternalStorageState.DISABLED:
return
if st in (ExternalStorageState.CHECK, ExternalStorageState.MOUNT):
self.mount_storage()
elif st == ExternalStorageState.UNMOUNT:
self.unmount_storage()
elif st == ExternalStorageState.FORMAT:
dialog = ConfirmDialog(
tr("Are you sure you want to format this drive? This will erase all data."),
confirm_text=tr("Format"),
cancel_text=tr("Cancel"),
)
gui_app.set_modal_overlay(dialog, callback=self._confirm_format)
def _confirm_format(self, result: DialogResult):
if result == DialogResult.CONFIRM:
self.format_storage()
def mount_storage(self):
self._value_text = tr("mounting")
self._state = ExternalStorageState.LOADING
def _work():
cmd = """
sudo mount -o remount,rw / &&
sudo mkdir -p /mnt/external_realdata &&
(grep -q '/dev/sdg1 /mnt/external_realdata' /etc/fstab ||
echo '/dev/sdg1 /mnt/external_realdata ext4 defaults,nofail 0 2' >> /etc/fstab) &&
sudo systemctl daemon-reexec &&
sudo mount /mnt/external_realdata &&
sudo chown -R comma:comma /mnt/external_realdata &&
sudo chmod -R 775 /mnt/external_realdata &&
sudo mount -o remount,ro /
"""
subprocess.call(["sh", "-c", cmd])
self.debounced_refresh()
threading.Thread(target=_work, daemon=True).start()
def unmount_storage(self):
self._value_text = tr("unmounting")
self._state = ExternalStorageState.LOADING
def _work():
subprocess.call(["sh", "-c", "sudo umount /mnt/external_realdata"])
self.debounced_refresh()
threading.Thread(target=_work, daemon=True).start()
def format_storage(self):
self._formatting = True
self._value_text = tr("formatting")
self._state = ExternalStorageState.LOADING
def _work():
cmd = """
sudo wipefs -a /dev/sdg &&
sudo parted -s /dev/sdg mklabel gpt mkpart primary ext4 0% 100% &&
sudo mkfs.ext4 -F -L openpilot /dev/sdg1
"""
exitcode = subprocess.call(["sh", "-c", cmd])
def apply():
self._formatting = False
if exitcode == 0:
self.mount_storage()
else:
self._value_text = tr("needs format")
self._state = ExternalStorageState.FORMAT
apply()
threading.Thread(target=_work, daemon=True).start()
def external_storage_item(title: str | Callable[[], str], description: str | Callable[[], str]) -> ListItem:
return ListItem(
title=title,
description=description,
action_item=ExternalStorageAction()
)