Skip to content

Commit aff2ac5

Browse files
authored
Merge pull request #2769 from keflavich/atomic_url
Fix atomic URL
2 parents 458e55f + ec73103 commit aff2ac5

File tree

3 files changed

+19
-2
lines changed

3 files changed

+19
-2
lines changed

CHANGES.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,11 @@ alfalfa
4747
- Removal of the non-functional ``get_spectrym`` method as that service has
4848
disappeared. [#2578]
4949

50+
atomic
51+
^^^^^^
52+
53+
- Change URL and improve error handling. [#2769]
54+
5055
esa.hubble
5156
^^^^^^^^^^
5257

astroquery/atomic/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ class Conf(_config.ConfigNamespace):
7777
Configuration parameters for `astroquery.atomic`.
7878
"""
7979
url = _config.ConfigItem(
80-
'https://www.pa.uky.edu/~peter/atomic/',
80+
'https://linelist.pa.uky.edu/atomic/',
8181
'Atomic Line List URL')
8282

8383
timeout = _config.ConfigItem(

astroquery/atomic/core.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,18 @@ def query_object_async(self, *, wavelength_range=None, wavelength_type='', wavel
248248
return response
249249

250250
def _parse_result(self, response):
251-
data = StringIO(BeautifulSoup(response.text, features='html5lib').find('pre').text.strip())
251+
252+
if 'ERROR: request form contains no information' in response.text:
253+
raise ValueError("The server returned an error. Please check the URL."
254+
f" The full error message is {response.text}")
255+
elif 'ERROR' in response.text:
256+
raise ValueError(f"The server returned an error. The full error message is {response.text}")
257+
258+
html_pre = BeautifulSoup(response.text, features='html5lib').find('pre')
259+
if html_pre is None:
260+
raise ValueError("Data format not recognized. The <pre> tag was missing from the response.")
261+
262+
data = StringIO(html_pre.text.strip())
252263
# `header` is e.g.:
253264
# "u'-LAMBDA-VAC-ANG-|-SPECTRUM--|TT|--------TERM---------|---J-J---|----LEVEL-ENERGY--CM-1----'"
254265
# `colnames` is then
@@ -299,6 +310,7 @@ def _submit_form(self, input_data=None, cache=True):
299310
log.debug(f"final payload = {payload} from url={url}")
300311
response = self._request("POST", url=url, data=payload,
301312
timeout=self.TIMEOUT, cache=cache)
313+
response.raise_for_status()
302314
log.debug("Retrieved data from POST request")
303315
return response
304316

0 commit comments

Comments
 (0)