From 3e0ff9dd9cc41e47c8afac1a9c05bf30b3b005f3 Mon Sep 17 00:00:00 2001 From: dutta-alankar Date: Sun, 28 Apr 2024 12:43:01 +0200 Subject: [PATCH] [ENH] server communication error code added --- astro_plasma/core/download_database.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/astro_plasma/core/download_database.py b/astro_plasma/core/download_database.py index c033446..ded291a 100644 --- a/astro_plasma/core/download_database.py +++ b/astro_plasma/core/download_database.py @@ -24,6 +24,8 @@ def fetch_list_from_url(link_list_url: str) -> List[str]: # print(link_list_url) response = requests.get(link_list_url, stream=True) + if response.status_code != 200: + sys.exit(f"Problem communicating with dataserver! (error code: {response.status_code}") # print(response) links = response.content.decode("utf-8").split("\n") return links @@ -33,6 +35,8 @@ def fetch_list_from_url(link_list_url: str) -> List[str]: def get_filename(url: str) -> str: try: with requests.get(url, stream=True) as req: + if req.status_code != 200: + sys.exit(f"Problem communicating with dataserver! (error code: {req.status_code}") if content_disposition := req.headers.get("Content-Disposition"): param, options = werkzeug.http.parse_options_header(content_disposition) if param == "attachment" and (filename := options.get("filename")):