From a167ac93818555a529072b5a50d1fbdf2722baa1 Mon Sep 17 00:00:00 2001 From: Robert Sacks Date: Mon, 5 Jun 2017 03:53:44 -0400 Subject: [PATCH] [modules/publicip] Added option to use own ip retrieval service --- bumblebee/modules/publicip.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/bumblebee/modules/publicip.py b/bumblebee/modules/publicip.py index f6576eb..99899fe 100644 --- a/bumblebee/modules/publicip.py +++ b/bumblebee/modules/publicip.py @@ -5,6 +5,7 @@ Requires the following python packages: Parameters: * publicip.region: us-central (default), us-east, us-west, uk, de, pl, nl + * publicip.service: web address that returns plaintext ip address (ex. "http://l2.io/ip") """ try: @@ -28,6 +29,7 @@ class Module(bumblebee.engine.Module): "nl":"http://tnx.nl/ip", "uk":"http://ident.me"} self._region = self.parameter("region", "us-central") + self._service = self.parameter("service", "") self._ip = "" @@ -36,7 +38,11 @@ class Module(bumblebee.engine.Module): def update(self, widgets): try: - self._ip = get(self._avail_regions[self._region]).text.rstrip() + if self._service: + self.address = self._service + else: + self.address = self._avail_regions[self._region] + self._ip = get(self.address).text.rstrip() except Exception: - self._ip = "Not Connected" + self._ip = "No Connection"