Skip to content
This repository was archived by the owner on Dec 31, 2025. It is now read-only.

Commit af78600

Browse files
committed
Fixed crashes with missing hamlib
Added debug infos OS/Py at startup
1 parent 1b7472d commit af78600

5 files changed

Lines changed: 760 additions & 744 deletions

File tree

dragonlog/DragonLog.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,8 @@
5959
from .contest import CONTESTS, CONTEST_IDS, CONTEST_NAMES, build_contest_list, ExchangeData
6060
from .distance import distance
6161
from .cty import CountryData, Country, CountryNotFoundException, CountryCodeNotFoundException
62-
from .RigControl import RigControl
62+
from .RigControl import RigControl, RigctldNotConfiguredException, RigctldExecutionException, \
63+
NoExecutableFoundException, CATSettingsMissingException
6364
from . import ColorPalettes
6465
from .DragonLog_Statistics import StatisticsWidget
6566
from .local_callbook import (LocalCallbook, LocalCallbookData, CallHistoryData,
@@ -334,6 +335,8 @@ def __init__(self, file=None, app_path='.', ini_file=''):
334335

335336
self.log = Logger(self.logTextEdit, self.settings)
336337
self.log.info(f'Starting {self.programName} {self.programVersion}...')
338+
self.log.debug(f'Platform: {platform.platform()}')
339+
self.log.debug(f'Python: {sys.version}')
337340
if not OPTION_OPENPYXL:
338341
self.log.info(f'Option XL-Format not available')
339342
if not OPTION_QRCODEREADER:
@@ -987,7 +990,12 @@ def resetTableFilter(self):
987990
self.fContestComboBox.setCurrentIndex(0)
988991

989992
def ctrlHamlib(self, start):
990-
self.__rigctl__.ctrlRigctld(start)
993+
try:
994+
self.__rigctl__.ctrlRigctld(start)
995+
except (RigctldNotConfiguredException, CATSettingsMissingException, RigctldExecutionException):
996+
self.log.error(f'rigctld is not properly configured')
997+
except Exception as exc:
998+
self.log.exception(exc)
991999

9921000
def logQSO(self):
9931001
if not self.__db_con__.isOpen():

dragonlog/RigControl.py

Lines changed: 27 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ class RigctldExecutionException(Exception):
5656
}
5757

5858

59+
# noinspection PyPep8Naming
5960
class RigControl(QtCore.QObject):
6061
frequencyChanged = QtCore.pyqtSignal(float)
6162
bandChanged = QtCore.pyqtSignal(str)
@@ -109,13 +110,15 @@ def __init__(self, parent, settings: QtCore.QSettings, logger: Logger,
109110
if platform.system() == 'Windows':
110111
self.__rigctl_startupinfo__ = subprocess.STARTUPINFO()
111112
self.__rigctl_startupinfo__.dwFlags |= subprocess.STARTF_USESHOWWINDOW
112-
if self.settings.value('cat/rigctldPath', None):
113-
if self.__is_exe__(self.settings.value('cat/rigctldPath', '')):
114-
self.init_hamlib(self.settings.value('cat/rigctldPath'))
115-
else:
116-
raise NoExecutableFoundException(self.settings.value('cat/rigctldPath', ''))
113+
try:
114+
self.init_hamlib(self.settings.value('cat/rigctldPath'))
115+
except (NoExecutableFoundException, RigctldExecutionException):
116+
pass
117117
else:
118-
self.init_hamlib('rigctld')
118+
try:
119+
self.init_hamlib('rigctld')
120+
except (NoExecutableFoundException, RigctldExecutionException):
121+
pass
119122

120123
self.__refreshTimer__ = QtCore.QTimer(self)
121124
self.__refreshTimer__.timeout.connect(self.__refreshRigData__)
@@ -145,9 +148,8 @@ def init_hamlib(self, rigctld_path: str):
145148
self.log.error(f'Error executing rigctld: {self.__get_errcode__(res.returncode)}')
146149
raise RigctldExecutionException(rigctld_path)
147150
self.log.debug('Executed rigctld to list rigs')
148-
except FileNotFoundError:
149-
self.log.warning('rigctld is not available')
150-
raise NoExecutableFoundException(rigctld_path)
151+
except (FileNotFoundError, OSError):
152+
raise NoExecutableFoundException(rigctld_path) from None
151153

152154
first = True
153155
rig_pos = 0
@@ -181,16 +183,20 @@ def init_hamlib(self, rigctld_path: str):
181183

182184
# From Settings
183185
def __collectRigCaps__(self, rig_id: str):
184-
res = subprocess.run([self.__rigctld_path__, f'--model={rig_id}', '-u'],
185-
capture_output=True,
186-
startupinfo=self.__rigctl_startupinfo__)
187-
stdout = str(res.stdout, sys.getdefaultencoding()).replace('\r', '')
188-
self.__rig_caps__ = []
189-
for ln in stdout.split('\n'):
190-
if ln.startswith('Can '):
191-
cap, able = ln.split(':')
192-
if able.strip() == 'Y':
193-
self.__rig_caps__.append(cap[4:].lower())
186+
try:
187+
res = subprocess.run([self.__rigctld_path__, f'--model={rig_id}', '-u'],
188+
capture_output=True,
189+
startupinfo=self.__rigctl_startupinfo__)
190+
stdout = str(res.stdout, sys.getdefaultencoding()).replace('\r', '')
191+
self.__rig_caps__ = []
192+
for ln in stdout.split('\n'):
193+
if ln.startswith('Can '):
194+
cap, able = ln.split(':')
195+
if able.strip() == 'Y':
196+
self.__rig_caps__.append(cap[4:].lower())
197+
except (FileNotFoundError, OSError):
198+
self.log.warning(f'rigctld is not available or not executable: {self.__rigctld_path__}')
199+
raise NoExecutableFoundException(self.__rigctld_path__) from None
194200

195201
@property
196202
def availableManufacturers(self) -> list:
@@ -207,6 +213,7 @@ def capabilities(self) -> list:
207213
def ctrlRigctld(self, start: bool):
208214
if start:
209215
if not self.__rigctld_path__:
216+
self.statusChanged.emit(False)
210217
self.log.warning('rigctld is not available')
211218
raise RigctldNotConfiguredException()
212219

@@ -216,6 +223,7 @@ def ctrlRigctld(self, start: bool):
216223
rig_if = self.settings.value('cat/interface', '')
217224
rig_speed = self.settings.value('cat/baud', '')
218225
if not rig_mfr or not rig_model or not rig_if or not rig_speed:
226+
self.statusChanged.emit(False)
219227
raise CATSettingsMissingException()
220228

221229
rig_id = self.__rig_ids__[f'{rig_mfr}/{rig_model}']

0 commit comments

Comments
 (0)