docs: take the first person out of the checker's messages
This commit is contained in:
parent
39269ca61b
commit
945c8eb6b6
5 changed files with 12 additions and 13 deletions
|
|
@ -137,7 +137,7 @@ def _check(raw_url: str, client: str, listing: bool) -> bytes:
|
||||||
|
|
||||||
if outcome.report is None:
|
if outcome.report is None:
|
||||||
return pages.message(
|
return pages.message(
|
||||||
"We couldn't check that page",
|
"That page couldn't be checked",
|
||||||
[outcome.message or "Something went wrong. Try again."],
|
[outcome.message or "Something went wrong. Try again."],
|
||||||
[("/check", "Try again"), ("/spec/0.1", "The spec")],
|
[("/check", "Try again"), ("/spec/0.1", "The spec")],
|
||||||
).encode()
|
).encode()
|
||||||
|
|
|
||||||
|
|
@ -57,8 +57,7 @@ def check_page(
|
||||||
return (
|
return (
|
||||||
None,
|
None,
|
||||||
response,
|
response,
|
||||||
f"We couldn't read that page (it returned {response.status}). "
|
f"That page returned {response.status}. Check the address and try again.",
|
||||||
"Check the address and try again.",
|
|
||||||
)
|
)
|
||||||
report = validate_bytes(
|
report = validate_bytes(
|
||||||
response.body, url=response.url, response=response, fetcher=fetcher
|
response.body, url=response.url, response=response, fetcher=fetcher
|
||||||
|
|
@ -93,7 +92,7 @@ def submit(
|
||||||
)
|
)
|
||||||
return Outcome(
|
return Outcome(
|
||||||
message="This site was taken out of the directory. Write to the "
|
message="This site was taken out of the directory. Write to the "
|
||||||
"address on the about page if that looks wrong."
|
"address on the home page if that looks wrong."
|
||||||
)
|
)
|
||||||
|
|
||||||
limited = db.rate_limited(connection, client=client, domain=domain, listing=listing)
|
limited = db.rate_limited(connection, client=client, domain=domain, listing=listing)
|
||||||
|
|
@ -206,7 +205,7 @@ def recheck(
|
||||||
try:
|
try:
|
||||||
response = fetcher.get(row["url"], headers=conditional or None)
|
response = fetcher.get(row["url"], headers=conditional or None)
|
||||||
except (UrlError, FetchError):
|
except (UrlError, FetchError):
|
||||||
return _transient(connection, row, "We couldn't reach your site.")
|
return _transient(connection, row, "Your site didn't answer.")
|
||||||
|
|
||||||
elapsed = int((time.monotonic() - started) * 1000)
|
elapsed = int((time.monotonic() - started) * 1000)
|
||||||
if response.status == NOT_MODIFIED:
|
if response.status == NOT_MODIFIED:
|
||||||
|
|
@ -263,7 +262,7 @@ def _transient(connection: sqlite3.Connection, row: sqlite3.Row, note: str) -> s
|
||||||
db.remove(
|
db.remove(
|
||||||
connection,
|
connection,
|
||||||
row["id"],
|
row["id"],
|
||||||
f"{note} We tried for {db.TRANSIENT_LIMIT} days.",
|
f"{note} It stayed that way for {db.TRANSIENT_LIMIT} days.",
|
||||||
)
|
)
|
||||||
return "fail"
|
return "fail"
|
||||||
return "unreachable"
|
return "unreachable"
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,7 @@ CSS_CAP = 256 * 1024
|
||||||
|
|
||||||
MAX_REDIRECTS = 3
|
MAX_REDIRECTS = 3
|
||||||
MAX_URL_LENGTH = 2048
|
MAX_URL_LENGTH = 2048
|
||||||
USER_AGENT = "mews.page checker (+https://mews.page/about)"
|
USER_AGENT = "mews.page checker (+https://mews.page/)"
|
||||||
|
|
||||||
_PSL = PublicSuffixList()
|
_PSL = PublicSuffixList()
|
||||||
|
|
||||||
|
|
@ -247,11 +247,11 @@ def resolve(url: str, *, allow_loopback: bool = False) -> str:
|
||||||
infos = socket.getaddrinfo(host, port, type=socket.SOCK_STREAM)
|
infos = socket.getaddrinfo(host, port, type=socket.SOCK_STREAM)
|
||||||
except socket.gaierror as error:
|
except socket.gaierror as error:
|
||||||
raise FetchError(
|
raise FetchError(
|
||||||
"We couldn't find that domain name. Check the address and try again."
|
"That domain name couldn't be found. Check the address and try again."
|
||||||
) from error
|
) from error
|
||||||
addresses = [info[4][0] for info in infos]
|
addresses = [info[4][0] for info in infos]
|
||||||
if not addresses:
|
if not addresses:
|
||||||
raise FetchError("We couldn't find that domain name.")
|
raise FetchError("That domain name couldn't be found.")
|
||||||
for address in addresses:
|
for address in addresses:
|
||||||
vet_address(address, allow_loopback=allow_loopback)
|
vet_address(address, allow_loopback=allow_loopback)
|
||||||
return addresses[0]
|
return addresses[0]
|
||||||
|
|
@ -356,7 +356,7 @@ class Fetcher:
|
||||||
except httpx.TimeoutException as error:
|
except httpx.TimeoutException as error:
|
||||||
raise FetchError("That page took too long to answer.") from error
|
raise FetchError("That page took too long to answer.") from error
|
||||||
except httpx.HTTPError as error:
|
except httpx.HTTPError as error:
|
||||||
raise FetchError("We couldn't connect to that site.") from error
|
raise FetchError("That site couldn't be reached.") from error
|
||||||
return Fetched(url, response.status_code, response.headers, body, truncated)
|
return Fetched(url, response.status_code, response.headers, body, truncated)
|
||||||
|
|
||||||
def _read(self, response: httpx.Response, cap: int) -> tuple[bytes, bool]:
|
def _read(self, response: httpx.Response, cap: int) -> tuple[bytes, bool]:
|
||||||
|
|
|
||||||
|
|
@ -914,8 +914,8 @@ def validate_url(
|
||||||
report = Report(url=response.url)
|
report = Report(url=response.url)
|
||||||
report.add(
|
report.add(
|
||||||
"well-formed",
|
"well-formed",
|
||||||
f"We couldn't read that page (it returned {response.status}). "
|
f"That page returned {response.status}. Check the address "
|
||||||
"Check the address and try again.",
|
"and try again.",
|
||||||
)
|
)
|
||||||
return report
|
return report
|
||||||
return validate_bytes(
|
return validate_bytes(
|
||||||
|
|
|
||||||
|
|
@ -120,7 +120,7 @@ def test_an_address_that_is_not_a_page_is_refused(service):
|
||||||
|
|
||||||
def test_an_unreachable_page_is_reported(service, site):
|
def test_an_unreachable_page_is_reported(service, site):
|
||||||
_, body = post(site.base + "/missing.html", listing=True)
|
_, body = post(site.base + "/missing.html", listing=True)
|
||||||
assert "it returned 404" in body
|
assert "That page returned 404" in body
|
||||||
|
|
||||||
|
|
||||||
def test_resubmitting_a_site_updates_the_same_row(
|
def test_resubmitting_a_site_updates_the_same_row(
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue