from owrx.controllers.admin import AuthorizationMixin from owrx.controllers.template import WebpageController from owrx.controllers.settings import SettingsFormController from owrx.source import SdrDeviceDescription, SdrDeviceDescriptionMissing, SdrClientClass from owrx.config import Config from owrx.connection import OpenWebRxReceiverClient from owrx.controllers.settings import Section from urllib.parse import quote, unquote from owrx.sdr import SdrService from owrx.form import TextInput, DropdownInput, Option from owrx.form.validator import RequiredValidator from owrx.property import PropertyLayer, PropertyStack from abc import ABCMeta, abstractmethod class SdrDeviceListController(AuthorizationMixin, WebpageController): def template_variables(self): variables = super().template_variables() variables["content"] = self.render_devices() variables["title"] = "SDR device settings" variables["modal"] = "" return variables def render_devices(self): def render_device(device_id, config): sources = SdrService.getAllSources() source = sources[device_id] if device_id in sources else None additional_info = "" state_info = "Unknown" if source is not None: profiles = source.getProfiles() currentProfile = profiles[source.getProfileId()] clients = {c: len(source.getClients(c)) for c in SdrClientClass} clients = {c: v for c, v in clients.items() if v} connections = len([c for c in source.getClients() if isinstance(c, OpenWebRxReceiverClient)]) additional_info = """