@@ -56,6 +56,7 @@ class RigctldExecutionException(Exception):
5656}
5757
5858
59+ # noinspection PyPep8Naming
5960class 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