@@ -27,6 +27,7 @@ class JPLSpecClass(BaseQuery):
2727
2828 # use the Configuration Items imported from __init__.py
2929 URL = conf .server
30+ FTP_CAT_URL = conf .ftp_cat_server
3031 TIMEOUT = conf .timeout
3132
3233 def __init__ (self ):
@@ -142,6 +143,7 @@ def query_lines(self, min_frequency, max_frequency, *,
142143 parse_name_locally = False ,
143144 get_query_payload = False ,
144145 fallback_to_getmolecule = True ,
146+ use_getmolecule = True ,
145147 cache = True ):
146148 """
147149 Query the JPLSpec service for spectral lines.
@@ -153,6 +155,9 @@ def query_lines(self, min_frequency, max_frequency, *,
153155 governs whether `get_molecule` will be used when no results are returned
154156 by the query service. This workaround is needed while JPLSpec's query
155157 tool is broken.
158+
159+ use_getmolecule is an option to force the query to use get_molecule.
160+ It is needed if the JPL server is completely unresponsive.
156161 """
157162 response = self .query_lines_async (min_frequency = min_frequency ,
158163 max_frequency = max_frequency ,
@@ -166,11 +171,13 @@ def query_lines(self, min_frequency, max_frequency, *,
166171 if get_query_payload :
167172 return response
168173 else :
169- return self ._parse_result (response , fallback_to_getmolecule = fallback_to_getmolecule )
174+ return self ._parse_result (response , fallback_to_getmolecule = fallback_to_getmolecule ,
175+ use_getmolecule = use_getmolecule )
170176
171177 query_lines .__doc__ = process_asyncs .async_to_sync_docstr (query_lines_async .__doc__ )
172178
173- def _parse_result (self , response , * , verbose = False , fallback_to_getmolecule = False ):
179+ def _parse_result (self , response , * , verbose = False , fallback_to_getmolecule = False ,
180+ use_getmolecule = True ):
174181 """
175182 Parse a response into an `~astropy.table.Table`
176183
@@ -201,7 +208,7 @@ def _parse_result(self, response, *, verbose=False, fallback_to_getmolecule=Fals
201208 QN": Quantum numbers for the lower state.
202209 """
203210
204- if 'Zero lines were found' in response .text :
211+ if 'Zero lines were found' in response .text or use_getmolecule :
205212 if fallback_to_getmolecule :
206213 self .lookup_ids = build_lookup ()
207214 payload = parse_qs (response .request .body )
@@ -320,7 +327,7 @@ def get_molecule(self, molecule_id, *, cache=True):
320327 molecule_str = parse_molid (molecule_id )
321328
322329 # Construct the URL to the catalog file
323- url = f'https://spec.jpl.nasa.gov/ftp/pub/catalog /c{ molecule_str } .cat'
330+ url = f'{ self . FTP_CAT_URL } /c{ molecule_str } .cat'
324331
325332 # Request the catalog file
326333 response = self ._request (method = 'GET' , url = url ,
0 commit comments