Skip to content

Commit

Permalink
handle import and name errors with the Authentication class
Browse files Browse the repository at this point in the history
  • Loading branch information
Samweli authored and nyalldawson committed Jun 15, 2020
1 parent f9b897b commit a17a49e
Showing 1 changed file with 19 additions and 7 deletions.
26 changes: 19 additions & 7 deletions python/plugins/MetaSearch/dialogs/maindialog.py
Expand Up @@ -51,7 +51,11 @@

from owslib.fes import BBox, PropertyIsLike
from owslib.ows import ExceptionReport
from owslib.util import Authentication

try:
from owslib.util import Authentication
except ImportError:
pass

from MetaSearch import link_types
from MetaSearch.dialogs.manageconnectionsdialog import ManageConnectionsDialog
Expand Down Expand Up @@ -829,12 +833,16 @@ def show_metadata(self):
identifier = get_item_data(item, 'identifier')

self.disable_ssl_verification = self.disableSSLVerification.isChecked()
auth = None

if self.disable_ssl_verification:
try:
auth = Authentication(verify=False)
except NameError:
pass

try:
with OverrideCursor(Qt.WaitCursor):
auth = None
if self.disable_ssl_verification:
auth = Authentication(verify=False)
cat = CatalogueServiceWeb(self.catalog_url, timeout=self.timeout, # spellok
username=self.catalog_username,
password=self.catalog_password,
Expand Down Expand Up @@ -914,12 +922,16 @@ def _get_csw(self):
"""convenience function to init owslib.csw.CatalogueServiceWeb""" # spellok

self.disable_ssl_verification = self.disableSSLVerification.isChecked()
auth = None

if self.disable_ssl_verification:
try:
auth = Authentication(verify=False)
except NameError:
pass

# connect to the server
with OverrideCursor(Qt.WaitCursor):
auth = None
if self.disable_ssl_verification:
auth = Authentication(verify=False)
try:
self.catalog = CatalogueServiceWeb(self.catalog_url, # spellok
timeout=self.timeout,
Expand Down

0 comments on commit a17a49e

Please sign in to comment.