not1mm 24.3.16__py3-none-any.whl → 24.3.24__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (68) hide show
  1. not1mm/__main__.py +288 -124
  2. not1mm/bandmap.py +207 -191
  3. not1mm/checkwindow.py +62 -109
  4. not1mm/data/MASTER.SCP +1077 -749
  5. not1mm/data/bandmap.ui +4 -4
  6. not1mm/data/checkwindow.ui +9 -16
  7. not1mm/data/cty.json +1 -1
  8. not1mm/data/logwindow.ui +16 -11
  9. not1mm/data/main.ui +16 -6
  10. not1mm/data/vfo.ui +64 -52
  11. not1mm/fsutils.py +63 -0
  12. not1mm/lib/about.py +4 -2
  13. not1mm/lib/cat_interface.py +1 -1
  14. not1mm/lib/cwinterface.py +1 -1
  15. not1mm/lib/database.py +4 -4
  16. not1mm/lib/edit_contact.py +2 -2
  17. not1mm/lib/edit_macro.py +2 -3
  18. not1mm/lib/edit_opon.py +2 -2
  19. not1mm/lib/edit_station.py +3 -3
  20. not1mm/lib/ham_utility.py +1 -1
  21. not1mm/lib/lookup.py +1 -1
  22. not1mm/lib/multicast.py +9 -4
  23. not1mm/lib/n1mm.py +1 -1
  24. not1mm/lib/new_contest.py +2 -2
  25. not1mm/lib/select_contest.py +2 -2
  26. not1mm/lib/settings.py +3 -4
  27. not1mm/lib/super_check_partial.py +8 -5
  28. not1mm/lib/version.py +1 -1
  29. not1mm/logwindow.py +62 -105
  30. not1mm/plugins/10_10_fall_cw.py +1 -1
  31. not1mm/plugins/10_10_spring_cw.py +1 -1
  32. not1mm/plugins/10_10_summer_phone.py +1 -1
  33. not1mm/plugins/10_10_winter_phone.py +1 -1
  34. not1mm/plugins/arrl_10m.py +1 -1
  35. not1mm/plugins/arrl_dx_cw.py +1 -1
  36. not1mm/plugins/arrl_dx_ssb.py +1 -1
  37. not1mm/plugins/arrl_field_day.py +1 -1
  38. not1mm/plugins/arrl_ss_cw.py +1 -1
  39. not1mm/plugins/arrl_ss_phone.py +1 -1
  40. not1mm/plugins/arrl_vhf_jan.py +1 -1
  41. not1mm/plugins/arrl_vhf_jun.py +1 -1
  42. not1mm/plugins/arrl_vhf_sep.py +1 -1
  43. not1mm/plugins/canada_day.py +1 -1
  44. not1mm/plugins/cq_160_cw.py +1 -1
  45. not1mm/plugins/cq_160_ssb.py +1 -1
  46. not1mm/plugins/cq_wpx_cw.py +1 -1
  47. not1mm/plugins/cq_wpx_ssb.py +1 -1
  48. not1mm/plugins/cq_ww_cw.py +1 -1
  49. not1mm/plugins/cq_ww_ssb.py +1 -1
  50. not1mm/plugins/cwt.py +1 -1
  51. not1mm/plugins/general_logging.py +1 -1
  52. not1mm/plugins/iaru_hf.py +1 -1
  53. not1mm/plugins/jidx_cw.py +1 -1
  54. not1mm/plugins/jidx_ph.py +1 -1
  55. not1mm/plugins/naqp_cw.py +1 -1
  56. not1mm/plugins/naqp_ssb.py +1 -1
  57. not1mm/plugins/phone_weekly_test.py +1 -1
  58. not1mm/plugins/stew_perry_topband.py +1 -1
  59. not1mm/plugins/winter_field_day.py +1 -1
  60. not1mm/vfo.py +78 -98
  61. {not1mm-24.3.16.dist-info → not1mm-24.3.24.dist-info}/METADATA +67 -55
  62. {not1mm-24.3.16.dist-info → not1mm-24.3.24.dist-info}/RECORD +68 -66
  63. testing/detectdark.py +35 -0
  64. testing/test.py +13 -11
  65. {not1mm-24.3.16.dist-info → not1mm-24.3.24.dist-info}/LICENSE +0 -0
  66. {not1mm-24.3.16.dist-info → not1mm-24.3.24.dist-info}/WHEEL +0 -0
  67. {not1mm-24.3.16.dist-info → not1mm-24.3.24.dist-info}/entry_points.txt +0 -0
  68. {not1mm-24.3.16.dist-info → not1mm-24.3.24.dist-info}/top_level.txt +0 -0
not1mm/checkwindow.py CHANGED
@@ -3,47 +3,29 @@
3
3
  Check Window
