Uptime Windows 10 – MacOS – Linux

Obtenir l’Uptime sous windows 10.

Rien d’extraordinaire ici, le but c’est d’afficher l’uptime de l’ordinateur via une interface graphique très simple. Pour fermer l’application il suffit de cliquer dessus.

#-------------------------------------------------------------------------------
# Name:        softs37-Afficher Uptime.pyw
# Purpose:     Afficher l'uptime de l'ordinateur
#
# Author:      cGIfl300
#
# Created:     15/03/2019
# Copyright:   (c) cGIfl300 2019
# Licence:     GPLv3
#    This program is free software: you can redistribute it and/or modify
#    it under the terms of the GNU General Public License as published by
#    the Free Software Foundation, either version 3 of the License, or
#    (at your option) any later version.
#
#    This program is distributed in the hope that it will be useful,
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#    GNU General Public License for more details.
#
#    You should have received a copy of the GNU General Public License
#    along with this program.  If not, see <https://www.gnu.org/licenses/>.
#-------------------------------------------------------------------------------
from s37uptime import *
from tkinter import *

def maj():
    temp = s37uptime()
    afficher = 'L\'ordinateur fonctionne depuis :\n{}h{:02d}minutes'.format(temp[0],
    temp[1])
    affichemoi.set(afficher)
    w.after(10000, maj)

def doQuitter(caraboule):
    w.destroy()

w = Tk()
affichemoi = StringVar()
label01=Label(w, textvariable=affichemoi)
label01.pack()
label01.bind(sequence="<Button>", func=doQuitter)
w.title('Uptime')
w.overrideredirect(1)
maj()
w.mainloop()
#-------------------------------------------------------------------------------
# Name:        s37uptime
# Purpose:     returning computer's uptime to an easy to use format
#
# Author:      cGIfl300
#
# Created:     09/03/2019
#
#    Copyright (C) 2019  cGIfl300
#
#    This program is free software: you can redistribute it and/or modify
#    it under the terms of the GNU General Public License as published by
#    the Free Software Foundation, either version 3 of the License, or
#    (at your option) any later version.
#
#    This program is distributed in the hope that it will be useful,
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#    GNU General Public License for more details.
#
#    You should have received a copy of the GNU General Public License
#    along with this program.  If not, see <https://www.gnu.org/licenses/>.
#-------------------------------------------------------------------------------

from uptime import *

def s37uptime():
    uptimebrut = uptime()
    heure = round(uptimebrut/(3600))
    minutes = round((uptimebrut - heure * 3600)/60)
    if minutes < 0:
        heure = heure - 1
        minutes = round((uptimebrut - heure * 3600)/60)
    return (heure, minutes)

#retour = s37uptime()
#print (retour[0],"h",retour[1],"minutes")