removed duplicate function

This commit is contained in:
Michael Clemens 2021-06-02 12:41:56 +02:00
parent 091feae555
commit d90e8234ce
1 changed files with 34 additions and 56 deletions

View File

@ -1,17 +1,22 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
# qrzlogger #######################################################################
# ========= # _ #
# # __ _ _ _ __| |___ __ _ __ _ ___ _ _ #
# This script is a QRZ.com command line QSO logger. # / _` | '_|_ / / _ \/ _` / _` / -_) '_| #
# It does the following: # \__, |_| /__|_\___/\__, \__, \___|_| #
# 1) asks the user for a call sign # |_| |___/|___/ #
# 2) displays available call sign info pulled from QRZ.com # #
# 3) displays all previous QSOs with this call (pulled from QRZ.com logbook) # #
# 4) alles the user to enter QSO specific data (date, time, report, band etc.) # A python application to log QSOs directly to QRZ.com from the CLI #
# 5) uploads the QSO to QRZ.com's logbook # #
# 6) lists the last 5 logged QSOs ((pulled from QRZ.com logbook) # Author: Michael Clemens, DL6MHC (qrzlogger@qrz.is) #
# 7) starts again from 1) # #
# Documentation: Please see the README.md file #
# License: Please see the LICENSE file #
# Repository: https://github.com/exitnode/qrzlogger #
# #
#######################################################################
import requests import requests
@ -28,11 +33,14 @@ from datetime import timezone
import configparser import configparser
from colored import fore, back, style from colored import fore, back, style
class QRZLogger():
class QRZLogger():
# initialize things # initialize things
def __init__(self): def __init__(self):
self.version = "0.6.2"
# Define the configuration object # Define the configuration object
self.config = configparser.ConfigParser() self.config = configparser.ConfigParser()
self.config_file = os.path.expanduser('~/.qrzlogger.ini') self.config_file = os.path.expanduser('~/.qrzlogger.ini')
@ -42,7 +50,7 @@ class QRZLogger():
if self.config and self.config['log']['log_file']: if self.config and self.config['log']['log_file']:
self.log_file = self.config['log']['log_file'] self.log_file = self.config['log']['log_file']
else: else:
self.log_file = "/tmp/qrzlogger.log" self.log_file = os.path.expanduser('~/.qrzlogger.log')
# QRZ.com URLs # QRZ.com URLs
@ -66,6 +74,18 @@ class QRZLogger():
self.configColors() self.configColors()
# print an awesome banner
def printBanner(self):
v = self.version
print(self.logocol)
print(" _ ")
print(" __ _ _ _ __| |___ __ _ __ _ ___ _ _ ")
print(" / _` | '_|_ / / _ \/ _` / _` / -_) '_|")
print(" \__, |_| /__|_\___/\__, \__, \___|_| ")
print(" |_| -=DL6MHC=- |___/|___/ v"+v+" ")
print(style.RESET)
# Read color settings from config file # Read color settings from config file
def configColors(self): def configColors(self):
if self.config and self.config['colors']['use_colors'] == "yes": if self.config and self.config['colors']['use_colors'] == "yes":
@ -439,48 +459,6 @@ class QRZLogger():
elif inp == "n": elif inp == "n":
return False return False
# initialize things
def __init__(self):
# Define the configuration object
self.config = configparser.ConfigParser()
self.config_file = os.path.expanduser('~/.qrzlogger.ini')
self.writeDefaultConfig(self.config, self.config_file)
if self.config and self.config['log']['log_file']:
self.log_file = self.config['log']['log_file']
else:
self.log_file = "/tmp/qrzlogger.log"
# QRZ.com URLs
self.xml_url = "https://xmldata.QRZ.com/xml/current/"
self.api_url = "https://logbook.qrz.com/api"
# headers for all POST requests
self.headers = CaseInsensitiveDict()
self.headers["Content-Type"] = "application/x-www-form-urlencoded"
# Default colors
self.inputcol = style.RESET
self.hlcol = style.RESET
self.defvalcol = style.RESET
self.errorcol = style.RESET
self.successcol = style.RESET
self.tablecol = style.RESET
self.logocol = style.RESET
# read colors from config and overwrite default vaulues
self.configColors()
# print an awesome banner
def printBanner(self):
print(self.logocol + " _ ")
print(" __ _ _ _ __| |___ __ _ __ _ ___ _ _ ")
print(" / _` | '_|_ / / _ \/ _` / _` / -_) '_|")
print(" \__, |_| /__|_\___/\__, \__, \___|_| ")
print(" |_| DL6MHC |___/|___/ v0.6.1 " + style.RESET)
##################################################### #####################################################