From b5b5f0aeb80b9e5ffd832fe21ff618dabb62e08e Mon Sep 17 00:00:00 2001 From: Michael Clemens Date: Fri, 20 May 2022 18:46:00 +0200 Subject: [PATCH] bug fixes LotW QSL check is now optional --- README.md | 11 +++++++-- src/colorspot/__main__.py | 52 +++++++++++++++++++++------------------ 2 files changed, 37 insertions(+), 26 deletions(-) diff --git a/README.md b/README.md index 88dcb82..96c2a35 100644 --- a/README.md +++ b/README.md @@ -5,13 +5,20 @@ This script is a command line DX cluster client. It adds the following benefits * displays the DX station's country * displays the DX station's continent * displays if the DX station uses LotW - * downloads your LotW QSL file and marks all lines with countries that need to be confirmed + * downloads your LotW QSL file and marks all lines with countries that need to be confirmed (optional) * displays lines in different colors depending on the continent or band (user configurable) # Screnshot ![screenshot](/screenshot.png?raw=true "screenshot") +# Limitations + +The following limitations are present: + + * read-only: you can't send commands to the dx cluster server via this tool + * no filters: you need to configure your filter on the server + # Installation ColorSpot needs Python 3 and the following libraries: @@ -48,7 +55,7 @@ To update colorspot, execute the following command: * adapt _~/.colorspot.ini_ to your needs. Important setting are: * cluster/host and cluster/port: Change this if you want to use another cluster server * cluster/user: Enter here your call sign - * lotw/user: Enter here your lotw user name (your call sign) + * lotw/user: Enter here your lotw user name (your call sign). Leave at "N0CALL" to disable this feature. * lotw/password: Enter here your lotw password * lotw/mode: Enter here the mode you would like to filter the QSL download from LotW * execute the application again with "colorspot" diff --git a/src/colorspot/__main__.py b/src/colorspot/__main__.py index 4dbffe5..d2cba11 100755 --- a/src/colorspot/__main__.py +++ b/src/colorspot/__main__.py @@ -57,13 +57,17 @@ class ColorSpot(): self.check_files() - if self.check_lotw_confirmed: + if self.config['lotw']['user'] != "N0CALL" and self.check_lotw_confirmed: self.confirmed_entities = self.get_confirmed_entities() if self.check_cty: with open(self.config_dir + self.config['files']['cty'], encoding='us-ascii') as csvfile: self.cty = list(csv.reader(csvfile, delimiter=',')) + if self.check_lotw_activity: + with open(self.config_dir + self.config['files']['lotw_activity'], encoding='us-ascii') as csvfile: + self.lotw_activity = list(csv.reader(csvfile, delimiter=',')) + def print_banner(self): """print an awesome banner""" @@ -163,22 +167,25 @@ class ColorSpot(): Downloads all files and unzips them (if necessary)""" # check for lotw qsl information file - self.check_lotw_confirmed = exists(self.config_dir + self.config['files']['lotw_confirmed']) - if not self.check_lotw_confirmed: - 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'] - 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) - self.download_file(url, self.config_dir + self.config['files']['lotw_confirmed']) + if self.config['lotw']['user'] != "N0CALL": 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) + if not self.check_lotw_confirmed: + 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'] + 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) + 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) + else: + self.check_lotw_confirmed = False # check for cty.csv file self.check_cty = exists(self.config_dir + self.config['files']['cty']) @@ -228,13 +235,10 @@ 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_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: - if call == row[0]: - ret = row[1] - return ret + for row in self.lotw_activity: + if call == row[0]: + ret = row[1] + return ret return ret @@ -328,7 +332,7 @@ class ColorSpot(): # If the DX station's entity hasn't been worked/confirmed via # LotW yet, the row's background will be color coded. - if self.check_lotw_confirmed and \ + if self.check_lotw_confirmed and self.config['lotw']['user'] != "N0CALL" and \ cty_details[2] not in self.confirmed_entities: background = self.config['colors']['alert_bg'] foreground = self.config['colors']['alert_fg']