added contest mode via -c argument

This commit is contained in:
Michael Clemens 2022-07-31 17:23:15 +02:00
parent a1824dc7f4
commit 3910e0fc06
2 changed files with 38 additions and 17 deletions

View File

@ -42,7 +42,7 @@ To download or update qrzlogger, clone the repo:
# Usage # Usage
* execute the application with "python3 qrzlogger.py" * execute the application with "python3 qrzlogger.py" for normal mode or with "python3 qrzlogger.py -c" for contest mode
* qrzlogger creates a default config file and states its location (e.g. _~/.qrzlogger.ini_) * qrzlogger creates a default config file and states its location (e.g. _~/.qrzlogger.ini_)
* adapt _~/.qrzlogger.ini_ to your needs. Important setting are: * adapt _~/.qrzlogger.ini_ to your needs. Important setting are:
* station_call: This is your station call (must match with the QRZ.com logbook) * station_call: This is your station call (must match with the QRZ.com logbook)
@ -53,4 +53,4 @@ To download or update qrzlogger, clone the repo:
# License # License
see ![LICENSE](LICENSE) see ![LICENSE](LICENSE)

View File

@ -57,6 +57,9 @@ class QRZLogger():
else: else:
self.log_file = os.path.expanduser('~/.qrzlogger.log') self.log_file = os.path.expanduser('~/.qrzlogger.log')
self.contest = False
if len(sys.argv) > 1 and str(sys.argv[1]) == "-c":
self.contest = True
# QRZ.com URLs # QRZ.com URLs
self.xml_url = "https://xmldata.QRZ.com/xml/current/" self.xml_url = "https://xmldata.QRZ.com/xml/current/"
@ -458,17 +461,33 @@ class QRZLogger():
# If this is the first try filling out the QSO fields # If this is the first try filling out the QSO fields
# then we use defaults # then we use defaults
if qso is None: if qso is None:
questions = { if not self.contest:
"band": ["Band", self.config['qso_defaults']['band']], questions = {
"rst_rcvd": ["RST Received", self.config['qso_defaults']['rst_rcvd']], "band": ["Band", self.config['qso_defaults']['band']],
"rst_sent": ["RST Sent", self.config['qso_defaults']['rst_sent']], "rst_rcvd": ["RST Received", self.config['qso_defaults']['rst_rcvd']],
"comment": ["Comment", ""], "rst_sent": ["RST Sent", self.config['qso_defaults']['rst_sent']],
"freq": ["Frequency", ""], "comment": ["Comment", ""],
"mode": ["Mode", self.config['qso_defaults']['mode']], "freq": ["Frequency", ""],
"tx_pwr": ["Power (in W)", self.config['qso_defaults']['tx_pwr']], "mode": ["Mode", self.config['qso_defaults']['mode']],
"qso_date" : ["QSO Date", dt_now.strftime("%Y%m%d")], "tx_pwr": ["Power (in W)", self.config['qso_defaults']['tx_pwr']],
"time_on": ["QSO Time", dt_now.strftime("%H%M")] "qso_date" : ["QSO Date", dt_now.strftime("%Y%m%d")],
} "time_on": ["QSO Time", dt_now.strftime("%H%M")]
}
else:
questions = {
"band": ["Band", self.config['qso_defaults']['band']],
"srx": ["Serial Received", "001"],
"srx_string": ["Info Received", ""],
"stx": ["Serial Sent", "001"],
"stx_string": ["Info Sent", ""],
"freq": ["Frequency", ""],
"mode": ["Mode", self.config['qso_defaults']['mode']],
"rst_rcvd": ["RST Received", self.config['qso_defaults']['rst_rcvd']],
"rst_sent": ["RST Sent", self.config['qso_defaults']['rst_sent']],
"comment": ["Comment", ""],
"qso_date" : ["QSO Date", dt_now.strftime("%Y%m%d")],
"time_on": ["QSO Time", dt_now.strftime("%H%M")]
}
# if this is not the first try, we pre-fill the # if this is not the first try, we pre-fill the
# vaulues we got from the last try # vaulues we got from the last try
else: else:
@ -486,7 +505,7 @@ class QRZLogger():
return None return None
if inp == "d": if inp == "d":
return questions return questions
if inp == "quit": if inp == "quit" or inp == "exit":
sys.exit() sys.exit()
if inp != "": if inp != "":
questions[question][1] = inp questions[question][1] = inp
@ -500,7 +519,6 @@ class QRZLogger():
except: # pylint: disable=bare-except except: # pylint: disable=bare-except
print(self.errorcol + "\nUnable to read default frequency \ print(self.errorcol + "\nUnable to read default frequency \
values from config file." + attr('reset')) values from config file." + attr('reset'))
return questions return questions
@ -509,7 +527,7 @@ class QRZLogger():
call = "" call = ""
while True: while True:
call = input("\n\n%sEnter Callsign:%s " % (self.inputcol, attr('reset'))) call = input("\n\n%sEnter Callsign:%s " % (self.inputcol, attr('reset')))
if call == "quit": if call == "quit" or call == "exit":
sys.exit() sys.exit()
# check if it has the format of a valid call sign # check if it has the format of a valid call sign
# (at least 3 characters, only alphanumeric and slashes) # (at least 3 characters, only alphanumeric and slashes)
@ -558,7 +576,7 @@ class QRZLogger():
break break
if answer == "N": if answer == "N":
break break
if answer == "QUIT": if answer == "QUIT" or answer == "EXIT":
sys.exit() sys.exit()
return done return done
@ -589,6 +607,9 @@ def main():
qrz = QRZLogger() qrz = QRZLogger()
qrz.print_banner() qrz.print_banner()
if qrz.contest:
print("\nContest mode enabled.")
keeponlogging = True keeponlogging = True
session_key = None session_key = None