bumblebee-status/modules/contrib/publicip.py

28 lines
574 B
Python
Raw Normal View History

2020-04-11 09:15:29 +02:00
"""Displays public IP address
"""
2020-04-11 09:20:19 +02:00
import core.module
import core.widget
import core.decorators
import util.location
2020-04-11 09:20:19 +02:00
class Module(core.module.Module):
@core.decorators.every(minutes=60)
def __init__(self, config):
super().__init__(config, core.widget.Widget(self.public_ip))
self.__ip = ''
2020-04-11 09:15:29 +02:00
def public_ip(self, widget):
2020-04-11 09:20:19 +02:00
return self.__ip
2020-04-11 09:15:29 +02:00
2020-04-11 09:20:19 +02:00
def update(self):
2020-04-11 09:15:29 +02:00
try:
self.__ip = util.location.public_ip()
2020-04-11 09:15:29 +02:00
except Exception:
2020-04-11 09:20:19 +02:00
self.__ip = 'n/a'
# vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4