diff --git a/server/app/__init__.py b/server/app/__init__.py index 36c08fb..a33dceb 100644 --- a/server/app/__init__.py +++ b/server/app/__init__.py @@ -17,11 +17,10 @@ # under the License. """ASF Infra Reporting Dashboard - Plugins""" -import secrets import asfquart import asfquart.generics import quart -from .lib import config, log, middleware, assets +from .lib import log, assets import os @@ -48,8 +47,6 @@ async def static_files(path="index.html"): async def load_endpoints(): """Load all API end points and tasks. This is run before Quart starts serving requests""" async with APP.app_context(): - from . import endpoints - from . import plugins # Regenerate documentation if debug: diff --git a/server/app/endpoints/builds.py b/server/app/endpoints/builds.py index 65f8cde..46d73e4 100644 --- a/server/app/endpoints/builds.py +++ b/server/app/endpoints/builds.py @@ -18,9 +18,7 @@ """ASF Infrastructure Reporting Dashboard""" """Handler for builds data""" import asfquart -from asfquart.auth import Requirements as R import asyncio -from ..lib import middleware from ..plugins import ghascanner import time import json diff --git a/server/app/endpoints/downloads.py b/server/app/endpoints/downloads.py index bee5e99..6a81a78 100644 --- a/server/app/endpoints/downloads.py +++ b/server/app/endpoints/downloads.py @@ -19,8 +19,6 @@ """Handler for download stats - ported from https://github.com/apache/infrastructure-dlstats""" import asfquart -from asfquart.auth import Requirements as R -from ..lib import middleware, config from ..plugins import downloads @asfquart.auth.require @@ -29,7 +27,6 @@ ) async def process_downloads(): form_data = await asfquart.utils.formdata() - session = await asfquart.session.read() project = form_data.get("project", "httpd") # Project/podling to fetch stats for duration = form_data.get("duration", 7) # Timespan to search (in whole days) diff --git a/server/app/endpoints/jira.py b/server/app/endpoints/jira.py index a3d877a..493a869 100644 --- a/server/app/endpoints/jira.py +++ b/server/app/endpoints/jira.py @@ -21,7 +21,6 @@ import asfquart.auth from asfquart.auth import Requirements as R import asfquart.session -from ..lib import middleware, config from ..plugins import jirastats @@ -31,7 +30,6 @@ ) async def process_jira(): form_data = await asfquart.utils.formdata() - session = await asfquart.session.read() action = form_data.get("action") if action == "stats": # Basic stats return jirastats.get_issues() diff --git a/server/app/endpoints/machines.py b/server/app/endpoints/machines.py index d6b2878..fc552bd 100644 --- a/server/app/endpoints/machines.py +++ b/server/app/endpoints/machines.py @@ -18,8 +18,6 @@ """ASF Infrastructure Reporting Dashboard""" """Handler for mail stats""" import asfquart -from asfquart.auth import Requirements as R -from ..lib import config from ..plugins import machines @@ -28,6 +26,4 @@ "/api/machines", ) async def process_fingerprints(): - form_data = await asfquart.utils.formdata() - session = await asfquart.session.read() return machines.get_fps() diff --git a/server/app/endpoints/mailstats.py b/server/app/endpoints/mailstats.py index e8e08b0..5089596 100644 --- a/server/app/endpoints/mailstats.py +++ b/server/app/endpoints/mailstats.py @@ -19,7 +19,6 @@ """Handler for mail stats""" import asfquart from asfquart.auth import Requirements as R -from ..lib import middleware, config from ..plugins import mailstats @@ -28,8 +27,6 @@ "/api/mailstats", ) async def process_mailstats(): - form_data = await asfquart.utils.formdata() - session = await asfquart.session.read() return mailstats.get_stats() diff --git a/server/app/endpoints/sitesource.py b/server/app/endpoints/sitesource.py index 9b7d819..52e3c26 100644 --- a/server/app/endpoints/sitesource.py +++ b/server/app/endpoints/sitesource.py @@ -18,7 +18,7 @@ """ASF Infrastructure Reporting Dashboard""" """Handler for site source page""" import asfquart -from ..lib import middleware, config +from ..lib import middleware from .. import plugins site_source_url = middleware.CachedJson("https://www.apache.org/site-sources.json", expiry=1800) @@ -28,8 +28,6 @@ "/api/sitesource", ) async def process_sitesource(): - form_data = await asfquart.utils.formdata() - session = await asfquart.session.read() return await site_source_url.json diff --git a/server/app/endpoints/uptime.py b/server/app/endpoints/uptime.py index b3d98da..b6cc50f 100644 --- a/server/app/endpoints/uptime.py +++ b/server/app/endpoints/uptime.py @@ -16,11 +16,10 @@ # specific language governing permissions and limitations # under the License. """ASF Infrastructure Reporting Dashboard""" -import functools """Handler for uptime stats""" import asfquart -from ..lib import middleware, config +from ..lib import config from ..plugins import uptime @@ -28,16 +27,9 @@ "/api/uptime", ) async def process_uptime(): - form_data = await asfquart.utils.formdata() - session = await asfquart.session.read() uptime_stats = uptime.get_stats() series = config.reporting.uptime.get("series", {}) uptime_collated = {} - uptime_summed = { - "year": 100.0, - "month": 100.0, - "week": 100.0, - } if series: u_y = 0 u_m = 0 diff --git a/server/app/endpoints/userid.py b/server/app/endpoints/userid.py index e4c7326..32b8f84 100644 --- a/server/app/endpoints/userid.py +++ b/server/app/endpoints/userid.py @@ -17,7 +17,7 @@ # under the License. """ASF Infrastructure Reporting Dashboard""" """Handler for userID availability/syntax checks""" -from ..lib import middleware, config +from ..lib import config import os import yaml import psycopg diff --git a/server/app/plugins/downloads.py b/server/app/plugins/downloads.py index 2d8aeb0..17f88fb 100644 --- a/server/app/plugins/downloads.py +++ b/server/app/plugins/downloads.py @@ -17,7 +17,7 @@ # under the License. """ASF Infrastructure Reporting Dashboard - Download Statistics Tasks""" import asyncio -from ..lib import middleware, config +from ..lib import config import elasticsearch import elasticsearch_dsl from .. import plugins diff --git a/server/app/plugins/machines.py b/server/app/plugins/machines.py index 11d68f4..a04d29d 100644 --- a/server/app/plugins/machines.py +++ b/server/app/plugins/machines.py @@ -23,13 +23,7 @@ - fp.json: a json file for nodeping to work with """ import asyncio -from ..lib import config from .. import plugins -import aiohttp -import aiohttp.client_exceptions -import functools -import os -import json import requests import subprocess import base64 @@ -37,7 +31,6 @@ import time import datetime import fnmatch -import sys KEYSCAN = "/usr/bin/ssh-keyscan" IPDATA = requests.get( @@ -122,13 +115,13 @@ async def fpscan(): stderr=asyncio.subprocess.PIPE # (KEYSCAN, '-T', '1', '-4', '-t', 'ecdsa', f"{name}.apache.org"), stderr=asyncio.subprocess.PIPE ) - keydata_rsa, rsa_stderr = await kdata_rsa.communicate() - keydata_ecdsa, ecdsa_stderr = await kdata_ecdsa.communicate() + keydata_rsa, _rsa_stderr = await kdata_rsa.communicate() + keydata_ecdsa, _ecdsa_stderr = await kdata_ecdsa.communicate() if not keydata_rsa: unreachable.append(name) continue - gunk, rsa_sha256 = l2fp(keydata_rsa) - gunk, ecdsa_sha256 = l2fp(keydata_ecdsa) + _gunk, rsa_sha256 = l2fp(keydata_rsa) + _gunk, ecdsa_sha256 = l2fp(keydata_ecdsa) reachable += 1 now = int(time.time()) now_str = datetime.datetime.fromtimestamp(now).strftime("%c") @@ -154,7 +147,7 @@ async def fpscan(): except KeyboardInterrupt: break - except subprocess.CalledProcessError as e: + except subprocess.CalledProcessError: unreachable.append(name) stamp = time.strftime("%Y-%m-%d %H:%M:%S %z", time.gmtime()) diff --git a/server/app/plugins/mailstats.py b/server/app/plugins/mailstats.py index c034707..8d4eb82 100644 --- a/server/app/plugins/mailstats.py +++ b/server/app/plugins/mailstats.py @@ -90,7 +90,6 @@ async def mail_scan(): mxout_stats[hostname] = trim_stats(await req.json()) except (aiohttp.ClientError, asyncio.TimeoutError, json.JSONDecodeError) as e: print(f"Could not fetch JSON from {hostname}: {e}") - mxout_collated = {} _stats.clear() _stats.update(mxout_stats) _stats["collated"] = collate_stats(*mxout_stats.values())