From ced530b50a41680eb550ccad5a340a043b7ed954 Mon Sep 17 00:00:00 2001 From: Stefan Date: Thu, 26 Apr 2018 09:47:42 +0100 Subject: [PATCH] Updated to support DVAP and DVRPTR too by parsing qn.cfg as appropriate. --- Makefile | 2 ++ dash/qng-info.py | 21 ++++++++++++++++----- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/Makefile b/Makefile index 2489773..11d5e88 100644 --- a/Makefile +++ b/Makefile @@ -164,6 +164,8 @@ installmmdvm : systemctl start mmdvm.service installdash : + /usr/bin/apt-get -y install python3-pip + /usr/bin/pip3 install libconf /bin/cp -f dash/qng-dash.sh $(BINDIR) /bin/cp -f dash/qng-info.py $(BINDIR) /bin/cp -f dash/qngdash $(CRONDIR) diff --git a/dash/qng-info.py b/dash/qng-info.py index b8e24bf..69de139 100755 --- a/dash/qng-info.py +++ b/dash/qng-info.py @@ -5,6 +5,7 @@ import datetime import socket import csv import configparser +import libconf # HTML to send to browser html = """ @@ -64,17 +65,27 @@ def get_data(): readCSV = csv.reader(csvfile, delimiter=',') for row in readCSV: reflector = row[1] + row[2] - config = configparser.ConfigParser() - config.read('/usr/local/etc/MMDVM.qn') - cs = config['General']['callsign'] - rawfreq = config['Info']['txfrequency'] - freq = float(rawfreq)/1000000 + with open('/usr/local/etc/qn.cfg') as f: + config = libconf.load(f) + cs = config.ircddb.login + for key in config.module: + if config['module'][key]['type'] == 'mmdvm': + freq = get_MMDVM() + else: + freq = config['module'][key]['frequency'] data.append(cs) data.append(freq) data.append(str(get_ip())) data.append(reflector) return data +def get_MMDVM(): + MMDVM_config = configparser.ConfigParser() + MMDVM_config.read('/usr/local/etc/MMDVM.qn') + rawfreq = config['Info']['txfrequency'] + freq = float(rawfreq)/1000000 + return freq + def run(): print('starting server...')