4
4
  """
5
5
  # pylint: disable=no-name-in-module, unused-import, no-member, invalid-name, c-extension-no-member
6
+ # pylint: disable=logging-fstring-interpolation, line-too-long
6
7
 
7
8
  import logging
8
-
9
+ import os
9
10
  import platform
10
11
  import queue
11
- import os
12
- import sys
13
-
14
12
  from json import loads
15
- from pathlib import Path
16
13
 
17
- from PyQt5 import uic
18
- from PyQt5.QtCore import QDir
19
- from PyQt5.QtWidgets import QApplication, QListWidgetItem, QMainWindow
20
- from PyQt5.QtGui import QFontDatabase
14
+ from PyQt5 import QtGui, uic
15
+ from PyQt5.QtCore import Qt
16
+ from PyQt5.QtWidgets import QListWidgetItem
17
+ from PyQt5.QtWidgets import QWidget
21
18
 
19
+ import not1mm.fsutils as fsutils
22
20
  from not1mm.lib.database import DataBase
23
21
  from not1mm.lib.multicast import Multicast
24
22
  from not1mm.lib.super_check_partial import SCP
25
23
 
26
- os.environ["QT_QPA_PLATFORMTHEME"] = "gnome"
27
-
28
- WORKING_PATH = os.path.dirname(__loader__.get_filename())
29
-
30
- if "XDG_DATA_HOME" in os.environ:
31
- DATA_PATH = os.environ.get("XDG_DATA_HOME")
32
- else:
33
- DATA_PATH = str(Path.home() / ".local" / "share")
34
- DATA_PATH += "/not1mm"
24
+ logger = logging.getLogger(__name__)
35
25
 
36
- if "XDG_CONFIG_HOME" in os.environ:
37
- CONFIG_PATH = os.environ.get("XDG_CONFIG_HOME")
38
- else:
39
- CONFIG_PATH = str(Path.home() / ".config")
40
- CONFIG_PATH += "/not1mm"
41
26
 
42
-
43
- class MainWindow(QMainWindow):
44
- """
45
- The main window
46
- """
27
+ class CheckWindow(QWidget):
28
+ """The check window. Shows list or probable stations."""
47
29
 
48
30
  multicast_interface = None
49
31
  dbname = None
@@ -52,45 +34,66 @@ class MainWindow(QMainWindow):
52
34
  def __init__(self, *args, **kwargs):
53
35
  super().__init__(*args, **kwargs)
54
36
  self.load_pref()
55
- self.dbname = DATA_PATH + "/" + self.pref.get("current_database", "ham.db")
56
- self.database = DataBase(self.dbname, WORKING_PATH)
37
+ self.dbname = fsutils.USER_DATA_PATH / self.pref.get(
38
+ "current_database", "ham.db"
39
+ )
40
+ self.database = DataBase(self.dbname, fsutils.APP_DATA_PATH)
57
41
  self.database.current_contest = self.pref.get("contest", 0)
58
- data_path = WORKING_PATH + "/data/checkwindow.ui"
59
- uic.loadUi(data_path, self)
60
- self.setWindowTitle("CheckWindow")
42
+
43
+ uic.loadUi(fsutils.APP_DATA_PATH / "checkwindow.ui", self)
44
+
61
45
  self.logList.clear()
62
46
  self.masterList.clear()
63
47
  self.telnetList.clear()
64
48
  self.callhistoryList.clear()
65
49
  self.callhistoryList.hide()
66
50
  self.callhistoryListLabel.hide()
67
- self.mscp = SCP(WORKING_PATH)
51
+ self.mscp = SCP(fsutils.APP_DATA_PATH)
68
52
  self._udpwatch = None
69
53
  self.udp_fifo = queue.Queue()
70
54
  self.multicast_interface = Multicast(
71
55
  self.pref.get("multicast_group", "239.1.1.1"),
72
56
  self.pref.get("multicast_port", 2239),
73
- self.pref.get("interface_ip", "0.0.0.0"),
57
+ self.pref.get("interface_ip", "127.0.0.1"),
74
58
  )
75
59
  self.multicast_interface.ready_read_connect(self.watch_udp)
76
60
 
77
- def quit_app(self):
78
- """
79
- Called when the user clicks the exit button.
80
-
81
- Parameters
82
- ----------
83
- None
84
-
85
- Returns
86
- -------
87
- None
88
- """
89
- app.quit()
90
-
91
- def load_pref(self):
61
+ def setDarkMode(self, dark: bool):
62
+ """Forces a darkmode palette."""
63
+
64
+ if dark:
65
+ darkPalette = QtGui.QPalette()
66
+ darkColor = QtGui.QColor(45, 45, 45)
67
+ disabledColor = QtGui.QColor(127, 127, 127)
68
+ darkPalette.setColor(QtGui.QPalette.Window, darkColor)
69
+ darkPalette.setColor(QtGui.QPalette.WindowText, Qt.white)
70
+ darkPalette.setColor(QtGui.QPalette.Base, QtGui.QColor(18, 18, 18))
71
+ darkPalette.setColor(QtGui.QPalette.AlternateBase, darkColor)
72
+ darkPalette.setColor(QtGui.QPalette.Text, Qt.white)
73
+ darkPalette.setColor(
74
+ QtGui.QPalette.Disabled, QtGui.QPalette.Text, disabledColor
75
+ )
76
+ darkPalette.setColor(QtGui.QPalette.Button, darkColor)
77
+ darkPalette.setColor(QtGui.QPalette.ButtonText, Qt.white)
78
+ darkPalette.setColor(
79
+ QtGui.QPalette.Disabled, QtGui.QPalette.ButtonText, disabledColor
80
+ )
81
+ darkPalette.setColor(QtGui.QPalette.BrightText, Qt.red)
82
+ darkPalette.setColor(QtGui.QPalette.Link, QtGui.QColor(42, 130, 218))
83
+ darkPalette.setColor(QtGui.QPalette.Highlight, QtGui.QColor(42, 130, 218))
84
+ darkPalette.setColor(QtGui.QPalette.HighlightedText, Qt.black)
85
+ darkPalette.setColor(
86
+ QtGui.QPalette.Disabled, QtGui.QPalette.HighlightedText, disabledColor
87
+ )
88
+
89
+ self.setPalette(darkPalette)
90
+ else:
91
+ palette = self.style().standardPalette()
92
+ self.setPalette(palette)
93
+
94
+ def load_pref(self) -> None:
92
95
  """
