try to catch bad downloads since ALMA now auto-redirects to login for
these DLs
@@ -527,6 +527,13 @@ class AlmaClass(QueryWithLogin):
for fileLink in unique(files):
try:
log.debug("Downloading {0} to {1}".format(fileLink, savedir))
+ check_filename = self._request('HEAD', fileLink, stream=True)
+ check_filename.raise_for_status()
+ if 'text/html' in check_filename.headers['Content-Type']:
+ raise ValueError("Bad query. This can happen if you "
+ "attempt to download proprietary "
+ "data when not logged in")
+
filename = self._request("GET", fileLink, save=True,
savedir=savedir,
timeout=self.TIMEOUT,
