summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorRuben Pollan <meskio@sindominio.net>2017-06-15 11:23:06 +0200
committerRuben Pollan <meskio@sindominio.net>2017-06-15 11:23:06 +0200
commit69e4fb92bad4bb593d59cfe29eb51d238e0fd8db (patch)
tree889f820e0053a81a49c396008576083e1c46428e /src
parentf0988aaae940f0eaa13cda941cf5de7978c74297 (diff)
[feat] handle maintenance mode from nicknym (503 responses)
Diffstat (limited to 'src')
-rw-r--r--src/leap/bitmask/keymanager/nicknym.py11
1 files changed, 8 insertions, 3 deletions
diff --git a/src/leap/bitmask/keymanager/nicknym.py b/src/leap/bitmask/keymanager/nicknym.py
index 8e3a08f9..b585d112 100644
--- a/src/leap/bitmask/keymanager/nicknym.py
+++ b/src/leap/bitmask/keymanager/nicknym.py
@@ -22,7 +22,7 @@ import urllib
from twisted.internet import defer
from twisted.logger import Logger
from twisted.web import client
-from twisted.web._responses import NOT_FOUND
+from twisted.web._responses import NOT_FOUND, SERVICE_UNAVAILABLE
from leap.bitmask.keymanager.errors import KeyNotFound
from leap.common.check import leap_assert
@@ -135,16 +135,21 @@ class Nicknym(object):
:rtype: Deferred
"""
- def check_404(response):
+ def check_code(response):
if response.code == NOT_FOUND:
message = ' %s: Key not found. Request: %s' \
% (response.code, uri)
self.log.warn(message)
raise KeyNotFound(message), None, sys.exc_info()[2]
+ if response.code == SERVICE_UNAVAILABLE:
+ message = ' %s: Service unavailable (maybe in maintenance).' \
+ 'Request: %s' % (response.code, uri)
+ self.log.warn(message)
+ raise KeyNotFound(message), None, sys.exc_info()[2]
return response
d = self._async_client_pinned.request(str(uri), 'GET',
- callback=check_404)
+ callback=check_code)
d.addCallback(client.readBody)
return d