added logging of failed and successfull QSOs as ADIf into log file

This commit is contained in:
Michael Clemens 2021-05-25 12:37:10 +02:00
parent 0c7e099cb8
commit c225aeebfc
2 changed files with 11 additions and 0 deletions

View File

@ -5,6 +5,7 @@ api_key = 1234-ABCD-1234-A1B2
qrz_user = N0CALL
qrz_pass = q1w2e3r4t5z6u7i8o9
xml_fields = ("call", "band", "mode", "qso_date", "time_on", "rst_sent", "rst_rcvd", "comment")
log_file = qrzlogger.log
# default values for new QSOs
band = 40m

View File

@ -65,6 +65,11 @@ headers["Content-Type"] = "application/x-www-form-urlencoded"
session = None
session_key = None
if config['qrzlogger']['log_file']:
log_file = config['qrzlogger']['log_file']
else:
log_file = "qrzlogger.log"
# Read user definable colors from config
if config['qrzlogger']['use_colors'] == "yes":
inputcol = eval(config['qrzlogger']['inputcol'])
@ -328,6 +333,7 @@ def queryQSOData(qso):
# QRZ.com logbook entry via the API
def sendQSO(qso):
logid = "null"
log_status = "FAILED: "
# construct ADIF QSO entry
adif = '<station_callsign:' + str(len(config['qrzlogger']['station_call'])) + '>' + config['qrzlogger']['station_call']
@ -362,12 +368,16 @@ def sendQSO(qso):
logid = "null"
print(successcol)
print("QSO successfully uploaded to QRZ.com (LOGID "+ logid + ")")
log_status = "SUCCESS: "
print(style.RESET)
with open(log_file, "a") as log:
log.write(log_status + adif + "\n")
return logid
else:
print(errorcol + "\nA critical error occured. Please review all previous output." + style.RESET)
# ask a user a simple y/n question
# returns True if "y"
# returns False in "n"