Skip to content

Commit

Permalink
Removed some datetime.utcnow() and pkgutil.getloader() deprecations.
Browse files Browse the repository at this point in the history
  • Loading branch information
mbridak committed Jan 28, 2024
1 parent 4b2d641 commit 7e4f8a5
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 13 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ brother.

## Recent Changes

- [24.1.27] Removed some datetime.utcnow() and pkgutil.getloader() deprecations.
- [23.11.9] Merged from @wvolz fixing crash related to tuning to a non ham band.
- [23.6.25] Fixed missing Canadian sections.
- [23.6.24] Fix 6M CW default frequency. Wierdness with VFO fixed.
Expand Down
30 changes: 19 additions & 11 deletions fdlogger/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

# from xmlrpc.client import ServerProxy, Error
import struct
import datetime as dt
import os
import socket
import sys
Expand Down Expand Up @@ -122,7 +123,7 @@ def __init__(self, *args, **kwargs):
"""Initialize"""
super().__init__(*args, **kwargs)
self.working_path = os.path.dirname(
pkgutil.get_loader("fdlogger").get_filename()
__loader__.get_filename()
)
data_path = self.working_path + "/data/main.ui"
uic.loadUi(data_path, self)
Expand Down Expand Up @@ -654,7 +655,7 @@ def getvalue(self, item):
def update_time(self):
"""updates the time"""
now = datetime.now().isoformat(" ")[5:19].replace("-", "/")
utcnow = datetime.utcnow().isoformat(" ")[5:19].replace("-", "/")
utcnow = datetime.now(dt.UTC).isoformat(" ")[5:19].replace("-", "/")
self.localtime.setText(now)
self.utctime.setText(utcnow)

Expand Down Expand Up @@ -1278,8 +1279,15 @@ def changeband(self):

def changemode(self):
"""change mode"""
self.mode = self.mode_selector.currentText()
self.send_status_udp()
if self.mode != self.mode_selector.currentText():
self.mode = self.mode_selector.currentText()
if self.mode == "PH":
if int(self.oldfreq) < 10000000:
self.cat_control.set_mode("LSB")
else:
self.cat_control.set_mode("USB")
self.cat_control.set_mode(self.mode)
self.send_status_udp()

def changepower(self):
"""change power"""
Expand Down Expand Up @@ -1634,7 +1642,7 @@ def log_contact(self):
"mode": self.mode,
"band": self.band,
"frequency": self.oldfreq,
"date_and_time": datetime.utcnow().strftime("%Y-%m-%d %H:%M:%S"),
"date_and_time": datetime.now(dt.UTC).strftime("%Y-%m-%d %H:%M:%S"),
"power": int(self.power_selector.value()),
"grid": self.contactlookup["grid"],
"opname": self.contactlookup["name"],
Expand Down Expand Up @@ -1662,7 +1670,7 @@ def log_contact(self):
self.n1mm.contact_info["band"] = self.band
self.n1mm.contact_info["mycall"] = self.preference.get("mycall")
self.n1mm.contact_info["IsRunQSO"] = str(self.run_state)
self.n1mm.contact_info["timestamp"] = datetime.utcnow().strftime(
self.n1mm.contact_info["timestamp"] = datetime.now(dt.UTC).strftime(
"%Y-%m-%d %H:%M:%S"
)
self.n1mm.contact_info["call"] = self.callsign_entry.text()
Expand Down Expand Up @@ -2464,7 +2472,7 @@ def __init__(self, parent=None):
"""initialize dialog"""
super().__init__(parent)
self.working_path = os.path.dirname(
pkgutil.get_loader("fdlogger").get_filename()
__loader__.get_filename()
)
data_path = self.working_path + "/data/dialog.ui"
uic.loadUi(data_path, self)
Expand Down Expand Up @@ -2580,7 +2588,7 @@ def delete_contact(self):
logger.warning("%s", err)

if window.preference.get("send_n1mm_packets"):
window.n1mm.contactdelete["timestamp"] = datetime.utcnow().strftime(
window.n1mm.contactdelete["timestamp"] = datetime.now(dt.UTC).strftime(
"%Y-%m-%d %H:%M:%S"
)
window.n1mm.contactdelete["call"] = self.contact.get("callsign")
Expand All @@ -2598,7 +2606,7 @@ def __init__(self, parent=None):
"""initialize dialog"""
super().__init__(parent)
self.working_path = os.path.dirname(
pkgutil.get_loader("fdlogger").get_filename()
__loader__.get_filename()
)
data_path = self.working_path + "/data/startup.ui"
uic.loadUi(data_path, self)
Expand Down Expand Up @@ -2663,7 +2671,7 @@ def startup_dialog_finished():

app = QtWidgets.QApplication(sys.argv)
app.setStyle("Fusion")
working_path = os.path.dirname(pkgutil.get_loader("fdlogger").get_filename())
working_path = os.path.dirname(__loader__.get_filename())
font_path = working_path + "/data"
families = load_fonts_from_dir(os.fspath(font_path))
window = MainWindow()
Expand Down Expand Up @@ -2709,7 +2717,7 @@ def startup_dialog_finished():

def run():
"""Main Entry"""
PATH = os.path.dirname(pkgutil.get_loader("fdlogger").get_filename())
PATH = os.path.dirname(__loader__.get_filename())
os.system(
"xdg-icon-resource install --size 64 --context apps --mode user "
f"{PATH}/icon/k6gte-fdlogger.png k6gte-fdlogger"
Expand Down
2 changes: 1 addition & 1 deletion fdlogger/lib/version.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
"""It's the version"""
__version__ = "23.11.9"
__version__ = "24.1.27"
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"

[project]
name = "fdlogger"
version = "23.11.9"
version = "24.1.27"
description = "ARRL Field Day logger GUI"
readme = "README.md"
requires-python = ">=3.9"
Expand Down
Empty file modified update_version.sh
100755 → 100644
Empty file.

0 comments on commit 7e4f8a5

Please sign in to comment.