GQRX Changes

- Checks for GQRX config file
    - If one exists, reset the 'crashed' option
    - If one does not, create one from the template
- New templates package
    - Useful for storing large files to be called on later
This commit is contained in:
Logan Cusano
2022-04-09 01:13:06 -04:00
parent bb56566d37
commit 5a3729627b
3 changed files with 78 additions and 1 deletions

View File

@@ -3,13 +3,30 @@ import logging
import threading
import subprocess
import time
from pathlib import Path
from telnetlib import Telnet
from BotResources import *
from time import sleep
def reset_crashed(_config_path):
config = configparser.SafeConfigParser()
config.read(_config_path)
if config.has_section('General'):
if config.getboolean('General', 'crashed'):
config['General']['crashed'] = 'false'
with open(_config_path, 'w') as config_file:
config.write(config_file)
return True
else:
return False
class GQRXHandler(threading.Thread):
def __init__(self):
super().__init__()
self.GQRX_Config_Path = Path(f"{Path.home()}/.config/gqrx/drb_defaults.conf")
self.GQRXDir: str = GQRX_BIN_LOCATION
self.GQRXEXE: str = shutil.which(GQRX_BIN)
self.GQRXProc = None
@@ -92,7 +109,11 @@ class GQRXHandler(threading.Thread):
if self.GQRXProc is not None:
self.close_gqrx()
gqrx_kwargs = [f""]
gqrx_kwargs = [f"-c drb_defaults.conf"]
self.logger.info(f"Resetting 'crashed' option in the GQRX config")
self.reset_or_create_config()
self.logger.info(f"Starting GQRX")
@@ -176,3 +197,17 @@ class GQRXHandler(threading.Thread):
self.change_mode(_mode)
self.change_freq(_freq)
self.change_squelch(_squelch)
def reset_or_create_config(self):
if self.GQRX_Config_Path.is_file():
self.logger.debug(f"GQRX Config exists, resetting 'crashed' setting")
reset_crashed(_config_path=self.GQRX_Config_Path)
else:
self.logger.debug(f"GQRX config does not exist, creating it from template")
from templates.gqrx_config_template import drb_defaults
config = drb_defaults
try:
with open(self.GQRX_Config_Path, 'w+') as config_file:
config_file.write(config)
except OSError as err:
self.logger.error(err)