Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
return table
except Exception as ex:
(is_valid, err_msg) = _check_ned_valid(response.content)
if not is_valid:
if err_msg:
raise RemoteServiceError(
"The remote service returned the following error "
"message.\nERROR: {err_msg}".format(err_msg=err_msg))
else:
raise RemoteServiceError(
"The remote service returned an error, but with no "
"message.")
else:
self.response = response
self.table_parse_error = ex
raise TableParseError(
"Failed to parse NED result! The raw response can be "
"found in self.response, and the error in "
# Check that object name was not malformed
if 'Either wrong or missing coordinate/object name' in content:
raise Exception("Malformed coordinate/object name")
# Check that the results are not of length zero
if len(content) == 0:
raise Exception("The LCOGT server sent back an empty reply")
# Read it in using the astropy VO table reader
try:
first_table = votable.parse(six.BytesIO(response.content),
pedantic=False).get_first_table()
except Exception as ex:
self.response = response
self.table_parse_error = ex
raise TableParseError("Failed to parse LCOGT votable! The raw "
" response can be found in self.response,"
" and the error in self.table_parse_error.")
# Convert to astropy.table.Table instance
table = first_table.to_table()
# Check if table is empty
if len(table) == 0:
warnings.warn("Query returned no results, so the table will "
"be empty", NoResultsWarning)
return table
help_section = (title, [])
for inp in section.findAll('div', class_='inputdiv'):
sp = inp.find('span')
buttons = inp.findAll('input')
for b in buttons:
# old version:for=id=rawView; name=viewFormat
# new version:for=id=rawView; name=result_view
payload_keyword = b.attrs['name']
bid = b.attrs['id']
label = inp.find('label')
if sp is not None:
name = whitespace.sub(" ", sp.text)
elif label.attrs['for'] == bid:
name = whitespace.sub(" ", label.text)
else:
raise TableParseError("ALMA query page has"
" an unrecognized entry")
if b.attrs['type'] == 'text':
help_section[1].append((name, payload_keyword))
elif b.attrs['type'] == 'radio':
value = b.attrs['value']
if 'checked' in b.attrs:
checked = b.attrs['checked'] == 'checked'
checkbox = "(x)" if checked else "( )"
else:
checkbox = "( )"
help_section[1].append((name, payload_keyword,
checkbox, value))
elif b.attrs['type'] == 'checkbox':
if 'checked' in b.attrs:
checked = b.attrs['checked'] == 'checked'
else:
# Check to see that the query engine is working
if 'SQLConnect failed' in content:
raise Exception("The IRSA server is currently down")
# Check that the results are not of length zero
if len(content) == 0:
raise Exception("The IRSA server sent back an empty reply")
# Read it in using the astropy VO table reader
try:
first_table = votable.parse(six.BytesIO(response.content),
pedantic=False).get_first_table()
except Exception as ex:
self.response = response
self.table_parse_error = ex
raise TableParseError("Failed to parse IRSA votable! The raw "
"response can be found in self.response, "
"and the error in self.table_parse_error.")
# Convert to astropy.table.Table instance
table = first_table.to_table()
# Check if table is empty
if len(table) == 0:
warnings.warn("Query returned no results, so the table will "
"be empty", NoResultsWarning)
return table
tf = six.BytesIO(new_content.encode())
first_table = votable.parse(
tf, pedantic=False,
datatype_mapping=datatype_mapping).get_first_table()
try:
table = first_table.to_table(use_names_over_ids=True)
except TypeError:
warnings.warn("NRAO table parsing: astropy versions prior "
"to 6558975c use the table column IDs instead "
"of names.")
table = first_table.to_table()
return table
except Exception as ex:
self.response = response
self.table_parse_error = ex
raise TableParseError("Failed to parse NRAO votable result! The "
"raw response can be found in self.response,"
# Check that the results are not of length zero
if len(response.content) == 0:
raise Exception("The IRSA server sent back an empty reply")
# Write table to temporary file
output = tempfile.NamedTemporaryFile()
output.write(response.content)
output.flush()
# Read it in using the astropy VO table reader
try:
first_table = votable.parse(output.name, pedantic=False).get_first_table()
except Exception as ex:
self.response = response
self.table_parse_error = ex
raise TableParseError("Failed to parse IRSA votable! The raw response can be found "
"in self.response, and the error in self.table_parse_error.")
# Convert to astropy.table.Table instance
table = first_table.to_table()
# Check if table is empty
if len(table) == 0:
warnings.warn("Query returned no results, so the table will be empty")
return table