diff --git a/server/src/uds/REST/methods/transports.py b/server/src/uds/REST/methods/transports.py index 0d2ee357..437fa0f6 100644 --- a/server/src/uds/REST/methods/transports.py +++ b/server/src/uds/REST/methods/transports.py @@ -96,7 +96,7 @@ class Transports(ModelHandler): 'value': [], 'values': sorted( [ - {'id': x.value[0], 'text': x.value[0].replace('CrOS', 'Chrome OS')} + {'id': x.name, 'text': x.name} for x in OsDetector.knownOss ], key=lambda x: x['text'].lower(), diff --git a/server/src/uds/core/transports/transport.py b/server/src/uds/core/transports/transport.py index ddc80d43..fafc5492 100644 --- a/server/src/uds/core/transports/transport.py +++ b/server/src/uds/core/transports/transport.py @@ -157,7 +157,7 @@ class Transport(Module): Helper method to check if transport supports requested operating system. Class method """ - return cls.supportedOss.count(osType) > 0 + return osType in cls.supportedOss @classmethod def providesConnetionInfo(cls) -> bool: diff --git a/server/src/uds/models/transport.py b/server/src/uds/models/transport.py index e19ae47a..a9019a65 100644 --- a/server/src/uds/models/transport.py +++ b/server/src/uds/models/transport.py @@ -45,6 +45,7 @@ from .tag import TaggingMixin # Not imported at runtime, just for type checking if typing.TYPE_CHECKING: from uds.models import Network, ServicePool + from uds.core.util.os_detector import KnownOS logger = logging.getLogger(__name__) @@ -130,10 +131,8 @@ class Transport(ManagedObjectModel, TaggingMixin): # Deny, must not be in any network return self.networks.filter(net_start__lte=ip, net_end__gte=ip).exists() is False - def validForOs(self, os: str) -> bool: - if not self.allowed_oss or os in self.allowed_oss.split(','): - return True - return False + def validForOs(self, os: 'KnownOS') -> bool: + return not self.allowed_oss or os.name in self.allowed_oss.split(',') def __str__(self) -> str: return '{} of type {} (id:{})'.format(self.name, self.data_type, self.id) diff --git a/server/src/uds/web/util/services.py b/server/src/uds/web/util/services.py index 59aa9a89..88786a3d 100644 --- a/server/src/uds/web/util/services.py +++ b/server/src/uds/web/util/services.py @@ -59,6 +59,7 @@ from uds.core.auths.auth import webPassword # Not imported at runtime, just for type checking if typing.TYPE_CHECKING: from uds.core.util.request import ExtendedHttpRequestWithUser + from uds.core.util.os_detector import KnownOS from uds.models import Image @@ -137,7 +138,7 @@ def getServicesData( nets = '' validTrans = '' - osType = request.os['OS'] + osType: 'KnownOS' = request.os['OS'] logger.debug('OS: %s', osType) if request.user.isStaff():