[modules/uptime] Update to new API
This commit is contained in:
parent
6fd0dbd19d
commit
e7b9a0e2f8
1 changed files with 10 additions and 17 deletions
|
@ -2,29 +2,22 @@
|
||||||
|
|
||||||
"""Displays the system uptime."""
|
"""Displays the system uptime."""
|
||||||
|
|
||||||
# Use absolute_import because there's already a datatime module
|
|
||||||
# in the same directory
|
|
||||||
from __future__ import absolute_import
|
|
||||||
|
|
||||||
import bumblebee.input
|
|
||||||
import bumblebee.output
|
|
||||||
import bumblebee.engine
|
|
||||||
|
|
||||||
from datetime import timedelta
|
from datetime import timedelta
|
||||||
|
|
||||||
class Module(bumblebee.engine.Module):
|
import core.module
|
||||||
def __init__(self, engine, config):
|
import core.widget
|
||||||
super(Module, self).__init__(engine, config,
|
|
||||||
bumblebee.output.Widget(full_text=self.output)
|
class Module(core.module.Module):
|
||||||
)
|
def __init__(self, config):
|
||||||
self._uptime = ""
|
super().__init__(config, core.widget.Widget(self.output))
|
||||||
|
self.__uptime = ''
|
||||||
|
|
||||||
def output(self, _):
|
def output(self, _):
|
||||||
return "{}".format(self._uptime)
|
return '{}'.format(self.__uptime)
|
||||||
|
|
||||||
def update(self, widgets):
|
def update(self):
|
||||||
with open('/proc/uptime', 'r') as f:
|
with open('/proc/uptime', 'r') as f:
|
||||||
uptime_seconds = int(float(f.readline().split()[0]))
|
uptime_seconds = int(float(f.readline().split()[0]))
|
||||||
self._uptime = timedelta(seconds = uptime_seconds)
|
self.__uptime = timedelta(seconds = uptime_seconds)
|
||||||
|
|
||||||
# vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4
|
# vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4
|
||||||
|
|
Loading…
Reference in a new issue