mirror of
https://codeberg.org/mclemens/dxpager.git
synced 2024-09-30 05:06:02 -04:00
added de-duplication based on DX call and frequency
This commit is contained in:
parent
e740d7b1cc
commit
de0f482277
@ -8,6 +8,7 @@ worked/confirmed before. To achieve this, it
|
||||
* determines the DX station's continent
|
||||
* determines if the DX station uses LotW
|
||||
* determines if the DX station's country has been confirmed via LotW
|
||||
* de-duplicates spots
|
||||
* and finally - if it's a new DXCC - sends the information to your dapnet pager
|
||||
|
||||
# Limitations
|
||||
@ -21,6 +22,7 @@ The following limitations are present:
|
||||
|
||||
DXPager needs Python 3 and the following libraries:
|
||||
|
||||
* cachetools
|
||||
* requests
|
||||
|
||||
Furthermore, you need an account at LotW and hampager.de
|
||||
|
13
dxpager.py
13
dxpager.py
@ -38,7 +38,9 @@ from telnetlib import Telnet
|
||||
from pathlib import Path
|
||||
import json
|
||||
import requests
|
||||
import hashlib
|
||||
from requests.auth import HTTPBasicAuth
|
||||
from cachetools import TTLCache
|
||||
|
||||
|
||||
class DXPager():
|
||||
@ -49,6 +51,8 @@ class DXPager():
|
||||
|
||||
self.print_banner()
|
||||
|
||||
|
||||
self.cache = TTLCache(maxsize=100, ttl=3600)
|
||||
self.config = configparser.ConfigParser()
|
||||
self.home_dir = str(Path.home())
|
||||
self.config_dir = self.home_dir + "/.config/dxpager/"
|
||||
@ -253,7 +257,6 @@ class DXPager():
|
||||
try:
|
||||
# Extract all necessary fields from the line and store them
|
||||
# into different variables.
|
||||
#print(line)
|
||||
call_de = re.search('D(X|x) de (.+?): ', line).group(2)
|
||||
freq = re.search(': +(.+?) ', line).group(1)
|
||||
call_dx = re.search(freq + ' +(.+?) ', line).group(1)
|
||||
@ -282,20 +285,24 @@ class DXPager():
|
||||
# Removes the trailing .0 from a frequency for better readability
|
||||
freq = freq.replace('.0', '')
|
||||
|
||||
msg = "{}: {} de {} {} {}({}){}{}"\
|
||||
msg = "{}: {} de {} {} {} ({}){}{}"\
|
||||
.format(time, call_dx, call_de, freq, areaname, continent, lotw, comment)
|
||||
dapnet_json = json.dumps({"text": msg, "callSignNames": \
|
||||
[self.config['dapnet']['dapnet_callsigns']], \
|
||||
"transmitterGroupNames": [self.config['dapnet']['dapnet_txgroup']], \
|
||||
"emergency": False})
|
||||
cf = call_dx+freq
|
||||
hash_entry = hashlib.md5(cf.encode())
|
||||
# If the DX station's entity hasn't been worked/confirmed via
|
||||
# LotW yet, the message will be sent to the dapnet API
|
||||
if self.check_lotw_confirmed and self.config['lotw']['user'] != "N0CALL" \
|
||||
if hash_entry.hexdigest() not in self.cache.keys() and \
|
||||
self.check_lotw_confirmed and self.config['lotw']['user'] != "N0CALL" \
|
||||
and cty_details[2] not in self.confirmed_entities:
|
||||
response = requests.post(self.config['dapnet']['dapnet_url'], \
|
||||
data=dapnet_json, auth=HTTPBasicAuth(\
|
||||
self.config['dapnet']['dapnet_user'],\
|
||||
self.config['dapnet']['dapnet_pass']))
|
||||
self.cache[hash_entry.hexdigest()] = cf
|
||||
print("!!! Sent to DAPNET: {} Response: {}".format(msg, response))
|
||||
else:
|
||||
print(" Not sent to DAPNET: {}".format(msg))
|
||||
|
Loading…
Reference in New Issue
Block a user