Skip to content

Commit

Permalink
handle sessions with clean logout before exit
Browse files Browse the repository at this point in the history
  • Loading branch information
zakkarry committed Oct 13, 2024
1 parent b2aaf7b commit 274cc87
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions deluge-mover.py
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,8 @@ def main():
f"\n\n[{CRED}error{CEND}]: {CYELLOW}Your WebUI is not automatically connectable to the Deluge daemon.{CEND}\n"
f"{CYELLOW}\t Open the WebUI's connection manager to resolve this.{CEND}\n\n"
)
deluge_handler.call("auth.delete_session", [], 0)
deluge_handler.session.close()
exit(1)
else:
print(f"[json-rpc/web.connect] Successfully reconnected to daemon.\n")
Expand All @@ -245,6 +247,8 @@ def main():
print(
f"\n\n[{CGREEN}deluge-mover{CEND}]: {CBOLD}no eligible torrents.\n\t\tscript completed.{CEND}\n\n"
)
deluge_handler.call("auth.delete_session", [], 0)
deluge_handler.session.close()
exit(0)
# loop through items in torrent list
for hash, values in filtered_torrents:
Expand Down Expand Up @@ -276,6 +280,7 @@ def main():
f"[{CGREEN}init{CEND}] -> {CYELLOW}{CBOLD}Executing unRAID Mover...{CEND}\n"
)
time.sleep(3)
deluge_handler.call("auth.delete_session", [], 0)
deluge_handler.session.close()

if use_mover_old:
Expand Down Expand Up @@ -307,10 +312,13 @@ def main():
print(
f"\n\n[{CRED}error{CEND}]: {CYELLOW}Your WebUI is likely not connected to the Deluge daemon. Open the WebUI to resolve this.{CEND}\n\n"
)
deluge_handler.call("auth.delete_session", [], 0)
deluge_handler.session.close()
exit(1)
except Exception as e:
print(f"\n\n[{CRED}error{CEND}]: {CBOLD}{e}{CEND}\n\n")

deluge_handler.call("auth.delete_session", [], 0)
deluge_handler.session.close()


Expand Down

0 comments on commit 274cc87

Please sign in to comment.