Merge branch 'master' into pep8
This commit is contained in:
commit
63a14cb590
2 changed files with 24 additions and 7 deletions
|
@ -41,9 +41,8 @@ class Module(bumblebee.engine.Module):
|
||||||
if not token:
|
if not token:
|
||||||
self._count = 0
|
self._count = 0
|
||||||
return
|
return
|
||||||
|
|
||||||
notifications = requests.get("https://api.github.com/notifications?access_token={}"
|
notifications = requests.get("https://api.github.com/notifications", headers={"Authorization":"token {}".format(token)}).text
|
||||||
.format(token)).text
|
|
||||||
unread = 0
|
unread = 0
|
||||||
for notification in json.loads(notifications):
|
for notification in json.loads(notifications):
|
||||||
if "unread" in notification and notification["unread"]:
|
if "unread" in notification and notification["unread"]:
|
||||||
|
|
|
@ -1,9 +1,15 @@
|
||||||
"""Displays public IP address
|
"""Displays public IP address
|
||||||
|
|
||||||
|
Requires the following python packages:
|
||||||
|
* requests
|
||||||
|
|
||||||
|
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:
|
try:
|
||||||
from urllib2 import urlopen
|
from requests import get
|
||||||
except ImportError:
|
except ImportError:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
@ -15,7 +21,15 @@ class Module(bumblebee.engine.Module):
|
||||||
super(Module, self).__init__(engine, config,
|
super(Module, self).__init__(engine, config,
|
||||||
bumblebee.output.Widget(full_text=self.public_ip)
|
bumblebee.output.Widget(full_text=self.public_ip)
|
||||||
)
|
)
|
||||||
|
self._avail_regions = {"us-east":"http://l2.io/ip",
|
||||||
|
"us-central":"http://whatismyip.akamai.com",
|
||||||
|
"us-west":"http://ipv4bot.whatismyipaddress.com",
|
||||||
|
"pl":"http://ip.42.pl/raw",
|
||||||
|
"de":"http://myexternalip.com/raw",
|
||||||
|
"nl":"http://tnx.nl/ip",
|
||||||
|
"uk":"http://ident.me"}
|
||||||
|
self._region = self.parameter("region", "us-central")
|
||||||
|
self._service = self.parameter("service", "")
|
||||||
self._ip = ""
|
self._ip = ""
|
||||||
|
|
||||||
|
|
||||||
|
@ -24,7 +38,11 @@ class Module(bumblebee.engine.Module):
|
||||||
|
|
||||||
def update(self, widgets):
|
def update(self, widgets):
|
||||||
try:
|
try:
|
||||||
self._ip = urlopen("http://ip.42.pl/raw").read()
|
if self._service:
|
||||||
|
self.address = self._service
|
||||||
|
else:
|
||||||
|
self.address = self._avail_regions[self._region]
|
||||||
|
self._ip = get(self.address).text.rstrip()
|
||||||
except Exception:
|
except Exception:
|
||||||
self._ip = "Not Connected"
|
self._ip = "No Connection"
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue