From: Stefan Schantl Date: Wed, 15 Jan 2020 16:44:02 +0000 (+0100) Subject: Convert provider's responses to string X-Git-Tag: 013~5 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=472b2408b1755b651573b82ef950fca8bd1804fe;p=ddns.git Convert provider's responses to string In Python 3, the HTTPResponse class returns all data that was received from the web server as bytes(). To perform string matching, we need to convert it into unicode first. Signed-off-by: Stefan Schantl --- diff --git a/src/ddns/providers.py b/src/ddns/providers.py index d0c01e7..7a1d97c 100644 --- a/src/ddns/providers.py +++ b/src/ddns/providers.py @@ -370,7 +370,7 @@ class DDNSProtocolDynDNS2(object): response = DDNSProvider.send_request(self, self.url, data=data, username=self.username, password=self.password) # Get the full response message. - output = response.read() + output = response.read().decode() # Handle success messages. if output.startswith("good") or output.startswith("nochg"): @@ -447,7 +447,7 @@ class DDNSProviderAllInkl(DDNSProvider): response = self.send_request(self.url, username=self.username, password=self.password) # Get the full response message. - output = response.read() + output = response.read().decode() # Handle success messages. if output.startswith("good") or output.startswith("nochg"): @@ -723,7 +723,7 @@ class DDNSProviderDNSpark(DDNSProvider): response = self.send_request(self.url, username=self.username, password=self.password, data=data) # Get the full response message. - output = response.read() + output = response.read().decode() # Handle success messages. if output.startswith("ok") or output.startswith("nochange"): @@ -772,7 +772,7 @@ class DDNSProviderDtDNS(DDNSProvider): response = self.send_request(self.url, data=data) # Get the full response message. - output = response.read() + output = response.read().decode() # Remove all leading and trailing whitespace. output = output.strip() @@ -883,7 +883,7 @@ class DDNSProviderDynUp(DDNSProvider): response = self.send_request(self.url, data=data) # Get the full response message. - output = response.read() + output = response.read().decode() # Remove all leading and trailing whitespace. output = output.strip() @@ -945,7 +945,7 @@ class DDNSProviderEasyDNS(DDNSProvider): response = self.send_request(self.url, data=data, username=self.username, password=self.password) # Get the full response message. - output = response.read() + output = response.read().decode() # Remove all leading and trailing whitespace. output = output.strip() @@ -1007,7 +1007,7 @@ class DDNSProviderDynsNet(DDNSProvider): response = self.send_request(self.url, data=data) # Get the full response message. - output = response.read() + output = response.read().decode() # Handle success messages. if output.startswith("200"): @@ -1053,7 +1053,7 @@ class DDNSProviderEnomCom(DDNSResponseParserXML, DDNSProvider): response = self.send_request(self.url, data=data) # Get the full response message. - output = response.read() + output = response.read().decode() # Handle success messages. if self.get_xml_tag_value(output, "ErrCount") == "0": @@ -1134,7 +1134,7 @@ class DDNSProviderFreeDNSAfraidOrg(DDNSProvider): response = self.send_request(url, data=data) # Get the full response message. - output = response.read() + output = response.read().decode() # Handle success messages. if output.startswith("Updated") or "has not changed" in output: @@ -1305,7 +1305,7 @@ class DDNSProviderNamecheap(DDNSResponseParserXML, DDNSProvider): response = self.send_request(self.url, data=data) # Get the full response message. - output = response.read() + output = response.read().decode() # Handle success messages. if self.get_xml_tag_value(output, "IP") == address: @@ -1493,7 +1493,7 @@ class DDNSProviderRegfish(DDNSProvider): response = self.send_request(self.url, username=self.username, password=self.password, data=data) # Get the full response message. - output = response.read() + output = response.read().decode() # Handle success messages. if "100" in output or "101" in output: @@ -1564,7 +1564,7 @@ class DDNSProviderServercow(DDNSProvider): response = self.send_request(self.url, data=data) # Read response - output = response.read() + output = response.read().decode() # Server responds with OK if update was successful if output.startswith("OK"): @@ -1712,7 +1712,7 @@ class DDNSProviderZoneedit(DDNSProvider): response = self.send_request(self.url, username=self.username, password=self.password, data=data) # Get the full response message. - output = response.read() + output = response.read().decode() # Handle success messages. if output.startswith("