Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
pllim committed Sep 16, 2015
1 parent 3255216 commit 4469a28
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions astropy/vo/validator/tstquery.py
Expand Up @@ -10,7 +10,8 @@
#. If fails, use RA=0 DEC=0 SR=0.1.
"""
from __future__ import absolute_import, division, print_function, unicode_literals
from __future__ import (absolute_import, division, print_function,
unicode_literals)

# STDLIB
import warnings
Expand All @@ -28,12 +29,12 @@ def parse_cs(id):
id = id.decode('ascii')

# Production server.
url = 'http://vao.stsci.edu/directory/getRecord.aspx?' \
'id={0}&format=xml'.format(id)
url = ('http://vao.stsci.edu/directory/getRecord.aspx?'
'id={0}&format=xml'.format(id))

# Test server (in case production server fails).
backup_url = 'http://vaotest.stsci.edu/directory/getRecord.aspx?' \
'id={0}&format=xml'.format(id)
backup_url = ('http://vaotest.stsci.edu/directory/getRecord.aspx?'
'id={0}&format=xml'.format(id))

tqp = ['ra', 'dec', 'sr']
d = OrderedDict()
Expand All @@ -60,13 +61,18 @@ def parse_cs(id):
tq = dom.getElementsByTagName('testQuery')
if tq:
for key in tqp:
d[key.upper()] = tq[0].getElementsByTagName(
key)[0].firstChild.nodeValue.strip()
try:
d[key.upper()] = tq[0].getElementsByTagName(
key)[0].firstChild.nodeValue.strip()
except Exception as e: # pragma: no cover
urls_failed = True
urls_errmsg = ('Incomplete testQuery for {0}, '
'using default'.format(id))
else: # pragma: no cover
urls_failed = True
urls_errmsg = 'No testQuery found for {0}, using default'.format(id)

# If no testQuery found, use RA=0 DEC=0 SR=1
# If no testQuery found, use RA=0 DEC=0 SR=0.1
if urls_failed: # pragma: no cover
d = OrderedDict({'RA': '0', 'DEC': '0', 'SR': '0.1'})
warnings.warn(urls_errmsg, AstropyUserWarning)
Expand Down

0 comments on commit 4469a28

Please sign in to comment.