MCPcopy Create free account
hub / github.com/internetarchive/openlibrary / get_web_error

Function get_web_error

scripts/get_web_error.py:25–43  ·  view source on GitHub ↗

ssh into hosts ol-web1 and ol-web2 and if filename is found in the docker_container openlibrary_web_1 then return its contents.

(
    filename: str,
    hosts=("ol-web1.us.archive.org", "ol-web2.us.archive.org"),
    docker_container: str = "openlibrary_web_1",
)

Source from the content-addressed store, hash-verified

23
24
25def get_web_error(
26 filename: str,
27 hosts=("ol-web1.us.archive.org", "ol-web2.us.archive.org"),
28 docker_container: str = "openlibrary_web_1",
29) -> str:
30 """
31 ssh into hosts ol-web1 and ol-web2 and if filename is found in the
32 docker_container openlibrary_web_1 then return its contents.
33 """
34 file_path = f"/var/log/openlibrary/ol-errors/{filename}"
35 for host in hosts:
36 cmd = f"ssh -A -t {host} 'docker exec -i {docker_container} cat {file_path}'"
37 try:
38 if output := subprocess.check_output(cmd, shell=True, text=True):
39 return output
40 except subprocess.CalledProcessError as e:
41 print(f"Error: {e!r}")
42 raise (e)
43 return f"Error: {file_path} was not found on {' or '.join(hosts)}."
44
45
46if __name__ == "__main__":

Callers 1

get_web_error.pyFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected