forked from Support/sp-hydra-veil-gui
Disconnect directly
This commit is contained in:
parent
031704471b
commit
766d4e29fe
2 changed files with 22 additions and 22 deletions
|
|
@ -239,11 +239,7 @@ def connect_with_billing_code(profile_id: int, billing_code: str) -> Result:
|
|||
return literally_connect(profile_id=profile_id)
|
||||
|
||||
|
||||
@type_checker
|
||||
def literally_disconnect(
|
||||
profile_id: int,
|
||||
ignore_state_conflict: Optional[bool] = False
|
||||
) -> Result:
|
||||
def literally_disconnect(profile_id: int) -> Result:
|
||||
"""Get a profile and use core to disable it."""
|
||||
|
||||
# Step 1: Get the Profile
|
||||
|
|
@ -254,8 +250,9 @@ def literally_disconnect(
|
|||
profile = profile_result.data
|
||||
|
||||
# EXCEPTIONS
|
||||
ignored = get_ignored_exceptions(ignore_state_conflict=ignore_state_conflict)
|
||||
ignored = get_ignored_exceptions(ignore_state_conflict=False)
|
||||
|
||||
print("Literally disconnecting")
|
||||
try:
|
||||
final_result = disable_profile(
|
||||
profile=profile,
|
||||
|
|
@ -272,11 +269,13 @@ def literally_disconnect(
|
|||
return translate_error(error=error, profile_id=profile_id)
|
||||
|
||||
|
||||
|
||||
def disconnect_profile(profile_id: int, ui_caller: Callable) -> Result:
|
||||
"""Background Thread to literally_disconnect"""
|
||||
take_action(
|
||||
action=literally_disconnect,
|
||||
ui_caller=ui_caller,
|
||||
profile_id=profile_id
|
||||
)
|
||||
return Result(valid=True)
|
||||
print("GUI is disconnecting a profile")
|
||||
return literally_disconnect(profile_id)
|
||||
|
||||
# take_action(
|
||||
# action=literally_disconnect,
|
||||
# ui_caller=ui_caller,
|
||||
# profile_id=profile_id
|
||||
# )
|
||||
|
|
|
|||
|
|
@ -199,6 +199,7 @@ class MenuPage(Page):
|
|||
|
||||
# 3. Connection Status
|
||||
connected = is_connected(profile_id)
|
||||
print(f"is {profile_id} connected? {connected}")
|
||||
|
||||
# 4. Route:
|
||||
if connected:
|
||||
|
|
@ -584,13 +585,15 @@ class MenuPage(Page):
|
|||
|
||||
def post_disconnect(self, result: Result):
|
||||
"""Recieve the callback after disconnection"""
|
||||
print(f"result is {result}")
|
||||
|
||||
# --------------------
|
||||
# BOTTOM LEFT STATUS BAR
|
||||
# --------------------
|
||||
if result.message:
|
||||
if len(result.message) > 20:
|
||||
self.update_status.disable_marquee
|
||||
self.update_status.update_status(result.message)
|
||||
# if result.message:
|
||||
# if len(result.message) > 20:
|
||||
# self.update_status.disable_marquee
|
||||
# self.update_status.update_status(result.message)
|
||||
|
||||
# --------------------
|
||||
# WORKED
|
||||
|
|
@ -651,11 +654,9 @@ class MenuPage(Page):
|
|||
|
||||
def disconnect(self):
|
||||
self.update_status.update_status("Disconnecting...")
|
||||
disconnect_profile(profile_id=self.reverse_id, ui_caller=self.post_disconnect)
|
||||
|
||||
|
||||
|
||||
|
||||
print(f"Disconnecting profile {self.reverse_id}")
|
||||
result = disconnect_profile(profile_id=self.reverse_id, ui_caller=self.post_disconnect)
|
||||
print("Disconnected")
|
||||
|
||||
# self._set_task_busy(True)
|
||||
# self.worker = disable_profile(self.reverse_id, self.connection_manager.get_connected_profiles(),
|
||||
|
|
|
|||
Loading…
Reference in a new issue