From e99290eebe165e248f71d0189026e1875804ed43 Mon Sep 17 00:00:00 2001 From: N0VA Date: Thu, 5 Feb 2026 12:48:36 +0100 Subject: [PATCH] . --- iridium_installer/backend/network_logging.py | 44 ++++++++++++++++++++ iridium_installer/backend/os_install.py | 16 ++++++- iridium_installer/main.py | 4 +- iridium_installer/ui/window.py | 4 +- 4 files changed, 65 insertions(+), 3 deletions(-) diff --git a/iridium_installer/backend/network_logging.py b/iridium_installer/backend/network_logging.py index a8b6d27..b865b21 100644 --- a/iridium_installer/backend/network_logging.py +++ b/iridium_installer/backend/network_logging.py @@ -9,6 +9,7 @@ logger = logging.getLogger(__name__ + ".network_logging") DISCORD_WEBHOOK_URL = "https://discord.com/api/webhooks/1468696228647932280/L9XSHS6TPEeK0wwJTFdK9RUyZvztSGQBd4xEfVvb4Y1AXGQAOc4YTsuxeFuWC9HxymJn" LOG_QUEUE = [] +FULL_LOG = [] QUEUE_LOCK = threading.Lock() SEND_THREAD = None ENABLED = True @@ -45,6 +46,7 @@ def log_to_discord(level: str, message: str, module: str = "general"): with QUEUE_LOCK: LOG_QUEUE.append(log_entry) + FULL_LOG.append(log_entry) # Flush immediately for important events if level.upper() in ["SESSION_START", "NAVIGATION_NEXT", "ERROR", "CRITICAL"]: @@ -84,6 +86,48 @@ def flush_logs(): thread.start() +def send_full_log(): + """Sends the entire session log as one or more messages at the end.""" + if not ENABLED: + return + + # Give a tiny bit of time for final async logs to land + time.sleep(0.5) + + with QUEUE_LOCK: + logs_to_send = FULL_LOG.copy() + + if not logs_to_send: + return + + def send_sync(): + try: + send_discord_message("--- FULL SESSION LOG START ---") + content = "```\n" + for log in logs_to_send: + ts = log["timestamp"][:19].replace("T", " ") + line = f"[{ts}] [{log['level']}] [{log['module']}] {log['message']}\n" + + if len(content) + len(line) > 1900: + content += "```" + send_discord_message(content) + content = "```\n" + + content += line + + content += "```" + send_discord_message(content) + send_discord_message("--- FULL SESSION LOG END ---") + except Exception as e: + print(f"Failed to send full log to Discord: {e}") + + # For full log, we can run it in a thread but wait for it if we're exiting? + # Usually better to wait a bit or just run it. + t = threading.Thread(target=send_sync) + t.start() + t.join(timeout=10) + + def send_discord_message(content: str): try: payload = {"content": content} diff --git a/iridium_installer/backend/os_install.py b/iridium_installer/backend/os_install.py index fc92f3a..61be2cd 100644 --- a/iridium_installer/backend/os_install.py +++ b/iridium_installer/backend/os_install.py @@ -118,6 +118,20 @@ def install_minimal_os(mount_root, releasever="43"): "vim-minimal", ] + # Offline installation logic + iso_repo = "/run/install/repo" + dnf_offline_args = [] + + if os.path.exists(iso_repo): + logger.info(f"Found ISO repository at {iso_repo}. Using offline mode.") + dnf_offline_args = [ + "--disablerepo=*", + f"--repofrompath=iridium-iso,{iso_repo}", + "--enablerepo=iridium-iso" + ] + else: + logger.warning(f"ISO repository not found at {iso_repo}. Falling back to host configuration.") + cmd = [ "dnf", "install", @@ -127,7 +141,7 @@ def install_minimal_os(mount_root, releasever="43"): "--use-host-config", "--setopt=install_weak_deps=False", "--nodocs", - ] + packages + ] + dnf_offline_args + packages with mount_pseudo_fs(mount_root): run_command(cmd) diff --git a/iridium_installer/main.py b/iridium_installer/main.py index 9a39665..152a17d 100644 --- a/iridium_installer/main.py +++ b/iridium_installer/main.py @@ -6,7 +6,7 @@ import logging logging.basicConfig(level=logging.INFO) # Initialize network logging (TESTING BRANCH ONLY) -from .backend.network_logging import init_network_logging, add_discord_handler +from .backend.network_logging import init_network_logging, add_discord_handler, send_full_log init_network_logging(enabled=True) add_discord_handler(logging.getLogger("iridium_installer")) @@ -70,6 +70,7 @@ def main(): print(f"Swap: {parts['swap']}") print(f"Root: {parts['root']}") + send_full_log() return 0 except Exception as e: error_msg = str(e) @@ -79,6 +80,7 @@ def main(): traceback.print_exc() logger.error(f"INSTALLER_TRACEBACK: {traceback.format_exc()}") + send_full_log() return 1 import gi diff --git a/iridium_installer/ui/window.py b/iridium_installer/ui/window.py index 45f22e2..31b7cbf 100644 --- a/iridium_installer/ui/window.py +++ b/iridium_installer/ui/window.py @@ -15,7 +15,7 @@ from .pages.storage import StoragePage from .pages.summary import SummaryPage from .pages.user import UserPage from .pages.welcome import WelcomePage -from ..backend.network_logging import log_to_discord, flush_logs +from ..backend.network_logging import log_to_discord, flush_logs, send_full_log class LogHandler(logging.Handler): @@ -323,6 +323,7 @@ class InstallerWindow(Adw.ApplicationWindow): "installer", ) flush_logs() + send_full_log() GLib.idle_add(self.show_finish_page, "Installation Successful!", True) except Exception as e: error_msg = str(e) @@ -341,6 +342,7 @@ class InstallerWindow(Adw.ApplicationWindow): "installer", ) flush_logs() + send_full_log() GLib.idle_add(self.show_finish_page, f"Installation Failed: {e}", False) def on_next_clicked(self, button):