From 110bd8b29583b1dec929c5821421159db12af1b0 Mon Sep 17 00:00:00 2001 From: firestarsdog <229254897+firestarsdog@users.noreply.github.com> Date: Mon, 6 Jul 2026 02:33:45 -0400 Subject: [PATCH] BigUI WIP: Fix boot screen downloads BigUI WIP: Fix boot screen downloads --- .../starpilot/simple_download_manager.py | 11 ++++++-- starpilot/assets/theme_manager.py | 28 +++++++++++-------- .../common/starpilot_download_utilities.py | 6 ++-- 3 files changed, 30 insertions(+), 15 deletions(-) diff --git a/selfdrive/ui/layouts/settings/starpilot/simple_download_manager.py b/selfdrive/ui/layouts/settings/starpilot/simple_download_manager.py index 9b4bae959..c593d9927 100644 --- a/selfdrive/ui/layouts/settings/starpilot/simple_download_manager.py +++ b/selfdrive/ui/layouts/settings/starpilot/simple_download_manager.py @@ -164,6 +164,7 @@ class SimpleDownloadManager(Widget): self._content_height = 0.0 self._list_items: list[str] = [] + self._slug_map: dict[str, str] = {} self._item_rects: dict[str, rl.Rectangle] = {} self._pill_rects: list[rl.Rectangle] = [] self._confirm_target: str | None = None @@ -209,7 +210,13 @@ class SimpleDownloadManager(Widget): if not raw.strip(): return [] names = [s.strip() for s in raw.split(",") if s.strip()] - return [_theme_display_name(n) for n in names] + self._slug_map = {} + result = [] + for n in names: + display = _theme_display_name(n) + self._slug_map[display] = n + result.append(display) + return result def _current_value(self) -> str: return self.params.get(self.asset_param, encoding="utf-8") or "" @@ -233,7 +240,7 @@ class SimpleDownloadManager(Widget): def _start_download(self, display_name: str): if self._downloading: return - slug = _display_to_slug(display_name) + slug = self._slug_map.get(display_name) or _display_to_slug(display_name) if not slug: return self._downloading = True diff --git a/starpilot/assets/theme_manager.py b/starpilot/assets/theme_manager.py index efedb8782..140a75840 100644 --- a/starpilot/assets/theme_manager.py +++ b/starpilot/assets/theme_manager.py @@ -14,7 +14,7 @@ from dateutil import easter from pathlib import Path from urllib.parse import quote_plus -from openpilot.starpilot.common.starpilot_download_utilities import GITLAB_URL, download_file, get_repository_url, handle_error, verify_download +from openpilot.starpilot.common.starpilot_download_utilities import GITHUB_URL, GITLAB_URL, download_file, get_repository_url, handle_error, verify_download from openpilot.starpilot.common.theme_asset_names import find_matching_theme_asset_file, find_matching_theme_asset_name from openpilot.starpilot.common.starpilot_utilities import delete_file, extract_zip, load_json_file, update_json_file from openpilot.starpilot.common.starpilot_variables import ACTIVE_THEME_PATH, RANDOM_EVENTS_PATH, RESOURCES_REPO, THEME_SAVE_PATH @@ -225,6 +225,9 @@ class ThemeManager: self.downloading_theme = False return + alternate_url = GITLAB_URL if "raw.githubusercontent" in repo_url else GITHUB_URL + primary_source = "GitLab" if "gitlab" in repo_url else "GitHub" + if theme_component == "boot_logos": download_link = f"{repo_url}/Themes/bootlogo" download_path = THEME_SAVE_PATH / "bootlogos" / theme_name @@ -253,7 +256,7 @@ class ThemeManager: for theme_url in theme_urls: delete_file(theme_path) - print(f"Downloading theme from GitHub: {theme_name}") + print(f"Downloading theme from {primary_source}: {theme_name}") download_file(CANCEL_DOWNLOAD_PARAM, theme_path, asset_param, self.params_memory, DOWNLOAD_PROGRESS_PARAM, self.session, theme_url) if self.params_memory.get_bool(CANCEL_DOWNLOAD_PARAM): @@ -264,7 +267,7 @@ class ThemeManager: return if verify_download(theme_path, self.params_memory, self.session, theme_url): - print(f"Theme {theme_name} downloaded and verified successfully from GitHub!") + print(f"Theme {theme_name} downloaded and verified successfully from {primary_source}!") self.update_theme_size(theme_component, theme_name, theme_path.stat().st_size) if extension == ".zip": @@ -279,7 +282,7 @@ class ThemeManager: self.update_themes(starpilot_toggles) return - if self.handle_verification_failure(extension, theme_component, theme_name, asset_param, theme_path, download_path, starpilot_toggles): + if self.handle_verification_failure(extension, theme_component, theme_name, asset_param, theme_path, download_path, starpilot_toggles, alternate_url): return handle_error(download_path, asset_param, "Download failed...", "Download failed...", self.params_memory, DOWNLOAD_PROGRESS_PARAM) @@ -462,29 +465,32 @@ class ThemeManager: "christmas_week": date(year, 12, 25) } - def handle_verification_failure(self, extension, theme_component, theme_name, asset_param, theme_path, download_path, starpilot_toggles): + def handle_verification_failure(self, extension, theme_component, theme_name, asset_param, theme_path, download_path, starpilot_toggles, fallback_url=GITLAB_URL): + is_github = "raw.githubusercontent" in fallback_url + source = "GitHub" if is_github else "GitLab" + if theme_component == "boot_logos": - download_link = f"{GITLAB_URL}/Themes/bootlogo" + download_link = f"{fallback_url}/Themes/bootlogo" name_candidates = list(dict.fromkeys([theme_name, theme_name.replace("_", "-"), theme_name.replace("-", "_")])) elif theme_component == "distance_icons": - download_link = f"{GITLAB_URL}/Distance-Icons/{theme_name}" + download_link = f"{fallback_url}/Distance-Icons/{theme_name}" name_candidates = [theme_name] elif theme_component == "steering_wheels": - download_link = f"{GITLAB_URL}/Steering-Wheels/{theme_name}" + download_link = f"{fallback_url}/Steering-Wheels/{theme_name}" name_candidates = [theme_name] else: - download_link = f"{GITLAB_URL}/Themes/{theme_name}/{theme_component}" + download_link = f"{fallback_url}/Themes/{theme_name}/{theme_component}" name_candidates = [theme_name] for candidate in name_candidates: delete_file(theme_path) theme_url = f"{download_link}/{candidate}{extension}" if theme_component == "boot_logos" else download_link + extension - print(f"Downloading theme from GitLab: {theme_name}") + print(f"Downloading theme from {source}: {theme_name}") download_file(CANCEL_DOWNLOAD_PARAM, theme_path, asset_param, self.params_memory, DOWNLOAD_PROGRESS_PARAM, self.session, theme_url) if verify_download(theme_path, self.params_memory, self.session, theme_url): - print(f"Theme {theme_name} downloaded and verified successfully from GitLab!") + print(f"Theme {theme_name} downloaded and verified successfully from {source}!") self.update_theme_size(theme_component, theme_name, theme_path.stat().st_size) if extension == ".zip": diff --git a/starpilot/common/starpilot_download_utilities.py b/starpilot/common/starpilot_download_utilities.py index 3300cb48a..a73d10be2 100644 --- a/starpilot/common/starpilot_download_utilities.py +++ b/starpilot/common/starpilot_download_utilities.py @@ -1,4 +1,5 @@ #!/usr/bin/env python3 +import os import requests from datetime import datetime, timezone @@ -6,8 +7,9 @@ from datetime import datetime, timezone from openpilot.starpilot.common.starpilot_utilities import delete_file, is_url_pingable from openpilot.starpilot.common.starpilot_variables import RESOURCES_REPO +GITLAB_RESOURCES_REPO = os.getenv("STARPILOT_GITLAB_RESOURCES_REPO", "firestar5683/FrogPilot-Resources") GITHUB_URL = f"https://raw.githubusercontent.com/{RESOURCES_REPO}" -GITLAB_URL = f"https://gitlab.com/{RESOURCES_REPO}/-/raw" +GITLAB_URL = f"https://gitlab.com/{GITLAB_RESOURCES_REPO}/-/raw" def download_file(cancel_param, destination, download_param, params_memory, progress_param, session, url, offset_bytes=0, total_bytes=0): try: @@ -83,7 +85,7 @@ def get_remote_file_size(params_memory, session, url): def get_repository_url(session): - if is_url_pingable("https://github.com") and not github_rate_limited(session): + if (is_url_pingable("https://github.com") or is_url_pingable("https://api.github.com")) and not github_rate_limited(session): return GITHUB_URL if is_url_pingable("https://gitlab.com"): return GITLAB_URL