moniteur/modules/uptime.py

23 lines
647 B
Python

#!/usr/bin/python3
# -*- coding: utf-8 -*-
from curses import color_pair as get_pair
# C'est pour importer des modules du repertoire parent
from os.path import dirname
from sys import path as pythonpath
pythonpath.insert (0, dirname (dirname (__file__)))
from utils import seconds_to_time
def uptime ():
'''
Returns formated uptime
'''
return seconds_to_time (round (float (open ('/proc/uptime').readline ().split ()[0])))
def main (line, screen):
screen.addstr (line, 0, '-->', get_pair (5))
screen.addstr (line, 3, 'Durée de fonctionnement :', get_pair (1))
screen.addstr (line, 29, uptime (), get_pair (2))
line += 1
return (line)