moved all files to ~/.config/colorspot/
This commit is contained in:
parent
c54b7d4c11
commit
585153e84b
@ -1,6 +1,6 @@
|
||||
[metadata]
|
||||
name = colorspot
|
||||
version = 0.1.1
|
||||
version = 0.1.3
|
||||
author = Michael Clemens
|
||||
author_email = colorspot@qrz.is
|
||||
description = A colorful CLI DX cluster client with LotW integration
|
||||
@ -23,7 +23,6 @@ python_requires = >=3.6
|
||||
install_requires=
|
||||
colored
|
||||
requests
|
||||
zipfile
|
||||
|
||||
[options.packages.find]
|
||||
where = src
|
||||
|
@ -1,3 +1,3 @@
|
||||
from colorspot.__main__ import ColorSpot
|
||||
|
||||
__version__ = '0.1.1'
|
||||
__version__ = '0.1.3'
|
||||
|
@ -37,6 +37,7 @@ import zipfile
|
||||
from telnetlib import Telnet
|
||||
import requests
|
||||
from colored import fg, bg, attr
|
||||
from pathlib import Path
|
||||
|
||||
class ColorSpot():
|
||||
"""ColorSpot class"""
|
||||
@ -47,7 +48,11 @@ class ColorSpot():
|
||||
self.print_banner()
|
||||
|
||||
self.config = configparser.ConfigParser()
|
||||
self.config_file = os.path.expanduser('~/.colorspot.ini')
|
||||
self.home_dir = str(Path.home())
|
||||
self.config_dir = self.home_dir + "/.config/colorspot/"
|
||||
# Check if config directory exists and else create it
|
||||
Path(self.config_dir).mkdir(parents=True, exist_ok=True)
|
||||
self.config_file = os.path.expanduser(self.config_dir + 'colorspot.ini')
|
||||
self.read_config(self.config, self.config_file)
|
||||
|
||||
self.check_files()
|
||||
@ -56,7 +61,7 @@ class ColorSpot():
|
||||
self.confirmed_entities = self.get_confirmed_entities()
|
||||
|
||||
if self.check_cty:
|
||||
with open(self.config['files']['cty'], encoding='us-ascii') as csvfile:
|
||||
with open(self.config_dir + self.config['files']['cty'], encoding='us-ascii') as csvfile:
|
||||
self.cty = list(csv.reader(csvfile, delimiter=','))
|
||||
|
||||
|
||||
@ -156,10 +161,11 @@ class ColorSpot():
|
||||
def check_files(self):
|
||||
"""Checks if all necessary files are in the file system.
|
||||
Downloads all files and unzips them (if necessary)"""
|
||||
|
||||
# check for lotw qsl information file
|
||||
self.check_lotw_confirmed = exists(self.config['files']['lotw_confirmed'])
|
||||
self.check_lotw_confirmed = exists(self.config_dir + self.config['files']['lotw_confirmed'])
|
||||
if not self.check_lotw_confirmed:
|
||||
print("The file " + self.config['files']['lotw_confirmed'] + " is missing.")
|
||||
print("The file " + self.config_dir + self.config['files']['lotw_confirmed'] + " is missing.")
|
||||
user = self.config['lotw']['user']
|
||||
password = self.config['lotw']['password']
|
||||
mode = self.config['lotw']['mode']
|
||||
@ -167,37 +173,38 @@ class ColorSpot():
|
||||
"&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)
|
||||
self.download_file(url, self.config['files']['lotw_confirmed'])
|
||||
self.check_lotw_confirmed = exists(self.config['files']['lotw_confirmed'])
|
||||
self.download_file(url, self.config_dir + self.config['files']['lotw_confirmed'])
|
||||
self.check_lotw_confirmed = exists(self.config_dir + 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
|
||||
self.check_cty = exists(self.config['files']['cty'])
|
||||
self.check_cty = exists(self.config_dir + self.config['files']['cty'])
|
||||
if not self.check_cty:
|
||||
url = self.config['files']['cty_url']
|
||||
print("The file " + self.config['files']['cty'] + " is missing.")
|
||||
print("The file " + self.config_dir + self.config['files']['cty'] + " is missing.")
|
||||
print("Trying to download " + url)
|
||||
zip_name = self.download_file(url, "bigcty.zip" )
|
||||
# TODO: pfad?
|
||||
zip_name = self.download_file(url, self.config_dir + "bigcty.zip" )
|
||||
with zipfile.ZipFile(zip_name, 'r') as zip_ref:
|
||||
zip_ref.extract("cty.csv")
|
||||
zip_ref.extract("cty.csv", path=self.config_dir)
|
||||
os.remove(zip_name)
|
||||
self.check_cty = exists(self.config['files']['cty'])
|
||||
self.check_cty = exists(self.config_dir + self.config['files']['cty'])
|
||||
if self.check_cty:
|
||||
print("File successfully downloaded and extracted.")
|
||||
else:
|
||||
print("something went wrong while downloading " + url)
|
||||
|
||||
# check for lotw user activity file
|
||||
self.check_lotw_activity = exists(self.config['files']['lotw_activity'])
|
||||
self.check_lotw_activity = exists(self.config_dir + self.config['files']['lotw_activity'])
|
||||
if not self.check_lotw_activity:
|
||||
url = self.config['files']['lotw_activity_url']
|
||||
print("The file " + self.config['files']['lotw_activity'] + " is missing.")
|
||||
print("The file " + self.config_dir + self.config['files']['lotw_activity'] + " is missing.")
|
||||
print("Trying to download " + url)
|
||||
self.download_file(url, self.config['files']['lotw_activity'])
|
||||
self.check_lotw_activity = exists(self.config['files']['lotw_activity'])
|
||||
self.download_file(url, self.config_dir + self.config['files']['lotw_activity'])
|
||||
self.check_lotw_activity = exists(self.config_dir + self.config['files']['lotw_activity'])
|
||||
if self.check_lotw_activity:
|
||||
print("File successfully downloaded")
|
||||
else:
|
||||
@ -208,7 +215,7 @@ class ColorSpot():
|
||||
"""Reads the file downlaoded from LotW with all confirmed QSOs,
|
||||
extracts all confirmed DXCCs and puts them into a list"""
|
||||
ret = []
|
||||
with open(self.config['files']['lotw_confirmed'], encoding='us-ascii') as file:
|
||||
with open(self.config_dir + self.config['files']['lotw_confirmed'], encoding='us-ascii') as file:
|
||||
for row in file:
|
||||
if re.search("<DXCC:", row):
|
||||
dxcc = row.partition(">")[2].lower().rstrip()
|
||||
@ -221,7 +228,7 @@ class ColorSpot():
|
||||
"""Reads the LotW user activity file and returns the date
|
||||
of the last upload date if a specific call sign"""
|
||||
ret = ""
|
||||
with open(self.config['files']['lotw_activity'], encoding='us-ascii') as csvfile:
|
||||
with open(self.config_dir + self.config['files']['lotw_activity'], encoding='us-ascii') as csvfile:
|
||||
csv_file = csv.reader(csvfile, delimiter=',')
|
||||
#loop through the csv file
|
||||
for row in csv_file:
|
||||
|
Loading…
Reference in New Issue
Block a user