url = "http://dyndns.kasserver.com"
def update(self):
-
# There is no additional data required so we directly can
# send our request.
- try:
- # Send request to the server.
- response = self.send_request(self.url, username=self.username, password=self.password)
-
- # Handle 401 HTTP Header (Authentication Error)
- except urllib2.HTTPError, e:
- if e.code == 401:
- raise DDNSAuthenticationError
-
- raise
+ response = self.send_request(self.url, username=self.username, password=self.password)
# Get the full response message.
output = response.read()
if response.code == 200:
return
- # Handle error codes.
- elif response.code == 401:
- raise DDNSAuthenticationError
-
# If we got here, some other update error happened.
raise DDNSUpdateError
if response.code == 200:
return
- # Handle error codes.
- if response.code == 403:
- raise DDNSAuthenticationError
- elif response.code == 400:
- raise DDNSRequestError
-
# If we got here, some other update error happened.
raise DDNSUpdateError
return resp
except urllib2.HTTPError, e:
+ # 400 - Bad request
+ if e.code == 400:
+ raise DDNSRequestError(e.reason)
+
+ # 401 - Authorization Required
+ # 403 - Forbidden
+ elif e.code in (401, 403):
+ raise DDNSAuthenticationError(e.reason)
+
+ # 500 - Internal Server Error
+ elif e.code == 500:
+ raise DDNSInternalServerError(e.reason)
+
# 503 - Service Unavailable
- if e.code == 503:
- raise DDNSServiceUnavailableError
+ elif e.code == 503:
+ raise DDNSServiceUnavailableError(e.reason)
# Raise all other unhandled exceptions.
raise