fixed bug in adif generation

This commit is contained in:
Michael Clemens 2021-05-20 21:37:43 +02:00
parent 756f8ca033
commit 5499f99f03
1 changed files with 34 additions and 13 deletions

View File

@ -112,6 +112,7 @@ def getQSOsForCallsign(callsign):
data = urllib.parse.urlencode(fetch) data = urllib.parse.urlencode(fetch)
resp = requests.post(config['qrzlogger']['api_url'], headers=headers, data=data) resp = requests.post(config['qrzlogger']['api_url'], headers=headers, data=data)
#resp = requests.post(config['qrzlogger']['api_url'], data=fetch)
str_resp = resp.content.decode("utf-8") str_resp = resp.content.decode("utf-8")
response = urllib.parse.unquote(str_resp) response = urllib.parse.unquote(str_resp)
@ -197,8 +198,8 @@ def queryQSOData(qso):
qso_time = dt_now.strftime("%H%M") qso_time = dt_now.strftime("%H%M")
band = "40m" band = "40m"
mode = "SSB" mode = "SSB"
r_rcvd = "59" rst_rcvd = "59"
r_sent = "59" rst_sent = "59"
power = "100" power = "100"
comment = "" comment = ""
@ -208,8 +209,8 @@ def queryQSOData(qso):
"qso_time": ["QSO Time: ", qso_time], "qso_time": ["QSO Time: ", qso_time],
"band": ["Band: ", band], "band": ["Band: ", band],
"mode": ["Mode: ", mode], "mode": ["Mode: ", mode],
"r_rcvd": ["RPT Received: ", r_rcvd], "rst_rcvd": ["RST Received: ", rst_rcvd],
"r_sent": ["RPT Sent: ", r_sent], "rst_sent": ["RST Sent: ", rst_sent],
"power": ["Power (in W): ", power], "power": ["Power (in W): ", power],
"comment": ["Comment: ", comment] "comment": ["Comment: ", comment]
} }
@ -227,21 +228,41 @@ def queryQSOData(qso):
# Sends the previously collected QSO information as a new # Sends the previously collected QSO information as a new
# QRZ.com logbook entry via the API # QRZ.com logbook entry via the API
def sendQSO(qso): def sendQSO(qso):
mycall = "DL6MHC"
'''
band = qso['band'][1]
mode = qso['mode'][1]
qso_date = qso['qso_date'][1]
qso_time = qso['qso_time'][1]
r_rcvd = qso['r_rcvd'][1]
r_sent = qso['r_sent'][1]
power=qso['power'][1]
comment=qso['comment'][1]
'''
insert = { 'KEY' : config['qrzlogger']['api_key'], 'ACTION' : 'INSERT', 'ADIF' : insert = { 'KEY' : config['qrzlogger']['api_key'], 'ACTION' : 'INSERT', 'ADIF' :
'<band:3>' + qso["band"][1] + '<band:' + str(len(qso['band'][1])) + '>' + qso['band'][1] +
'<mode:3>' + qso["mode"][1] + '<mode:' + str(len(qso['mode'][1])) + '>' + qso['mode'][1] +
'<call:4>' + call + '<call:' + str(len(call)) + '>' + call +
'<qso_date:8>' + qso["qso_date"][1] + '<qso_date:' + str(len(qso['qso_date'][1])) + '>' + qso['qso_date'][1] +
'<station_callsign:6>DL6MHC' + '<station_callsign:' + str(len(mycall)) + '>' + mycall +
'<time_on:4>' + qso["qso_time"][1] + '<time_on:' + str(len(qso['qso_time'][1])) + '>' + qso['qso_time'][1] +
'<rst_rcvd:' + str(len(qso['rst_rcvd'][1])) + '>' + qso['rst_rcvd'][1] +
'<rst_sent:' + str(len(qso['rst_sent'][1])) + '>' + qso['rst_sent'][1] +
'<power:' + str(len(qso['power'][1])) + '>' + qso['power'][1] +
'<comment:' + str(len(qso['comment'][1])) + '>' + qso['comment'][1] +
'<eor>'} '<eor>'}
print(insert)
data = urllib.parse.urlencode(insert) data = urllib.parse.urlencode(insert)
#print(data)
#resp = requests.post(config['qrzlogger']['api_url'], data=insert)
resp = requests.post(config['qrzlogger']['api_url'], headers=headers, data=data) resp = requests.post(config['qrzlogger']['api_url'], headers=headers, data=data)
str_resp = resp.content.decode("utf-8") #str_resp = resp.content.decode("utf-8")
response = urllib.parse.unquote(str_resp) #response = urllib.parse.unquote(str_resp)
print(response) #print(res)
return result return result