Skip to content

Commit

Permalink
[ENH] server communication error code added
Browse files Browse the repository at this point in the history
  • Loading branch information
dutta-alankar committed Apr 28, 2024
1 parent 7b87f41 commit 3e0ff9d
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions astro_plasma/core/download_database.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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")):
Expand Down

0 comments on commit 3e0ff9d

Please sign in to comment.