Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions threddsclient/catalog.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,18 @@ def find_datasets(soup, catalog):
if any([x.match(name) for x in catalog.skip]):
logger.info("Skipping dataset based on 'skips'. Name: {0}".format(name))
continue
elif ds.get('urlPath') is None:
datasets.append(CollectionDataset(ds, catalog))
else:
elif ds.get('urlPath'):
"""
THREDDS has no urlPath for collections
"""
datasets.append(DirectDataset(ds, catalog))
elif ds.find_all('access', recursive=False):
"""
HYRAX has data access within sub elements
"""
datasets.append(DirectDataset(ds, catalog))
else:
datasets.append(CollectionDataset(ds, catalog))
return datasets


Expand Down
16 changes: 13 additions & 3 deletions threddsclient/nodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
logger = logging.getLogger(__name__)

FILE_SERVICE = ["HTTPServer"]
OPENDAP_SERVICE = ["OPENDAP", "OpenDAP"]
OPENDAP_SERVICE = ["OPENDAP", "OpenDAP", "OPeNDAP"]
WMS_SERVICE = ["WMS"]
WCS_SERVICE = ["WCS"]

Expand Down Expand Up @@ -39,6 +39,9 @@ def __init__(self, soup, catalog):
Node.__init__(self, soup, catalog)
self.base = soup.get('base')
self.url = urlparse.urljoin(self.catalog.url, self.base)
# To fix issues with HYRAX servers
if 'catalog.xml' not in self.url and not self.url.endswith('/'):
self.url = self.url + '/'
self.service_type = soup.get('serviceType')
self.content_type = "application/service"
self.services = [Service(s, self.catalog) for s in soup.find_all('service', recursive=False)]
Expand Down Expand Up @@ -100,6 +103,8 @@ def service_name(self):
elif self.soup.metadata:
if self.soup.metadata.serviceName:
service_name = self.soup.metadata.serviceName.text
elif self.soup.access:
service_name = self.soup.access.get('serviceName')
elif self.soup.parent.metadata:
if self.soup.parent.metadata.serviceName:
service_name = self.soup.parent.metadata.serviceName.text
Expand Down Expand Up @@ -162,7 +167,12 @@ class DirectDataset(Dataset):
"""
def __init__(self, soup, catalog):
Dataset.__init__(self, soup, catalog)
self.url_path = soup.get('urlPath')
if soup.get('urlPath'):
# Handling THREDDS
self.url_path = soup.get('urlPath')
elif soup.access.get('urlPath'):
# Handling HYRAX
self.url_path = soup.access.get('urlPath')
self.content_type = "application/netcdf"
self.modified = self._modified(soup)
self.bytes = self._bytes(soup)
Expand All @@ -171,7 +181,7 @@ def access_url(self, service_type=FILE_SERVICE):
url = None
for service in self.catalog.get_services(self.service_name):
if service.service_type in service_type:
url = urlparse.urljoin(service.url, self.url_path)
url = urlparse.urljoin(service.url, self.url_path.lstrip('/'))
break
return url

Expand Down
Loading