Skip to content

Commit

Permalink
Fix: Improve killing app
Browse files Browse the repository at this point in the history
(but not fully fixed yet)
  • Loading branch information
Raymo111 committed Aug 30, 2024
1 parent 0a5c0ae commit c4adfd7
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 18 deletions.
3 changes: 2 additions & 1 deletion nexus/Freqlog/Freqlog.py
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ def _update_timing():
# Cleanup and exit if queue is empty and logging is stopped
self.backend.close()
logging.warning("Stopped freqlogging")
break
return

def _get_chords(self):
"""
Expand Down Expand Up @@ -374,6 +374,7 @@ def start_logging(self, new_word_threshold: float | None = None, chord_char_thre
self.is_logging = True
logging.warning("Started freqlogging")
self._process_queue()
exit(0)

def _log_start(self):
self.listener = vinput.EventListener(True, True, True)
Expand Down
6 changes: 3 additions & 3 deletions nexus/GUI.py
Original file line number Diff line number Diff line change
Expand Up @@ -629,13 +629,13 @@ def graceful_quit(self):
"""Quit gracefully"""
if self.freqlog:
self.freqlog.stop_logging()
self.freqlog = None
self.app.quit()
del self.freqlog
exit(1)

def exec(self):
"""Start the GUI"""
# Handle SIGINT
signal.signal(signal.SIGINT, self.graceful_quit)
signal.signal(signal.SIGINT, lambda *_: self.graceful_quit())

# Start GUI
self.window.show()
Expand Down
32 changes: 18 additions & 14 deletions nexus/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ def main():
6: Tried to ban already banned word or unban already unbanned word
7: ValueError during merge db (likely requirements not met)
8: Upgrade cancelled
9: Keyboard interrupt during startup banlist password input
11: Python version < 3.11
100: Feature not yet implemented
"""
Expand Down Expand Up @@ -270,20 +271,23 @@ def _prompt_for_password(new: bool, desc: str = "") -> str:
:param new: Whether this is a new password
:param desc: Description of database (optional)
"""
if desc:
desc += " "
if new:
while True:
password = getpass(f"Choose a new password to encrypt your {desc}banlist with: ")
if len(password) < 8:
logging.warning("Password should be at least 8 characters long.")
if input(f"Continue without securely encrypting your {desc}banlist? [y/N]: ").lower() != "y":
continue
if getpass(f"Confirm {desc}banlist password: ") == password:
return password
logging.error("Passwords don't match")
else:
return getpass(f"Enter your {desc}banlist password: ")
try:
if desc:
desc += " "
if new:
while True:
password = getpass(f"Choose a new password to encrypt your {desc}banlist with: ")
if len(password) < 8:
logging.warning("Password should be at least 8 characters long.")
if input(f"Continue without securely encrypting your {desc}banlist? [y/N]: ").lower() != "y":
continue
if getpass(f"Confirm {desc}banlist password: ") == password:
return password
logging.error("Passwords don't match")
else:
return getpass(f"Enter your {desc}banlist password: ")
except KeyboardInterrupt:
sys.exit(9)

# Parse commands
if args.command == "mergedb": # Merge databases
Expand Down

0 comments on commit c4adfd7

Please sign in to comment.