mirror of
https://github.com/dkmstr/openuds.git
synced 2025-09-20 05:44:48 +03:00
Fix type() method calls to getType() in code to avoid clashes with "type" builtin
This commit is contained in:
@@ -168,7 +168,7 @@ class Authenticators(ModelHandler):
|
|||||||
'mfa_id': item.mfa.uuid if item.mfa else '',
|
'mfa_id': item.mfa.uuid if item.mfa else '',
|
||||||
'small_name': item.small_name,
|
'small_name': item.small_name,
|
||||||
'users_count': item.users.count(),
|
'users_count': item.users.count(),
|
||||||
'type': type_.type(),
|
'type': type_.getType(),
|
||||||
'type_name': type_.name(),
|
'type_name': type_.name(),
|
||||||
'type_info': self.typeInfo(type_),
|
'type_info': self.typeInfo(type_),
|
||||||
'permission': permissions.getEffectivePermission(self._user, item),
|
'permission': permissions.getEffectivePermission(self._user, item),
|
||||||
|
@@ -113,7 +113,7 @@ class MFA(ModelHandler):
|
|||||||
'validity': item.validity,
|
'validity': item.validity,
|
||||||
'tags': [tag.tag for tag in item.tags.all()],
|
'tags': [tag.tag for tag in item.tags.all()],
|
||||||
'comments': item.comments,
|
'comments': item.comments,
|
||||||
'type': type_.type(),
|
'type': type_.getType(),
|
||||||
'type_name': type_.name(),
|
'type_name': type_.name(),
|
||||||
'permission': permissions.getEffectivePermission(self._user, item),
|
'permission': permissions.getEffectivePermission(self._user, item),
|
||||||
}
|
}
|
||||||
|
@@ -122,7 +122,7 @@ class Notifiers(ModelHandler):
|
|||||||
'enabled': item.enabled,
|
'enabled': item.enabled,
|
||||||
'tags': [tag.tag for tag in item.tags.all()],
|
'tags': [tag.tag for tag in item.tags.all()],
|
||||||
'comments': item.comments,
|
'comments': item.comments,
|
||||||
'type': type_.type(),
|
'type': type_.getType(),
|
||||||
'type_name': type_.name(),
|
'type_name': type_.name(),
|
||||||
'permission': permissions.getEffectivePermission(self._user, item),
|
'permission': permissions.getEffectivePermission(self._user, item),
|
||||||
}
|
}
|
||||||
|
@@ -71,7 +71,7 @@ class OsManagers(ModelHandler):
|
|||||||
'name': osm.name,
|
'name': osm.name,
|
||||||
'tags': [tag.tag for tag in osm.tags.all()],
|
'tags': [tag.tag for tag in osm.tags.all()],
|
||||||
'deployed_count': osm.deployedServices.count(),
|
'deployed_count': osm.deployedServices.count(),
|
||||||
'type': type_.type(),
|
'type': type_.getType(),
|
||||||
'type_name': type_.name(),
|
'type_name': type_.name(),
|
||||||
'servicesTypes': [type_.servicesType], # A list for backward compatibility. TODO: To be removed when admin interface is changed
|
'servicesTypes': [type_.servicesType], # A list for backward compatibility. TODO: To be removed when admin interface is changed
|
||||||
'comments': osm.comments,
|
'comments': osm.comments,
|
||||||
|
@@ -89,7 +89,7 @@ class Providers(ModelHandler):
|
|||||||
offers = [
|
offers = [
|
||||||
{
|
{
|
||||||
'name': gettext(t.name()),
|
'name': gettext(t.name()),
|
||||||
'type': t.type(),
|
'type': t.getType(),
|
||||||
'description': gettext(t.description()),
|
'description': gettext(t.description()),
|
||||||
'icon': t.icon64().replace('\n', ''),
|
'icon': t.icon64().replace('\n', ''),
|
||||||
}
|
}
|
||||||
@@ -106,7 +106,7 @@ class Providers(ModelHandler):
|
|||||||
.count(),
|
.count(),
|
||||||
'maintenance_mode': item.maintenance_mode,
|
'maintenance_mode': item.maintenance_mode,
|
||||||
'offers': offers,
|
'offers': offers,
|
||||||
'type': type_.type(),
|
'type': type_.getType(),
|
||||||
'type_name': type_.name(),
|
'type_name': type_.name(),
|
||||||
'comments': item.comments,
|
'comments': item.comments,
|
||||||
'permission': permissions.getEffectivePermission(self._user, item),
|
'permission': permissions.getEffectivePermission(self._user, item),
|
||||||
|
@@ -265,7 +265,7 @@ class Services(DetailHandler): # pylint: disable=too-many-public-methods
|
|||||||
offers = [
|
offers = [
|
||||||
{
|
{
|
||||||
'name': _(t.name()),
|
'name': _(t.name()),
|
||||||
'type': t.type(),
|
'type': t.getType(),
|
||||||
'description': _(t.description()),
|
'description': _(t.description()),
|
||||||
'icon': t.icon64().replace('\n', ''),
|
'icon': t.icon64().replace('\n', ''),
|
||||||
}
|
}
|
||||||
@@ -273,11 +273,11 @@ class Services(DetailHandler): # pylint: disable=too-many-public-methods
|
|||||||
]
|
]
|
||||||
else:
|
else:
|
||||||
for t in parent.getType().getProvidedServices():
|
for t in parent.getType().getProvidedServices():
|
||||||
if forType == t.type():
|
if forType == t.getType():
|
||||||
offers = [
|
offers = [
|
||||||
{
|
{
|
||||||
'name': _(t.name()),
|
'name': _(t.name()),
|
||||||
'type': t.type(),
|
'type': t.getType(),
|
||||||
'description': _(t.description()),
|
'description': _(t.description()),
|
||||||
'icon': t.icon64().replace('\n', ''),
|
'icon': t.icon64().replace('\n', ''),
|
||||||
}
|
}
|
||||||
|
@@ -164,7 +164,7 @@ class Transports(ModelHandler):
|
|||||||
'pools': pools,
|
'pools': pools,
|
||||||
'pools_count': len(pools),
|
'pools_count': len(pools),
|
||||||
'deployed_count': item.deployedServices.count(),
|
'deployed_count': item.deployedServices.count(),
|
||||||
'type': type_.type(),
|
'type': type_.getType(),
|
||||||
'type_name': type_.name(),
|
'type_name': type_.name(),
|
||||||
'protocol': type_.protocol,
|
'protocol': type_.protocol,
|
||||||
'permission': permissions.getEffectivePermission(self._user, item),
|
'permission': permissions.getEffectivePermission(self._user, item),
|
||||||
|
@@ -284,7 +284,7 @@ class BaseModelHandler(Handler):
|
|||||||
"""
|
"""
|
||||||
res = types.rest.TypeInfo(
|
res = types.rest.TypeInfo(
|
||||||
name=_(type_.name()),
|
name=_(type_.name()),
|
||||||
type=type_.type(),
|
type=type_.getType(),
|
||||||
description=_(type_.description()),
|
description=_(type_.description()),
|
||||||
icon=type_.icon64().replace('\n', ''),
|
icon=type_.icon64().replace('\n', ''),
|
||||||
).asDict(**self.typeInfo(type_))
|
).asDict(**self.typeInfo(type_))
|
||||||
|
@@ -125,10 +125,12 @@ class Module(UserInterface, Environmentable, Serializable):
|
|||||||
# if this modules is marked as "Experimental"
|
# if this modules is marked as "Experimental"
|
||||||
experimental: typing.ClassVar[bool] = False
|
experimental: typing.ClassVar[bool] = False
|
||||||
|
|
||||||
|
# uuid of this module, if any
|
||||||
|
# Maybe used by some modules to identify themselves
|
||||||
_uuid: str
|
_uuid: str
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def name(cls: typing.Type['Module']) -> str:
|
def name(cls: type['Module']) -> str:
|
||||||
"""
|
"""
|
||||||
Returns "translated" typeName, using gettext for transforming
|
Returns "translated" typeName, using gettext for transforming
|
||||||
cls.typeName
|
cls.typeName
|
||||||
@@ -142,7 +144,7 @@ class Module(UserInterface, Environmentable, Serializable):
|
|||||||
return _(cls.typeName)
|
return _(cls.typeName)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def type(cls: typing.Type['Module']) -> str:
|
def getType(cls: type['Module']) -> str:
|
||||||
"""
|
"""
|
||||||
Returns typeType
|
Returns typeType
|
||||||
|
|
||||||
@@ -155,7 +157,7 @@ class Module(UserInterface, Environmentable, Serializable):
|
|||||||
return cls.typeType
|
return cls.typeType
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def description(cls: typing.Type['Module']) -> str:
|
def description(cls: type['Module']) -> str:
|
||||||
"""
|
"""
|
||||||
This method returns the "translated" description, that is, using
|
This method returns the "translated" description, that is, using
|
||||||
gettext for transforming cls.typeDescription.
|
gettext for transforming cls.typeDescription.
|
||||||
@@ -170,7 +172,7 @@ class Module(UserInterface, Environmentable, Serializable):
|
|||||||
return _(cls.typeDescription)
|
return _(cls.typeDescription)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def icon(cls: typing.Type['Module']) -> bytes:
|
def icon(cls: type['Module']) -> bytes:
|
||||||
"""
|
"""
|
||||||
Reads the file specified by iconFile at module folder, and returns it content.
|
Reads the file specified by iconFile at module folder, and returns it content.
|
||||||
This is used to obtain an icon so administration can represent it.
|
This is used to obtain an icon so administration can represent it.
|
||||||
@@ -187,7 +189,7 @@ class Module(UserInterface, Environmentable, Serializable):
|
|||||||
return utils.loadIcon(os.path.dirname(typing.cast(str, sys.modules[cls.__module__].__file__)) + '/' + cls.iconFile)
|
return utils.loadIcon(os.path.dirname(typing.cast(str, sys.modules[cls.__module__].__file__)) + '/' + cls.iconFile)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def icon64(cls: typing.Type['Module']) -> str:
|
def icon64(cls: type['Module']) -> str:
|
||||||
return utils.loadIconBase64(os.path.dirname(typing.cast(str, sys.modules[cls.__module__].__file__)) + '/' + cls.iconFile)
|
return utils.loadIconBase64(os.path.dirname(typing.cast(str, sys.modules[cls.__module__].__file__)) + '/' + cls.iconFile)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
|
@@ -144,7 +144,7 @@ class ServiceProvider(module.Module):
|
|||||||
the typeType that Service has.
|
the typeType that Service has.
|
||||||
"""
|
"""
|
||||||
for _type in cls.offers:
|
for _type in cls.offers:
|
||||||
if _type.type() == typeName:
|
if _type.getType() == typeName:
|
||||||
return _type
|
return _type
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
@@ -61,7 +61,7 @@ class ServiceProviderFactory(factory.ModuleFactory[ServiceProvider]):
|
|||||||
# We will check that if service provided by "provider" needs
|
# We will check that if service provided by "provider" needs
|
||||||
# cache, but service do not provides publicationType,
|
# cache, but service do not provides publicationType,
|
||||||
# that service will not be registered and it will be informed
|
# that service will not be registered and it will be informed
|
||||||
typeName = type_.type().lower()
|
typeName = type_.getType().lower()
|
||||||
|
|
||||||
if typeName in self.providers():
|
if typeName in self.providers():
|
||||||
logger.debug('%s already registered as Service Provider', type_)
|
logger.debug('%s already registered as Service Provider', type_)
|
||||||
|
@@ -65,4 +65,4 @@ class ModuleFactory(Factory[T]):
|
|||||||
Inserts an object into the factory.
|
Inserts an object into the factory.
|
||||||
'''
|
'''
|
||||||
# logger.debug('Adding %s as %s', type_.type(), type_.__module__)
|
# logger.debug('Adding %s as %s', type_.type(), type_.__module__)
|
||||||
super().put(type_.type().lower(), type_)
|
super().put(type_.getType().lower(), type_)
|
||||||
|
@@ -520,7 +520,7 @@ class ServicePool(UUIDModel, TaggingMixin): # type: ignore
|
|||||||
"""
|
"""
|
||||||
from uds.core import services # pylint: disable=import-outside-toplevel
|
from uds.core import services # pylint: disable=import-outside-toplevel
|
||||||
|
|
||||||
servicesNotNeedingPub = [t.type() for t in services.factory().servicesThatDoNotNeedPublication()]
|
servicesNotNeedingPub = [t.getType() for t in services.factory().servicesThatDoNotNeedPublication()]
|
||||||
# Get services that HAS publications
|
# Get services that HAS publications
|
||||||
query = (
|
query = (
|
||||||
ServicePool.objects.filter(
|
ServicePool.objects.filter(
|
||||||
|
Reference in New Issue
Block a user