Removed useless Super() inits in the constructor in services. (0.21.7)

This commit is contained in:
Johannes Findeisen 2023-08-20 05:36:39 +02:00
commit ea95f1d990
14 changed files with 25 additions and 85 deletions

View file

@ -18,7 +18,7 @@ from linspector.environment import Environment
from linspector.linspector import Linspector
from linspector.monitors import Monitors
__version__ = '0.21.6'
__version__ = '0.21.7'
__author__ = 'Johannes Findeisen <you@hanez.org>'

View file

@ -7,6 +7,6 @@ See LICENSE (MIT license).
class Service:
def __init__(self, configuration, environment, log):
self.__configuration = configuration
self.__environment = environment
self.__log = log
self._configuration = configuration
self._environment = environment
self._log = log

View file

@ -14,11 +14,6 @@ def create(configuration, environment, log):
# let's say all below 4** are no errors and others are an error. Or maybe define ranges, or just
# maybe the status code that produces an error.
class HTTPConnectService(Service):
def __init__(self, configuration, environment, log):
super().__init__(configuration, environment, log)
self.__configuration = configuration
self.__environment = environment
self.__log = log
def execute(self, **kwargs):
return

View file

@ -12,11 +12,6 @@ def create(configuration, environment, log):
# Get a true or false when a keyword is found in a http request.
class HTTPKeywordService(Service):
def __init__(self, configuration, environment, log):
super().__init__(configuration, environment, log)
self.__configuration = configuration
self.__environment = environment
self.__log = log
def execute(self, **kwargs):
return

View file

@ -15,15 +15,10 @@ class DummyService(Service):
This is a dummy service which is doing nothing but logging. It will be used if some other
service fails at load / configuration, or it can be used for testing.
"""
def __init__(self, configuration, environment, log):
super().__init__(configuration, environment, log)
self.__configuration = configuration
self.__environment = environment
self.__log = log
def execute(self, identifier, monitor, service, **kwargs):
self.__log.info('identifier=' + identifier +
' host=' + monitor.get_host() +
' service=' + service +
' status=' + 'OK')
self._log.info('identifier=' + identifier +
' host=' + monitor.get_host() +
' service=' + service +
' status=' + 'OK')
return True

View file

@ -17,11 +17,6 @@ class RandomService(Service):
"""
This is a service that produces random data and status results. It is only used for testing.
"""
def __init__(self, configuration, environment, log):
super().__init__(configuration, environment, log)
self.__configuration = configuration
self.__environment = environment
self.__log = log
def execute(self, identifier, monitor, service, **kwargs):
status = random.randint(0, 1)
@ -39,9 +34,9 @@ class RandomService(Service):
sha512 = hashlib.sha512(str((str(rnd1) + str(rnd2) + str(rnd3) + str(rnd4) +
str(rnd5) + str(rnd6) + str(rnd7) + str(rnd8) + str(sha256))).
encode('utf-8')).hexdigest()
self.__log.info('identifier=' + identifier +
' host=' + monitor.get_host() +
' service=' + service +
' status=' + ('OK' if status == 0 else 'ERROR') + ' message=' +
sha512)
self._log.info('identifier=' + identifier +
' host=' + monitor.get_host() +
' service=' + service +
' status=' + ('OK' if status == 0 else 'ERROR') + ' message=' +
sha512)
return True

View file

@ -11,11 +11,6 @@ def create(configuration, environment, log):
class PingService(Service):
def __init__(self, configuration, environment, log):
super().__init__(configuration, environment, log)
self.__configuration = configuration
self.__environment = environment
self.__log = log
def execute(self, **kwargs):
return

View file

@ -13,11 +13,6 @@ def create(configuration, environment, log):
class PortService(Service):
def __init__(self, configuration, environment, log):
super().__init__(configuration, environment, log)
self.__configuration = configuration
self.__environment = environment
self.__log = log
def execute(self, execution, **kwargs):

View file

@ -16,11 +16,6 @@ def create(configuration, environment, log):
class SSHService(Service):
def __init__(self, configuration, environment, log):
super().__init__(configuration, environment, log)
self.__configuration = configuration
self.__environment = environment
self.__log = log
def execute(self, **kwargs):
path = os.path.join(os.environ['HOME'], '.ssh', 'id_rsa')

View file

@ -12,11 +12,6 @@ def create(configuration, environment, log):
# TODO: check for all required configuration options and set defaults if needed.
class TCPConnectService(Service):
def __init__(self, configuration, environment, log):
super().__init__(configuration, environment, log)
self.__configuration = configuration
self.__environment = environment
self.__log = log
def execute(self, **kwargs):
return

View file

@ -12,11 +12,6 @@ def create(configuration, environment, log):
class GetService(Service):
def __init__(self, configuration, environment, log):
super().__init__(configuration, environment, log)
self.__configuration = configuration
self.__environment = environment
self.__log = log
def execute(self, **kwargs):
return

View file

@ -11,11 +11,6 @@ def create(configuration, environment, log):
class ShellService(Service):
def __init__(self, configuration, environment, log):
super().__init__(configuration, environment, log)
self.__configuration = configuration
self.__environment = environment
self.__log = log
def execute(self, **kwargs):
return

View file

@ -11,11 +11,6 @@ def get(configuration, environment, log):
class UptimeService(Service):
def __init__(self, configuration, environment, log):
super().__init__(configuration, environment, log)
self.__configuration = configuration
self.__environment = environment
self.__log = log
def execute(self, **kwargs):
return

View file

@ -13,31 +13,26 @@ def create(configuration, environment, log):
class IsConnectedService(Service):
def __init__(self, configuration, environment, log):
super().__init__(configuration, environment, log)
self.__configuration = configuration
self.__environment = environment
self.__log = log
def execute(self, identifier, monitor, service, **kwargs):
self.__log.debug('identifier=' + identifier +
' service=' + service +
' object=' + str(self) +
' kwargs=' + str(kwargs))
self._log.debug('identifier=' + identifier +
' service=' + service +
' object=' + str(self) +
' kwargs=' + str(kwargs))
try:
fc = FritzStatus(address=monitor.get_host(),
password=kwargs['password'])
except Exception as err:
self.__log.error('identifier=' + identifier +
' host=' + monitor.get_host() +
' service=' + service +
' error=' + str(err))
self._log.error('identifier=' + identifier +
' host=' + monitor.get_host() +
' service=' + service +
' error=' + str(err))
return False
self.__log.info('identifier=' + identifier +
' host=' + monitor.get_host() +
' service=' + service +
' status=' + ('OK' if fc.is_connected else 'ERROR'))
self._log.info('identifier=' + identifier +
' host=' + monitor.get_host() +
' service=' + service +
' status=' + ('OK' if fc.is_connected else 'ERROR'))
if fc.is_connected:
return True