New logging
This commit is contained in:
@@ -1,9 +1,11 @@
|
||||
import logging
|
||||
from telnetlib import Telnet
|
||||
from BotResources import check_negative
|
||||
from time import sleep
|
||||
|
||||
class GQRXHandler():
|
||||
def __init__(self, hostname: str = "localhost", port: int = 7356):
|
||||
self.logger = logging.getLogger("Discord_Radio_Bot.GQRXHandler")
|
||||
self.hostname = hostname
|
||||
self.port = port
|
||||
|
||||
@@ -12,24 +14,24 @@ class GQRXHandler():
|
||||
self.create_telnet_connection()
|
||||
|
||||
def create_telnet_connection(self):
|
||||
print("Creating connection")
|
||||
self.logger.info("Creating connection")
|
||||
self.tel_conn = Telnet(self.hostname, self.port)
|
||||
self.tel_conn.open(self.hostname, self.port)
|
||||
|
||||
def change_freq(self, freq):
|
||||
print(f"Changing freq to {freq}")
|
||||
self.logger.debug(f"Changing freq to {freq}")
|
||||
self.tel_conn.write(bytes(f"F {int(freq)}", 'utf-8'))
|
||||
self.tel_conn.read_until(b'RPRT 0')
|
||||
|
||||
def change_squelch(self, squelch):
|
||||
if not check_negative(squelch):
|
||||
squelch = float(-abs(squelch))
|
||||
print(f"Changing squelch to {squelch}")
|
||||
self.logger.debug(f"Changing squelch to {squelch}")
|
||||
self.tel_conn.write(bytes(f"L SQL {float(squelch)}", 'utf-8'))
|
||||
self.tel_conn.read_until(b'RPRT 0')
|
||||
|
||||
def change_mode(self, mode):
|
||||
print(f"Changing mode to {mode}")
|
||||
self.logger.debug(f"Changing mode to {mode}")
|
||||
self.tel_conn.write(bytes(f"M {str(mode)}", 'utf-8'))
|
||||
self.tel_conn.read_until(b'RPRT 0')
|
||||
|
||||
|
||||
Reference in New Issue
Block a user