hydraveil-gui/gui/v2/actions/error_handlers.py

38 lines
1.5 KiB
Python

from gui.v2.infrastructure.action_registry import register_action
from core.infrastructure.global_state_coordinator import coordinate_evaluation
from core.models.Result import Result, ResultError
from core.errors.logger import logger
from gui.v2.infrastructure.setup_observers import connection_observer
# from gui.v2.infrastructure.ThreadSafetyTool import ThreadSafetyTool
# mainthread = ThreadSafetyTool()
from gui.v2.infrastructure.take_plumbing_action import take_action
def post_state_evaluation(result: Result):
"""Success path for initial state evaluation"""
print("Initial State evaluation complete.")
# if not result.valid and result.error_type == ResultError.ZOMBIE_SESSION and result.data:
# active_session_profiles = result.data
# logger.info("Removing Zombie Session profiles on the main thread.")
# for each_profile in active_session_profiles:
# logger.info(f"Removing this profile {active_session_profiles} from session since it's a fresh restart.")
# SessionStateController.remove(each_profile.id)
@register_action(ResultError.ZOMBIE_SYSTEM)
def evaluate_bad_state():
"""Start core's evaluation of state with a GUI observer."""
take_action(
action=coordinate_evaluation,
ui_caller=post_state_evaluation,
connection_observer=connection_observer
)
@register_action(ResultError.SUBSCRIPTION)
def navigate_to_new_sub_page() -> Result:
return Result(valid=False, error_type=ResultError.NAVIGATE_TO, navigate_to="id")