Compare commits
2 commits
d845ec805f
...
befdfd8bb8
Author | SHA1 | Date | |
---|---|---|---|
|
befdfd8bb8 | ||
|
56645e3ff8 |
18
check.py
18
check.py
|
@ -76,6 +76,7 @@ not_here_list = [
|
|||
"This page does not exist yet",
|
||||
"404 Not Found",
|
||||
"500 Internal Server Error",
|
||||
"500: Internal Server Error",
|
||||
"Test Page for the Apache HTTP Server",
|
||||
"Site not found · GitHub Pages",
|
||||
"504: Gateway time-out",
|
||||
|
@ -185,21 +186,24 @@ class Conference:
|
|||
@property
|
||||
def url(self) -> str:
|
||||
"""Conference URL."""
|
||||
return self.src_url.format(year=self.year)
|
||||
return self.build_url(year=self.year)
|
||||
|
||||
def build_url(self, year: int) -> str:
|
||||
"""Build conference URL."""
|
||||
return self.src_url.format(year=year, two_digit_year=year % 2000)
|
||||
|
||||
@property
|
||||
def past_url(self) -> str:
|
||||
"""URL for previous year."""
|
||||
return self.src_url.format(year=self.year - 1)
|
||||
return self.build_url(year=self.year - 1)
|
||||
|
||||
def check(self) -> tuple[bool, str, str | None]:
|
||||
"""Check if conference is live."""
|
||||
no_dot = {"bsideskbh.dk", "pif.camp"}
|
||||
session = (
|
||||
s if all(hostname not in self.url for hostname in no_dot) else s_no_dot
|
||||
)
|
||||
url = self.url
|
||||
session = s if all(hostname not in url for hostname in no_dot) else s_no_dot
|
||||
try:
|
||||
r = session.get(self.url)
|
||||
r = session.get(url)
|
||||
except requests.exceptions.ConnectionError:
|
||||
return (False, "connection refused", None)
|
||||
|
||||
|
@ -228,7 +232,7 @@ class Conference:
|
|||
|
||||
def check_web_site(self) -> bool:
|
||||
"""Check if an individual web site is live."""
|
||||
assert "{year}" in self.src_url
|
||||
assert "{year}" in self.src_url or "{two_digit_year}" in self.src_url
|
||||
live, msg, redirect_to_url = self.check()
|
||||
if not live:
|
||||
return False
|
||||
|
|
Loading…
Reference in a new issue