From a128d542ceb08f7b44f5afcfc60c729ed8cca02a Mon Sep 17 00:00:00 2001 From: Josef Haupt Date: Fri, 1 Nov 2024 15:56:33 +0100 Subject: [PATCH] work around new gradio 5 behaviour (#498) Co-authored-by: Josef Haupt --- birdnet_analyzer/gui/utils.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/birdnet_analyzer/gui/utils.py b/birdnet_analyzer/gui/utils.py index 022ef5f0..422b222e 100644 --- a/birdnet_analyzer/gui/utils.py +++ b/birdnet_analyzer/gui/utils.py @@ -477,6 +477,12 @@ def on_custom_classifier_selection_click(): ) +def _get_win_drives(): + from string import ascii_uppercase as UPPER_CASE + + return [f"{drive}:\\" for drive in UPPER_CASE] + + def open_window(builder: list[Callable] | Callable): multiprocessing.freeze_support() @@ -497,7 +503,13 @@ def open_window(builder: list[Callable] | Callable): build_settings() build_footer() - url = demo.queue(api_open=False).launch(prevent_thread_lock=True, quiet=True, show_api=False, enable_monitoring=False)[1] + url = demo.queue(api_open=False).launch( + prevent_thread_lock=True, + quiet=True, + show_api=False, + enable_monitoring=False, + allowed_paths=_get_win_drives() if sys.platform == "win32" else ["/"], + )[1] _WINDOW = webview.create_window("BirdNET-Analyzer", url.rstrip("/") + "?__theme=light", min_size=(1024, 768)) set_window(_WINDOW)