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.linspector import Linspector
from linspector.monitors import Monitors from linspector.monitors import Monitors
__version__ = '0.21.6' __version__ = '0.21.7'
__author__ = 'Johannes Findeisen <you@hanez.org>' __author__ = 'Johannes Findeisen <you@hanez.org>'

View file

@ -7,6 +7,6 @@ See LICENSE (MIT license).
class Service: class Service:
def __init__(self, configuration, environment, log): def __init__(self, configuration, environment, log):
self.__configuration = configuration self._configuration = configuration
self.__environment = environment self._environment = environment
self.__log = log 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 # 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. # maybe the status code that produces an error.
class HTTPConnectService(Service): 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): def execute(self, **kwargs):
return 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. # Get a true or false when a keyword is found in a http request.
class HTTPKeywordService(Service): 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): def execute(self, **kwargs):
return 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 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. 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): def execute(self, identifier, monitor, service, **kwargs):
self.__log.info('identifier=' + identifier + self._log.info('identifier=' + identifier +
' host=' + monitor.get_host() + ' host=' + monitor.get_host() +
' service=' + service + ' service=' + service +
' status=' + 'OK') ' status=' + 'OK')
return True 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. 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): def execute(self, identifier, monitor, service, **kwargs):
status = random.randint(0, 1) status = random.randint(0, 1)
@ -39,9 +34,9 @@ class RandomService(Service):
sha512 = hashlib.sha512(str((str(rnd1) + str(rnd2) + str(rnd3) + str(rnd4) + sha512 = hashlib.sha512(str((str(rnd1) + str(rnd2) + str(rnd3) + str(rnd4) +
str(rnd5) + str(rnd6) + str(rnd7) + str(rnd8) + str(sha256))). str(rnd5) + str(rnd6) + str(rnd7) + str(rnd8) + str(sha256))).
encode('utf-8')).hexdigest() encode('utf-8')).hexdigest()
self.__log.info('identifier=' + identifier + self._log.info('identifier=' + identifier +
' host=' + monitor.get_host() + ' host=' + monitor.get_host() +
' service=' + service + ' service=' + service +
' status=' + ('OK' if status == 0 else 'ERROR') + ' message=' + ' status=' + ('OK' if status == 0 else 'ERROR') + ' message=' +
sha512) sha512)
return True return True

View file

@ -11,11 +11,6 @@ def create(configuration, environment, log):
class PingService(Service): 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): def execute(self, **kwargs):
return return

View file

@ -13,11 +13,6 @@ def create(configuration, environment, log):
class PortService(Service): 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): def execute(self, execution, **kwargs):

View file

@ -16,11 +16,6 @@ def create(configuration, environment, log):
class SSHService(Service): 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): def execute(self, **kwargs):
path = os.path.join(os.environ['HOME'], '.ssh', 'id_rsa') 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. # TODO: check for all required configuration options and set defaults if needed.
class TCPConnectService(Service): 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): def execute(self, **kwargs):
return return

View file

@ -12,11 +12,6 @@ def create(configuration, environment, log):
class GetService(Service): 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): def execute(self, **kwargs):
return return

View file

@ -11,11 +11,6 @@ def create(configuration, environment, log):
class ShellService(Service): 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): def execute(self, **kwargs):
return return

View file

@ -11,11 +11,6 @@ def get(configuration, environment, log):
class UptimeService(Service): 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): def execute(self, **kwargs):
return return

View file

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