Skip to content

Commit

Permalink
Fix for accessing THREDDS catalogs hosted at a Context Path other tha…
Browse files Browse the repository at this point in the history
…n /thredds
  • Loading branch information
joelrahman committed Sep 7, 2016
1 parent b8b2045 commit 560a5ac
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions siphon/catalog.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@
from .http_util import create_http_session, urlopen

try:
from urlparse import urljoin
from urlparse import urljoin, urlparse
except ImportError:
# Python 3
from urllib.parse import urljoin
from urllib.parse import urljoin, urlparse

log = logging.getLogger(__name__)
log.addHandler(logging.StreamHandler()) # Python 2.7 needs a handler set
Expand Down Expand Up @@ -277,7 +277,14 @@ def make_access_urls(self, catalog_url, all_services, metadata=None):
service_name = metadata["serviceName"]

access_urls = {}
server_url = catalog_url.split('/thredds/')[0]
if catalog_url.find('/thredds/') >= 0:
server_url = catalog_url.split('/thredds/')[0]
else:
url_components = urlparse(catalog_url)
if url_components.path:
server_url = catalog_url.split(url_components.path)[0]
else:
server_url = catalog_url

found_service = None
if service_name:
Expand Down

0 comments on commit 560a5ac

Please sign in to comment.