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
|
|
|
|
|
2020-04-15 13:26:08 +02:00
|
|
|
import util.location
|
|
|
|
|
2020-05-03 11:15:52 +02:00
|
|
|
|
2020-04-11 09:20:19 +02:00
|
|
|
class Module(core.module.Module):
|
|
|
|
@core.decorators.every(minutes=60)
|
2020-04-26 16:39:24 +02:00
|
|
|
def __init__(self, config, theme):
|
|
|
|
super().__init__(config, theme, core.widget.Widget(self.public_ip))
|
2020-04-11 09:20:19 +02:00
|
|
|
|
2020-05-03 11:15:52 +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:
|
2020-04-15 13:26:08 +02:00
|
|
|
self.__ip = util.location.public_ip()
|
2020-04-11 09:15:29 +02:00
|
|
|
except Exception:
|
2020-05-03 11:15:52 +02:00
|
|
|
self.__ip = "n/a"
|
|
|
|
|
2020-04-11 09:20:19 +02:00
|
|
|
|
|
|
|
# vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4
|