# HG changeset patch # User Goffi # Date 1461690299 -7200 # Node ID f6d560cabeee85a5f91406dd952bc9c8046ccc66 # Parent 2c1a1b56dd22421be6a8166c57046f84cd76a240 plugin misc ip: fixed exception when a web error happen while retrieving IP from external website diff -r 2c1a1b56dd22 -r f6d560cabeee src/plugins/plugin_misc_ip.py --- a/src/plugins/plugin_misc_ip.py Sat Apr 23 23:46:35 2016 +0200 +++ b/src/plugins/plugin_misc_ip.py Tue Apr 26 19:04:59 2016 +0200 @@ -23,6 +23,7 @@ log = getLogger(__name__) from sat.tools import xml_tools from twisted.web import client as webclient +from twisted.web import error as web_error from twisted.internet import defer from twisted.internet import reactor from twisted.internet import protocol @@ -51,6 +52,7 @@ "description": _("""This plugin help to discover our external IP address.""") } +# TODO: GET_IP_PAGE should be configurable in sat.conf GET_IP_PAGE = "http://www.goffi.org/sat_tools/get_ip.php" # This page must only return external IP of the requester GET_IP_LABEL = D_(u"Allow external get IP") GET_IP_CATEGORY = "General" @@ -289,6 +291,9 @@ except (internet_error.DNSLookupError, internet_error.TimeoutError): log.warning(u"Can't access Domain Name System") ip = None + except web_error.Error as e: + log.warning(u"Error while retrieving IP on {url}: {message}".format(url=GET_IP_PAGE, message=e)) + ip = None else: self._external_ip_cache = ip defer.returnValue(ip)