Update order of imports and improve error handling in various modules
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import pathlib
|
||||
import time
|
||||
from dataclasses import dataclass
|
||||
import pathlib
|
||||
|
||||
import RNS
|
||||
|
||||
@@ -12,8 +12,7 @@ class Announce:
|
||||
timestamp: int
|
||||
|
||||
class AnnounceService:
|
||||
"""
|
||||
Service to listen for Reticulum announces and collect them.
|
||||
"""Service to listen for Reticulum announces and collect them.
|
||||
Calls update_callback whenever a new announce is received.
|
||||
"""
|
||||
|
||||
@@ -37,7 +36,7 @@ class AnnounceService:
|
||||
if app_data:
|
||||
try:
|
||||
display_name = app_data.decode("utf-8")
|
||||
except:
|
||||
except UnicodeDecodeError:
|
||||
pass
|
||||
announce = Announce(destination_hash.hex(), display_name, ts)
|
||||
self.announces = [ann for ann in self.announces if ann.destination_hash != announce.destination_hash]
|
||||
|
||||
@@ -1,13 +1,15 @@
|
||||
import datetime
|
||||
|
||||
import RNS
|
||||
|
||||
APP_LOGS: list[str] = []
|
||||
ERROR_LOGS: list[str] = []
|
||||
RET_LOGS: list[str] = []
|
||||
_original_RNS_log = RNS.log
|
||||
_original_rns_log = RNS.log
|
||||
def log_ret(msg, *args, **kwargs):
|
||||
timestamp = datetime.datetime.now().isoformat()
|
||||
RET_LOGS.append(f"[{timestamp}] {msg}")
|
||||
return _original_RNS_log(msg, *args, **kwargs)
|
||||
return _original_rns_log(msg, *args, **kwargs)
|
||||
RNS.log = log_ret
|
||||
|
||||
def log_error(msg: str):
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import pathlib
|
||||
import threading
|
||||
import time
|
||||
import pathlib
|
||||
from dataclasses import dataclass
|
||||
|
||||
import RNS
|
||||
from dataclasses import dataclass
|
||||
|
||||
|
||||
@dataclass
|
||||
@@ -13,8 +13,7 @@ class PageRequest:
|
||||
field_data: dict | None = None
|
||||
|
||||
class PageFetcher:
|
||||
"""
|
||||
Fetcher to download pages from the Reticulum network.
|
||||
"""Fetcher to download pages from the Reticulum network.
|
||||
"""
|
||||
|
||||
def __init__(self):
|
||||
@@ -64,7 +63,7 @@ class PageFetcher:
|
||||
ev.set()
|
||||
|
||||
link.set_link_established_callback(
|
||||
lambda l: l.request(req.page_path, req.field_data, response_callback=on_response, failed_callback=on_failed)
|
||||
lambda link: link.request(req.page_path, req.field_data, response_callback=on_response, failed_callback=on_failed)
|
||||
)
|
||||
ev.wait(timeout=15)
|
||||
data_str = result['data'] or 'No content received'
|
||||
|
||||
@@ -2,8 +2,7 @@ import flet as ft
|
||||
|
||||
|
||||
def render_plaintext(content: str) -> ft.Control:
|
||||
"""
|
||||
Fallback plaintext renderer: displays raw text safely in a monospace, selectable control.
|
||||
"""Fallback plaintext renderer: displays raw text safely in a monospace, selectable control.
|
||||
"""
|
||||
return ft.Text(
|
||||
content,
|
||||
|
||||
@@ -24,8 +24,8 @@ class TabsManager:
|
||||
def _add_tab_internal(self, title: str, content: ft.Control):
|
||||
idx = len(self.manager.tabs)
|
||||
url_field = ft.TextField(
|
||||
value=title,
|
||||
expand=True,
|
||||
value=title,
|
||||
expand=True,
|
||||
text_style=ft.TextStyle(size=12),
|
||||
content_padding=ft.padding.only(top=8, bottom=8, left=8, right=8)
|
||||
)
|
||||
|
||||
@@ -1,7 +1,10 @@
|
||||
import flet as ft
|
||||
import pathlib
|
||||
|
||||
import flet as ft
|
||||
|
||||
from ren_browser.logs import ERROR_LOGS, RET_LOGS
|
||||
|
||||
|
||||
def open_settings_tab(page: ft.Page, tab_manager):
|
||||
config_path = pathlib.Path(__file__).resolve().parents[2] / "config" / "config"
|
||||
try:
|
||||
|
||||
@@ -10,7 +10,6 @@ from ren_browser.tabs.tabs import TabsManager
|
||||
|
||||
|
||||
def build_ui(page: Page):
|
||||
import ren_browser.app as app_module
|
||||
page.theme_mode = ft.ThemeMode.DARK
|
||||
page.appbar = ft.AppBar()
|
||||
page.window.maximized = True
|
||||
|
||||
Reference in New Issue
Block a user