Skip to content

Commit

Permalink
Re-worked
Browse files Browse the repository at this point in the history
  • Loading branch information
Adrian Damian authored and Adrian Damian committed Nov 29, 2023
1 parent b585d3b commit 99d3c0f
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 18 deletions.
37 changes: 20 additions & 17 deletions pyvo/dal/sia2.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ class SIA2Service(DALService, AvailabilityMixin, CapabilityMixin):
generally not notice that, though.
"""

def __init__(self, baseurl, session=None):
def __init__(self, baseurl, session=None, check_baseurl=True):
"""
instantiate an SIA2 service
Expand All @@ -166,6 +166,9 @@ def __init__(self, baseurl, session=None):
url - URL of the SIA2service (base or query endpoint)
session : object
optional session to use for network requests
check_baseurl : bool
True - use the capabilities end point of the service to get the
query end point, False - baseurl is the query end point
"""

super().__init__(baseurl, session=session)
Expand All @@ -177,22 +180,22 @@ def __init__(self, baseurl, session=None):
if hasattr(self._session, 'update_from_capabilities'):
self._session.update_from_capabilities(self.capabilities)

self.query_ep = baseurl # default service query end point
for cap in self.capabilities:
# assumes that the access URL is the same regardless of the
# authentication method except BasicAA which is not supported
# in pyvo. So pick any access url as long as it's not
found = False
if cap.standardid.lower() == SIA2_STANDARD_ID.lower():
for interface in cap.interfaces:
if interface.accessurls and \
not (len(interface.securitymethods) == 1
and interface.securitymethods[0].standardid
== 'ivo://ivoa.net/sso#BasicAA'):
self.query_ep = interface.accessurls[0].content
found = True
break
if found:
self.query_ep = baseurl.strip('&') # default service end point
if check_baseurl:
for cap in self.capabilities:
# assumes that the access URL is the same regardless of the
# authentication method except BasicAA which is not supported
# in pyvo. So pick any access url as long as it's not
if cap.standardid.lower() == SIA2_STANDARD_ID.lower():
for interface in cap.interfaces:
if interface.accessurls and \
not (len(interface.securitymethods) == 1
and interface.securitymethods[0].standardid
== 'ivo://ivoa.net/sso#BasicAA'):
self.query_ep = interface.accessurls[0].content
break
else:
continue
break

def search(self, pos=None, band=None, time=None, pol=None,
Expand Down
7 changes: 7 additions & 0 deletions pyvo/dal/tests/test_sia2.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,13 @@ def test_capabilities(self):
service = SIA2Service('https://example.com/sia/myquery?param=1')
assert service.query_ep == 'https://example.com/sia/v2query'

# capabilities checking is bypassed all together with the
# check_baseurl=False flag
service = SIA2Service('https://example.com/sia/myquery?param=1&',
check_baseurl=False)
assert service.query_ep == 'https://example.com/sia/myquery?param=1'


POSITIONS = [(2, 4, 0.0166 * u.deg),
(12, 12.5, 34, 36),
(12.0 * u.deg, 34.0 * u.deg,
Expand Down
5 changes: 4 additions & 1 deletion pyvo/registry/regtap.py
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,10 @@ def to_service(self):
raise ValueError("PyVO has no support for interfaces with"
f" standard id {self.standard_id}.")

return service_class(self.access_url)
if service_class == sia2.SIA2Service:
return service_class(self.access_url, check_baseurl=False)
else:
return service_class(self.access_url)

def supports(self, standard_id):
"""returns true if we believe the interface should be able to talk
Expand Down

0 comments on commit 99d3c0f

Please sign in to comment.