Skip to content

Commit ffc1ec4

Browse files
authored
Merge pull request #738 from keflavich/alma-retrieving
ALMA: improve repeat staging behavior
2 parents c783770 + 51db6ba commit ffc1ec4

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

astroquery/alma/core.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -234,9 +234,16 @@ def stage_data(self, uids):
234234
self._staging_log['initial_response'] = response
235235
log.debug("First response URL: {0}".format(response.url))
236236
if response.status_code == 405:
237-
raise HTTPError("Received an error 405: this may indicate you "
238-
"have already staged the data. Try downloading "
239-
"the file URLs directly with download_files.")
237+
if hasattr(self,'_last_successful_staging_log'):
238+
log.warn("Error 405 received. If you have previously staged "
239+
"the same UIDs, the result returned is probably "
240+
"correct, otherwise you may need to create a fresh "
241+
"astroquery.Alma instance.")
242+
return self._last_successful_staging_log['result']
243+
else:
244+
raise HTTPError("Received an error 405: this may indicate you "
245+
"have already staged the data. Try downloading "
246+
"the file URLs directly with download_files.")
240247
response.raise_for_status()
241248

242249
if 'j_spring_cas_security_check' in response.url:
@@ -310,6 +317,8 @@ def stage_data(self, uids):
310317
))
311318
tbl = self._json_summary_to_table(json_data, base_url=base_url)
312319
self._staging_log['result'] = tbl
320+
self._staging_log['file_urls'] = tbl['URL']
321+
self._last_successful_staging_log = self._staging_log
313322

314323
return tbl
315324

0 commit comments

Comments
 (0)