From 3ab54c38d7cd7e03507a950d996f7c0137f44427 Mon Sep 17 00:00:00 2001 From: Jakob Mellberg Date: Wed, 20 Mar 2024 08:36:06 +0100 Subject: [PATCH] ruff format --- kea_exporter/cli.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/kea_exporter/cli.py b/kea_exporter/cli.py index 438a6e8..168322c 100644 --- a/kea_exporter/cli.py +++ b/kea_exporter/cli.py @@ -6,15 +6,18 @@ from . import __project__, __version__ -class Timer(): +class Timer: def __init__(self): self.reset() + def reset(self): self.start_time = time.time() + def time_elapsed(self): now_time = time.time() return now_time - self.start_time + @click.command() @click.option( "-m", @@ -85,12 +88,14 @@ def cli(mode, port, address, interval, **kwargs): def local_wsgi_app(registry): func = make_wsgi_app(registry, False) + def app(environ, start_response): if t.time_elapsed() >= interval: exporter.update() t.reset() output_array = func(environ, start_response) return output_array + return app httpd.set_app(local_wsgi_app(REGISTRY)) @@ -100,5 +105,6 @@ def app(environ, start_response): while True: time.sleep(1) + if __name__ == "__main__": cli()