forked from Support/sp-hydra-veil-gui
New polling system in the background to sync state
This commit is contained in:
parent
168355b087
commit
15261b012e
4 changed files with 21 additions and 18 deletions
|
|
@ -24,7 +24,7 @@ from core.Errors import UnknownConnectionTypeError
|
||||||
from core.errors.logger import logger as core_logger
|
from core.errors.logger import logger as core_logger
|
||||||
from core.models.Result import Result, ResultError
|
from core.models.Result import Result, ResultError
|
||||||
from core.observers.Notifications import Notifications, EventType
|
from core.observers.Notifications import Notifications, EventType
|
||||||
from core.infrastructure.global_state_coordinator import quantity_connected
|
from core.infrastructure.state_management.global_state_controller import quantity_connected
|
||||||
|
|
||||||
core_logger.propagate = False
|
core_logger.propagate = False
|
||||||
|
|
||||||
|
|
@ -34,7 +34,7 @@ from gui.v2.infrastructure.thread_singleton import get_main_thread_dispatcher
|
||||||
mainthread = get_main_thread_dispatcher()
|
mainthread = get_main_thread_dispatcher()
|
||||||
|
|
||||||
# Sync:
|
# Sync:
|
||||||
from gui.v2.actions.menu_coordinator import sync_now
|
from gui.v2.actions.menu_coordinator import sync_now, disconnect_active
|
||||||
from gui.v2.actions.sync import generate_grid_positions
|
from gui.v2.actions.sync import generate_grid_positions
|
||||||
|
|
||||||
from gui.v2.infrastructure import orm
|
from gui.v2.infrastructure import orm
|
||||||
|
|
@ -78,7 +78,6 @@ from gui.v2.actions.ticket_failure import (
|
||||||
clear_ticket_verification_failure,
|
clear_ticket_verification_failure,
|
||||||
)
|
)
|
||||||
from gui.v2.actions.should_be_synchronized import should_be_synchronized
|
from gui.v2.actions.should_be_synchronized import should_be_synchronized
|
||||||
from gui.v2.actions.menu_coordinator import disconnect_active
|
|
||||||
from gui.v2.ui.presenters.main_presenters import disconnect_message
|
from gui.v2.ui.presenters.main_presenters import disconnect_message
|
||||||
from gui.v2.ui.popups.confirmation_popup import ConfirmationPopup
|
from gui.v2.ui.popups.confirmation_popup import ConfirmationPopup
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,6 @@
|
||||||
|
from gui.v2.infrastructure.thread_singleton import get_main_thread_dispatcher
|
||||||
|
from core.infrastructure.state_management.state_poll_loop import PollState
|
||||||
|
|
||||||
from core.services.helpers.install_dependencies import setup_singbox_binary
|
from core.services.helpers.install_dependencies import setup_singbox_binary
|
||||||
from core.utils.basic_operations.does_file_exist import does_file_exist
|
from core.utils.basic_operations.does_file_exist import does_file_exist
|
||||||
from core.services.helpers.install_dependencies import SUDO_SINGBOX_LOCATION
|
from core.services.helpers.install_dependencies import SUDO_SINGBOX_LOCATION
|
||||||
|
|
@ -13,7 +16,11 @@ from gui.v2.infrastructure.take_plumbing_action import take_action
|
||||||
|
|
||||||
def post_state_evaluation(result: Result):
|
def post_state_evaluation(result: Result):
|
||||||
"""Success path for initial state evaluation"""
|
"""Success path for initial state evaluation"""
|
||||||
print("Initial State evaluation complete.")
|
print("Initial State evaluation complete, starting to poll..")
|
||||||
|
poll_state = PollState(ui_dispatcher=get_main_thread_dispatcher())
|
||||||
|
poll_state.start_polling()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# if not result.valid and result.error_type == ResultError.ZOMBIE_SESSION and result.data:
|
# if not result.valid and result.error_type == ResultError.ZOMBIE_SESSION and result.data:
|
||||||
# active_session_profiles = result.data
|
# active_session_profiles = result.data
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
# core
|
# core
|
||||||
from core.controllers.SessionStateController import SessionStateController
|
from core.infrastructure.state_management.global_state_controller import connected_system_profile_id, connected_session_profile_ids
|
||||||
from core.infrastructure.global_state_coordinator import connected_system_profile_id, connected_session_profile_ids
|
from core.observers.Notifications import Notifications, EventType
|
||||||
|
# from core.controllers.SessionStateController import SessionStateController
|
||||||
|
|
||||||
# from core.services.networking.systemwide.systemwide_wireguard import change_port_then_reconnect
|
# from core.services.networking.systemwide.systemwide_wireguard import change_port_then_reconnect
|
||||||
# from core.services.networking.ports.port_orchestrator import change_wg_port
|
# from core.services.networking.ports.port_orchestrator import change_wg_port
|
||||||
|
|
@ -36,6 +37,7 @@ from gui.v2.actions.error_handlers import navigate_to_new_sub_page
|
||||||
# generic
|
# generic
|
||||||
from typing import Callable
|
from typing import Callable
|
||||||
from functools import partial
|
from functools import partial
|
||||||
|
import atexit
|
||||||
|
|
||||||
@type_checker
|
@type_checker
|
||||||
def get_profile(profile_id: int):
|
def get_profile(profile_id: int):
|
||||||
|
|
@ -349,14 +351,8 @@ def sync_now(ui_caller: Callable):
|
||||||
connection_observer=connection_observer
|
connection_observer=connection_observer
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# def finish(result: Result):
|
||||||
|
# print("goodbye")
|
||||||
|
|
||||||
def kill_profile_from_grave(profile_id: int) -> Result:
|
|
||||||
killed = SessionStateController.scortched_earth_kill_profile(profile_id)
|
|
||||||
|
|
||||||
if killed:
|
# atexit.register(disconnect_active(ui_caller=finish))
|
||||||
logger.info("psutil worked to kill it.")
|
|
||||||
return Result(valid=True)
|
|
||||||
else:
|
|
||||||
error_msg = "Even psutil scortched earth failed to kill the profile."
|
|
||||||
logger.error(error_msg)
|
|
||||||
return Result(valid=False, error_type=ResultError.STATE, message=error_msg)
|
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
from core.infrastructure.global_state_coordinator import connected_session_profile_ids, verified_system_profile_id, is_systemwide_on, is_connected, evaluate_state_on_startup
|
from core.infrastructure.state_management.global_state_controller import connected_session_profile_ids, verified_system_profile_id, is_systemwide_on, is_connected
|
||||||
|
from core.infrastructure.global_state_coordinator import evaluate_state_on_startup
|
||||||
|
from core.services.networking.general_connection_tools.disconnect import kill_profile_from_grave
|
||||||
from gui.v2.infrastructure.take_plumbing_action import take_action
|
from gui.v2.infrastructure.take_plumbing_action import take_action
|
||||||
from gui.v2.actions.error_handlers import post_state_evaluation
|
from gui.v2.actions.error_handlers import post_state_evaluation
|
||||||
|
|
||||||
|
|
@ -20,7 +21,7 @@ from PyQt6.QtWidgets import (
|
||||||
QMessageBox, QPushButton, QScrollArea, QTextEdit, QVBoxLayout, QWidget,
|
QMessageBox, QPushButton, QScrollArea, QTextEdit, QVBoxLayout, QWidget,
|
||||||
)
|
)
|
||||||
|
|
||||||
from gui.v2.actions.menu_coordinator import connect_profile, disconnect_profile, kill_profile_from_grave
|
from gui.v2.actions.menu_coordinator import connect_profile, disconnect_profile
|
||||||
|
|
||||||
from gui.v2.actions.menu_profiles import find_verification_icon, get_profile_details, load_menu_profiles, menu_icons
|
from gui.v2.actions.menu_profiles import find_verification_icon, get_profile_details, load_menu_profiles, menu_icons
|
||||||
from gui.v2.actions.menu_tasks import (
|
from gui.v2.actions.menu_tasks import (
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue