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)
|
return literally_connect(profile_id=profile_id)
|
||||||
|
|
||||||
|
|
||||||
@type_checker
|
def literally_disconnect(profile_id: int) -> Result:
|
||||||
def literally_disconnect(
|
|
||||||
profile_id: int,
|
|
||||||
ignore_state_conflict: Optional[bool] = False
|
|
||||||
) -> Result:
|
|
||||||
"""Get a profile and use core to disable it."""
|
"""Get a profile and use core to disable it."""
|
||||||
|
|
||||||
# Step 1: Get the Profile
|
# Step 1: Get the Profile
|
||||||
|
|
@ -254,8 +250,9 @@ def literally_disconnect(
|
||||||
profile = profile_result.data
|
profile = profile_result.data
|
||||||
|
|
||||||
# EXCEPTIONS
|
# EXCEPTIONS
|
||||||
ignored = get_ignored_exceptions(ignore_state_conflict=ignore_state_conflict)
|
ignored = get_ignored_exceptions(ignore_state_conflict=False)
|
||||||
|
|
||||||
|
print("Literally disconnecting")
|
||||||
try:
|
try:
|
||||||
final_result = disable_profile(
|
final_result = disable_profile(
|
||||||
profile=profile,
|
profile=profile,
|
||||||
|
|
@ -272,11 +269,13 @@ def literally_disconnect(
|
||||||
return translate_error(error=error, profile_id=profile_id)
|
return translate_error(error=error, profile_id=profile_id)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def disconnect_profile(profile_id: int, ui_caller: Callable) -> Result:
|
def disconnect_profile(profile_id: int, ui_caller: Callable) -> Result:
|
||||||
"""Background Thread to literally_disconnect"""
|
print("GUI is disconnecting a profile")
|
||||||
take_action(
|
return literally_disconnect(profile_id)
|
||||||
action=literally_disconnect,
|
|
||||||
ui_caller=ui_caller,
|
# take_action(
|
||||||
profile_id=profile_id
|
# action=literally_disconnect,
|
||||||
)
|
# ui_caller=ui_caller,
|
||||||
return Result(valid=True)
|
# profile_id=profile_id
|
||||||
|
# )
|
||||||
|
|
|
||||||
|
|
@ -199,6 +199,7 @@ class MenuPage(Page):
|
||||||
|
|
||||||
# 3. Connection Status
|
# 3. Connection Status
|
||||||
connected = is_connected(profile_id)
|
connected = is_connected(profile_id)
|
||||||
|
print(f"is {profile_id} connected? {connected}")
|
||||||
|
|
||||||
# 4. Route:
|
# 4. Route:
|
||||||
if connected:
|
if connected:
|
||||||
|
|
@ -584,13 +585,15 @@ class MenuPage(Page):
|
||||||
|
|
||||||
def post_disconnect(self, result: Result):
|
def post_disconnect(self, result: Result):
|
||||||
"""Recieve the callback after disconnection"""
|
"""Recieve the callback after disconnection"""
|
||||||
|
print(f"result is {result}")
|
||||||
|
|
||||||
# --------------------
|
# --------------------
|
||||||
# BOTTOM LEFT STATUS BAR
|
# BOTTOM LEFT STATUS BAR
|
||||||
# --------------------
|
# --------------------
|
||||||
if result.message:
|
# if result.message:
|
||||||
if len(result.message) > 20:
|
# if len(result.message) > 20:
|
||||||
self.update_status.disable_marquee
|
# self.update_status.disable_marquee
|
||||||
self.update_status.update_status(result.message)
|
# self.update_status.update_status(result.message)
|
||||||
|
|
||||||
# --------------------
|
# --------------------
|
||||||
# WORKED
|
# WORKED
|
||||||
|
|
@ -651,11 +654,9 @@ class MenuPage(Page):
|
||||||
|
|
||||||
def disconnect(self):
|
def disconnect(self):
|
||||||
self.update_status.update_status("Disconnecting...")
|
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._set_task_busy(True)
|
||||||
# self.worker = disable_profile(self.reverse_id, self.connection_manager.get_connected_profiles(),
|
# self.worker = disable_profile(self.reverse_id, self.connection_manager.get_connected_profiles(),
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue