Now showing EIBI and repeaters last download times.
This commit is contained in:
parent
159989694a
commit
36ea6e7f52
|
|
@ -60,7 +60,7 @@ class ClientController(AuthorizationMixin, WebpageController):
|
||||||
c["name"] if "name" in c else "",
|
c["name"] if "name" in c else "",
|
||||||
"banned" if c["ban"] else c["sdr"] + " " + c["band"] if "sdr" in c else "n/a",
|
"banned" if c["ban"] else c["sdr"] + " " + c["band"] if "sdr" in c else "n/a",
|
||||||
"until" if c["ban"] else "since",
|
"until" if c["ban"] else "since",
|
||||||
c["ts"].strftime('%H:%M:%S'),
|
c["ts"].strftime("%H:%M:%S"),
|
||||||
ClientController.renderButtons(c)
|
ClientController.renderButtons(c)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,9 @@ from owrx.controllers.admin import AuthorizationMixin
|
||||||
from owrx.controllers.template import WebpageController
|
from owrx.controllers.template import WebpageController
|
||||||
from owrx.breadcrumb import Breadcrumb, BreadcrumbItem, BreadcrumbMixin
|
from owrx.breadcrumb import Breadcrumb, BreadcrumbItem, BreadcrumbMixin
|
||||||
from owrx.service import Services
|
from owrx.service import Services
|
||||||
|
from owrx.repeaters import Repeaters
|
||||||
|
from owrx.eibi import EIBI
|
||||||
|
from datetime import datetime
|
||||||
import json
|
import json
|
||||||
import re
|
import re
|
||||||
|
|
||||||
|
|
@ -30,10 +33,29 @@ class ServiceController(AuthorizationMixin, WebpageController):
|
||||||
</tr>
|
</tr>
|
||||||
{services}
|
{services}
|
||||||
</table>
|
</table>
|
||||||
|
{status}
|
||||||
""".format(
|
""".format(
|
||||||
services="".join(ServiceController.renderService(c) for c in Services.listAll())
|
services="".join(ServiceController.renderService(c) for c in Services.listAll()),
|
||||||
|
status=ServiceController.renderStatus()
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def renderStatus():
|
||||||
|
result = ""
|
||||||
|
ts = Repeaters.lastDownloaded()
|
||||||
|
if ts > 0:
|
||||||
|
ts = datetime.fromtimestamp(ts).strftime("%H:%M:%S, %m/%d/%Y")
|
||||||
|
result += "<div style='color:green;width:100%;text-align:center;'>Repeaters database downloaded at {0}.</div>\n".format(ts)
|
||||||
|
else:
|
||||||
|
result += "<div style='color:red;width:100%;text-align:center;'>Repeaters database not downloaded.</div>\n"
|
||||||
|
ts = EIBI.lastDownloaded()
|
||||||
|
if ts > 0:
|
||||||
|
ts = datetime.fromtimestamp(ts).strftime("%H:%M:%S, %m/%d/%Y")
|
||||||
|
result += "<div style='color:green;width:100%;text-align:center;'>Shortwave schedule downloaded at {0}.</div>\n".format(ts)
|
||||||
|
else:
|
||||||
|
result += "<div style='color:red;width:100%;text-align:center;'>Shortwave schedule not downloaded.</div>\n"
|
||||||
|
return "<p style='width:100%;'>\n" + result + "</p>\n"
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def renderService(c):
|
def renderService(c):
|
||||||
# Choose units based on frequency
|
# Choose units based on frequency
|
||||||
|
|
|
||||||
16
owrx/eibi.py
16
owrx/eibi.py
|
|
@ -37,6 +37,18 @@ class EIBI(object):
|
||||||
coreConfig = CoreConfig()
|
coreConfig = CoreConfig()
|
||||||
return "{data_directory}/eibi.json".format(data_directory=coreConfig.get_data_directory())
|
return "{data_directory}/eibi.json".format(data_directory=coreConfig.get_data_directory())
|
||||||
|
|
||||||
|
# Get last downloaded timestamp or 0 for none
|
||||||
|
@staticmethod
|
||||||
|
def lastDownloaded():
|
||||||
|
try:
|
||||||
|
file = EIBI._getCachedScheduleFile()
|
||||||
|
if os.path.isfile(file) and os.path.getsize(file) > 0:
|
||||||
|
return os.path.getmtime(file)
|
||||||
|
else:
|
||||||
|
return 0
|
||||||
|
except Exception as e:
|
||||||
|
return 0
|
||||||
|
|
||||||
# Offset frequency for proper tuning
|
# Offset frequency for proper tuning
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def correctFreq(freq: int, mode: str) -> int:
|
def correctFreq(freq: int, mode: str) -> int:
|
||||||
|
|
@ -109,10 +121,8 @@ class EIBI(object):
|
||||||
def refresh(self):
|
def refresh(self):
|
||||||
# This file contains cached schedule
|
# This file contains cached schedule
|
||||||
file = self._getCachedScheduleFile()
|
file = self._getCachedScheduleFile()
|
||||||
ts = os.path.getmtime(file) if os.path.isfile(file) else 0
|
|
||||||
|
|
||||||
# If cached schedule is stale...
|
# If cached schedule is stale...
|
||||||
if time.time() - ts >= self.refreshPeriod:
|
if time.time() - self.lastDownloaded() >= self.refreshPeriod:
|
||||||
# Load EIBI database file from the web
|
# Load EIBI database file from the web
|
||||||
schedule = self.loadFromWeb()
|
schedule = self.loadFromWeb()
|
||||||
if schedule:
|
if schedule:
|
||||||
|
|
|
||||||
|
|
@ -34,6 +34,18 @@ class Repeaters(object):
|
||||||
coreConfig = CoreConfig()
|
coreConfig = CoreConfig()
|
||||||
return "{data_directory}/repeaters.json".format(data_directory=coreConfig.get_data_directory())
|
return "{data_directory}/repeaters.json".format(data_directory=coreConfig.get_data_directory())
|
||||||
|
|
||||||
|
# Get last downloaded timestamp or 0 for none
|
||||||
|
@staticmethod
|
||||||
|
def lastDownloaded():
|
||||||
|
try:
|
||||||
|
file = Repeaters._getCachedDatabaseFile()
|
||||||
|
if os.path.isfile(file) and os.path.getsize(file) > 0:
|
||||||
|
return os.path.getmtime(file)
|
||||||
|
else:
|
||||||
|
return 0
|
||||||
|
except Exception as e:
|
||||||
|
return 0
|
||||||
|
|
||||||
# Compute distance, in kilometers, between two latlons.
|
# Compute distance, in kilometers, between two latlons.
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def distKm(p1, p2):
|
def distKm(p1, p2):
|
||||||
|
|
@ -115,12 +127,10 @@ class Repeaters(object):
|
||||||
# Load cached database or refresh it from the web.
|
# Load cached database or refresh it from the web.
|
||||||
#
|
#
|
||||||
def refresh(self):
|
def refresh(self):
|
||||||
# This file contains cached database
|
# This file contains cached repeaters database
|
||||||
file = self._getCachedDatabaseFile()
|
file = self._getCachedDatabaseFile()
|
||||||
ts = os.path.getmtime(file) if os.path.isfile(file) else 0
|
|
||||||
|
|
||||||
# If cached database is stale...
|
# If cached database is stale...
|
||||||
if time.time() - ts >= self.refreshPeriod:
|
if time.time() - self.lastDownloaded() >= self.refreshPeriod:
|
||||||
# Load EIBI database file from the web
|
# Load EIBI database file from the web
|
||||||
repeaters = self.loadFromWeb()
|
repeaters = self.loadFromWeb()
|
||||||
if repeaters:
|
if repeaters:
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue