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
|
|
|
|
|
|
|
|
class Module(core.module.Module):
|
|
|
|
def __init__(self, config):
|
|
|
|
super().__init__(config, core.widget.Widget(self.output))
|
|
|
|
self.__uptime = ''
|
2020-04-13 09:29:16 +02:00
|
|
|
|
|
|
|
def output(self, _):
|
2020-04-13 09:32:29 +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-04-13 09:29:16 +02:00
|
|
|
with open('/proc/uptime', 'r') as f:
|
|
|
|
uptime_seconds = int(float(f.readline().split()[0]))
|
2020-04-13 09:32:29 +02:00
|
|
|
self.__uptime = timedelta(seconds = uptime_seconds)
|
2020-04-13 09:29:16 +02:00
|
|
|
|
|
|
|
# vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4
|