diff --git a/README.md b/README.md index ef18e0c..a62ccb0 100644 --- a/README.md +++ b/README.md @@ -78,6 +78,7 @@ brother. ## Recent Changes +- [24.2.21] Added OPON. - [24.2.19] Corrected the datetime.utcnow() deprecation to work on Python 3.9+ - [24.2.11] Trapped a KeyError in get_state() - [24.1.27] Removed some datetime.utcnow() and pkgutil.getloader() deprecations. diff --git a/fdlogger/__main__.py b/fdlogger/__main__.py index a2f0a5f..088d793 100644 --- a/fdlogger/__main__.py +++ b/fdlogger/__main__.py @@ -6,6 +6,7 @@ GPL V3 """ # pylint: disable=too-many-lines, invalid-name, no-member, no-value-for-parameter, line-too-long +# pylint: disable=logging-fstring-interpolation # Nothing to see here move along. # xplanet -body earth -window -longitude -117 -latitude 38 # -config Default -projection azmithal -radius 200 -wait 5 @@ -17,8 +18,6 @@ from json import dumps, loads, JSONDecodeError from shutil import copyfile -# import pkgutil - # from xmlrpc.client import ServerProxy, Error import struct import datetime as dt @@ -32,8 +31,6 @@ import time from itertools import chain -# from time import gmtime, strftime - import requests from PyQt5.QtNetwork import QUdpSocket, QHostAddress from PyQt5.QtGui import QFontDatabase @@ -47,6 +44,7 @@ from fdlogger.lib.database import DataBase from fdlogger.lib.cwinterface import CW from fdlogger.lib.n1mm import N1MM + from fdlogger.lib.edit_opon import OpOn from fdlogger.lib.version import __version__ except ModuleNotFoundError: from lib.lookup import HamDBlookup, HamQTH, QRZlookup @@ -55,6 +53,7 @@ from lib.database import DataBase from lib.cwinterface import CW from lib.n1mm import N1MM + from lib.edit_opon import OpOn from lib.version import __version__ @@ -119,6 +118,7 @@ class MainWindow(QtWidgets.QMainWindow): groupcall = None server_commands = [] server_seen = None + opon_dialog = None def __init__(self, *args, **kwargs): """Initialize""" @@ -262,6 +262,49 @@ def __init__(self, *args, **kwargs): self.udp_socket.bind(QHostAddress.LocalHost, 2237) self.udp_socket.readyRead.connect(self.on_udp_socket_ready_read) + def get_opon(self) -> None: + """ + Ctrl+O Open the OPON dialog. + + Parameters + ---------- + None + + Returns + ------- + None + """ + + self.opon_dialog = OpOn(os.path.dirname(__loader__.get_filename())) + self.opon_dialog.accepted.connect(self.new_op) + self.opon_dialog.open() + + def new_op(self) -> None: + """ + Called when the user clicks the OK button on the OPON dialog. + Create the new directory and copy the phonetic files. + + Parameters + ---------- + None + + Returns + ------- + None + """ + + if self.opon_dialog.NewOperator.text(): + newop = self.opon_dialog.NewOperator.text().upper() + if newop: + self.n1mm.set_operator(newop) + self.preference["mycall"] = newop + self.preference["n1mm_operator"] = newop + logger.debug(f"{newop=}") + self.writepreferences() + self.opon_dialog.close() + + # self.make_op_dir() + def show_people(self): """Display operators""" rev_dict = {} @@ -1066,7 +1109,9 @@ def poll_radio(self): else: logger.info("cat_control %s", self.cat_control) self.radio_icon.setPixmap(QtGui.QPixmap(self.radio_grey)) - self.oldmode = self.mode # Set so the UDP packet sends mode when no radio connected - NY4I + self.oldmode = ( + self.mode + ) # Set so the UDP packet sends mode when no radio connected - NY4I def flash(self): """Flash the screen""" @@ -1396,6 +1441,10 @@ def calltest(self): ).upper() self.callsign_entry.setText(cleaned) self.callsign_entry.setCursorPosition(washere) + if cleaned == "OPON": + self.get_opon() + self.clearinputs() + return self.super_check() def classtest(self): @@ -1663,12 +1712,16 @@ def log_contact(self): if self.preference.get("send_n1mm_packets"): if self.oldfreq == 0: - self.n1mm.contact_info["rxfreq"] = str(self.fakefreq(self.band, self.mode)) - self.n1mm.contact_info["txfreq"] = str(self.fakefreq(self.band, self.mode)) + self.n1mm.contact_info["rxfreq"] = str( + self.fakefreq(self.band, self.mode) + ) + self.n1mm.contact_info["txfreq"] = str( + self.fakefreq(self.band, self.mode) + ) else: self.n1mm.contact_info["rxfreq"] = str(self.oldfreq)[:-1] self.n1mm.contact_info["txfreq"] = str(self.oldfreq)[:-1] - + self.n1mm.contact_info["mode"] = self.oldmode if self.oldmode in ("CW", "DG"): self.n1mm.contact_info["points"] = "2" @@ -2577,6 +2630,7 @@ def save_changes(self): def delete_contact(self): """delete the contact""" + oldguy = self.database.contact_by_id(self.theitem) self.database.delete_contact(self.theitem) if window.connect_to_server: stale = datetime.now() + timedelta(seconds=30) @@ -2598,8 +2652,8 @@ def delete_contact(self): window.n1mm.contactdelete["timestamp"] = datetime.now( dt.timezone.utc ).strftime("%Y-%m-%d %H:%M:%S") - window.n1mm.contactdelete["call"] = self.contact.get("callsign") - window.n1mm.contactdelete["ID"] = self.contact.get("unique_id") + window.n1mm.contactdelete["call"] = oldguy[0][1] + window.n1mm.contactdelete["ID"] = self.unique_id window.n1mm.send_contact_delete() self.change.lineChanged.emit() diff --git a/fdlogger/data/opon.ui b/fdlogger/data/opon.ui new file mode 100644 index 0000000..6e0a51f --- /dev/null +++ b/fdlogger/data/opon.ui @@ -0,0 +1,93 @@ + + + Dialog + + + + 0 + 0 + 382 + 90 + + + + + JetBrains Mono + + + + Dialog + + + + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + + + + + Operator: + + + + + + + Operator + + + Callsign of current operator. + + + + + + + + + Qt::Vertical + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + + + + + + + buttonBox + accepted() + Dialog + accept() + + + 248 + 254 + + + 157 + 274 + + + + + buttonBox + rejected() + Dialog + reject() + + + 316 + 260 + + + 286 + 274 + + + + + diff --git a/fdlogger/lib/edit_opon.py b/fdlogger/lib/edit_opon.py new file mode 100644 index 0000000..bfa4dc8 --- /dev/null +++ b/fdlogger/lib/edit_opon.py @@ -0,0 +1,15 @@ +"""Edit OpOn""" + +from PyQt5 import QtWidgets, uic + + +class OpOn(QtWidgets.QDialog): + """Change the current operator""" + + def __init__(self, WORKING_PATH, parent=None): + super().__init__(parent) + uic.loadUi(WORKING_PATH + "/data/opon.ui", self) + self.buttonBox.clicked.connect(self.store) + + def store(self): + """dialog magic""" diff --git a/fdlogger/lib/n1mm.py b/fdlogger/lib/n1mm.py index 62796f0..043fb34 100644 --- a/fdlogger/lib/n1mm.py +++ b/fdlogger/lib/n1mm.py @@ -18,7 +18,7 @@ class N1MM: """ "Send N1MM style packets""" radio_info = { - "app": "K6GTE-WFD", + "app": "K6GTE-FDLOGGER", "StationName": "", "uNICORNbLOOD": "1", "RadioNr": "1", @@ -43,8 +43,8 @@ class N1MM: } contact_info = { - "app": "K6GTE-WFD", - "contestname": "Winter Field Day", + "app": "K6GTE-FDLOGGER", + "contestname": "ARRL Field Day", "contestnr": "1", "timestamp": "", "mycall": "", @@ -92,26 +92,26 @@ class N1MM: } contactdelete = { - "app": "K6GTE-WFD", + "app": "K6GTE-FDLOGGER", "timestamp": "", "call": "", "contestnr": "1", "StationName": "", "ID": "", } - + bandToUDPBand = { - "160" : "1.8", - "80" : "3.5", - "40" : "7", - "20" : "14", - "15" : "21", - "10" : "28", - "6" : "50", - "2" : "144", - "222" : "222", - "432" : "420", - "SAT" : "144", # The fakefreqs are 2m so I picked 2m for SAT - NY4I + "160": "1.8", + "80": "3.5", + "40": "7", + "20": "14", + "15": "21", + "10": "28", + "6": "50", + "2": "144", + "222": "222", + "432": "420", + "SAT": "144", # The fakefreqs are 2m so I picked 2m for SAT - NY4I } def __init__( diff --git a/fdlogger/lib/version.py b/fdlogger/lib/version.py index 2b30c00..8571bcb 100644 --- a/fdlogger/lib/version.py +++ b/fdlogger/lib/version.py @@ -1,2 +1,2 @@ """It's the version""" -__version__ = "24.2.19" +__version__ = "24.2.21" diff --git a/pyproject.toml b/pyproject.toml index 1423a53..7f75a33 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta" [project] name = "fdlogger" -version = "24.2.19" +version = "24.2.21" description = "ARRL Field Day logger GUI" readme = "README.md" requires-python = ">=3.9"