http: raise exception if expired token (#880)

- add raise DCOSAuthenticationException in dcos.http.request if token is
   invalid.
 - raise DCOSAuthenticationException or DCOSAuthorizationException in
   dcos.packagemanager.PackageManager().has_capability if user is not logged in
This commit is contained in:
Maksym Naboka
2017-01-18 17:47:37 -08:00
committed by tamarrow
parent c2d59ff8a6
commit 95dea4e3a3
2 changed files with 5 additions and 1 deletions

View File

@@ -159,7 +159,7 @@ def request(method,
if auth_token is not None:
msg = ("Your core.dcos_acs_token is invalid. "
"Please run: `dcos auth login`")
raise DCOSException(msg)
raise DCOSAuthenticationException(msg)
else:
raise DCOSAuthenticationException(response)
elif response.status_code == 422:

View File

@@ -67,6 +67,10 @@ class PackageManager:
try:
response = self.cosmos.call_endpoint(
'capabilities').json()
except DCOSAuthenticationException:
raise
except DCOSAuthorizationException:
raise
except Exception as e:
logger.exception(e)
return False