From 4511f8db5bb3b44fcac30ba8231e00ebd1c02f1d Mon Sep 17 00:00:00 2001 From: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> Date: Wed, 24 Jul 2024 18:32:16 +0200 Subject: [PATCH 1/5] move addons manager to ui --- client/ayon_core/tools/tray/__init__.py | 2 -- client/ayon_core/tools/tray/{ => ui}/addons_manager.py | 0 client/ayon_core/tools/tray/ui/tray.py | 2 +- 3 files changed, 1 insertion(+), 3 deletions(-) rename client/ayon_core/tools/tray/{ => ui}/addons_manager.py (100%) diff --git a/client/ayon_core/tools/tray/__init__.py b/client/ayon_core/tools/tray/__init__.py index 9dbacc54c2..c8fcd7841e 100644 --- a/client/ayon_core/tools/tray/__init__.py +++ b/client/ayon_core/tools/tray/__init__.py @@ -1,5 +1,4 @@ from .webserver import HostMsgAction -from .addons_manager import TrayAddonsManager from .lib import ( TrayState, get_tray_state, @@ -11,7 +10,6 @@ __all__ = ( "HostMsgAction", - "TrayAddonsManager", "TrayState", "get_tray_state", diff --git a/client/ayon_core/tools/tray/addons_manager.py b/client/ayon_core/tools/tray/ui/addons_manager.py similarity index 100% rename from client/ayon_core/tools/tray/addons_manager.py rename to client/ayon_core/tools/tray/ui/addons_manager.py diff --git a/client/ayon_core/tools/tray/ui/tray.py b/client/ayon_core/tools/tray/ui/tray.py index 660c61ac94..2a2c79129b 100644 --- a/client/ayon_core/tools/tray/ui/tray.py +++ b/client/ayon_core/tools/tray/ui/tray.py @@ -28,13 +28,13 @@ WrappedCallbackItem, get_ayon_qt_app, ) -from ayon_core.tools.tray import TrayAddonsManager from ayon_core.tools.tray.lib import ( set_tray_server_url, remove_tray_server_url, TrayIsRunningError, ) +from .addons_manager import TrayAddonsManager from .host_console_listener import HostListener from .info_widget import InfoWidget from .dialogs import ( From a4bb042337daf099c1a4adb5a9414da892b603b8 Mon Sep 17 00:00:00 2001 From: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> Date: Wed, 24 Jul 2024 18:32:45 +0200 Subject: [PATCH 2/5] move structures out of webserver --- client/ayon_core/tools/tray/__init__.py | 2 +- client/ayon_core/tools/tray/{webserver => }/structures.py | 0 client/ayon_core/tools/tray/webserver/__init__.py | 2 -- 3 files changed, 1 insertion(+), 3 deletions(-) rename client/ayon_core/tools/tray/{webserver => }/structures.py (100%) diff --git a/client/ayon_core/tools/tray/__init__.py b/client/ayon_core/tools/tray/__init__.py index c8fcd7841e..2490122358 100644 --- a/client/ayon_core/tools/tray/__init__.py +++ b/client/ayon_core/tools/tray/__init__.py @@ -1,4 +1,4 @@ -from .webserver import HostMsgAction +from .structures import HostMsgAction from .lib import ( TrayState, get_tray_state, diff --git a/client/ayon_core/tools/tray/webserver/structures.py b/client/ayon_core/tools/tray/structures.py similarity index 100% rename from client/ayon_core/tools/tray/webserver/structures.py rename to client/ayon_core/tools/tray/structures.py diff --git a/client/ayon_core/tools/tray/webserver/__init__.py b/client/ayon_core/tools/tray/webserver/__init__.py index 93bfbd6aee..c40b5b85c3 100644 --- a/client/ayon_core/tools/tray/webserver/__init__.py +++ b/client/ayon_core/tools/tray/webserver/__init__.py @@ -1,10 +1,8 @@ -from .structures import HostMsgAction from .base_routes import RestApiEndpoint from .server import find_free_port, WebServerManager __all__ = ( - "HostMsgAction", "RestApiEndpoint", "find_free_port", "WebServerManager", From 5bf69857378cb1fe653be7fbb774f543ca8d78a6 Mon Sep 17 00:00:00 2001 From: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> Date: Wed, 24 Jul 2024 18:33:04 +0200 Subject: [PATCH 3/5] implemented helper function 'make_sure_tray_is_running' to run tray --- client/ayon_core/tools/tray/__init__.py | 2 ++ client/ayon_core/tools/tray/lib.py | 40 ++++++++++++++++++++++++- 2 files changed, 41 insertions(+), 1 deletion(-) diff --git a/client/ayon_core/tools/tray/__init__.py b/client/ayon_core/tools/tray/__init__.py index 2490122358..2e179f0620 100644 --- a/client/ayon_core/tools/tray/__init__.py +++ b/client/ayon_core/tools/tray/__init__.py @@ -4,6 +4,7 @@ get_tray_state, is_tray_running, get_tray_server_url, + make_sure_tray_is_running, main, ) @@ -15,5 +16,6 @@ "get_tray_state", "is_tray_running", "get_tray_server_url", + "make_sure_tray_is_running", "main", ) diff --git a/client/ayon_core/tools/tray/lib.py b/client/ayon_core/tools/tray/lib.py index 76cf20d3b4..5018dc6620 100644 --- a/client/ayon_core/tools/tray/lib.py +++ b/client/ayon_core/tools/tray/lib.py @@ -13,7 +13,7 @@ import ayon_api import requests -from ayon_core.lib import Logger +from ayon_core.lib import Logger, get_ayon_launcher_args, run_detached_process from ayon_core.lib.local_settings import get_ayon_appdirs @@ -356,6 +356,44 @@ def is_tray_running( return state != TrayState.NOT_RUNNING +def make_sure_tray_is_running( + ayon_url: Optional[str] = None, + variant: Optional[str] = None, + env: Optional[Dict[str, str]] = None +): + """Make sure that tray for AYON url and variant is running. + + Args: + ayon_url (Optional[str]): AYON server url. + variant (Optional[str]): Settings variant. + env (Optional[Dict[str, str]]): Environment variables for the process. + + """ + state = get_tray_state(ayon_url, variant) + if state == TrayState.RUNNING: + return + + if state == TrayState.STARTING: + _wait_for_starting_tray(ayon_url, variant) + state = get_tray_state(ayon_url, variant) + if state == TrayState.RUNNING: + return + + args = get_ayon_launcher_args("tray", "--force") + if env is None: + env = os.environ.copy() + + if ayon_url: + env["AYON_SERVER_URL"] = ayon_url + + # TODO maybe handle variant in a better way + if variant: + if variant == "staging": + args.append("--use-staging") + + run_detached_process(args, env=env) + + def main(force=False): from ayon_core.tools.tray.ui import main From adc55dee1a844575c3bf8cc46fd4e3ca26174067 Mon Sep 17 00:00:00 2001 From: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> Date: Wed, 24 Jul 2024 18:38:52 +0200 Subject: [PATCH 4/5] unset QT_API --- client/ayon_core/tools/tray/lib.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/client/ayon_core/tools/tray/lib.py b/client/ayon_core/tools/tray/lib.py index 5018dc6620..c26f4835b1 100644 --- a/client/ayon_core/tools/tray/lib.py +++ b/client/ayon_core/tools/tray/lib.py @@ -382,6 +382,9 @@ def make_sure_tray_is_running( args = get_ayon_launcher_args("tray", "--force") if env is None: env = os.environ.copy() + + # Make sure 'QT_API' is not set + env.pop("QT_API", None) if ayon_url: env["AYON_SERVER_URL"] = ayon_url From 1d23d076fc49fc4c56bf63a5cb0dc4e4f6b2348a Mon Sep 17 00:00:00 2001 From: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> Date: Thu, 25 Jul 2024 10:40:46 +0200 Subject: [PATCH 5/5] fix import in broker --- client/ayon_core/tools/stdout_broker/broker.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/ayon_core/tools/stdout_broker/broker.py b/client/ayon_core/tools/stdout_broker/broker.py index 4f7118e2a8..c449fa7df9 100644 --- a/client/ayon_core/tools/stdout_broker/broker.py +++ b/client/ayon_core/tools/stdout_broker/broker.py @@ -8,7 +8,7 @@ import websocket from ayon_core.lib import Logger -from ayon_core.tools.tray.webserver import HostMsgAction +from ayon_core.tools.tray import HostMsgAction log = Logger.get_logger(__name__)