changeset 1953:f6d560cabeee

plugin misc ip: fixed exception when a web error happen while retrieving IP from external website
author Goffi <goffi@goffi.org>
date Tue, 26 Apr 2016 19:04:59 +0200 (2016-04-26)
parents 2c1a1b56dd22
children a74047906dfd
files src/plugins/plugin_misc_ip.py
diffstat 1 files changed, 5 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- 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)