1
0
mirror of https://github.com/dkmstr/openuds.git synced 2025-01-10 01:17:59 +03:00

More typing fixes

This commit is contained in:
Adolfo Gómez García 2023-03-25 13:43:54 +01:00
parent 562e9201c8
commit b983d5d409
No known key found for this signature in database
GPG Key ID: DD1ABF20724CDA23
13 changed files with 25 additions and 25 deletions

View File

@ -53,7 +53,7 @@ def __init__():
from uds.core import auths
# Dinamycally import children of this package. The __init__.py files must declare authenticators as subclasses of auths.Authenticator
pkgpath = os.path.dirname(sys.modules[__name__].__file__)
pkgpath = os.path.dirname(sys.modules[__name__].__file__) # type: ignore
for _, name, _ in pkgutil.iter_modules([pkgpath]):
# __import__(name, globals(), locals(), [], 1)
importlib.import_module('.' + name, __name__) # import module

View File

@ -689,7 +689,7 @@ class ServicePool(UUIDModel, TaggingMixin): # type: ignore
log.doLog(self, level, message, log.INTERNAL)
@staticmethod
def beforeDelete(sender, **kwargs):
def beforeDelete(sender, **kwargs) -> None:
"""
Used to invoke the Service class "Destroy" before deleting it from database.

View File

@ -243,7 +243,7 @@ class User(UUIDModel):
@staticmethod
def beforeDelete(sender, **kwargs):
def beforeDelete(sender, **kwargs) -> None:
"""
Used to invoke the Service class "Destroy" before deleting it from database.

View File

