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