added close connection / exit function
This commit is contained in:
parent
210a41de64
commit
3804a7448b
@ -64,8 +64,7 @@ class MenuHelper:
|
||||
# check if choice is in menu
|
||||
match self.start_menu[choice]:
|
||||
case "Exit":
|
||||
print(f"{utilityHelper.blinkMessage('Exiting system')}")
|
||||
exit()
|
||||
utilityHelper.closeConnection(self.peer_ip_addr, self.peer_port)
|
||||
|
||||
case "Explore the Blockchain":
|
||||
blockHelper.exploreBlocks(self)
|
||||
@ -114,8 +113,7 @@ class MenuHelper:
|
||||
# check if choice is in menu
|
||||
match self.user_main_menu[choice]:
|
||||
case "Exit":
|
||||
print(f"{utilityHelper.blinkMessage('Exiting system')}")
|
||||
exit()
|
||||
utilityHelper.closeConnection(self.peer_ip_addr, self.peer_port)
|
||||
|
||||
case "Log out":
|
||||
self.user.logout()
|
||||
|
@ -3,6 +3,7 @@ import hashlib
|
||||
import os
|
||||
from helpers import BlockHelper as blockHelper
|
||||
from helpers import TaskHelper as taskHelper
|
||||
from helpers import SocketHelper as socketHelper
|
||||
|
||||
class bcolors:
|
||||
HEADER = '\033[95m'
|
||||
@ -94,5 +95,16 @@ def headerMessage(text):
|
||||
def blinkMessage(text):
|
||||
return bcolors.BLINK + text + bcolors.ENDC
|
||||
|
||||
def closeConnection(ip, port):
|
||||
socketHelper.sendObj(ip, "EXIT", port)
|
||||
print(f"{bcolors.WARNING}Closing connection{bcolors.ENDC}")
|
||||
close()
|
||||
|
||||
def close():
|
||||
print(f"{bcolors.WARNING}Exiting system{bcolors.ENDC}")
|
||||
os._exit(0)
|
||||
# close connection
|
||||
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user