use safe_get instead

This commit is contained in:
2026-06-06 23:15:38 +02:00
parent 589f5afa07
commit 586223fe1a
+8 -2
View File
@@ -19,6 +19,12 @@ def parse_path(path: str) -> str:
def include_path(path: str) -> bool:
return not any([x in path for x in EXCLUDES])
def safe_get(path: str) -> bool:
try:
return requests.get(path).ok
except:
return False
if __name__ == "__main__":
output_file = "out/status.txt"
print(f"writing to file `{output_file}`...")
@@ -28,12 +34,12 @@ if __name__ == "__main__":
print("----- TOM -----")
tom_paths = filtered_paths |> map$("https://pvv.ntnu.no/"+.) |> list
tom_oks = tom_paths |> map$(requests.get) |> map$(x -> x.ok) |> list
tom_oks = tom_paths |> map$(safe_get) |> list
zip(tom_oks, tom_paths) |> map$(x -> str(x[0]) + ":\t" + x[1]) |> "\n".join |> print
print("----- TEMMIE -----")
tem_paths = filtered_paths |> map$("https://temmie.pvv.ntnu.no/"+.) |> list
tem_oks = tem_paths |> map$(requests.get) |> map$(x -> x.ok) |> list
tem_oks = tem_paths |> map$(safe_get) |> list
zip(tem_oks, tem_paths) |> map$(x -> str(x[0]) + ":\t" + x[1]) |> "\n".join |> print
sys.stdout.close()