updated dash for qn.cfg format

pull/14/head
Tom Early 6 years ago
parent 3f71c3e683
commit c2ee9973e0

@ -170,7 +170,6 @@ installdtmf : qndtmf
installdash :
/usr/bin/apt-get -y install python3-pip
/usr/bin/pip3 install libconf
/bin/cp -f dash/qng-info.py $(BINDIR)
/bin/cp -f dash/qngdash $(CRONDIR)
/bin/sh /usr/bin/python3 $(BINDIR)/qng-info.py &

@ -3,7 +3,6 @@ import socket
import datetime
import csv
import configparser
import libconf
import json
import requests
import subprocess
@ -20,10 +19,11 @@ html = """<!DOCTYPE html>
<p>This status page shows the Callsign, Frequency, IP address and Connected Reflector for the QnetGateway D-Star Hotspot.</p>
<p><strong>Callsign:</strong> {1}<br>
<strong>Frequency:</strong> {2}MHz<br>
<strong>IP Address:</strong> {3}<br>
<strong>External IP Address:</strong> {4}<br>
<strong>Reflector:</strong> {5}</p>
<strong>Modem:</strong> {2}<br>
<strong>Frequency:</strong> {3}MHz<br>
<strong>IP Address:</strong> {4}<br>
<strong>External IP Address:</strong> {5}<br>
<strong>Reflector:</strong> {6}</p>
<form>
<strong>Note:</strong> Please enter a valid 7 character reflector code.</br>
<strong>Link Reflector: </strong> <input type="text" name="LINK"> <input type="submit" value="Link Reflector"></br>
@ -46,16 +46,16 @@ def get_ip():
s.close()
return IP
def get_data():
global data
data = []
reflector = "Unlinked"
with open('/usr/local/etc/RPTR_STATUS.txt') as csvfile:
with open('/usr/local/etc/rptr_status') as csvfile:
readCSV = csv.reader(csvfile, delimiter=',')
for row in readCSV:
reflector = row[1] + row[2]
data.append(cs)
data.append(modem)
data.append(freq)
data.append(intip)
data.append(extip)
@ -71,15 +71,29 @@ def get_MMDVM():
intip = get_ip()
extip = requests.get('https://ipapi.co/json/').json()['ip']
with open('/usr/local/etc/qn.cfg') as f:
config = libconf.load(f)
cs = config.ircddb.login
for key in config.module:
module = key
if config['module'][key]['type'] == 'mmdvm':
cfg = dict()
with open('/usr/local/etc/qn.cfg', 'r') as f:
for line in f:
if line.strip()[0] == "#":
continue
kv = line.strip().split("=")
cfg[kv[0]] = kv[1].strip("'")
cs = cfg['ircddb_login']
for module in ( 'a', 'b', 'c' ):
key = 'module_' + module
if key in cfg:
modem = cfg[key]
if modem == 'mmdvmhost':
freq = get_MMDVM()
elif key + "_tx_frequency" in cfg:
freq = cfg[key + "_tx_frequency"]
elif key + "_frequency" in cfg:
freq = cfg[key + "_frequency"]
else:
freq = config['module'][key]['frequency']
freq = 0.0
break
#Setup Socket WebServer
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
@ -102,6 +116,6 @@ while True:
sleep(8)
data = get_data()
response = html.format(data[2], data[0], data[1], data[2], data[3], data[4])
response = html.format(data[3], data[0], data[1], data[2], data[3], data[4], data[5])
conn.send(bytes(response, "UTF-8"))
conn.close()

Loading…
Cancel
Save

Powered by TurnKey Linux.