mirror of
https://codeberg.org/mclemens/colorspot.git
synced 2024-10-02 23:26:11 -04:00
moved urls to config
downloads qsls from lotw now
This commit is contained in:
parent
de323722f4
commit
116567b979
27
colorspot.py
27
colorspot.py
@ -32,10 +32,10 @@ class ColorSpot():
|
|||||||
self.read_config(self.config, self.config_file)
|
self.read_config(self.config, self.config_file)
|
||||||
|
|
||||||
self.check_files()
|
self.check_files()
|
||||||
|
|
||||||
if self.check_lotw_confirmed:
|
if self.check_lotw_confirmed:
|
||||||
self.confirmed_entities = self.get_confirmed_entities()
|
self.confirmed_entities = self.get_confirmed_entities()
|
||||||
|
|
||||||
|
|
||||||
if self.check_cty:
|
if self.check_cty:
|
||||||
self.cty = list(csv.reader(open(self.config['files']['cty'], "r"), delimiter=","))
|
self.cty = list(csv.reader(open(self.config['files']['cty'], "r"), delimiter=","))
|
||||||
|
|
||||||
@ -46,15 +46,10 @@ class ColorSpot():
|
|||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def download_file(url, local_filename):
|
def download_file(url, local_filename):
|
||||||
#local_filename = url.split('/')[-1]
|
|
||||||
# NOTE the stream=True parameter below
|
|
||||||
with requests.get(url, stream=True) as r:
|
with requests.get(url, stream=True) as r:
|
||||||
r.raise_for_status()
|
r.raise_for_status()
|
||||||
with open(local_filename, 'wb') as f:
|
with open(local_filename, 'wb') as f:
|
||||||
for chunk in r.iter_content(chunk_size=8192):
|
for chunk in r.iter_content(chunk_size=8192):
|
||||||
# If you have chunk encoded response uncomment if
|
|
||||||
# and set chunk_size parameter to None.
|
|
||||||
#if chunk:
|
|
||||||
f.write(chunk)
|
f.write(chunk)
|
||||||
return local_filename
|
return local_filename
|
||||||
|
|
||||||
@ -63,12 +58,24 @@ class ColorSpot():
|
|||||||
self.check_lotw_confirmed = exists(self.config['files']['lotw_confirmed'])
|
self.check_lotw_confirmed = exists(self.config['files']['lotw_confirmed'])
|
||||||
if not self.check_lotw_confirmed:
|
if not self.check_lotw_confirmed:
|
||||||
print("The file " + self.config['files']['lotw_confirmed'] + " is missing.")
|
print("The file " + self.config['files']['lotw_confirmed'] + " is missing.")
|
||||||
|
user = self.config['lotw']['user']
|
||||||
|
password = self.config['lotw']['password']
|
||||||
|
mode = self.config['lotw']['mode']
|
||||||
|
url = "https://lotw.arrl.org/lotwuser/lotwreport.adi?login={}&password={}&qso_query=1&qso_qsl=yes&qso_mode={}&qso_qsldetail=yes&qso_qslsince=1970-01-01".format(user, password, mode)
|
||||||
|
print("Trying to download " + url)
|
||||||
|
file_name = self.download_file(url, self.config['files']['lotw_confirmed'])
|
||||||
|
self.check_lotw_confirmed = exists(self.config['files']['lotw_confirmed'])
|
||||||
|
if self.check_lotw_confirmed:
|
||||||
|
print("File successfully downloaded")
|
||||||
|
else:
|
||||||
|
print("something went wrong while downloading " + url)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# check for cty.csv file
|
# check for cty.csv file
|
||||||
self.check_cty = exists(self.config['files']['cty'])
|
self.check_cty = exists(self.config['files']['cty'])
|
||||||
if not self.check_cty:
|
if not self.check_cty:
|
||||||
url = "https://www.country-files.com/bigcty/download/bigcty.zip"
|
url = self.config['files']['cty_url']
|
||||||
print("The file " + self.config['files']['cty'] + " is missing.")
|
print("The file " + self.config['files']['cty'] + " is missing.")
|
||||||
print("Trying to download " + url)
|
print("Trying to download " + url)
|
||||||
zip_name = self.download_file(url, "bigcty.zip" )
|
zip_name = self.download_file(url, "bigcty.zip" )
|
||||||
@ -84,7 +91,7 @@ class ColorSpot():
|
|||||||
# check for lotw user activity file
|
# check for lotw user activity file
|
||||||
self.check_lotw_activity = exists(self.config['files']['lotw_activity'])
|
self.check_lotw_activity = exists(self.config['files']['lotw_activity'])
|
||||||
if not self.check_lotw_activity:
|
if not self.check_lotw_activity:
|
||||||
url = "https://lotw.arrl.org/lotw-user-activity.csv"
|
url = self.config['files']['lotw_activity_url']
|
||||||
print("The file " + self.config['files']['lotw_activity'] + " is missing.")
|
print("The file " + self.config['files']['lotw_activity'] + " is missing.")
|
||||||
print("Trying to download " + url)
|
print("Trying to download " + url)
|
||||||
file_name = self.download_file(url, self.config['files']['lotw_activity'])
|
file_name = self.download_file(url, self.config['files']['lotw_activity'])
|
||||||
@ -123,8 +130,10 @@ class ColorSpot():
|
|||||||
'timeout': '100'}
|
'timeout': '100'}
|
||||||
config['files'] = {
|
config['files'] = {
|
||||||
'cty': 'cty.csv',
|
'cty': 'cty.csv',
|
||||||
|
'cty_url': 'https://www.country-files.com/bigcty/download/bigcty.zip',
|
||||||
'lotw_confirmed': 'lotw.adi',
|
'lotw_confirmed': 'lotw.adi',
|
||||||
'lotw_activity': 'lotw-user-activity.csv'}
|
'lotw_activity': 'lotw-user-activity.csv',
|
||||||
|
'lotw_activity_url': 'https://lotw.arrl.org/lotw-user-activity.csv'}
|
||||||
config['lotw'] = {
|
config['lotw'] = {
|
||||||
'user': 'N0CALL',
|
'user': 'N0CALL',
|
||||||
'password': 'XXXXXXXXX',
|
'password': 'XXXXXXXXX',
|
||||||
|
Loading…
Reference in New Issue
Block a user