@ -50,7 +50,7 @@ osmanagers.factory().insert(WinRandomPassManager)
managers.downloadsManager().registerDownloadable(
'UDSActorSetup-{version}.exe'.format(version=VERSION),
_('UDS Actor for windows machines'),
os.path.dirname(sys.modules[__package__].__file__)
os.path.dirname(sys.modules[__package__].__file__) # type: ignore
+ '/files/UDSActorSetup-{version}.exe'.format(version=VERSION),
'application/x-msdos-program',
)
@ -58,7 +58,7 @@ managers.downloadsManager().registerDownloadable(
managers.downloadsManager().registerDownloadable(
'UDSActorUnmanagedSetup-{version}.exe'.format(version=VERSION),
_('UDS Actor for Unmanaged windows machines. Used ONLY for static machines.'),
os.path.dirname(sys.modules[__package__].__file__)
os.path.dirname(sys.modules[__package__].__file__) # type: ignore
+ '/files/UDSActorUnmanagedSetup-{version}.exe'.format(version=VERSION),
'application/x-msdos-program',
)

View File

@ -185,7 +185,7 @@ class WindowsOsManager(osmanagers.OSManager):
pass
def loginNotified(self, userService, userName=None):
if '\\' not in userName:
if userName and '\\' not in userName:
osmanagers.OSManager.loggedIn(userService, userName)
def logoutNotified(self, userService, userName=None):

View File

@ -193,7 +193,7 @@ class WinDomainOsManager(WindowsOsManager):
for server in reversed(
sorted(
dns.resolver.query('_ldap._tcp.' + self._domain, 'SRV'),
dns.resolver.query('_ldap._tcp.' + self._domain, 'SRV'), # type: ignore
key=lambda i: i.priority * 10000 + i.weight,
)
):

View File

@ -54,7 +54,7 @@ def __init__():
from uds.core import osmanagers
# Dinamycally import children of this package.
pkgpath = os.path.dirname(sys.modules[__name__].__file__)
pkgpath = os.path.dirname(sys.modules[__name__].__file__) # type: ignore
for _, name, _ in pkgutil.iter_modules([pkgpath]):
# __import__(name, globals(), locals(), [], 1)

View File

@ -44,7 +44,7 @@ def loadPlugins():
logger.debug('Initializing plugins...')
# Dinamycally import children of this package. The __init__.py files must import classes
pkgpath = os.path.dirname(sys.modules[__name__].__file__)
pkgpath = os.path.dirname(sys.modules[__name__].__file__) # type: ignore
for _, name, _ in pkgutil.iter_modules([pkgpath]):
# __import__(name, globals(), locals(), [], 1)
importlib.import_module('.' + name, __name__) # Local import

View File

@ -80,7 +80,7 @@ class OGDeployment(UserDeployment):
def initialize(self) -> None:
self._queue = []
dbs = self.dbservice()
self._uuid = dbs.uuid if dbs else ''
self._uuid = dbs.uuid if dbs and dbs.uuid else ''
def service(self) -> 'OGService':
return typing.cast('OGService', super().service())

View File

@ -79,7 +79,7 @@ class IPMachineDeployed(services.UserDeployment, AutoAttributes):
# Try to resolve name...
try:
res = dns.resolver.resolve(ip)
ip = res[0].address
ip = res[0].address # type: ignore # If no address, it will raise an exception
except Exception:
self.service().parent().doLog(
log.WARN, f'User service could not resolve Name {ip}.'

View File

@ -59,7 +59,7 @@ def __init__():
from uds.core import services
# Dinamycally import children of this package.
pkgpath = os.path.dirname(sys.modules[__name__].__file__)
pkgpath = os.path.dirname(sys.modules[__name__].__file__) # type: ignore
for _, name, _ in pkgutil.iter_modules([pkgpath]):
# __import__('uds.services.' + name, globals(), locals(), [])
importlib.import_module('.' + name, __name__) # import module

View File

@ -138,7 +138,7 @@ def getServicesData(
{
'id': idd(i),
'name': i.name,
'link': html.udsAccessLink(request, 'M' + meta.uuid, idd(i)),
'link': html.udsAccessLink(request, 'M' + meta.uuid, idd(i)), # type: ignore
'priority': i.priority,
}
for i in transports
@ -162,9 +162,9 @@ def getServicesData(
# if first pool, get all its transports and check that are valid
for t in transportIterator(member):
if inAll is None:
tmpSet.add(t.uuid)
tmpSet.add(t.uuid) # type: ignore
elif t.uuid in inAll: # For subsequent, reduce...
tmpSet.add(t.uuid)
tmpSet.add(t.uuid) # type: ignore
inAll = tmpSet
# tmpSet has ALL common transports
@ -208,7 +208,7 @@ def getServicesData(
'id': 'meta',
'name': 'meta',
'link': html.udsAccessLink(
request, 'M' + meta.uuid, None
request, 'M' + meta.uuid, None # type: ignore
),
'priority': 0,
}
@ -234,14 +234,14 @@ def getServicesData(
services.append(
{
'id': 'M' + meta.uuid,
'id': 'M' + meta.uuid, # type: ignore
'is_meta': True,
'name': meta.name,
'visual_name': meta.visual_name,
'description': meta.comments,
'group': group,
'transports': metaTransports,
'imageId': meta.image and meta.image.uuid or 'x',
'imageId': meta.image and meta.image.uuid or 'x', # type: ignore
'show_transports': len(metaTransports) > 1,
'allow_users_remove': meta.allow_users_remove,
'allow_users_reset': meta.allow_users_reset,
@ -276,9 +276,9 @@ def getServicesData(
and t.validForOs(osType)
):
if typeTrans.ownLink:
link = reverse('TransportOwnLink', args=('F' + sPool.uuid, t.uuid))
link = reverse('TransportOwnLink', args=('F' + sPool.uuid, t.uuid)) # type: ignore
else:
link = html.udsAccessLink(request, 'F' + sPool.uuid, t.uuid)
link = html.udsAccessLink(request, 'F' + sPool.uuid, t.uuid) # type: ignore
trans.append(
{'id': t.uuid, 'name': t.name, 'link': link, 'priority': t.priority}
)
@ -336,7 +336,7 @@ def getServicesData(
services.append(
{
'id': 'F' + sPool.uuid,
'id': 'F' + sPool.uuid, # type: ignore
'is_meta': False,
'name': datator(sPool.name),
'visual_name': datator(
@ -415,10 +415,10 @@ def enableService(
error = '' # No error
if typeTrans.ownLink:
url = reverse('TransportOwnLink', args=('A' + userService.uuid, trans.uuid))
url = reverse('TransportOwnLink', args=('A' + userService.uuid, trans.uuid)) # type: ignore
else:
data = {
'service': 'A' + userService.uuid,
'service': 'A' + userService.uuid, # type: ignore
'transport': trans.uuid,
'user': request.user.uuid,
'password': password,

View File

@ -274,11 +274,11 @@ def ticketAuth(
transportInstance = transport.getInstance()
if transportInstance.ownLink is True:
link = reverse(
'TransportOwnLink', args=('A' + userService.uuid, transport.uuid)
'TransportOwnLink', args=('A' + userService.uuid, transport.uuid) # type: ignore
)
else:
link = html.udsAccessLink(
request, 'A' + userService.uuid, transport.uuid
request, 'A' + userService.uuid, transport.uuid # type: ignore
)
request.session['launch'] = link