be more accurate when checking if cosmos enabled (#555)

This commit is contained in:
tamarrow
2016-04-08 13:22:27 -07:00
parent 1ed8c5a669
commit 4ff786358d
2 changed files with 9 additions and 2 deletions

View File

@@ -37,10 +37,14 @@ class Cosmos():
# authorized for the command specified, not this endpoint
except DCOSAuthorizationException:
return True
# all other errors are treated as endpoint not available
# allow exception through so we can show user actual http exception
# except 404, because then the url is fine, just not cosmos enabled
except DCOSHTTPException as e:
logger.exception(e)
return e.status() != 404
except Exception as e:
logger.exception(e)
return False
return True
return response.status_code == 200

View File

@@ -14,6 +14,9 @@ class DCOSHTTPException(DCOSException):
def __init__(self, response):
self.response = response
def status(self):
return self.response.status_code
def __str__(self):
return 'Error while fetching [{0}]: HTTP {1}: {2}'.format(
self.response.request.url,