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:
@@ -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)
|
||||
|
||||
0
templates/__init__.py
Normal file
0
templates/__init__.py
Normal file
42
templates/gqrx_config_template.py
Normal file
42
templates/gqrx_config_template.py
Normal file
@@ -0,0 +1,42 @@
|
||||
drb_defaults = """[General]
|
||||
configversion=2
|
||||
crashed=false
|
||||
|
||||
[audio]
|
||||
gain=-20
|
||||
udp_host=localhost
|
||||
|
||||
[dxcluster]
|
||||
DXCAddress=localhost
|
||||
DXCFilter=
|
||||
DXCPort=7300
|
||||
DXCSpotTimeout=10
|
||||
DXCUsername=nocall
|
||||
|
||||
[fft]
|
||||
averaging=85
|
||||
fft_window=5
|
||||
waterfall_span=1
|
||||
|
||||
[gui]
|
||||
geometry=@ByteArray(\x1\xd9\xd0\xcb\0\x3\0\0\0\0\x4t\0\0\0$\0\0\a\x7f\0\0\x3\x12\0\0\x4v\0\0\0\x42\0\0\a\x7f\0\0\x3\x12\0\0\0\0\0\0\0\0\a\x80\0\0\x4v\0\0\0\x42\0\0\a\x7f\0\0\x3\x12)
|
||||
state=@ByteArray(\0\0\0\xff\0\0\0\0\xfd\0\0\0\x2\0\0\0\x1\0\0\x1G\0\0\x2t\xfc\x2\0\0\0\x2\xfc\0\0\0\x42\0\0\x1\x89\0\0\x1\x89\0\b\0!\xfa\0\0\0\x1\x2\0\0\0\x3\xfb\0\0\0\x18\0\x44\0o\0\x63\0k\0I\0n\0p\0u\0t\0\x43\0t\0l\x1\0\0\0\0\xff\xff\xff\xff\0\0\x1P\0\xff\xff\xff\xfb\0\0\0\x12\0\x44\0o\0\x63\0k\0R\0x\0O\0p\0t\x1\0\0\0\0\xff\xff\xff\xff\0\0\x1g\0\a\xff\xff\xfb\0\0\0\xe\0\x44\0o\0\x63\0k\0\x46\0\x66\0t\x1\0\0\0\0\xff\xff\xff\xff\0\0\0\xc8\0\a\xff\xff\xfc\0\0\x1\xd1\0\0\0\xe5\0\0\0\xc3\0\xff\xff\xff\xfa\0\0\0\0\x2\0\0\0\x2\xfb\0\0\0\x12\0\x44\0o\0\x63\0k\0\x41\0u\0\x64\0i\0o\x1\0\0\0\0\xff\xff\xff\xff\0\0\0\xc3\0\xff\xff\xff\xfb\0\0\0\xe\0\x44\0o\0\x63\0k\0R\0\x44\0S\0\0\0\0\0\xff\xff\xff\xff\0\0\0h\0\xff\xff\xff\0\0\0\x3\0\0\0\0\0\0\0\0\xfc\x1\0\0\0\x1\xfb\0\0\0\x1a\0\x44\0o\0\x63\0k\0\x42\0o\0o\0k\0m\0\x61\0r\0k\0s\0\0\0\0\0\xff\xff\xff\xff\0\0\x1\x42\0\xff\xff\xff\0\0\x1\xbd\0\0\x2t\0\0\0\x1\0\0\0\x2\0\0\0\b\0\0\0\x2\xfc\0\0\0\x1\0\0\0\x2\0\0\0\x1\0\0\0\x16\0m\0\x61\0i\0n\0T\0o\0o\0l\0\x42\0\x61\0r\x1\0\0\0\0\xff\xff\xff\xff\0\0\0\0\0\0\0\0)
|
||||
|
||||
[input]
|
||||
dc_cancel=true
|
||||
device="rtl=0"
|
||||
frequency=154785000
|
||||
gains=@Variant(\0\0\0\b\0\0\0\x1\0\0\0\x6\0L\0N\0\x41\0\0\0\x2\0\0\x1P)
|
||||
sample_rate=1800000
|
||||
|
||||
[receiver]
|
||||
agc_off=true
|
||||
demod=3
|
||||
filter_high_cut=2500
|
||||
filter_low_cut=-2500
|
||||
offset=-590400
|
||||
sql_level=-50
|
||||
|
||||
[remote_control]
|
||||
allowed_hosts=localhost, 127.0.0.1, ::1
|
||||
enabled=true"""
|
||||
Reference in New Issue
Block a user