New logging

This commit is contained in:
Logan Cusano
2022-03-28 01:27:37 -04:00
committed by Gitea
parent f8f6cb7e52
commit 1ed5436138
7 changed files with 158 additions and 95 deletions

View File

@@ -1,3 +1,4 @@
import logging
import shutil
import threading
import subprocess
@@ -21,6 +22,8 @@ class OP25Handler(threading.Thread):
self.Stop_OP25 = False
self.logger = logging.getLogger("Discord_Radio_Bot.OP25Handler")
def run(self) -> None:
while True:
if self.Start_OP25:
@@ -56,17 +59,17 @@ class OP25Handler(threading.Thread):
p25_kwargs = [f"./rx.py", "--args", "rtl", "-N", "LNA:49", "-s", "200000", "-o", "25600", "-U", "-f",
f"{self.Frequency}e6", "-X", "-2"]
print(f"Starting OP25")
self.logger.info(f"Starting OP25")
# Change the interpreter's working directory (idr why)
if self.HTTP_ENABLED:
p25_kwargs.extend(["-l", "http:0.0.0.0:8080"])
print(f"OP25 Keyword Args: {p25_kwargs}")
self.logger.debug(f"OP25 Keyword Args: {p25_kwargs}")
self.OP25Proc = subprocess.Popen(p25_kwargs, executable=self.OP25EXE, shell=False, cwd=self.OP25Dir)
def close_op25(self):
print(f"Closing OP25")
self.logger.info(f"Closing OP25")
try:
self.OP25Proc.kill()
@@ -74,11 +77,11 @@ class OP25Handler(threading.Thread):
while self.OP25Proc.poll() is None:
# Terminate the process every 5 seconds
if seconds_waited % 5 == 0:
print("Terminating OP25")
self.logger.debug("Terminating OP25")
self.OP25Proc.terminate()
time.sleep(1)
print(f"Waited {seconds_waited} seconds")
self.logger.debug(f"Waited {seconds_waited} seconds")
seconds_waited += 1
except Exception as e:
print(e)
self.logger.error(e)