the user can quit the application any time by entering "quit"

ctrl+c and ctrl+d are now handled
This commit is contained in:
Michael Clemens 2021-06-03 19:53:07 +02:00
parent 35dae7b23b
commit f704297c14
2 changed files with 85 additions and 78 deletions

View File

@ -1,6 +1,6 @@
[metadata]
name = qrzlogger
version = 0.6.2
version = 0.6.5
author = Michael Clemens
author_email = qrzlogger@qrz.is
description = A python application to log QSOs directly to QRZ.com from the command line

View File

@ -39,7 +39,7 @@ class QRZLogger():
# initialize things
def __init__(self):
self.version = "0.6.2"
self.version = "0.6.5"
# Define the configuration object
self.config = configparser.ConfigParser()
@ -435,6 +435,8 @@ class QRZLogger():
# If not, we keep the data provided by the user
if inp == "c":
return None
if inp == "quit":
sys.exit()
if inp != "":
questions[q][1] = inp
# check if we are asking for the band
@ -455,11 +457,13 @@ class QRZLogger():
# returns False in "n"
def askUser(self, question):
while True:
inp = input("\n" + self.inputcol + question + " [" + self.defvalcol + "y/n" + self.inputcol + "]: " + style.RESET)
inp = input("\n" + self.inputcol + question + " [" + self.defvalcol + "y/n/quit" + self.inputcol + "]: " + style.RESET)
if inp == "y":
return True
elif inp == "n":
return False
elif inp == "quit":
sys.exit()
@ -478,11 +482,14 @@ def main():
# Begin the main loop
while keeponlogging:
try:
# get a session after logging into QRZ with user/pass
session_key = q.get_session()
# query a call sign from the user
resume = True
call = input("\n\n%sEnter Callsign:%s " % (q.inputcol, style.RESET))
if call == "quit":
sys.exit()
# check if it has the format of a valid call sign
# (at least 3 characters, only alphanumeric and slashes)
if not (len(call) > 2 and call.replace("/", "").isalnum()):
@ -559,11 +566,11 @@ def main():
# the user has entered 'c' during the QSO detail entering process
else:
resume = False
print(q.inputcol)
print("73!")
print(style.RESET)
except:
print("\n\n73!\n")
sys.exit()
if __name__ == "__main__":
sys.exit(main())