fix circular import

This commit is contained in:
Jakub Trllo 2024-06-05 13:47:22 +02:00
parent 1d5d73ae0d
commit 48367f2638
4 changed files with 20 additions and 16 deletions

View file

@ -1,4 +1,5 @@
from .version import __version__
from .structures import HostMsgAction
from .webserver_module import (
WebServerAddon
)
@ -7,5 +8,6 @@ from .webserver_module import (
__all__ = (
"__version__",
"HostMsgAction",
"WebServerAddon",
)

View file

@ -9,22 +9,18 @@ from qtpy import QtWidgets
from ayon_core.addon import ITrayService
from ayon_core.tools.stdout_broker.window import ConsoleDialog
from .structures import HostMsgAction
log = logging.getLogger(__name__)
# Host listener icon type
class IconType:
IDLE = "idle"
RUNNING = "running"
FAILED = "failed"
class MsgAction:
CONNECTING = "connecting"
INITIALIZED = "initialized"
ADD = "add"
CLOSE = "close"
class HostListener:
def __init__(self, webserver, module):
self._window_per_id = {}
@ -96,22 +92,22 @@ class HostListener:
if msg.type == aiohttp.WSMsgType.TEXT:
host_name, action, text = self._parse_message(msg)
if action == MsgAction.CONNECTING:
if action == HostMsgAction.CONNECTING:
self._action_per_id[host_name] = None
# must be sent to main thread, or action wont trigger
self.module.execute_in_main_thread(
lambda: self._host_is_connecting(host_name, text))
elif action == MsgAction.CLOSE:
elif action == HostMsgAction.CLOSE:
# clean close
self._close(host_name)
await ws.close()
elif action == MsgAction.INITIALIZED:
elif action == HostMsgAction.INITIALIZED:
self.module.execute_in_main_thread(
# must be queued as _host_is_connecting might not
# be triggered/finished yet
lambda: self._set_host_icon(host_name,
IconType.RUNNING))
elif action == MsgAction.ADD:
elif action == HostMsgAction.ADD:
self.module.execute_in_main_thread(
lambda: self._add_text(host_name, text))
elif msg.type == aiohttp.WSMsgType.ERROR:

View file

@ -0,0 +1,6 @@
# Host listener message actions
class HostMsgAction:
CONNECTING = "connecting"
INITIALIZED = "initialized"
ADD = "add"
CLOSE = "close"

View file

@ -8,7 +8,7 @@ from datetime import datetime
import websocket
from ayon_core.lib import Logger
from ayon_core.modules.webserver.host_console_listener import MsgAction
from ayon_core.modules.webserver import HostMsgAction
log = Logger.get_logger(__name__)
@ -65,7 +65,7 @@ class StdOutBroker:
payload = {
"host": self.host_id,
"action": MsgAction.INITIALIZED,
"action": HostMsgAction.INITIALIZED,
"text": "Integration with {}".format(
str.capitalize(self.host_name))
}
@ -99,7 +99,7 @@ class StdOutBroker:
payload = {
"host": self.host_id,
"action": MsgAction.CONNECTING,
"action": HostMsgAction.CONNECTING,
"text": "Integration with {}".format(
str.capitalize(self.host_name))
}
@ -113,7 +113,7 @@ class StdOutBroker:
payload = {
"host": self.host_id,
"action": MsgAction.CLOSE,
"action": HostMsgAction.CLOSE,
"text": "Integration with {}".format(
str.capitalize(self.host_name))
}
@ -157,7 +157,7 @@ class StdOutBroker:
if lines:
payload = {
"host": self.host_id,
"action": MsgAction.ADD,
"action": HostMsgAction.ADD,
"text": "\n".join(lines)
}