mirror of
https://github.com/DJ2LS/FreeDATA
synced 2024-05-14 08:04:33 +00:00
iterate through all rigctld binaries
This commit is contained in:
parent
8ccff438d0
commit
e284a58db9
|
@ -713,15 +713,16 @@ def get_flag(byte, flag_name, flag_dict):
|
||||||
return get_bit(byte, position)
|
return get_bit(byte, position)
|
||||||
|
|
||||||
|
|
||||||
def find_binary_path(binary_name="rigctld", search_system_wide=False):
|
def find_binary_paths(binary_name="rigctld", search_system_wide=False):
|
||||||
"""
|
"""
|
||||||
Search for a binary within the current working directory and its subdirectories.
|
Search for a binary within the current working directory, its subdirectories, and optionally,
|
||||||
Optionally, check system-wide locations and PATH environment variable if not found.
|
system-wide locations and the PATH environment variable.
|
||||||
|
|
||||||
:param binary_name: The base name of the binary to search for, without extension.
|
:param binary_name: The base name of the binary to search for, without extension.
|
||||||
:param search_system_wide: Boolean flag to enable or disable system-wide search.
|
:param search_system_wide: Boolean flag to enable or disable system-wide search.
|
||||||
:return: The full path to the binary if found, otherwise None.
|
:return: A list of full paths to the binary if found, otherwise an empty list.
|
||||||
"""
|
"""
|
||||||
|
binary_paths = [] # Initialize an empty list to store found paths
|
||||||
# Adjust binary name for Windows
|
# Adjust binary name for Windows
|
||||||
if platform.system() == 'Windows':
|
if platform.system() == 'Windows':
|
||||||
binary_name += ".exe"
|
binary_name += ".exe"
|
||||||
|
@ -730,7 +731,7 @@ def find_binary_path(binary_name="rigctld", search_system_wide=False):
|
||||||
root_path = os.getcwd()
|
root_path = os.getcwd()
|
||||||
for dirpath, dirnames, filenames in os.walk(root_path):
|
for dirpath, dirnames, filenames in os.walk(root_path):
|
||||||
if binary_name in filenames:
|
if binary_name in filenames:
|
||||||
return os.path.join(dirpath, binary_name)
|
binary_paths.append(os.path.join(dirpath, binary_name))
|
||||||
|
|
||||||
# If system-wide search is enabled, look in system locations and PATH
|
# If system-wide search is enabled, look in system locations and PATH
|
||||||
if search_system_wide:
|
if search_system_wide:
|
||||||
|
@ -745,7 +746,10 @@ def find_binary_path(binary_name="rigctld", search_system_wide=False):
|
||||||
for path in system_paths:
|
for path in system_paths:
|
||||||
potential_path = os.path.join(path, binary_name)
|
potential_path = os.path.join(path, binary_name)
|
||||||
if os.path.isfile(potential_path):
|
if os.path.isfile(potential_path):
|
||||||
return potential_path
|
binary_paths.append(potential_path)
|
||||||
|
|
||||||
|
return binary_paths
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def kill_and_execute(binary_path, additional_args=None):
|
def kill_and_execute(binary_path, additional_args=None):
|
||||||
|
|
|
@ -260,15 +260,26 @@ class radio:
|
||||||
|
|
||||||
def start_service(self):
|
def start_service(self):
|
||||||
binary_name = "rigctld"
|
binary_name = "rigctld"
|
||||||
binary_path = helpers.find_binary_path(binary_name, search_system_wide=True)
|
binary_paths = helpers.find_binary_paths(binary_name, search_system_wide=True)
|
||||||
additional_args = self.format_rigctld_args()
|
additional_args = self.format_rigctld_args()
|
||||||
if binary_path:
|
|
||||||
self.log.info(f"Rigctld binary found at: {binary_path}")
|
if binary_paths:
|
||||||
|
for binary_path in binary_paths:
|
||||||
|
try:
|
||||||
|
self.log.info(f"Attempting to start rigctld using binary found at: {binary_path}")
|
||||||
helpers.kill_and_execute(binary_path, additional_args)
|
helpers.kill_and_execute(binary_path, additional_args)
|
||||||
self.log.info(f"Executed rigctld...")
|
self.log.info("Successfully executed rigctld.")
|
||||||
|
break # Exit the loop after successful execution
|
||||||
|
except Exception as e:
|
||||||
|
pass
|
||||||
|
# let's keep this hidden for the user to avoid confusion
|
||||||
|
# self.log.warning(f"Failed to start rigctld with binary at {binary_path}: {e}")
|
||||||
|
else:
|
||||||
|
self.log.warning("Failed to start rigctld with all found binaries.", binaries=binary_paths)
|
||||||
else:
|
else:
|
||||||
self.log.warning("Rigctld binary not found.")
|
self.log.warning("Rigctld binary not found.")
|
||||||
|
|
||||||
|
|
||||||
def format_rigctld_args(self):
|
def format_rigctld_args(self):
|
||||||
config = self.config['RADIO'] # Accessing the 'RADIO' section of the INI file
|
config = self.config['RADIO'] # Accessing the 'RADIO' section of the INI file
|
||||||
config_rigctld = self.config['RIGCTLD'] # Accessing the 'RIGCTLD' section of the INI file for custom args
|
config_rigctld = self.config['RIGCTLD'] # Accessing the 'RIGCTLD' section of the INI file for custom args
|
||||||
|
|
Loading…
Reference in a new issue