Skip to content

Commit

Permalink
Merge pull request #3140 from bsipocz/BUG_irsa_most_error_parsing
Browse files Browse the repository at this point in the history
BUG: fix `Most.query_object` error parsing
  • Loading branch information
bsipocz authored Dec 12, 2024
2 parents 3f4a051 + c95115f commit d27ac56
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
6 changes: 6 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,12 @@ esa.jwst

- Add download_files_from_program method to get all products by program id [#3073]

ipac.irsa
^^^^^^^^^

- Add more robust handling of errors returned in Most.query_object() responses.
[#3140]

mpc
^^^

Expand Down
7 changes: 6 additions & 1 deletion astroquery/ipac/irsa/most.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,11 @@ def _parse_full_regular_response(self, response, withTarballs=False):
html = BeautifulSoup(response.content, "html5lib")
download_tags = html.find_all("a", string=re.compile(".*Download.*"))

# If for some reason this wasn't a full response with downloadable tags,
# raise an explicit exception:
if not download_tags:
raise ValueError('Something has gone wrong, there are no results parsed. '
f'For full response see: {response.text}')
# this is "Download Results Table (above)"
results_response = self._request("GET", download_tags[0]["href"])
retdict["results"] = Table.read(results_response.text, format="ipac")
Expand Down Expand Up @@ -532,7 +537,7 @@ def query_object(self, catalog="wise_merge", input_mode="name_input", output_mod

# MOST will not raise an bad response if the query is bad because they
# are not a REST API
if "MOST: *** error:" in response.text:
if "MOST: *** error:" in response.text or "most: error:" in response.text:
raise InvalidQueryError(response.text)

# presume that response is HTML to simplify conditions
Expand Down

0 comments on commit d27ac56

Please sign in to comment.