Skip to content

Commit

Permalink
Merge pull request #144 from CharaChorder/stage
Browse files Browse the repository at this point in the history
Fix: Chord deletion
  • Loading branch information
Raymo111 committed Aug 30, 2024
2 parents fdfaa2b + c4adfd7 commit 770fe38
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 19 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
8 changes: 4 additions & 4 deletions nexus/GUI.py
Original file line number Diff line number Diff line change
Expand Up @@ -539,7 +539,7 @@ def delete_entry(self, is_chord=False):
"""Controller for right click menu/delete key delete entry"""
# Get word(s) from selected row(s)
table = self.chord_table if is_chord else self.chentry_table
selected_words = ([table.item(row.row(), 0).text() for row in table.selectionModel().selectedRows()]
selected_words = ({table.item(row.row(), 0).text(): None for row in table.selectionModel().selectedRows()}
if is_chord else {table.item(row.row(), 0).text(): CaseSensitivity.INSENSITIVE for row in
table.selectionModel().selectedRows()})
display_word = None
Expand Down 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
33 changes: 19 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 Expand Up @@ -372,6 +376,7 @@ def _prompt_for_password(new: bool, desc: str = "") -> str:
print(f"Word '{word}' not found")
exit_code = 5
case "delchordentry": # Delete chord entry
logging.debug("args.chord: " + str(args.chord))
for chord in args.chord:
if not freqlog.delete_logged_chord(chord):
print(f"Chord '{chord}' not found")
Expand Down

0 comments on commit 770fe38

Please sign in to comment.