Skip to content

Commit

Permalink
Fail more gracefully when password or user name are not entered
Browse files Browse the repository at this point in the history
Before we threw and exception but #13 told us we need to fail more
gracefully and not stop the build. This now does not stop the build, but
prints the fail exception.
  • Loading branch information
Letme committed Dec 18, 2018
1 parent 4004a9f commit 28d82a4
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
9 changes: 5 additions & 4 deletions mlx/coverity.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@
from mlx.coverity_services import CoverityConfigurationService, CoverityDefectService
try:
# For Python 3.0 and later
from urllib.error import URLError
from urllib.error import URLError, HTTPError
except ImportError:
# Fall back to Python 2's urllib2
from urllib2 import URLError
from urllib2 import URLError, HTTPError
from sphinx import __version__ as sphinx_version
if sphinx_version >= '1.6.0':
from sphinx.util.logging import getLogger
Expand Down Expand Up @@ -170,7 +170,8 @@ def process_coverity_nodes(app, doctree, fromdocname):
report_info(env, 'done')
coverity_service = CoverityDefectService(coverity_conf_service)
coverity_service.login(app.config.coverity_credentials['username'], app.config.coverity_credentials['password'])
except URLError:
except (URLError, HTTPError, Exception, ValueError) as error_info:
report_info(env, 'failed with: %s' % error_info)
# Create failed topnode
for node in doctree.traverse(CoverityDefect):
top_node = create_top_node("Failed to connect to Coverity Server")
Expand Down Expand Up @@ -205,7 +206,7 @@ def process_coverity_nodes(app, doctree, fromdocname):
checker=node['checker'], impact=node['impact'], kind=node['kind'],
classification=node['classification'], action=node['action'],
component=node['component'], cwe=node['cwe'], cid=node['cid'])
except (URLError, AttributeError) as e:
except (URLError, AttributeError, Exception) as e:
report_warning(env, 'failed with %s' % e)
continue
report_info(env, "%d received" % (defects['totalNumberOfRecords']))
Expand Down
1 change: 1 addition & 0 deletions mlx/coverity_services.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ def __init__(self, transport, hostname, port, ws_version=DEFAULT_WS_VERSION):
super(CoverityConfigurationService, self).__init__(transport, hostname, port, ws_version)
self.checkers = None
url = self.get_ws_url('configurationservice')
logging.getLogger('suds.client').setLevel(logging.CRITICAL)
try:
self.client = Client(url)
logging.info("Validated presence of Coverity Configuration Service [%s]", url)
Expand Down

0 comments on commit 28d82a4

Please sign in to comment.