diff --git a/cursed.coco b/cursed.coco index 67e563e..de1f7df 100644 --- a/cursed.coco +++ b/cursed.coco @@ -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()