Add Web UI to see when conference websites appeared

Closes: #4
This commit is contained in:
Edward Betts 2024-07-21 10:53:22 +09:00
parent 87009c2247
commit 187214cfa1
4 changed files with 114 additions and 26 deletions

View file

@ -2,11 +2,9 @@
"""Check if conference websites are live."""
import configparser
import os
import re
import smtplib
import typing
import warnings
from datetime import date
from email.mime.text import MIMEText
@ -18,13 +16,7 @@ from requests.adapters import HTTPAdapter
from urllib3.exceptions import InsecureRequestWarning
from urllib3.util.url import parse_url
class LiveConference(typing.TypedDict):
"""Live conference."""
conference: str
year: int
live: date
from conference import LiveConference, config, load_yaml
class AbsoluteDNSAdapter(HTTPAdapter):
@ -51,16 +43,6 @@ class AbsoluteDNSAdapter(HTTPAdapter):
return super().send(request, **kwargs)
config_file_path = os.path.expanduser(
os.path.join(
os.getenv("XDG_CONFIG_HOME", "~/.config"), "conference-check", "config"
)
)
config = configparser.ConfigParser()
config.read(os.path.expanduser(config_file_path))
# Suppress only the single InsecureRequestWarning from urllib3
warnings.filterwarnings("ignore", category=InsecureRequestWarning)
@ -96,6 +78,7 @@ not_here_list = [
"Wikimedia Error",
"The page you requested could not be found",
"Ooops! Could Not Find It",
"OpenStreetMap Authentication Proxy",
]
@ -145,13 +128,6 @@ def send_mail(subject: str, body: str) -> None:
s.quit()
def load_yaml(name: str) -> typing.Any:
"""Load YAML."""
filename = os.path.expanduser(config["data"][name])
assert os.path.exists(filename)
return yaml.safe_load(open(filename))
def check_conference_web_site(name: str, src_url: str, year: int) -> bool:
"""Check if an individual web site is live."""
assert "{year}" in src_url