Merge remote-tracking branch 'origin/v3.5'

This commit is contained in:
Adolfo Gómez García 2022-03-15 20:26:02 +01:00
commit 9ca143c2db
4 changed files with 7 additions and 7 deletions

View File

@ -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(),

View File

@ -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:

View File

@ -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)

View File

@ -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():