48 lines
1.4 KiB
Plaintext
48 lines
1.4 KiB
Plaintext
import requests
|
|
import os
|
|
import sys
|
|
|
|
# substrings in path to exclude
|
|
EXCLUDES = [
|
|
"wordpress"
|
|
]
|
|
|
|
def read_lines(path: str) -> list[str]:
|
|
with open(path, 'r') as f:
|
|
return f.read().splitlines()
|
|
|
|
# construct get-able url path
|
|
def parse_path(path: str) -> str:
|
|
# bet on `/home/pvv/_/` prefix
|
|
return "~" + path[12:] |> .replace("/web-docs", "")
|
|
|
|
def include_path(path: str) -> bool:
|
|
return not any([x in path for x in EXCLUDES])
|
|
|
|
def safe_get(path: str) -> str:
|
|
try:
|
|
return requests.get(path).status_code |> str
|
|
except Exception as e:
|
|
return str(e)
|
|
|
|
if __name__ == "__main__":
|
|
output_file = "out/status2.txt"
|
|
print(f"writing to file `{output_file}`...")
|
|
sys.stdout = open(output_file, "w")
|
|
|
|
filtered_paths = read_lines("out/cgi-paths.txt") |> map$(parse_path) |> filter$(include_path) |> list
|
|
|
|
print("----- TOM -----")
|
|
tom_paths = filtered_paths |> map$("https://pvv.ntnu.no/"+.) |> list
|
|
tom_oks = tom_paths |> map$(safe_get) |> list
|
|
zip(tom_oks, tom_paths) |> map$(":\t".join) |> "\n".join |> print
|
|
|
|
print("----- TEMMIE -----")
|
|
tem_paths = filtered_paths |> map$("https://temmie.pvv.ntnu.no/"+.) |> list
|
|
tem_oks = tem_paths |> map$(safe_get) |> list
|
|
zip(tem_oks, tem_paths) |> map$(":\t".join) |> "\n".join |> print
|
|
|
|
sys.stdout.close()
|
|
sys.stdout = sys.__stdout__
|
|
print(f"finished writing to file `{output_file}`.")
|