93
- Load preference file to get current db filename.
96
+ Load preference file to get current db filename and sets the initial darkmode state.
94
97
 
95
98
  Parameters
96
99
  ----------
@@ -101,17 +104,18 @@ class MainWindow(QMainWindow):
101
104
  None
102
105
  """
103
106
  try:
104
- if os.path.exists(CONFIG_PATH + "/not1mm.json"):
107
+ if os.path.exists(fsutils.CONFIG_FILE):
105
108
  with open(
106
- CONFIG_PATH + "/not1mm.json", "rt", encoding="utf-8"
109
+ fsutils.CONFIG_FILE, "rt", encoding="utf-8"
107
110
  ) as file_descriptor:
108
111
  self.pref = loads(file_descriptor.read())
109
- logger.info("%s", self.pref)
112
+ logger.info(f"loaded config file from {fsutils.CONFIG_FILE}")
110
113
  else:
111
114
  self.pref["current_database"] = "ham.db"
112
115
 
113
116
  except IOError as exception:
114
117
  logger.critical("Error: %s", exception)
118
+ self.setDarkMode(self.pref.get("darkmode", False))
115
119
 
116
120
  def watch_udp(self):
117
121
  """
@@ -126,6 +130,7 @@ class MainWindow(QMainWindow):
126
130
  None
127
131
  """
128
132
  while self.multicast_interface.server_udp.hasPendingDatagrams():
133
+ logger.error("Got multicast ")
129
134
  json_data = self.multicast_interface.read_datagram_as_json()
130
135
 
131
136
  if json_data.get("station", "") != platform.node():
@@ -145,8 +150,9 @@ class MainWindow(QMainWindow):
145
150
  if json_data.get("cmd", "") == "NEWDB":
146
151
  ...
147
152
  # self.load_new_db()
148
- if json_data.get("cmd", "") == "HALT":
149
- self.quit_app()
153
+
154
+ if json_data.get("cmd", "") == "DARKMODE":
155
+ self.setDarkMode(json_data.get("state", False))
150
156
 
151
157
  def clear_lists(self) -> None:
152
158
  """
@@ -228,56 +234,3 @@ class MainWindow(QMainWindow):
228
234
  listItem = QListWidgetItem(call)
229
235
  self.telnetList.addItem(listItem)
230
236
  self.telnetList.show()
231
-
232
-
233
- def load_fonts_from_dir(directory: str) -> set:
234
- """
235
- Load fonts from directory.
236
-
237
- Parameters
238
- ----------
239
- directory : str
240
- The directory to load fonts from.
241
-
242
- Returns
243
- -------
244
- set
245
- The set of font families loaded.
246
- """
247
- font_families = set()
248
- for _fi in QDir(directory).entryInfoList(["*.ttf", "*.woff", "*.woff2"]):
249
- _id = QFontDatabase.addApplicationFont(_fi.absoluteFilePath())
250
- font_families |= set(QFontDatabase.applicationFontFamilies(_id))
251
- return font_families
252
-
253
-
254
- def main():
255
- """main entry"""
256
- sys.exit(app.exec())
257
-
258
-
259
- logger = logging.getLogger("__main__")
260
- handler = logging.StreamHandler()
261
- formatter = logging.Formatter(
262
- datefmt="%H:%M:%S",
263
- fmt="[%(asctime)s] %(levelname)s %(module)s - %(funcName)s Line %(lineno)d:\n%(message)s",
264
- )
265
- handler.setFormatter(formatter)
266
- logger.addHandler(handler)
267
-
268
- if Path("./debug").exists():
269
- logger.setLevel(logging.DEBUG)
270
- logger.debug("debugging on")
271
- else:
272
- logger.setLevel(logging.WARNING)
273
- logger.warning("debugging off")
274
-
275
- app = QApplication(sys.argv)
276
- app.setStyle("Adwaita-Dark")
277
- font_path = WORKING_PATH + "/data"
278
- _families = load_fonts_from_dir(os.fspath(font_path))
279
- window = MainWindow()
280
- window.show()
281
-
282
- if __name__ == "__main__":
283
- main()