mirror of
https://github.com/usestrix/strix.git
synced 2026-08-23 19:32:37 +02:00
feat(tui): replace Textual with a Go/Bubble Tea interface (#941)
This commit is contained in:
@@ -13,6 +13,12 @@ logger = logging.getLogger(__name__)
|
||||
|
||||
SESSION_ID: str = uuid4().hex[:16]
|
||||
|
||||
# (connect, read) seconds. Telemetry is a beacon, never something a user waits
|
||||
# on, and these calls sit on the shutdown path: an endpoint that is blackholed by
|
||||
# a firewall stalls in connect, so the cap has to be short enough that quitting
|
||||
# still feels immediate.
|
||||
SEND_TIMEOUT: tuple[float, float] = (2.0, 3.0)
|
||||
|
||||
_FIRST_RUN_CACHED: bool | None = None
|
||||
|
||||
|
||||
|
||||
@@ -87,6 +87,33 @@ def configure_dependency_logging() -> None:
|
||||
logging.getLogger("asyncio").setLevel(logging.CRITICAL)
|
||||
logging.getLogger("asyncio").propagate = False
|
||||
warnings.filterwarnings("ignore", category=RuntimeWarning, module="asyncio")
|
||||
_silence_urllib3_finalizer_noise()
|
||||
|
||||
|
||||
_unraisable_hook_installed = False
|
||||
|
||||
|
||||
def _is_urllib3_closed_file_noise(unraisable: sys.UnraisableHookArgs) -> bool:
|
||||
return (
|
||||
isinstance(unraisable.exc_value, ValueError)
|
||||
and "I/O operation on closed file" in str(unraisable.exc_value)
|
||||
and type(unraisable.object).__module__.split(".")[0] == "urllib3"
|
||||
)
|
||||
|
||||
|
||||
def _silence_urllib3_finalizer_noise() -> None:
|
||||
global _unraisable_hook_installed # noqa: PLW0603
|
||||
if _unraisable_hook_installed:
|
||||
return
|
||||
_unraisable_hook_installed = True
|
||||
previous = sys.unraisablehook
|
||||
|
||||
def hook(unraisable: sys.UnraisableHookArgs) -> None:
|
||||
if _is_urllib3_closed_file_noise(unraisable):
|
||||
return
|
||||
previous(unraisable)
|
||||
|
||||
sys.unraisablehook = hook
|
||||
|
||||
|
||||
def setup_scan_logging(run_dir: Path, *, debug: bool | None = None) -> Callable[[], None]:
|
||||
|
||||
@@ -6,6 +6,7 @@ import requests
|
||||
|
||||
from strix.config import load_settings
|
||||
from strix.telemetry._common import (
|
||||
SEND_TIMEOUT,
|
||||
SESSION_ID,
|
||||
base_props,
|
||||
is_first_run,
|
||||
@@ -37,7 +38,8 @@ def _send(event: str, properties: dict[str, Any]) -> bool:
|
||||
"distinct_id": SESSION_ID,
|
||||
"properties": properties,
|
||||
}
|
||||
requests.post(f"{_POSTHOG_HOST}/capture/", json=payload, timeout=10)
|
||||
with requests.post(f"{_POSTHOG_HOST}/capture/", json=payload, timeout=SEND_TIMEOUT):
|
||||
pass
|
||||
except Exception: # noqa: BLE001
|
||||
logger.debug("posthog send failed for event %s", event, exc_info=True)
|
||||
return False
|
||||
|
||||
@@ -9,6 +9,7 @@ import requests
|
||||
|
||||
from strix.config import load_settings
|
||||
from strix.telemetry._common import (
|
||||
SEND_TIMEOUT,
|
||||
SESSION_ID,
|
||||
base_props,
|
||||
get_version,
|
||||
@@ -43,7 +44,8 @@ def _send(event: str, properties: dict[str, Any]) -> bool:
|
||||
url = f"{_SCARF_ENDPOINT}{path}"
|
||||
if query:
|
||||
url = f"{url}?{query}"
|
||||
requests.post(url, timeout=10)
|
||||
with requests.post(url, timeout=SEND_TIMEOUT):
|
||||
pass
|
||||
except Exception: # noqa: BLE001
|
||||
logger.debug("scarf send failed for event %s", event, exc_info=True)
|
||||
return False
|
||||
|
||||
Reference in New Issue
Block a user