bumblebee-status/modules/contrib/publicip.py

29 lines
589 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, theme):
super().__init__(config, theme, core.widget.Widget(self.public_ip))
2020-04-11 09:20:19 +02:00
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:
self.__ip = "n/a"
2020-04-11 09:20:19 +02:00
# vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4