mirror of
https://github.com/dkmstr/openuds.git
synced 2025-01-08 21:18:00 +03:00
fixed author names and more linting
This commit is contained in:
parent
4e385f2074
commit
a88b0b59a5
@ -36,7 +36,6 @@ import traceback
|
||||
|
||||
from django import http
|
||||
from django.utils.decorators import method_decorator
|
||||
from django.utils.translation import gettext as _
|
||||
from django.views.decorators.csrf import csrf_exempt
|
||||
from django.views.generic.base import View
|
||||
|
||||
@ -92,7 +91,9 @@ class Dispatcher(View):
|
||||
service = Dispatcher.services
|
||||
full_path_lst: typing.List[str] = []
|
||||
# Guess content type from content type header (post) or ".xxx" to method
|
||||
content_type: str = request.META.get('CONTENT_TYPE', 'application/json').split(';')[0]
|
||||
content_type: str = request.META.get('CONTENT_TYPE', 'application/json').split(
|
||||
';'
|
||||
)[0]
|
||||
|
||||
while path:
|
||||
clean_path = path[0]
|
||||
@ -112,13 +113,15 @@ class Dispatcher(View):
|
||||
logger.debug("REST request: %s (%s)", full_path, content_type)
|
||||
|
||||
# Here, service points to the path and the value of '' is the handler
|
||||
cls: typing.Optional[typing.Type[Handler]] = service[''] # Get "root" class, that is stored on
|
||||
cls: typing.Optional[typing.Type[Handler]] = service[
|
||||
''
|
||||
] # Get "root" class, that is stored on
|
||||
if not cls:
|
||||
return http.HttpResponseNotFound(
|
||||
'Method not found', content_type="text/plain"
|
||||
)
|
||||
|
||||
processor = processors.available_processors_mime_dict .get(
|
||||
processor = processors.available_processors_mime_dict.get(
|
||||
content_type, processors.default_processor
|
||||
)(request)
|
||||
|
||||
@ -146,7 +149,7 @@ class Dispatcher(View):
|
||||
|
||||
log.log_operation(handler, 500, log.ERROR)
|
||||
return http.HttpResponseServerError(
|
||||
'Invalid parameters invoking {0}: {1}'.format(full_path, e),
|
||||
f'Invalid parameters invoking {full_path}: {e}',
|
||||
content_type="text/plain",
|
||||
)
|
||||
except AttributeError:
|
||||
@ -174,7 +177,7 @@ class Dispatcher(View):
|
||||
# Invokes the handler's operation, add headers to response and returns
|
||||
try:
|
||||
response = operation()
|
||||
|
||||
|
||||
if not handler.raw: # Raw handlers will return an HttpResponse Object
|
||||
response = processor.getResponse(response)
|
||||
# Set response headers
|
||||
@ -208,7 +211,7 @@ class Dispatcher(View):
|
||||
trace_back = traceback.format_exc()
|
||||
logger.error('Exception processing request: %s', full_path)
|
||||
for i in trace_back.splitlines():
|
||||
logger.error(f'* {i}')
|
||||
logger.error('* %s', i)
|
||||
|
||||
return http.HttpResponseServerError(str(e), content_type="text/plain")
|
||||
|
||||
@ -250,7 +253,7 @@ class Dispatcher(View):
|
||||
"""
|
||||
logger.info('Initializing REST Handlers')
|
||||
# Our parent module "REST", because we are in "dispatcher"
|
||||
modName = __name__[:__name__.rfind('.')]
|
||||
modName = __name__[: __name__.rfind('.')]
|
||||
|
||||
# Register all subclasses of Handler
|
||||
modfinder.dynamicLoadAndRegisterPackages(
|
||||
@ -261,7 +264,5 @@ class Dispatcher(View):
|
||||
packageName='methods',
|
||||
)
|
||||
|
||||
return
|
||||
|
||||
|
||||
Dispatcher.initialize()
|
||||
|
@ -71,9 +71,9 @@ class AccessCalendars(DetailHandler):
|
||||
return AccessCalendars.as_dict(
|
||||
parent.calendarAccess.get(uuid=processUuid(item))
|
||||
)
|
||||
except Exception:
|
||||
except Exception as e:
|
||||
logger.exception('err: %s', item)
|
||||
raise self.invalidItemException()
|
||||
raise self.invalidItemException() from e
|
||||
|
||||
def getTitle(self, parent: 'ServicePool'):
|
||||
return _('Access restrictions by calendar')
|
||||
@ -96,8 +96,10 @@ class AccessCalendars(DetailHandler):
|
||||
access: str = self._params['access'].upper()
|
||||
if access not in (ALLOW, DENY):
|
||||
raise Exception()
|
||||
except Exception:
|
||||
raise self.invalidRequestException(_('Invalid parameters on request'))
|
||||
except Exception as e:
|
||||
raise self.invalidRequestException(
|
||||
_('Invalid parameters on request')
|
||||
) from e
|
||||
priority = int(self._params['priority'])
|
||||
|
||||
if uuid is not None:
|
||||
@ -115,18 +117,13 @@ class AccessCalendars(DetailHandler):
|
||||
log.doLog(
|
||||
parent,
|
||||
log.INFO,
|
||||
"Added access calendar {}/{} by {}".format(
|
||||
calendar.name, access, self._user.pretty_name
|
||||
),
|
||||
f'{"Added" if uuid is None else "Updated"} access calendar {calendar.name}/{access} by {self._user.pretty_name}',
|
||||
log.ADMIN,
|
||||
)
|
||||
|
||||
def deleteItem(self, parent: 'ServicePool', item: str) -> None:
|
||||
calendarAccess = parent.calendarAccess.get(uuid=processUuid(self._args[0]))
|
||||
logStr = "Removed access calendar {} by {}".format(
|
||||
calendarAccess.calendar.name, self._user.pretty_name
|
||||
)
|
||||
|
||||
logStr = f'Removed access calendar {calendarAccess.calendar.name} by {self._user.pretty_name}'
|
||||
calendarAccess.delete()
|
||||
|
||||
log.doLog(parent, log.INFO, logStr, log.ADMIN)
|
||||
@ -167,8 +164,8 @@ class ActionsCalendars(DetailHandler):
|
||||
]
|
||||
i = parent.calendaraction_set.get(uuid=processUuid(item))
|
||||
return ActionsCalendars.as_dict(i)
|
||||
except Exception:
|
||||
raise self.invalidItemException()
|
||||
except Exception as e:
|
||||
raise self.invalidItemException() from e
|
||||
|
||||
def getTitle(self, parent: 'ServicePool'):
|
||||
return _('Scheduled actions')
|
||||
@ -197,13 +194,10 @@ class ActionsCalendars(DetailHandler):
|
||||
params = json.dumps(self._params['params'])
|
||||
|
||||
# logger.debug('Got parameters: {} {} {} {} ----> {}'.format(calendar, action, eventsOffset, atStart, params))
|
||||
logStr = "Added scheduled action \"{},{},{},{},{}\" by {}".format(
|
||||
calendar.name,
|
||||
action,
|
||||
eventsOffset,
|
||||
atStart and 'Start' or 'End',
|
||||
params,
|
||||
self._user.pretty_name,
|
||||
logStr = (
|
||||
f'{"Added" if uuid is None else "Updated"} scheduled action '
|
||||
f'{calendar.name},{action},{eventsOffset},{"start" if atStart else "end"},{params} '
|
||||
f'by {self._user.pretty_name}'
|
||||
)
|
||||
|
||||
if uuid is not None:
|
||||
@ -229,13 +223,11 @@ class ActionsCalendars(DetailHandler):
|
||||
|
||||
def deleteItem(self, parent: 'ServicePool', item: str) -> None:
|
||||
calendarAction = CalendarAction.objects.get(uuid=processUuid(self._args[0]))
|
||||
logStr = "Removed scheduled action \"{},{},{},{},{}\" by {}".format(
|
||||
calendarAction.calendar.name,
|
||||
calendarAction.action,
|
||||
calendarAction.events_offset,
|
||||
calendarAction.at_start and 'Start' or 'End',
|
||||
calendarAction.params,
|
||||
self._user.pretty_name,
|
||||
logStr = (
|
||||
f'Removed scheduled action "{calendarAction.calendar.name},'
|
||||
f'{calendarAction.action},{calendarAction.events_offset},'
|
||||
f'{calendarAction.at_start and "Start" or "End"},'
|
||||
f'{calendarAction.params}" by {self._user.pretty_name}'
|
||||
)
|
||||
|
||||
calendarAction.delete()
|
||||
@ -247,17 +239,15 @@ class ActionsCalendars(DetailHandler):
|
||||
uuid = processUuid(item)
|
||||
calendarAction: CalendarAction = CalendarAction.objects.get(uuid=uuid)
|
||||
self.ensureAccess(calendarAction, permissions.PermissionType.MANAGEMENT)
|
||||
logStr = "Launched scheduled action \"{},{},{},{},{}\" by {}".format(
|
||||
calendarAction.calendar.name,
|
||||
calendarAction.action,
|
||||
calendarAction.events_offset,
|
||||
calendarAction.at_start and 'Start' or 'End',
|
||||
calendarAction.params,
|
||||
self._user.pretty_name,
|
||||
|
||||
logStr = (
|
||||
f'Launched scheduled action "{calendarAction.calendar.name},'
|
||||
f'{calendarAction.action},{calendarAction.events_offset},'
|
||||
f'{calendarAction.at_start and "Start" or "End"},'
|
||||
f'{calendarAction.params}" by {self._user.pretty_name}'
|
||||
)
|
||||
|
||||
log.doLog(parent, log.INFO, logStr, log.ADMIN)
|
||||
calendarAction.execute()
|
||||
|
||||
log.doLog(parent, log.INFO, logStr, log.ADMIN)
|
||||
|
||||
return self.success()
|
||||
|
@ -71,7 +71,7 @@ OK: typing.Final[
|
||||
str
|
||||
] = 'ok' # Constant to be returned when result is just "operation complete successfully"
|
||||
|
||||
|
||||
# pylint: disable=unused-argument
|
||||
class BaseModelHandler(Handler):
|
||||
"""
|
||||
Base Handler for Master & Detail Handlers
|
||||
@ -246,12 +246,12 @@ class BaseModelHandler(Handler):
|
||||
if not permissions.hasAccess(self._user, obj, permission, root):
|
||||
raise self.accessDenied()
|
||||
|
||||
def getPermissions(
|
||||
self, obj: models.Model, root: bool = False
|
||||
) -> int:
|
||||
def getPermissions(self, obj: models.Model, root: bool = False) -> int:
|
||||
return permissions.getEffectivePermission(self._user, obj, root)
|
||||
|
||||
def typeInfo(self, type_: typing.Type['Module']) -> typing.Dict[str, typing.Any]:
|
||||
def typeInfo(
|
||||
self, type_: typing.Type['Module'] # pylint: disable=unused-argument
|
||||
) -> typing.Dict[str, typing.Any]:
|
||||
"""
|
||||
Returns info about the type
|
||||
In fact, right now, it returns an empty dict, that will be extended by typeAsDict
|
||||
@ -316,7 +316,7 @@ class BaseModelHandler(Handler):
|
||||
args[key] = self._params[key]
|
||||
# del self._params[key]
|
||||
except KeyError as e:
|
||||
raise exceptions.RequestError('needed parameter not found in data {0}'.format(e))
|
||||
raise exceptions.RequestError(f'needed parameter not found in data {e}')
|
||||
|
||||
return args
|
||||
|
||||
@ -351,7 +351,7 @@ class BaseModelHandler(Handler):
|
||||
:param message: Custom message to add to exception. If it is None, "Invalid Request" is used
|
||||
"""
|
||||
message = message or _('Invalid Request')
|
||||
return exceptions.RequestError('{} {}: {}'.format(message, self.__class__, self._args))
|
||||
return exceptions.RequestError(f'{message} {self.__class__}: {self._args}')
|
||||
|
||||
def invalidResponseException(
|
||||
self, message: typing.Optional[str] = None
|
||||
@ -377,10 +377,14 @@ class BaseModelHandler(Handler):
|
||||
return exceptions.NotFound(message)
|
||||
# raise NotFound('{} {}: {}'.format(message, self.__class__, self._args))
|
||||
|
||||
def accessDenied(self, message: typing.Optional[str] = None) -> exceptions.HandlerError:
|
||||
def accessDenied(
|
||||
self, message: typing.Optional[str] = None
|
||||
) -> exceptions.HandlerError:
|
||||
return exceptions.AccessDenied(message or _('Access denied'))
|
||||
|
||||
def notSupported(self, message: typing.Optional[str] = None) -> exceptions.HandlerError:
|
||||
def notSupported(
|
||||
self, message: typing.Optional[str] = None
|
||||
) -> exceptions.HandlerError:
|
||||
return exceptions.NotSupportedError(message or _('Operation not supported'))
|
||||
|
||||
# Success methods
|
||||
@ -391,7 +395,7 @@ class BaseModelHandler(Handler):
|
||||
logger.debug('Returning success on %s %s', self.__class__, self._args)
|
||||
return OK
|
||||
|
||||
def test(self, type_: str):
|
||||
def test(self, type_: str) -> None: # pylint: disable=unused-argument
|
||||
"""
|
||||
Invokes a test for an item
|
||||
"""
|
||||
@ -440,7 +444,7 @@ class DetailHandler(BaseModelHandler):
|
||||
path: str,
|
||||
params: typing.Any,
|
||||
*args: str,
|
||||
**kwargs: typing.Any
|
||||
**kwargs: typing.Any,
|
||||
): # pylint: disable=super-init-not-called
|
||||
"""
|
||||
Detail Handlers in fact "disabled" handler most initialization, that is no needed because
|
||||
@ -473,9 +477,8 @@ class DetailHandler(BaseModelHandler):
|
||||
|
||||
return None
|
||||
|
||||
def get(
|
||||
self,
|
||||
) -> typing.Any: # pylint: disable=too-many-branches,too-many-return-statements
|
||||
# pylint: disable=too-many-branches,too-many-return-statements
|
||||
def get(self) -> typing.Any:
|
||||
"""
|
||||
Processes GET method for a detail Handler
|
||||
"""
|
||||
@ -596,7 +599,7 @@ class DetailHandler(BaseModelHandler):
|
||||
# return []
|
||||
# return {} # Returns one item
|
||||
raise NotImplementedError(
|
||||
'Must provide an getItems method for {} class'.format(self.__class__)
|
||||
f'Must provide an getItems method for {self.__class__} class'
|
||||
)
|
||||
|
||||
# Default save
|
||||
@ -853,10 +856,12 @@ class ModelHandler(BaseModelHandler):
|
||||
|
||||
logger.debug('After filtering: %s', res)
|
||||
return res
|
||||
except:
|
||||
except Exception as e:
|
||||
logger.exception('Exception:')
|
||||
logger.info('Filtering expression %s is invalid!', self.fltr)
|
||||
raise exceptions.RequestError('Filtering expression {} is invalid'.format(self.fltr))
|
||||
raise exceptions.RequestError(
|
||||
f'Filtering expression {self.fltr} is invalid'
|
||||
) from e
|
||||
|
||||
# Helper to process detail
|
||||
# Details can be managed (writen) by any user that has MANAGEMENT permission over parent
|
||||
@ -884,9 +889,8 @@ class ModelHandler(BaseModelHandler):
|
||||
if not self.detail:
|
||||
raise self.invalidRequestException()
|
||||
|
||||
detailCls = self.detail[
|
||||
self._args[1]
|
||||
] # pylint: disable=unsubscriptable-object
|
||||
# pylint: disable=unsubscriptable-object
|
||||
detailCls = self.detail[self._args[1]]
|
||||
args = list(self._args[2:])
|
||||
path = self._path + '/' + '/'.join(args[:2])
|
||||
detail = detailCls(
|
||||
@ -895,15 +899,15 @@ class ModelHandler(BaseModelHandler):
|
||||
method = getattr(detail, self._operation)
|
||||
|
||||
return method()
|
||||
except IndexError:
|
||||
raise self.invalidItemException()
|
||||
except (KeyError, AttributeError):
|
||||
raise self.invalidMethodException()
|
||||
except IndexError as e:
|
||||
raise self.invalidItemException() from e
|
||||
except (KeyError, AttributeError) as e:
|
||||
raise self.invalidMethodException() from e
|
||||
except exceptions.HandlerError:
|
||||
raise
|
||||
except Exception as e:
|
||||
logger.error('Exception processing detail: %s', e)
|
||||
raise self.invalidRequestException()
|
||||
raise self.invalidRequestException() from e
|
||||
|
||||
def getItems(
|
||||
self, *args, **kwargs
|
||||
@ -951,7 +955,6 @@ class ModelHandler(BaseModelHandler):
|
||||
except Exception as e: # maybe an exception is thrown to skip an item
|
||||
logger.debug('Got exception processing item from model: %s', e)
|
||||
# logger.exception('Exception getting item from {0}'.format(self.model))
|
||||
pass
|
||||
|
||||
def get(self) -> typing.Any:
|
||||
"""
|
||||
@ -961,6 +964,7 @@ class ModelHandler(BaseModelHandler):
|
||||
self.extractFilter()
|
||||
return self.doFilter(self.doGet())
|
||||
|
||||
# pylint: disable=too-many-return-statements
|
||||
def doGet(self) -> typing.Any:
|
||||
logger.debug('method GET for %s, %s', self.__class__.__name__, self._args)
|
||||
nArgs = len(self._args)
|
||||
@ -992,8 +996,8 @@ class ModelHandler(BaseModelHandler):
|
||||
operation = None
|
||||
try:
|
||||
operation = getattr(self, self._args[0])
|
||||
except Exception:
|
||||
raise self.invalidMethodException()
|
||||
except Exception as e:
|
||||
raise self.invalidMethodException() from e
|
||||
|
||||
return operation()
|
||||
|
||||
@ -1021,9 +1025,9 @@ class ModelHandler(BaseModelHandler):
|
||||
res = self.item_as_dict(val)
|
||||
self.fillIntanceFields(val, res)
|
||||
return res
|
||||
except Exception:
|
||||
except Exception as e:
|
||||
logger.exception('Got Exception looking for item')
|
||||
raise self.invalidItemException()
|
||||
raise self.invalidItemException() from e
|
||||
|
||||
# nArgs > 1
|
||||
# Request type info or gui, or detail
|
||||
@ -1047,8 +1051,8 @@ class ModelHandler(BaseModelHandler):
|
||||
uuid=self._args[0].lower()
|
||||
) # DB maybe case sensitive??, anyway, uuids are stored in lowercase
|
||||
return self.getLogs(item)
|
||||
except Exception:
|
||||
raise self.invalidItemException()
|
||||
except Exception as e:
|
||||
raise self.invalidItemException() from e
|
||||
|
||||
# If has detail and is requesting detail
|
||||
if self.detail is not None:
|
||||
@ -1073,7 +1077,7 @@ class ModelHandler(BaseModelHandler):
|
||||
Processes a PUT request
|
||||
"""
|
||||
logger.debug('method PUT for %s, %s', self.__class__.__name__, self._args)
|
||||
|
||||
|
||||
# Append request to _params, may be needed by some classes
|
||||
# I.e. to get the user IP, server name, etc..
|
||||
self._params['_request'] = self._request
|
||||
@ -1148,7 +1152,7 @@ class ModelHandler(BaseModelHandler):
|
||||
|
||||
res = self.item_as_dict(item)
|
||||
self.fillIntanceFields(item, res)
|
||||
except Exception as e:
|
||||
except Exception:
|
||||
logger.exception('Exception on put')
|
||||
if deleteOnError:
|
||||
item.delete()
|
||||
@ -1159,16 +1163,18 @@ class ModelHandler(BaseModelHandler):
|
||||
return res
|
||||
|
||||
except self.model.DoesNotExist:
|
||||
raise exceptions.NotFound('Item not found')
|
||||
raise exceptions.NotFound('Item not found') from None
|
||||
except IntegrityError: # Duplicate key probably
|
||||
raise exceptions.RequestError('Element already exists (duplicate key error)')
|
||||
raise exceptions.RequestError(
|
||||
'Element already exists (duplicate key error)'
|
||||
) from None
|
||||
except (exceptions.SaveException, g_exceptions.ValidationError) as e:
|
||||
raise exceptions.RequestError(str(e))
|
||||
raise exceptions.RequestError(str(e)) from e
|
||||
except (exceptions.RequestError, exceptions.ResponseError):
|
||||
raise
|
||||
except Exception:
|
||||
except Exception as e:
|
||||
logger.exception('Exception on put')
|
||||
raise exceptions.RequestError('incorrect invocation to PUT')
|
||||
raise exceptions.RequestError('incorrect invocation to PUT') from e
|
||||
|
||||
def delete(self) -> typing.Any:
|
||||
"""
|
||||
@ -1190,7 +1196,7 @@ class ModelHandler(BaseModelHandler):
|
||||
self.checkDelete(item)
|
||||
self.deleteItem(item)
|
||||
except self.model.DoesNotExist:
|
||||
raise exceptions.NotFound('Element do not exists')
|
||||
raise exceptions.NotFound('Element do not exists') from None
|
||||
|
||||
return OK
|
||||
|
||||
|
@ -32,6 +32,6 @@
|
||||
Sample authenticator. We import here the module, and uds.auths module will
|
||||
take care of registering it as provider
|
||||
|
||||
.. moduleauthor:: Adolfo Gómez, dkmaster at dkmon dot com
|
||||
Author: Adolfo Gómez, dkmaster at dkmon dot com
|
||||
"""
|
||||
from .authenticator import RadiusAuth
|
||||
|
@ -28,7 +28,7 @@
|
||||
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
"""
|
||||
.. moduleauthor:: Adolfo Gómez, dkmaster at dkmon dot com
|
||||
Author: Adolfo Gómez, dkmaster at dkmon dot com
|
||||
"""
|
||||
import logging
|
||||
import typing
|
||||
|
@ -27,7 +27,7 @@
|
||||
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
"""
|
||||
.. moduleauthor:: Adolfo Gómez, dkmaster at dkmon dot com
|
||||
Author: Adolfo Gómez, dkmaster at dkmon dot com
|
||||
"""
|
||||
from uds.core import managers
|
||||
from .saml import SAMLAuthenticator # import for registration on space,
|
||||
|
@ -28,7 +28,7 @@
|
||||
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
"""
|
||||
.. moduleauthor:: Adolfo Gómez, dkmaster at dkmon dot com
|
||||
Author: Adolfo Gómez, dkmaster at dkmon dot com
|
||||
"""
|
||||
import re
|
||||
from urllib.parse import urlparse
|
||||
|
@ -28,7 +28,7 @@
|
||||
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
"""
|
||||
.. moduleauthor:: Adolfo Gómez, dkmaster at dkmon dot com
|
||||
Author: Adolfo Gómez, dkmaster at dkmon dot com
|
||||
"""
|
||||
import logging
|
||||
import typing
|
||||
|
@ -32,7 +32,7 @@
|
||||
Sample authenticator. We import here the module, and uds.auths module will
|
||||
take care of registering it as provider
|
||||
|
||||
.. moduleauthor:: Adolfo Gómez, dkmaster at dkmon dot com
|
||||
Author: Adolfo Gómez, dkmaster at dkmon dot com
|
||||
"""
|
||||
from .SampleAuth import SampleAuth
|
||||
|
||||
|
@ -38,7 +38,7 @@ To create a new authentication module, you will need to follow this steps:
|
||||
|
||||
The registration of modules is done locating subclases of :py:class:`uds.core.auths.Authentication`
|
||||
|
||||
.. moduleauthor:: Adolfo Gómez, dkmaster at dkmon dot com
|
||||
Author: Adolfo Gómez, dkmaster at dkmon dot com
|
||||
"""
|
||||
from uds.core.util import modfinder
|
||||
|
||||
|
@ -30,7 +30,7 @@
|
||||
"""
|
||||
UDS authentication related interfaces and classes
|
||||
|
||||
.. moduleauthor:: Adolfo Gómez, dkmaster at dkmon dot com
|
||||
Author: Adolfo Gómez, dkmaster at dkmon dot com
|
||||
"""
|
||||
from .authenticator import (
|
||||
Authenticator,
|
||||
|
@ -30,7 +30,7 @@
|
||||
Provides useful functions for authenticating, used by web interface.
|
||||
|
||||
|
||||
.. moduleauthor:: Adolfo Gómez, dkmaster at dkmon dot com
|
||||
Author: Adolfo Gómez, dkmaster at dkmon dot com
|
||||
'''
|
||||
import logging
|
||||
import typing
|
||||
|
@ -30,7 +30,7 @@
|
||||
"""
|
||||
Base module for all authenticators
|
||||
|
||||
.. moduleauthor:: Adolfo Gómez, dkmaster at dkmon dot com
|
||||
Author: Adolfo Gómez, dkmaster at dkmon dot com
|
||||
"""
|
||||
import enum
|
||||
import logging
|
||||
|
@ -28,7 +28,7 @@
|
||||
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
"""
|
||||
.. moduleauthor:: Adolfo Gómez, dkmaster at dkmon dot com
|
||||
Author: Adolfo Gómez, dkmaster at dkmon dot com
|
||||
"""
|
||||
|
||||
|
||||
|
@ -29,7 +29,7 @@
|
||||
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
"""
|
||||
.. moduleauthor:: Adolfo Gómez, dkmaster at dkmon dot com
|
||||
Author: Adolfo Gómez, dkmaster at dkmon dot com
|
||||
"""
|
||||
import logging
|
||||
import typing
|
||||
|
@ -28,7 +28,7 @@
|
||||
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
"""
|
||||
.. moduleauthor:: Adolfo Gómez, dkmaster at dkmon dot com
|
||||
Author: Adolfo Gómez, dkmaster at dkmon dot com
|
||||
"""
|
||||
import re
|
||||
import logging
|
||||
|
@ -28,7 +28,7 @@
|
||||
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
"""
|
||||
.. moduleauthor:: Adolfo Gómez, dkmaster at dkmon dot com
|
||||
Author: Adolfo Gómez, dkmaster at dkmon dot com
|
||||
"""
|
||||
import logging
|
||||
import typing
|
||||
|
@ -28,7 +28,7 @@
|
||||
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
"""
|
||||
.. moduleauthor:: Adolfo Gómez, dkmaster at dkmon dot com
|
||||
Author: Adolfo Gómez, dkmaster at dkmon dot com
|
||||
"""
|
||||
import typing
|
||||
|
||||
|
@ -30,7 +30,7 @@
|
||||
"""
|
||||
UDS jobs related modules
|
||||
|
||||
.. moduleauthor:: Adolfo Gómez, dkmaster at dkmon dot com
|
||||
Author: Adolfo Gómez, dkmaster at dkmon dot com
|
||||
"""
|
||||
import typing
|
||||
from .job import Job
|
||||
|
@ -30,7 +30,7 @@
|
||||
"""
|
||||
UDS managers (downloads, users preferences, publications, ...)
|
||||
|
||||
.. moduleauthor:: Adolfo Gómez, dkmaster at dkmon dot com
|
||||
Author: Adolfo Gómez, dkmaster at dkmon dot com
|
||||
"""
|
||||
import typing
|
||||
|
||||
|
@ -27,7 +27,7 @@
|
||||
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
"""
|
||||
.. moduleauthor:: Adolfo Gómez, dkmaster at dkmon dot com
|
||||
Author: Adolfo Gómez, dkmaster at dkmon dot com
|
||||
"""
|
||||
import logging
|
||||
import typing
|
||||
|
@ -26,7 +26,7 @@
|
||||
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
"""
|
||||
.. moduleauthor:: Adolfo Gómez, dkmaster at dkmon dot com
|
||||
Author: Adolfo Gómez, dkmaster at dkmon dot com
|
||||
"""
|
||||
import os
|
||||
import json
|
||||
|
@ -27,7 +27,7 @@
|
||||
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
"""
|
||||
.. moduleauthor:: Adolfo Gómez, dkmaster at dkmon dot com
|
||||
Author: Adolfo Gómez, dkmaster at dkmon dot com
|
||||
"""
|
||||
from .provider import Notifier, NotificationLevel
|
||||
from .msgfactory import NotifierFactory
|
||||
|
@ -26,7 +26,7 @@
|
||||
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
"""
|
||||
.. moduleauthor:: Adolfo Gómez, dkmaster at dkmon dot com
|
||||
Author: Adolfo Gómez, dkmaster at dkmon dot com
|
||||
"""
|
||||
import datetime
|
||||
import time
|
||||
|
@ -26,7 +26,7 @@
|
||||
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
"""
|
||||
.. moduleauthor:: Adolfo Gómez, dkmaster at dkmon dot com
|
||||
Author: Adolfo Gómez, dkmaster at dkmon dot com
|
||||
"""
|
||||
import typing
|
||||
import enum
|
||||
|
@ -28,7 +28,7 @@
|
||||
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
"""
|
||||
.. moduleauthor:: Adolfo Gómez, dkmaster at dkmon dot com
|
||||
Author: Adolfo Gómez, dkmaster at dkmon dot com
|
||||
"""
|
||||
import sys
|
||||
import os.path
|
||||
|
@ -28,7 +28,7 @@
|
||||
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
# -*- coding: utf-8 -*-
|
||||
"""
|
||||
.. moduleauthor:: Adolfo Gómez, dkmaster at dkmon dot com
|
||||
Author: Adolfo Gómez, dkmaster at dkmon dot com
|
||||
"""
|
||||
|
||||
import logging
|
||||
|
@ -28,7 +28,7 @@
|
||||
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
"""
|
||||
.. moduleauthor:: Adolfo Gómez, dkmaster at dkmon dot com
|
||||
Author: Adolfo Gómez, dkmaster at dkmon dot com
|
||||
"""
|
||||
import codecs
|
||||
import datetime
|
||||
|
@ -28,7 +28,7 @@
|
||||
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
"""
|
||||
.. moduleauthor:: Adolfo Gómez, dkmaster at dkmon dot com
|
||||
Author: Adolfo Gómez, dkmaster at dkmon dot com
|
||||
"""
|
||||
import logging
|
||||
import typing
|
||||
|
@ -28,7 +28,7 @@
|
||||
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
"""
|
||||
.. moduleauthor:: Adolfo Gómez, dkmaster at dkmon dot com
|
||||
Author: Adolfo Gómez, dkmaster at dkmon dot com
|
||||
"""
|
||||
import base64
|
||||
import pickle # nosec: Safe pickle usage
|
||||
|
@ -30,7 +30,7 @@
|
||||
"""
|
||||
UDS Service modules interfaces and classes.
|
||||
|
||||
.. moduleauthor:: Adolfo Gómez, dkmaster at dkmon dot com
|
||||
Author: Adolfo Gómez, dkmaster at dkmon dot com
|
||||
"""
|
||||
from . import exceptions
|
||||
from . import types
|
||||
|
@ -28,7 +28,7 @@
|
||||
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
"""
|
||||
.. moduleauthor:: Adolfo Gómez, dkmaster at dkmon dot com
|
||||
Author: Adolfo Gómez, dkmaster at dkmon dot com
|
||||
"""
|
||||
import typing
|
||||
|
||||
|
@ -28,7 +28,7 @@
|
||||
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
"""
|
||||
.. moduleauthor:: Adolfo Gómez, dkmaster at dkmon dot com
|
||||
Author: Adolfo Gómez, dkmaster at dkmon dot com
|
||||
"""
|
||||
import logging
|
||||
import typing
|
||||
|
@ -28,7 +28,7 @@
|
||||
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
"""
|
||||
.. moduleauthor:: Adolfo Gómez, dkmaster at dkmon dot com
|
||||
Author: Adolfo Gómez, dkmaster at dkmon dot com
|
||||
"""
|
||||
import abc
|
||||
import typing
|
||||
|
@ -28,7 +28,7 @@
|
||||
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
"""
|
||||
.. moduleauthor:: Adolfo Gómez, dkmaster at dkmon dot com
|
||||
Author: Adolfo Gómez, dkmaster at dkmon dot com
|
||||
"""
|
||||
|
||||
import typing
|
||||
|
@ -28,7 +28,7 @@
|
||||
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
"""
|
||||
.. moduleauthor:: Adolfo Gómez, dkmaster at dkmon dot com
|
||||
Author: Adolfo Gómez, dkmaster at dkmon dot com
|
||||
"""
|
||||
VDI = 'vdi'
|
||||
VAPP = 'vApp'
|
||||
|
@ -28,7 +28,7 @@
|
||||
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
"""
|
||||
.. moduleauthor:: Adolfo Gómez, dkmaster at dkmon dot com
|
||||
Author: Adolfo Gómez, dkmaster at dkmon dot com
|
||||
"""
|
||||
import typing
|
||||
|
||||
|
@ -30,7 +30,7 @@
|
||||
"""
|
||||
UDS Service modules interfaces and classes.
|
||||
|
||||
.. moduleauthor:: Adolfo Gómez, dkmaster at dkmon dot com
|
||||
Author: Adolfo Gómez, dkmaster at dkmon dot com
|
||||
"""
|
||||
from .transport import Transport, TransportScript, DIRECT_GROUP, TUNNELED_GROUP
|
||||
from .transport_factory import TransportsFactory
|
||||
|
@ -27,7 +27,7 @@
|
||||
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
"""
|
||||
.. moduleauthor:: Adolfo Gómez, dkmaster at dkmon dot com
|
||||
Author: Adolfo Gómez, dkmaster at dkmon dot com
|
||||
"""
|
||||
# pylint: disable=too-many-lines
|
||||
import codecs
|
||||
|
@ -28,7 +28,7 @@
|
||||
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
"""
|
||||
.. moduleauthor:: Adolfo Gómez, dkmaster at dkmon dot com
|
||||
Author: Adolfo Gómez, dkmaster at dkmon dot com
|
||||
"""
|
||||
import datetime
|
||||
import hashlib
|
||||
|
@ -27,7 +27,7 @@
|
||||
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
"""
|
||||
.. moduleauthor:: Adolfo Gómez, dkmaster at dkmon dot com
|
||||
Author: Adolfo Gómez, dkmaster at dkmon dot com
|
||||
"""
|
||||
import logging
|
||||
import typing
|
||||
|
@ -28,7 +28,7 @@
|
||||
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
"""
|
||||
.. moduleauthor:: Adolfo Gómez, dkmaster at dkmon dot com
|
||||
Author: Adolfo Gómez, dkmaster at dkmon dot com
|
||||
"""
|
||||
import typing
|
||||
import logging
|
||||
|
@ -37,7 +37,7 @@ To create a new authentication module, you will need to follow this steps:
|
||||
|
||||
The registration of modules is done locating subclases of :py:class:`uds.core.auths.Authentication`
|
||||
|
||||
.. moduleauthor:: Adolfo Gómez, dkmaster at dkmon dot com
|
||||
Author: Adolfo Gómez, dkmaster at dkmon dot com
|
||||
"""
|
||||
import os.path
|
||||
import pkgutil
|
||||
|
@ -30,9 +30,9 @@ def update_network_model(apps, schema_editor): # pylint: disable=unused-argumen
|
||||
# Store the net_start and net_end on new fields "start" and "end", that are strings
|
||||
# to allow us to store ipv6 addresses
|
||||
# pylint: disable=protected-access
|
||||
net.start = uds.models.network.Network._hexlify(net.net_start)
|
||||
net.start = uds.models.network.Network.hexlify(net.net_start)
|
||||
# pylint: disable=protected-access
|
||||
net.end = uds.models.network.Network._hexlify(net.net_end)
|
||||
net.end = uds.models.network.Network.hexlify(net.net_end)
|
||||
net.version = 4 # Previous versions only supported ipv4
|
||||
net.save()
|
||||
except Exception as e:
|
||||
|
@ -26,7 +26,7 @@
|
||||
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
"""
|
||||
.. moduleauthor:: Adolfo Gómez, dkmaster at dkmon dot com
|
||||
Author: Adolfo Gómez, dkmaster at dkmon dot com
|
||||
"""
|
||||
import logging
|
||||
import typing
|
||||
|
@ -26,7 +26,7 @@
|
||||
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
"""
|
||||
.. moduleauthor:: Adolfo Gómez, dkmaster at dkmon dot com
|
||||
Author: Adolfo Gómez, dkmaster at dkmon dot com
|
||||
"""
|
||||
import typing
|
||||
import logging
|
||||
|
@ -28,7 +28,7 @@
|
||||
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
"""
|
||||
.. moduleauthor:: Adolfo Gómez, dkmaster at dkmon dot com
|
||||
Author: Adolfo Gómez, dkmaster at dkmon dot com
|
||||
"""
|
||||
from datetime import timedelta
|
||||
import logging
|
||||
@ -56,7 +56,7 @@ class Cache(models.Model):
|
||||
# "fake" relations declarations for type checking
|
||||
# objects: 'models.manager.Manager[Cache]'
|
||||
|
||||
class Meta:
|
||||
class Meta: # pylint: disable=too-few-public-methods
|
||||
"""
|
||||
Meta class to declare the name of the table at database
|
||||
"""
|
||||
@ -80,4 +80,4 @@ class Cache(models.Model):
|
||||
expired = "Expired"
|
||||
else:
|
||||
expired = "Active"
|
||||
return "{0} {1} = {2} ({3})".format(self.owner, self.key, self.value, expired)
|
||||
return f'{self.owner} {self.key} = {self.value} ({expired})'
|
||||
|
@ -1,6 +1,6 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# Copyright (c) 2016-2020 Virtual Cable S.L.U.
|
||||
# Copyright (c) 2016-2023 Virtual Cable S.L.U.
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without modification,
|
||||
@ -27,7 +27,7 @@
|
||||
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
"""
|
||||
.. moduleauthor:: Adolfo Gómez, dkmaster at dkmon dot com
|
||||
Author:: Adolfo Gómez, dkmaster at dkmon dot com
|
||||
"""
|
||||
import logging
|
||||
import typing
|
||||
@ -57,7 +57,7 @@ class Calendar(UUIDModel, TaggingMixin):
|
||||
calendaraction_set: 'models.manager.RelatedManager[CalendarAction]'
|
||||
calendaraccess_set: 'models.manager.RelatedManager[CalendarAccess]'
|
||||
|
||||
class Meta:
|
||||
class Meta: # pylint: disable=too-few-public-methods
|
||||
"""
|
||||
Meta class to declare db table
|
||||
"""
|
||||
@ -85,6 +85,4 @@ class Calendar(UUIDModel, TaggingMixin):
|
||||
return res
|
||||
|
||||
def __str__(self):
|
||||
return 'Calendar "{}" modified on {} with {} rules'.format(
|
||||
self.name, self.modified, self.rules.count()
|
||||
)
|
||||
return f'Calendar "{self.name}" modified on {self.modified}, rules: {self.rules.count()}'
|
||||
|
@ -29,7 +29,7 @@
|
||||
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
"""
|
||||
.. moduleauthor:: Adolfo Gómez, dkmaster at dkmon dot com
|
||||
Author: Adolfo Gómez, dkmaster at dkmon dot com
|
||||
"""
|
||||
import logging
|
||||
|
||||
@ -59,7 +59,7 @@ class CalendarAccess(UUIDModel):
|
||||
# "fake" declarations for type checking
|
||||
# objects: 'models.manager.Manager[CalendarAccess]'
|
||||
|
||||
class Meta:
|
||||
class Meta: # pylint: disable=too-few-public-methods
|
||||
"""
|
||||
Meta class to declare db table
|
||||
"""
|
||||
@ -69,7 +69,7 @@ class CalendarAccess(UUIDModel):
|
||||
app_label = 'uds'
|
||||
|
||||
def __str__(self) -> str:
|
||||
return 'Calendar Access {}/{}'.format(self.calendar, self.access)
|
||||
return f'Calendar Access {self.calendar}/{self.access}'
|
||||
|
||||
|
||||
class CalendarAccessMeta(UUIDModel):
|
||||
@ -83,7 +83,7 @@ class CalendarAccessMeta(UUIDModel):
|
||||
# "fake" declarations for type checking
|
||||
objects: 'models.BaseManager[CalendarAccessMeta]'
|
||||
|
||||
class Meta:
|
||||
class Meta: # pylint: disable=too-few-public-methods
|
||||
"""
|
||||
Meta class to declare db table
|
||||
"""
|
||||
@ -93,4 +93,4 @@ class CalendarAccessMeta(UUIDModel):
|
||||
app_label = 'uds'
|
||||
|
||||
def __str__(self):
|
||||
return 'Calendar Access Meta {}/{}'.format(self.calendar, self.access)
|
||||
return f'Calendar Access Meta {self.calendar}/{self.access}'
|
||||
|
@ -29,7 +29,7 @@
|
||||
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
"""
|
||||
.. moduleauthor:: Adolfo Gómez, dkmaster at dkmon dot com
|
||||
Author: Adolfo Gómez, dkmaster at dkmon dot com
|
||||
"""
|
||||
import datetime
|
||||
import json
|
||||
@ -254,7 +254,7 @@ class CalendarAction(UUIDModel):
|
||||
# "fake" declarations for type checking
|
||||
# objects: 'models.manager.Manager[CalendarAction]'
|
||||
|
||||
class Meta:
|
||||
class Meta: # pylint: disable=too-few-public-methods
|
||||
"""
|
||||
Meta class to declare db table
|
||||
"""
|
||||
@ -272,13 +272,13 @@ class CalendarAction(UUIDModel):
|
||||
ca = CALENDAR_ACTION_DICT.get(self.action)
|
||||
|
||||
if ca is None:
|
||||
raise Exception('{} not in action dict'.format(self.action))
|
||||
raise Exception(f'Action {self.action} not found')
|
||||
|
||||
params = json.loads(self.params)
|
||||
res = []
|
||||
for p in ca['params']:
|
||||
val = params[p['name']]
|
||||
pp = '{}='.format(p['name'])
|
||||
pp = f'{p["name"]}='
|
||||
# Transport
|
||||
if p['type'] == 'transport':
|
||||
try:
|
||||
@ -328,57 +328,51 @@ class CalendarAction(UUIDModel):
|
||||
v = int(params[field])
|
||||
return v if v >= 0 else 0
|
||||
|
||||
executed = False
|
||||
if CALENDAR_ACTION_CACHE_L1['id'] == self.action:
|
||||
# Actions related to calendar actions
|
||||
def set_l1_cache() -> None:
|
||||
self.service_pool.cache_l1_srvs = numVal('size')
|
||||
executed = True
|
||||
elif CALENDAR_ACTION_CACHE_L2['id'] == self.action:
|
||||
|
||||
def set_l2_cache() -> None:
|
||||
self.service_pool.cache_l2_srvs = numVal('size')
|
||||
executed = True
|
||||
elif CALENDAR_ACTION_INITIAL['id'] == self.action:
|
||||
|
||||
def set_initial() -> None:
|
||||
self.service_pool.initial_srvs = numVal('size')
|
||||
executed = True
|
||||
elif CALENDAR_ACTION_MAX['id'] == self.action:
|
||||
|
||||
def set_max() -> None:
|
||||
self.service_pool.max_srvs = numVal('size')
|
||||
executed = True
|
||||
elif CALENDAR_ACTION_PUBLISH['id'] == self.action:
|
||||
self.service_pool.publish(changeLog='Scheduled publication action')
|
||||
|
||||
def publish() -> None:
|
||||
nonlocal saveServicePool
|
||||
self.service_pool.publish()
|
||||
saveServicePool = False
|
||||
executed = True
|
||||
elif CALENDAR_ACTION_IGNORE_UNUSED['id'] == self.action:
|
||||
|
||||
def ignores_unused() -> None:
|
||||
self.service_pool.ignores_unused = params['state'] in ('true', '1', True)
|
||||
executed = True
|
||||
elif CALENDAR_ACTION_REMOVE_USERSERVICES['id'] == self.action:
|
||||
|
||||
def remove_userservices() -> None:
|
||||
# 1.- Remove usable assigned services (Ignore "creating ones", just for created)
|
||||
for userService in self.service_pool.assignedUserServices().filter(
|
||||
state=state.State.USABLE
|
||||
):
|
||||
userService.remove()
|
||||
saveServicePool = False
|
||||
executed = True
|
||||
elif CALENDAR_ACTION_REMOVE_STUCK_USERSERVICES['id'] == self.action:
|
||||
|
||||
def remove_stuck_userservice() -> None:
|
||||
# 1.- Remove stuck assigned services (Ignore "creating ones", just for created)
|
||||
since = getSqlDatetime() - datetime.timedelta(hours=numVal('hours'))
|
||||
for userService in self.service_pool.assignedUserServices().filter(
|
||||
state_date__lt=since, state=state.State.USABLE
|
||||
):
|
||||
userService.remove()
|
||||
saveServicePool = False
|
||||
executed = True
|
||||
elif CALENDAR_ACTION_DEL_ALL_TRANSPORTS['id'] == self.action:
|
||||
|
||||
def del_all_transport() -> None:
|
||||
# 2.- Remove all transports
|
||||
self.service_pool.transports.clear()
|
||||
saveServicePool = False
|
||||
executed = True
|
||||
elif CALENDAR_ACTION_DEL_ALL_GROUPS['id'] == self.action:
|
||||
|
||||
def del_all_groups() -> None:
|
||||
# 3.- Remove all groups
|
||||
self.service_pool.assignedGroups.clear()
|
||||
saveServicePool = False
|
||||
executed = True
|
||||
elif self.action in [
|
||||
CALENDAR_ACTION_CLEAN_CACHE_L1['id'],
|
||||
CALENDAR_ACTION_CLEAN_CACHE_L2['id'],
|
||||
]:
|
||||
|
||||
def clear_cache() -> None:
|
||||
# 4.- Remove all cache_l1_srvs
|
||||
for i in self.service_pool.cachedUserServices().filter(
|
||||
managers.userServiceManager().getCacheStateFilter(
|
||||
@ -389,92 +383,89 @@ class CalendarAction(UUIDModel):
|
||||
)
|
||||
):
|
||||
i.remove()
|
||||
saveServicePool = False
|
||||
executed = True
|
||||
elif CALENDAR_ACTION_CLEAN_CACHE_L2['id'] == self.action:
|
||||
# 5.- Remove all cache_l2_srvs
|
||||
for i in self.service_pool.cachedUserServices().filter(
|
||||
managers.userServiceManager().getCacheStateFilter(
|
||||
self.service_pool, services.UserDeployment.L2_CACHE
|
||||
)
|
||||
):
|
||||
i.remove()
|
||||
saveServicePool = False
|
||||
executed = True
|
||||
elif self.action in [
|
||||
CALENDAR_ACTION_ADD_TRANSPORT['id'],
|
||||
CALENDAR_ACTION_DEL_TRANSPORT['id'],
|
||||
CALENDAR_ACTION_ADD_GROUP['id'],
|
||||
CALENDAR_ACTION_DEL_GROUP['id'],
|
||||
]: # Add/remove transport or group
|
||||
saveServicePool = False
|
||||
caTransports = (
|
||||
CALENDAR_ACTION_ADD_TRANSPORT['id'],
|
||||
CALENDAR_ACTION_DEL_TRANSPORT['id'],
|
||||
)
|
||||
caGroups = (
|
||||
CALENDAR_ACTION_ADD_GROUP['id'],
|
||||
CALENDAR_ACTION_DEL_GROUP['id'],
|
||||
)
|
||||
if self.action in caTransports:
|
||||
try:
|
||||
t = Transport.objects.get(uuid=params['transport'])
|
||||
if self.action == caTransports[0]:
|
||||
self.service_pool.transports.add(t)
|
||||
else:
|
||||
self.service_pool.transports.remove(t)
|
||||
executed = True
|
||||
except Exception:
|
||||
self.service_pool.log(
|
||||
'Scheduled action not executed because transport is not available anymore'
|
||||
)
|
||||
elif self.action in caGroups:
|
||||
try:
|
||||
auth, grp = params['group'].split('@')
|
||||
grp = Authenticator.objects.get(uuid=auth).groups.get(uuid=grp)
|
||||
if self.action == caGroups[0]:
|
||||
self.service_pool.assignedGroups.add(grp)
|
||||
else:
|
||||
self.service_pool.assignedGroups.remove(grp)
|
||||
executed = True
|
||||
except Exception:
|
||||
self.service_pool.log(
|
||||
'Scheduled action not executed because group is not available anymore'
|
||||
)
|
||||
else:
|
||||
self.service_pool.log(
|
||||
'Scheduled action not executed because is not supported: {}'.format(
|
||||
self.action
|
||||
)
|
||||
)
|
||||
|
||||
if executed:
|
||||
def add_del_transport() -> None:
|
||||
try:
|
||||
t = Transport.objects.get(uuid=params['transport'])
|
||||
if self.action == CALENDAR_ACTION_ADD_TRANSPORT['id']:
|
||||
self.service_pool.transports.add(t)
|
||||
else:
|
||||
self.service_pool.transports.remove(t)
|
||||
except Exception:
|
||||
self.service_pool.log(
|
||||
'Executed action {} [{}]'.format(
|
||||
CALENDAR_ACTION_DICT.get(self.action, {})['description'],
|
||||
self.prettyParams,
|
||||
),
|
||||
'Scheduled action not executed because transport is not available anymore'
|
||||
)
|
||||
|
||||
def add_del_group() -> None:
|
||||
try:
|
||||
auth, grp = params['group'].split('@')
|
||||
grp = Authenticator.objects.get(uuid=auth).groups.get(uuid=grp)
|
||||
if self.action == CALENDAR_ACTION_ADD_GROUP['id']:
|
||||
self.service_pool.assignedGroups.add(grp)
|
||||
else:
|
||||
self.service_pool.assignedGroups.remove(grp)
|
||||
except Exception:
|
||||
self.service_pool.log(
|
||||
'Scheduled action not executed because group is not available anymore'
|
||||
)
|
||||
|
||||
actions: typing.Mapping[str, typing.Tuple[typing.Callable[[], None], bool]] = {
|
||||
# Id, actions (lambda), saveServicePool (bool)
|
||||
CALENDAR_ACTION_CACHE_L1['id']: (set_l1_cache, True),
|
||||
CALENDAR_ACTION_CACHE_L2['id']: (set_l2_cache, True),
|
||||
CALENDAR_ACTION_INITIAL['id']: (set_initial, True),
|
||||
CALENDAR_ACTION_MAX['id']: (set_max, True),
|
||||
CALENDAR_ACTION_PUBLISH['id']: (publish, False),
|
||||
CALENDAR_ACTION_IGNORE_UNUSED['id']: (ignores_unused, True),
|
||||
CALENDAR_ACTION_REMOVE_USERSERVICES['id']: (remove_userservices, False),
|
||||
CALENDAR_ACTION_REMOVE_STUCK_USERSERVICES['id']: (
|
||||
remove_stuck_userservice,
|
||||
False,
|
||||
),
|
||||
CALENDAR_ACTION_DEL_ALL_TRANSPORTS['id']: (del_all_transport, False),
|
||||
CALENDAR_ACTION_DEL_ALL_GROUPS['id']: (del_all_groups, False),
|
||||
CALENDAR_ACTION_CLEAN_CACHE_L1['id']: (clear_cache, False),
|
||||
CALENDAR_ACTION_CLEAN_CACHE_L2['id']: (clear_cache, False),
|
||||
CALENDAR_ACTION_ADD_TRANSPORT['id']: (
|
||||
add_del_transport,
|
||||
False,
|
||||
),
|
||||
CALENDAR_ACTION_DEL_TRANSPORT['id']: (
|
||||
add_del_transport,
|
||||
False,
|
||||
),
|
||||
CALENDAR_ACTION_ADD_GROUP['id']: (add_del_group, False),
|
||||
CALENDAR_ACTION_DEL_GROUP['id']: (add_del_group, False),
|
||||
}
|
||||
|
||||
fncAction, saveServicePool = actions.get(self.action, (None, False))
|
||||
|
||||
if fncAction:
|
||||
try:
|
||||
fncAction()
|
||||
|
||||
if saveServicePool:
|
||||
self.service_pool.save()
|
||||
|
||||
self.service_pool.log(
|
||||
f'Executed action {CALENDAR_ACTION_DICT.get(self.action, {}).get("description", self.action)} [{self.prettyParams}]',
|
||||
level=log.INFO,
|
||||
)
|
||||
except Exception:
|
||||
# Avoid invalid ACTIONS errors on log
|
||||
self.service_pool.log(
|
||||
'Action {} is not a valid scheduled action! please, remove it from your list.'.format(
|
||||
self.action
|
||||
)
|
||||
f'Error executing scheduled action {CALENDAR_ACTION_DICT.get(self.action, {}).get("description", self.action)} [{self.prettyParams}]'
|
||||
)
|
||||
logger.exception('Error executing scheduled action')
|
||||
else:
|
||||
self.service_pool.log(
|
||||
f'Scheduled action not executed because is not supported: {self.action}'
|
||||
)
|
||||
|
||||
# On save, will regenerate nextExecution
|
||||
if save:
|
||||
self.save()
|
||||
|
||||
if saveServicePool:
|
||||
self.service_pool.save()
|
||||
|
||||
def save(
|
||||
self, force_insert=False, force_update=False, using=None, update_fields=None
|
||||
):
|
||||
def save(self, *args, **kwargs):
|
||||
lastExecution = self.last_execution or getSqlDatetime()
|
||||
possibleNext = calendar.CalendarChecker(self.calendar).nextEvent(
|
||||
checkFrom=lastExecution - self.offset, startEvent=self.at_start
|
||||
@ -484,13 +475,12 @@ class CalendarAction(UUIDModel):
|
||||
else:
|
||||
self.next_execution = None
|
||||
|
||||
super().save(force_insert, force_update, using, update_fields)
|
||||
super().save(*args, **kwargs)
|
||||
|
||||
def __str__(self):
|
||||
return 'Calendar of {}, last_execution = {}, next execution = {}, action = {}, params = {}'.format(
|
||||
self.service_pool.name,
|
||||
self.last_execution,
|
||||
self.next_execution,
|
||||
self.action,
|
||||
self.params,
|
||||
return (
|
||||
f'Calendar of {self.service_pool.name},'
|
||||
f' last_execution = {self.last_execution},'
|
||||
f' next execution = {self.next_execution},'
|
||||
f' action = {self.action}, params = {self.params}'
|
||||
)
|
||||
|
@ -28,12 +28,11 @@
|
||||
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
"""
|
||||
.. moduleauthor:: Adolfo Gómez, dkmaster at dkmon dot com
|
||||
Author: Adolfo Gómez, dkmaster at dkmon dot com
|
||||
"""
|
||||
|
||||
import datetime
|
||||
import logging
|
||||
import hashlib
|
||||
import typing
|
||||
|
||||
from django.db import models
|
||||
@ -97,6 +96,7 @@ weekdays: typing.Tuple[rules.weekday, ...] = (
|
||||
)
|
||||
|
||||
|
||||
# pylint: disable=no-member # For some reason, pylint does not properly detect the ForeignKey, etc..
|
||||
class CalendarRule(UUIDModel):
|
||||
name = models.CharField(max_length=128)
|
||||
comments = models.CharField(max_length=256)
|
||||
@ -114,10 +114,7 @@ class CalendarRule(UUIDModel):
|
||||
Calendar, related_name='rules', on_delete=models.CASCADE
|
||||
)
|
||||
|
||||
# "fake" declarations for type checking
|
||||
# objects: 'models.manager.Manager["CalendarRule"]'
|
||||
|
||||
class Meta:
|
||||
class Meta: # pylint: disable=too-few-public-methods
|
||||
"""
|
||||
Meta class to declare db table
|
||||
"""
|
||||
@ -172,23 +169,14 @@ class CalendarRule(UUIDModel):
|
||||
def duration_as_minutes(self) -> int:
|
||||
return dunit_to_mins.get(self.duration_unit, 1) * self.duration
|
||||
|
||||
def save(
|
||||
self, force_insert=False, force_update=False, using=None, update_fields=None
|
||||
):
|
||||
def save(self, *args, **kwargs):
|
||||
logger.debug('Saving...')
|
||||
self.calendar.modified = getSqlDatetime()
|
||||
|
||||
res = super().save(force_insert, force_update, using, update_fields)
|
||||
res = super().save(*args, **kwargs)
|
||||
# Ensure saves associated calendar, so next execution of actions is updated with rule values
|
||||
self.calendar.save()
|
||||
return res
|
||||
|
||||
def __str__(self):
|
||||
return 'Rule {0}: {1}-{2}, {3}, Interval: {4}, duration: {5}'.format(
|
||||
self.name,
|
||||
self.start,
|
||||
self.end,
|
||||
self.frequency,
|
||||
self.interval,
|
||||
self.duration,
|
||||
)
|
||||
return f'Rule {self.name}: {self.start}-{self.end}, {self.frequency}, Interval: {self.interval}, duration: {self.duration}'
|
||||
|
@ -28,7 +28,7 @@
|
||||
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
"""
|
||||
.. moduleauthor:: Adolfo Gómez, dkmaster at dkmon dot com
|
||||
Author: Adolfo Gómez, dkmaster at dkmon dot com
|
||||
"""
|
||||
import logging
|
||||
|
||||
@ -55,7 +55,7 @@ class Config(models.Model):
|
||||
# "fake" declarations for type checking
|
||||
# objects: 'models.manager.Manager[Config]'
|
||||
|
||||
class Meta:
|
||||
class Meta: # pylint: disable=too-few-public-methods
|
||||
"""
|
||||
Meta class to declare default order and unique multiple field index
|
||||
"""
|
||||
@ -68,4 +68,4 @@ class Config(models.Model):
|
||||
app_label = 'uds'
|
||||
|
||||
def __str__(self) -> str:
|
||||
return "Config {} = {}".format(self.key, self.value)
|
||||
return f'Config {self.key} = {self.value}'
|
||||
|
@ -28,7 +28,7 @@
|
||||
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
"""
|
||||
.. moduleauthor:: Adolfo Gómez, dkmaster at dkmon dot com
|
||||
Author: Adolfo Gómez, dkmaster at dkmon dot com
|
||||
"""
|
||||
import logging
|
||||
|
||||
@ -61,7 +61,7 @@ class DelayedTask(models.Model):
|
||||
# "fake" declarations for type checking
|
||||
# objects: 'models.manager.Manager[DelayedTask]'
|
||||
|
||||
class Meta:
|
||||
class Meta: # pylint: disable=too-few-public-methods
|
||||
"""
|
||||
Meta class to declare default order and unique multiple field index
|
||||
"""
|
||||
@ -69,6 +69,4 @@ class DelayedTask(models.Model):
|
||||
app_label = 'uds'
|
||||
|
||||
def __str__(self) -> str:
|
||||
return "Run Queue task {0} owned by {3},inserted at {1} and with {2} seconds delay".format(
|
||||
self.type, self.insert_date, self.execution_delay, self.execution_time
|
||||
)
|
||||
return f'Run Queue task {self.type} owned by {self.execution_time},inserted at {self.insert_date} and with {self.execution_delay} seconds delay'
|
||||
|
@ -28,7 +28,7 @@
|
||||
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
"""
|
||||
.. moduleauthor:: Adolfo Gómez, dkmaster at dkmon dot com
|
||||
Author: Adolfo Gómez, dkmaster at dkmon dot com
|
||||
"""
|
||||
import logging
|
||||
import typing
|
||||
@ -51,6 +51,7 @@ if typing.TYPE_CHECKING:
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
# pylint: disable=no-member
|
||||
class Group(UUIDModel):
|
||||
"""
|
||||
This class represents a group, associated with one authenticator
|
||||
@ -73,7 +74,7 @@ class Group(UUIDModel):
|
||||
deployedServices: 'models.manager.RelatedManager[ServicePool]'
|
||||
permissions: 'models.manager.RelatedManager[Permissions]'
|
||||
|
||||
class Meta:
|
||||
class Meta: # pylint: disable=too-few-public-methods
|
||||
"""
|
||||
Meta class to declare default order and unique multiple field index
|
||||
"""
|
||||
@ -101,16 +102,12 @@ class Group(UUIDModel):
|
||||
|
||||
def __str__(self) -> str:
|
||||
if self.is_meta:
|
||||
return "Meta group {}(id:{}) with groups {}".format(
|
||||
self.name, self.id, list(self.groups.all())
|
||||
)
|
||||
return f'Meta group {self.name}(id:{self.id}) with groups {list(self.groups.all())}'
|
||||
|
||||
return "Group {}(id:{}) from auth {}".format(
|
||||
self.name, self.id, self.manager.name
|
||||
)
|
||||
return f'Group {self.name}(id:{self.id}) from auth {self.manager.name}'
|
||||
|
||||
@staticmethod
|
||||
def beforeDelete(sender, **kwargs) -> None:
|
||||
def beforeDelete(sender, **kwargs) -> None: # pylint: disable=unused-argument
|
||||
"""
|
||||
Used to invoke the Service class "Destroy" before deleting it from database.
|
||||
|
||||
|
@ -26,7 +26,7 @@
|
||||
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
"""
|
||||
.. moduleauthor:: Adolfo Gómez, dkmaster at dkmon dot com
|
||||
Author: Adolfo Gómez, dkmaster at dkmon dot com
|
||||
"""
|
||||
import io
|
||||
import codecs
|
||||
@ -77,7 +77,7 @@ class Image(UUIDModel):
|
||||
metaPools: 'models.manager.RelatedManager[MetaPool]'
|
||||
servicesPoolsGroup: 'models.manager.RelatedManager[ServicePoolGroup]'
|
||||
|
||||
class Meta:
|
||||
class Meta: # pylint: disable=too-few-public-methods
|
||||
"""
|
||||
Meta class to declare the name of the table at database
|
||||
"""
|
||||
@ -94,13 +94,13 @@ class Image(UUIDModel):
|
||||
return codecs.decode(data64.encode(), 'base64')
|
||||
|
||||
@staticmethod
|
||||
def resizeAndConvert(image: PIL.Image.Image, size: typing.Tuple[int, int]) -> typing.Tuple[int, int, bytes]:
|
||||
def resizeAndConvert(
|
||||
image: PIL.Image.Image, size: typing.Tuple[int, int]
|
||||
) -> typing.Tuple[int, int, bytes]:
|
||||
"""
|
||||
Resizes an image to the given size
|
||||
"""
|
||||
image.thumbnail(
|
||||
size=Image.MAX_IMAGE_SIZE, resample=PIL.Image.LANCZOS, reducing_gap=3.0
|
||||
)
|
||||
image.thumbnail(size=size, resample=PIL.Image.LANCZOS, reducing_gap=3.0)
|
||||
output = io.BytesIO()
|
||||
image.save(output, 'png')
|
||||
return (image.width, image.height, output.getvalue())
|
||||
@ -110,7 +110,9 @@ class Image(UUIDModel):
|
||||
try:
|
||||
stream = io.BytesIO(data)
|
||||
image = PIL.Image.open(stream)
|
||||
except Exception: # Image data is incorrect, replace as a simple transparent image
|
||||
except (
|
||||
Exception
|
||||
): # Image data is incorrect, replace as a simple transparent image
|
||||
image = PIL.Image.new('RGBA', (128, 128))
|
||||
|
||||
# Max image size, keeping aspect and using antialias
|
||||
@ -187,13 +189,9 @@ class Image(UUIDModel):
|
||||
def thumbnailResponse(self) -> HttpResponse:
|
||||
return HttpResponse(self.thumb, content_type='image/png')
|
||||
|
||||
def save(
|
||||
self, force_insert=False, force_update=False, using=None, update_fields=None
|
||||
):
|
||||
def save(self, *args, **kwargs):
|
||||
self.stamp = getSqlDatetime()
|
||||
return super().save(force_insert, force_update, using, update_fields)
|
||||
return super().save(*args, **kwargs)
|
||||
|
||||
def __str__(self):
|
||||
return 'Image id: {}, name: {}, size: {}, length: {} bytes, thumb length: {} bytes'.format(
|
||||
self.id, self.name, self.size, len(self.data), len(self.thumb)
|
||||
)
|
||||
return f'Image Id: {self.id}, Name: {self.name}, Size: {self.size}, Length: {len(self.data)} bytes, Thumb length: {len(self.thumb)} bytes'
|
||||
|
@ -28,7 +28,7 @@
|
||||
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
"""
|
||||
.. moduleauthor:: Adolfo Gómez, dkmaster at dkmon dot com
|
||||
Author: Adolfo Gómez, dkmaster at dkmon dot com
|
||||
"""
|
||||
import logging
|
||||
|
||||
@ -65,7 +65,7 @@ class Log(models.Model):
|
||||
# "fake" declarations for type checking
|
||||
# objects: 'models.manager.Manager[Log]'
|
||||
|
||||
class Meta:
|
||||
class Meta: # pylint: disable=too-few-public-methods
|
||||
"""
|
||||
Meta class to declare db table
|
||||
"""
|
||||
@ -78,11 +78,7 @@ class Log(models.Model):
|
||||
return logStrFromLevel(self.level)
|
||||
|
||||
def __str__(self) -> str:
|
||||
return "Log of {}({}): {} - {} - {} - {}".format(
|
||||
self.owner_type,
|
||||
self.owner_id,
|
||||
self.created,
|
||||
self.source,
|
||||
self.level,
|
||||
self.data,
|
||||
return (
|
||||
f'Log of {self.owner_type}({self.owner_id}):'
|
||||
f' {self.created} - {self.source} - {self.level} - {self.data}'
|
||||
)
|
||||
|
@ -1,7 +1,7 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
#
|
||||
# Copyright (c) 2012-2020 Virtual Cable S.L.U.
|
||||
# Copyright (c) 2012-2023 Virtual Cable S.L.U.
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without modification,
|
||||
@ -28,7 +28,7 @@
|
||||
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
"""
|
||||
.. moduleauthor:: Adolfo Gómez, dkmaster at dkmon dot com
|
||||
Author: Adolfo Gómez, dkmaster at dkmon dot com
|
||||
"""
|
||||
import logging
|
||||
import typing
|
||||
@ -57,7 +57,7 @@ class ManagedObjectModel(UUIDModel):
|
||||
|
||||
_cachedInstance: typing.Optional[Module] = None
|
||||
|
||||
class Meta(UUIDModel.Meta):
|
||||
class Meta(UUIDModel.Meta): # pylint: disable=too-few-public-methods
|
||||
"""
|
||||
Defines this is an abstract class
|
||||
"""
|
||||
@ -68,7 +68,7 @@ class ManagedObjectModel(UUIDModel):
|
||||
"""
|
||||
Returns an environment valid for the record this object represents
|
||||
"""
|
||||
return Environment.getEnvForTableElement(self._meta.verbose_name, self.id) # type: ignore
|
||||
return Environment.getEnvForTableElement(self._meta.verbose_name, self.id) # type: ignore # pylint: disable=no-member
|
||||
|
||||
def deserialize(
|
||||
self, obj: Module, values: typing.Optional[typing.Mapping[str, str]]
|
||||
@ -119,7 +119,7 @@ class ManagedObjectModel(UUIDModel):
|
||||
Must be overriden!!!
|
||||
"""
|
||||
raise NotImplementedError(
|
||||
'getType has not been implemented for {}'.format(self.__class__)
|
||||
f'getType has not been implemented for {self.__class__.__name__}'
|
||||
)
|
||||
|
||||
def isOfType(self, type_: str) -> bool:
|
||||
|
@ -1,7 +1,7 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
#
|
||||
# Copyright (c) 2018-2020 Virtual Cable S.L.U.
|
||||
# Copyright (c) 2018-2023 Virtual Cable S.L.U.
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without modification,
|
||||
@ -28,7 +28,7 @@
|
||||
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
"""
|
||||
.. moduleauthor:: Adolfo Gómez, dkmaster at dkmon dot com
|
||||
Author: Adolfo Gómez, dkmaster at dkmon dot com
|
||||
"""
|
||||
import logging
|
||||
import operator
|
||||
@ -133,7 +133,7 @@ class MetaPool(UUIDModel, TaggingMixin): # type: ignore
|
||||
calendarAccess: 'models.QuerySet[CalendarAccessMeta]'
|
||||
members: 'models.QuerySet["MetaPoolMember"]'
|
||||
|
||||
class Meta(UUIDModel.Meta):
|
||||
class Meta(UUIDModel.Meta): # pylint: disable=too-few-public-methods
|
||||
"""
|
||||
Meta class to declare the name of the table at database
|
||||
"""
|
||||
@ -196,9 +196,8 @@ class MetaPool(UUIDModel, TaggingMixin): # type: ignore
|
||||
logger.debug(
|
||||
'SHORT: %s %s %s', self.short_name, self.short_name is not None, self.name
|
||||
)
|
||||
if self.short_name.strip():
|
||||
return self.short_name
|
||||
return self.name
|
||||
sn = str(self.short_name).strip()
|
||||
return sn if sn else self.name
|
||||
|
||||
@staticmethod
|
||||
def getForGroups(
|
||||
@ -245,12 +244,11 @@ class MetaPool(UUIDModel, TaggingMixin): # type: ignore
|
||||
),
|
||||
)
|
||||
)
|
||||
# TODO: May we can include some other filters?
|
||||
|
||||
# May we can include some other filters?
|
||||
return meta
|
||||
|
||||
@staticmethod
|
||||
def beforeDelete(sender, **kwargs):
|
||||
def beforeDelete(sender, **kwargs): # pylint: disable=unused-argument
|
||||
"""
|
||||
Used to invoke the Service class "Destroy" before deleting it from database.
|
||||
|
||||
@ -259,7 +257,7 @@ class MetaPool(UUIDModel, TaggingMixin): # type: ignore
|
||||
|
||||
:note: If destroy raises an exception, the deletion is not taken.
|
||||
"""
|
||||
from uds.core.util.permissions import clean
|
||||
from uds.core.util.permissions import clean # pylint: disable=import-outside-toplevel
|
||||
|
||||
toDelete = kwargs['instance']
|
||||
|
||||
@ -270,9 +268,7 @@ class MetaPool(UUIDModel, TaggingMixin): # type: ignore
|
||||
clean(toDelete)
|
||||
|
||||
def __str__(self):
|
||||
return 'Meta pool: {}, no. pools: {}, visible: {}, policy: {}'.format(
|
||||
self.name, self.members.all().count(), self.visible, self.policy
|
||||
)
|
||||
return f'Meta pool: {self.name}, no. pools: {self.members.all().count()}, visible: {self.visible}, policy: {self.policy}'
|
||||
|
||||
|
||||
# Connects a pre deletion signal
|
||||
@ -289,7 +285,7 @@ class MetaPoolMember(UUIDModel):
|
||||
priority = models.PositiveIntegerField(default=0)
|
||||
enabled = models.BooleanField(default=True)
|
||||
|
||||
class Meta(UUIDModel.Meta):
|
||||
class Meta(UUIDModel.Meta): # pylint: disable=too-few-public-methods
|
||||
"""
|
||||
Meta class to declare the name of the table at database
|
||||
"""
|
||||
@ -298,6 +294,4 @@ class MetaPoolMember(UUIDModel):
|
||||
app_label = 'uds'
|
||||
|
||||
def __str__(self) -> str:
|
||||
return '{}/{} {} {}'.format(
|
||||
self.pool.name, self.meta_pool.name, self.priority, self.enabled
|
||||
)
|
||||
return f'Meta pool member: {self.pool.name}/{self.meta_pool.name}, priority: {self.priority}, enabled: {self.enabled}'
|
||||
|
@ -1,7 +1,7 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
#
|
||||
# Copyright (c) 2012-2022 Virtual Cable S.L.U.
|
||||
# Copyright (c) 2012-2023 Virtual Cable S.L.U.
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without modification,
|
||||
@ -28,7 +28,7 @@
|
||||
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
"""
|
||||
.. moduleauthor:: Adolfo Gómez, dkmaster at dkmon dot com
|
||||
Author: Adolfo Gómez, dkmaster at dkmon dot com
|
||||
"""
|
||||
import logging
|
||||
import typing
|
||||
@ -77,15 +77,15 @@ class MFA(ManagedObjectModel, TaggingMixin): # type: ignore
|
||||
We only need to get info from this, not access specific data (class specific info)
|
||||
"""
|
||||
# We only need to get info from this, not access specific data (class specific info)
|
||||
from uds.core import mfas
|
||||
from uds.core import mfas # pylint: disable=import-outside-toplevel
|
||||
|
||||
return mfas.factory().lookup(self.data_type) or mfas.MFA
|
||||
|
||||
def __str__(self) -> str:
|
||||
return "{0} of type {1} (id:{2})".format(self.name, self.data_type, self.id)
|
||||
return f'MFA {self.name} of type {self.data_type} (id:{self.id})'
|
||||
|
||||
@staticmethod
|
||||
def beforeDelete(sender, **kwargs) -> None:
|
||||
def beforeDelete(sender, **kwargs) -> None: # pylint: disable=unused-argument
|
||||
"""
|
||||
Used to invoke the Service class "Destroy" before deleting it from database.
|
||||
|
||||
|
@ -28,7 +28,7 @@
|
||||
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
"""
|
||||
.. moduleauthor:: Adolfo Gómez, dkmaster at dkmon dot com
|
||||
Author: Adolfo Gómez, dkmaster at dkmon dot com
|
||||
"""
|
||||
import logging
|
||||
import typing
|
||||
@ -72,7 +72,7 @@ class Network(UUIDModel, TaggingMixin): # type: ignore
|
||||
# "fake" declarations for type checking
|
||||
# objects: 'models.manager.Manager[Network]'
|
||||
|
||||
class Meta(UUIDModel.Meta):
|
||||
class Meta(UUIDModel.Meta): # pylint: disable=too-few-public-methods
|
||||
"""
|
||||
Meta class to declare default order
|
||||
"""
|
||||
@ -81,14 +81,15 @@ class Network(UUIDModel, TaggingMixin): # type: ignore
|
||||
app_label = 'uds'
|
||||
|
||||
@staticmethod
|
||||
def _hexlify(number: int) -> str:
|
||||
def hexlify(number: int) -> str:
|
||||
"""
|
||||
Converts a number to hex, but with 32 chars, and with leading zeros
|
||||
"""
|
||||
return '{:032x}'.format(number)
|
||||
# return f'{number:032x}'
|
||||
return hex(number)[2:].zfill(32)
|
||||
|
||||
@staticmethod
|
||||
def _unhexlify(number: str) -> int:
|
||||
def unhexlify(number: str) -> int:
|
||||
"""
|
||||
Converts a hex string to a number
|
||||
"""
|
||||
@ -100,7 +101,7 @@ class Network(UUIDModel, TaggingMixin): # type: ignore
|
||||
Returns the networks that are valid for specified ip in dotted quad (xxx.xxx.xxx.xxx)
|
||||
"""
|
||||
ipInt, version = net.ipToLong(ip)
|
||||
hex_value = Network._hexlify(ipInt)
|
||||
hex_value = Network.hexlify(ipInt)
|
||||
# hexlify is used to convert to hex, and then decode to convert to string
|
||||
return Network.objects.filter(
|
||||
version=version,
|
||||
@ -127,8 +128,8 @@ class Network(UUIDModel, TaggingMixin): # type: ignore
|
||||
nr = net.networkFromString(netRange)
|
||||
return Network.objects.create(
|
||||
name=name,
|
||||
start=Network._hexlify(nr.start),
|
||||
end=Network._hexlify(nr.end),
|
||||
start=Network.hexlify(nr.start),
|
||||
end=Network.hexlify(nr.end),
|
||||
net_string=netRange,
|
||||
version=nr.version,
|
||||
)
|
||||
@ -138,31 +139,31 @@ class Network(UUIDModel, TaggingMixin): # type: ignore
|
||||
"""
|
||||
Returns the network start as an integer
|
||||
"""
|
||||
return Network._unhexlify(self.start)
|
||||
return Network.unhexlify(self.start)
|
||||
|
||||
@net_start.setter
|
||||
def net_start(self, value: int) -> None:
|
||||
"""
|
||||
Sets the network start
|
||||
"""
|
||||
self.start = Network._hexlify(value)
|
||||
self.start = Network.hexlify(value)
|
||||
|
||||
@property
|
||||
def net_end(self) -> int:
|
||||
"""
|
||||
Returns the network end as an integer
|
||||
"""
|
||||
return Network._unhexlify(self.end)
|
||||
return Network.unhexlify(self.end)
|
||||
|
||||
@net_end.setter
|
||||
def net_end(self, value: int) -> None:
|
||||
"""
|
||||
Sets the network end
|
||||
"""
|
||||
self.end = Network._hexlify(value)
|
||||
self.end = Network.hexlify(value)
|
||||
|
||||
@property
|
||||
def netStart(self) -> str:
|
||||
def str_net_start(self) -> str:
|
||||
"""
|
||||
Property to access the quad dotted format of the stored network start
|
||||
|
||||
@ -172,7 +173,7 @@ class Network(UUIDModel, TaggingMixin): # type: ignore
|
||||
return net.longToIp(self.net_start)
|
||||
|
||||
@property
|
||||
def netEnd(self) -> str:
|
||||
def str_net_end(self) -> str:
|
||||
"""
|
||||
Property to access the quad dotted format of the stored network end
|
||||
|
||||
@ -198,23 +199,17 @@ class Network(UUIDModel, TaggingMixin): # type: ignore
|
||||
Overrides save to update the start, end and version fields
|
||||
"""
|
||||
rng = net.networkFromString(self.net_string)
|
||||
self.start = Network._hexlify(rng.start)
|
||||
self.end = Network._hexlify(rng.end)
|
||||
self.start = Network.hexlify(rng.start)
|
||||
self.end = Network.hexlify(rng.end)
|
||||
self.version = rng.version
|
||||
super().save(*args, **kwargs)
|
||||
|
||||
def __str__(self) -> str:
|
||||
return u'Network {} ({}) from {} to {} ({})'.format(
|
||||
self.name,
|
||||
self.net_string,
|
||||
net.longToIp(self.net_start),
|
||||
net.longToIp(self.net_end),
|
||||
self.version,
|
||||
)
|
||||
return f'Network {self.name} ({self.net_string}) from {self.str_net_start} to {self.str_net_end} ({self.version})'
|
||||
|
||||
@staticmethod
|
||||
def beforeDelete(sender, **kwargs) -> None:
|
||||
from uds.core.util.permissions import clean
|
||||
def beforeDelete(sender, **kwargs) -> None: # pylint: disable=unused-argument
|
||||
from uds.core.util.permissions import clean # pylint: disable=import-outside-toplevel
|
||||
|
||||
toDelete = kwargs['instance']
|
||||
|
||||
|
@ -26,14 +26,13 @@
|
||||
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
"""
|
||||
.. moduleauthor:: Adolfo Gómez, dkmaster at dkmon dot com
|
||||
Author: Adolfo Gómez, dkmaster at dkmon dot com
|
||||
"""
|
||||
from enum import IntEnum
|
||||
import logging
|
||||
import typing
|
||||
|
||||
from django.db import models, transaction
|
||||
from django.utils.translation import gettext as _
|
||||
|
||||
|
||||
from .managed_object_model import ManagedObjectModel
|
||||
@ -44,20 +43,22 @@ logger = logging.getLogger(__name__)
|
||||
if typing.TYPE_CHECKING:
|
||||
from uds.core.messaging import Notifier as NotificationProviderModule
|
||||
|
||||
|
||||
class NotificationLevel(IntEnum):
|
||||
"""
|
||||
Notification Levels
|
||||
"""
|
||||
|
||||
INFO = 0
|
||||
WARNING = 1
|
||||
ERROR = 2
|
||||
CRITICAL = 3
|
||||
|
||||
# Return all notification levels as tuples of (level value, level name)
|
||||
@classmethod
|
||||
def all(cls):
|
||||
return [(level.value, level.name) for level in (cls.INFO, cls.WARNING, cls.ERROR, cls.CRITICAL)]
|
||||
|
||||
@staticmethod
|
||||
def all() -> typing.List[typing.Tuple[int, str]]:
|
||||
return [(level.value, level.name) for level in NotificationLevel]
|
||||
|
||||
|
||||
# This model will be available on local "persistent" storage and also on configured database
|
||||
class Notification(models.Model):
|
||||
@ -75,7 +76,7 @@ class Notification(models.Model):
|
||||
# "fake" declarations for type checking
|
||||
# objects: 'models.BaseManager[Notification]'
|
||||
|
||||
class Meta:
|
||||
class Meta: # pylint: disable=too-few-public-methods
|
||||
"""
|
||||
Meta class to declare db table
|
||||
"""
|
||||
@ -107,7 +108,7 @@ class Notifier(ManagedObjectModel, TaggingMixin):
|
||||
# "fake" declarations for type checking
|
||||
objects: 'models.manager.Manager[Notifier]'
|
||||
|
||||
class Meta:
|
||||
class Meta: # pylint: disable=too-few-public-methods
|
||||
"""
|
||||
Meta class to declare db table
|
||||
"""
|
||||
@ -124,21 +125,22 @@ class Notifier(ManagedObjectModel, TaggingMixin):
|
||||
Returns:
|
||||
The python type for this record object
|
||||
"""
|
||||
from uds.core import messaging # pylint: disable=redefined-outer-name
|
||||
from uds.core import messaging # pylint: disable=import-outside-toplevel
|
||||
|
||||
kind_ = messaging.factory().lookup(self.data_type)
|
||||
if kind_ is None:
|
||||
raise Exception('Notifier type not found: {0}'.format(self.data_type))
|
||||
return kind_
|
||||
kind = messaging.factory().lookup(self.data_type)
|
||||
if kind is None:
|
||||
raise Exception(f'Notifier type not found: {self.data_type}')
|
||||
return kind
|
||||
|
||||
def getInstance(
|
||||
self, values: typing.Optional[typing.Dict[str, str]] = None
|
||||
) -> 'NotificationProviderModule':
|
||||
return typing.cast('NotificationProviderModule', super().getInstance(values=values))
|
||||
|
||||
return typing.cast(
|
||||
'NotificationProviderModule', super().getInstance(values=values)
|
||||
)
|
||||
|
||||
@staticmethod
|
||||
def beforeDelete(sender, **kwargs) -> None:
|
||||
def beforeDelete(sender, **kwargs) -> None: # pylint: disable=unused-argument
|
||||
"""
|
||||
Used to invoke the Service class "Destroy" before deleting it from database.
|
||||
|
||||
@ -155,7 +157,11 @@ class Notifier(ManagedObjectModel, TaggingMixin):
|
||||
s.destroy()
|
||||
s.env.clearRelatedData()
|
||||
except Exception as e:
|
||||
logger.error('Error processing deletion of notifier %s: %s (forced deletion)', toDelete.name, e)
|
||||
logger.error(
|
||||
'Error processing deletion of notifier %s: %s (forced deletion)',
|
||||
toDelete.name,
|
||||
e,
|
||||
)
|
||||
|
||||
logger.debug('Before delete mfa provider %s', toDelete)
|
||||
|
||||
|
@ -28,7 +28,7 @@
|
||||
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
"""
|
||||
.. moduleauthor:: Adolfo Gómez, dkmaster at dkmon dot com
|
||||
Author: Adolfo Gómez, dkmaster at dkmon dot com
|
||||
"""
|
||||
import logging
|
||||
import typing
|
||||
|
@ -28,7 +28,7 @@
|
||||
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
"""
|
||||
.. moduleauthor:: Adolfo Gómez, dkmaster at dkmon dot com
|
||||
Author: Adolfo Gómez, dkmaster at dkmon dot com
|
||||
"""
|
||||
import typing
|
||||
import enum
|
||||
|
@ -28,7 +28,7 @@
|
||||
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
"""
|
||||
.. moduleauthor:: Adolfo Gómez, dkmaster at dkmon dot com
|
||||
Author: Adolfo Gómez, dkmaster at dkmon dot com
|
||||
"""
|
||||
import logging
|
||||
import typing
|
||||
|
@ -28,7 +28,7 @@
|
||||
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
"""
|
||||
.. moduleauthor:: Adolfo Gómez, dkmaster at dkmon dot com
|
||||
Author: Adolfo Gómez, dkmaster at dkmon dot com
|
||||
"""
|
||||
import logging
|
||||
import typing
|
||||
|
@ -28,7 +28,7 @@
|
||||
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
"""
|
||||
.. moduleauthor:: Adolfo Gómez, dkmaster at dkmon dot com
|
||||
Author: Adolfo Gómez, dkmaster at dkmon dot com
|
||||
"""
|
||||
import logging
|
||||
import typing
|
||||
|
@ -28,7 +28,7 @@
|
||||
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
"""
|
||||
.. moduleauthor:: Adolfo Gómez, dkmaster at dkmon dot com
|
||||
Author: Adolfo Gómez, dkmaster at dkmon dot com
|
||||
"""
|
||||
import typing
|
||||
import logging
|
||||
|
@ -28,7 +28,7 @@
|
||||
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
"""
|
||||
.. moduleauthor:: Adolfo Gómez, dkmaster at dkmon dot com
|
||||
Author: Adolfo Gómez, dkmaster at dkmon dot com
|
||||
"""
|
||||
import logging
|
||||
import typing
|
||||
|
@ -28,7 +28,7 @@
|
||||
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
"""
|
||||
.. moduleauthor:: Adolfo Gómez, dkmaster at dkmon dot com
|
||||
Author: Adolfo Gómez, dkmaster at dkmon dot com
|
||||
"""
|
||||
|
||||
import logging
|
||||
|
@ -28,7 +28,7 @@
|
||||
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
"""
|
||||
.. moduleauthor:: Adolfo Gómez, dkmaster at dkmon dot com
|
||||
Author: Adolfo Gómez, dkmaster at dkmon dot com
|
||||
"""
|
||||
import typing
|
||||
import datetime
|
||||
|
@ -28,7 +28,7 @@
|
||||
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
"""
|
||||
.. moduleauthor:: Adolfo Gómez, dkmaster at dkmon dot com
|
||||
Author: Adolfo Gómez, dkmaster at dkmon dot com
|
||||
"""
|
||||
import typing
|
||||
import enum
|
||||
|
@ -28,7 +28,7 @@
|
||||
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
"""
|
||||
.. moduleauthor:: Adolfo Gómez, dkmaster at dkmon dot com
|
||||
Author: Adolfo Gómez, dkmaster at dkmon dot com
|
||||
"""
|
||||
import datetime
|
||||
import logging
|
||||
|
@ -28,7 +28,7 @@
|
||||
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
"""
|
||||
.. moduleauthor:: Adolfo Gómez, dkmaster at dkmon dot com
|
||||
Author: Adolfo Gómez, dkmaster at dkmon dot com
|
||||
"""
|
||||
import logging
|
||||
|
||||
|
@ -28,7 +28,7 @@
|
||||
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
"""
|
||||
.. moduleauthor:: Adolfo Gómez, dkmaster at dkmon dot com
|
||||
Author: Adolfo Gómez, dkmaster at dkmon dot com
|
||||
"""
|
||||
import typing
|
||||
import logging
|
||||
|
@ -26,7 +26,7 @@
|
||||
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
'''
|
||||
.. moduleauthor:: Adolfo Gómez, dkmaster at dkmon dot com
|
||||
Author: Adolfo Gómez, dkmaster at dkmon dot com
|
||||
'''
|
||||
import datetime
|
||||
import pickle # nosec: Tickets are generated by us, so we know they are safe
|
||||
|
@ -28,7 +28,7 @@
|
||||
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
"""
|
||||
.. moduleauthor:: Adolfo Gómez, dkmaster at dkmon dot com
|
||||
Author: Adolfo Gómez, dkmaster at dkmon dot com
|
||||
"""
|
||||
import logging
|
||||
import typing
|
||||
|
@ -26,7 +26,7 @@
|
||||
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
'''
|
||||
.. moduleauthor:: Adolfo Gómez, dkmaster at dkmon dot com
|
||||
Author: Adolfo Gómez, dkmaster at dkmon dot com
|
||||
'''
|
||||
import typing
|
||||
|
||||
|
@ -28,7 +28,7 @@
|
||||
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
"""
|
||||
.. moduleauthor:: Adolfo Gómez, dkmaster at dkmon dot com
|
||||
Author: Adolfo Gómez, dkmaster at dkmon dot com
|
||||
"""
|
||||
import logging
|
||||
|
||||
|
@ -28,7 +28,7 @@
|
||||
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
"""
|
||||
.. moduleauthor:: Adolfo Gómez, dkmaster at dkmon dot com
|
||||
Author: Adolfo Gómez, dkmaster at dkmon dot com
|
||||
"""
|
||||
import logging
|
||||
import typing
|
||||
|
@ -28,7 +28,7 @@
|
||||
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
"""
|
||||
.. moduleauthor:: Adolfo Gómez, dkmaster at dkmon dot com
|
||||
Author: Adolfo Gómez, dkmaster at dkmon dot com
|
||||
"""
|
||||
import logging
|
||||
import typing
|
||||
|
@ -28,7 +28,7 @@
|
||||
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
"""
|
||||
.. moduleauthor:: Adolfo Gómez, dkmaster at dkmon dot com
|
||||
Author: Adolfo Gómez, dkmaster at dkmon dot com
|
||||
"""
|
||||
import logging
|
||||
|
||||
|
@ -28,7 +28,7 @@
|
||||
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
"""
|
||||
.. moduleauthor:: Adolfo Gómez, dkmaster at dkmon dot com
|
||||
Author: Adolfo Gómez, dkmaster at dkmon dot com
|
||||
"""
|
||||
import logging
|
||||
|
||||
|
@ -28,7 +28,7 @@
|
||||
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
"""
|
||||
.. moduleauthor:: Adolfo Gómez, dkmaster at dkmon dot com
|
||||
Author: Adolfo Gómez, dkmaster at dkmon dot com
|
||||
"""
|
||||
import logging
|
||||
import typing
|
||||
@ -55,7 +55,7 @@ class UnsavedForeignKey(models.ForeignKey):
|
||||
"""
|
||||
|
||||
# Allows pointing to an unsaved object
|
||||
allow_unsaved_instance_assignment = True
|
||||
# allow_unsaved_instance_assignment = True
|
||||
|
||||
|
||||
def getSqlDatetime() -> datetime:
|
||||
|
@ -28,7 +28,7 @@
|
||||
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
"""
|
||||
.. moduleauthor:: Adolfo Gómez, dkmaster at dkmon dot com
|
||||
Author: Adolfo Gómez, dkmaster at dkmon dot com
|
||||
"""
|
||||
import logging
|
||||
|
||||
@ -51,7 +51,7 @@ class UUIDModel(models.Model):
|
||||
# Just a fake declaration to allow type checking
|
||||
id: int
|
||||
|
||||
class Meta:
|
||||
class Meta: # pylint: disable=too-few-public-methods
|
||||
abstract = True
|
||||
|
||||
def genUuid(self) -> str:
|
||||
|
@ -39,7 +39,7 @@ To create a new notifier module, you will need to follow this steps:
|
||||
|
||||
The registration of modules is done locating subclases of :py:class:`uds.core.messaging.Notifier`
|
||||
|
||||
.. moduleauthor:: Adolfo Gómez, dkmaster at dkmon dot com
|
||||
Author: Adolfo Gómez, dkmaster at dkmon dot com
|
||||
"""
|
||||
import logging
|
||||
|
||||
|
@ -28,7 +28,7 @@
|
||||
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
"""
|
||||
.. moduleauthor:: Adolfo Gómez, dkmaster at dkmon dot com
|
||||
Author: Adolfo Gómez, dkmaster at dkmon dot com
|
||||
"""
|
||||
import logging
|
||||
import smtplib
|
||||
|
@ -38,7 +38,7 @@ To create a new OS manager module, you will need to follow this steps:
|
||||
|
||||
The registration of modules is done locating subclases of :py:class:`uds.core.auths.Authentication`
|
||||
|
||||
.. moduleauthor:: Adolfo Gómez, dkmaster at dkmon dot com
|
||||
Author: Adolfo Gómez, dkmaster at dkmon dot com
|
||||
"""
|
||||
from uds.core.util import modfinder
|
||||
|
||||
|
@ -36,7 +36,7 @@ To create a new rwpoer module, you will need to follow this steps:
|
||||
|
||||
The registration of modules is done locating subclases of :py:class:`uds.core.reports.Report`
|
||||
|
||||
.. moduleauthor:: Adolfo Gómez, dkmaster at dkmon dot com
|
||||
Author: Adolfo Gómez, dkmaster at dkmon dot com
|
||||
"""
|
||||
import logging
|
||||
import typing
|
||||
|
@ -28,7 +28,7 @@
|
||||
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
"""
|
||||
.. moduleauthor:: Adolfo Gómez, dkmaster at dkmon dot com
|
||||
Author: Adolfo Gómez, dkmaster at dkmon dot com
|
||||
"""
|
||||
import datetime
|
||||
import logging
|
||||
|
@ -28,7 +28,7 @@
|
||||
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
"""
|
||||
.. moduleauthor:: Adolfo Gómez, dkmaster at dkmon dot com
|
||||
Author: Adolfo Gómez, dkmaster at dkmon dot com
|
||||
"""
|
||||
import datetime
|
||||
import logging
|
||||
|
@ -28,7 +28,7 @@
|
||||
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
"""
|
||||
.. moduleauthor:: Adolfo Gómez, dkmaster at dkmon dot com
|
||||
Author: Adolfo Gómez, dkmaster at dkmon dot com
|
||||
"""
|
||||
import typing
|
||||
|
||||
|
@ -28,7 +28,7 @@
|
||||
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
"""
|
||||
.. moduleauthor:: Adolfo Gómez, dkmaster at dkmon dot com
|
||||
Author: Adolfo Gómez, dkmaster at dkmon dot com
|
||||
"""
|
||||
import io
|
||||
import csv
|
||||
|
@ -27,7 +27,7 @@
|
||||
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
"""
|
||||
.. moduleauthor:: Adolfo Gómez, dkmaster at dkmon dot com
|
||||
Author: Adolfo Gómez, dkmaster at dkmon dot com
|
||||
"""
|
||||
import logging
|
||||
import typing
|
||||
|
@ -28,7 +28,7 @@
|
||||
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
"""
|
||||
.. moduleauthor:: Adolfo Gómez, dkmaster at dkmon dot com
|
||||
Author: Adolfo Gómez, dkmaster at dkmon dot com
|
||||
"""
|
||||
import typing
|
||||
|
||||
|
@ -27,7 +27,7 @@
|
||||
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
"""
|
||||
.. moduleauthor:: Adolfo Gómez, dkmaster at dkmon dot com
|
||||
Author: Adolfo Gómez, dkmaster at dkmon dot com
|
||||
"""
|
||||
import io
|
||||
import csv
|
||||
|
@ -28,7 +28,7 @@
|
||||
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
"""
|
||||
.. moduleauthor:: Adolfo Gómez, dkmaster at dkmon dot com
|
||||
Author: Adolfo Gómez, dkmaster at dkmon dot com
|
||||
"""
|
||||
import io
|
||||
import csv
|
||||
|
@ -27,7 +27,7 @@
|
||||
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
"""
|
||||
.. moduleauthor:: Adolfo Gómez, dkmaster at dkmon dot com
|
||||
Author: Adolfo Gómez, dkmaster at dkmon dot com
|
||||
"""
|
||||
import csv
|
||||
import io
|
||||
|
@ -27,7 +27,7 @@
|
||||
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
"""
|
||||
.. moduleauthor:: Adolfo Gómez, dkmaster at dkmon dot com
|
||||
Author: Adolfo Gómez, dkmaster at dkmon dot com
|
||||
"""
|
||||
import io
|
||||
import csv
|
||||
|
@ -27,7 +27,7 @@
|
||||
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
"""
|
||||
.. moduleauthor:: Adolfo Gómez, dkmaster at dkmon dot com
|
||||
Author: Adolfo Gómez, dkmaster at dkmon dot com
|
||||
"""
|
||||
|
||||
""" from django.utils.translation import gettext_noop as _
|
||||
|
@ -27,7 +27,7 @@
|
||||
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
"""
|
||||
.. moduleauthor:: Adolfo Gómez, dkmaster at dkmon dot com
|
||||
Author: Adolfo Gómez, dkmaster at dkmon dot com
|
||||
"""
|
||||
import io
|
||||
import csv
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user