Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions server/app/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand All @@ -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:
Expand Down
2 changes: 0 additions & 2 deletions server/app/endpoints/builds.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 0 additions & 3 deletions server/app/endpoints/downloads.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
Expand Down
2 changes: 0 additions & 2 deletions server/app/endpoints/jira.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand All @@ -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()
Expand Down
4 changes: 0 additions & 4 deletions server/app/endpoints/machines.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand All @@ -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()
3 changes: 0 additions & 3 deletions server/app/endpoints/mailstats.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand All @@ -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()


4 changes: 1 addition & 3 deletions server/app/endpoints/sitesource.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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


Expand Down
10 changes: 1 addition & 9 deletions server/app/endpoints/uptime.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,28 +16,20 @@
# 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


@asfquart.APP.route(
"/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
Expand Down
2 changes: 1 addition & 1 deletion server/app/endpoints/userid.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion server/app/plugins/downloads.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
17 changes: 5 additions & 12 deletions server/app/plugins/machines.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,21 +23,14 @@
- 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
import hashlib
import time
import datetime
import fnmatch
import sys

KEYSCAN = "/usr/bin/ssh-keyscan"
IPDATA = requests.get(
Expand Down Expand Up @@ -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")
Expand All @@ -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())
Expand Down
1 change: 0 additions & 1 deletion server/app/plugins/mailstats.py
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down
Loading