2020-04-13 09:29:16 +02:00
|
|
|
# pylint: disable=C0111,R0903
|
|
|
|
|
|
|
|
"""Displays the system uptime."""
|
|
|
|
|
|
|
|
from datetime import timedelta
|
|
|
|
|
2020-04-13 09:32:29 +02:00
|
|
|
import core.module
|
|
|
|
import core.widget
|
|
|
|
|
2020-05-03 11:15:52 +02:00
|
|
|
|
2020-04-13 09:32:29 +02:00
|
|
|
class Module(core.module.Module):
|
2020-04-26 16:39:24 +02:00
|
|
|
def __init__(self, config, theme):
|
|
|
|
super().__init__(config, theme, core.widget.Widget(self.output))
|
2020-05-03 11:15:52 +02:00
|
|
|
self.__uptime = ""
|
2020-04-13 09:29:16 +02:00
|
|
|
|
|
|
|
def output(self, _):
|
2020-05-03 11:15:52 +02:00
|
|
|
return "{}".format(self.__uptime)
|
2020-04-13 09:29:16 +02:00
|
|
|
|
2020-04-13 09:32:29 +02:00
|
|
|
def update(self):
|
2020-05-03 11:15:52 +02:00
|
|
|
with open("/proc/uptime", "r") as f:
|
2020-04-13 09:29:16 +02:00
|
|
|
uptime_seconds = int(float(f.readline().split()[0]))
|
2020-05-03 11:15:52 +02:00
|
|
|
self.__uptime = timedelta(seconds=uptime_seconds)
|
|
|
|
|
2020-04-13 09:29:16 +02:00
|
|
|
|
|
|
|
# vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4
|