15 lines
398 B
Python
15 lines
398 B
Python
import datetime
|
|
import math
|
|
|
|
class Py3status:
|
|
|
|
def uptime(self):
|
|
with open('/proc/uptime') as f:
|
|
secs = float(f.read().split()[0])
|
|
t = datetime.timedelta(seconds=math.floor(secs))
|
|
if t.days >= 1:
|
|
r = str(t).split(',')[0]
|
|
else:
|
|
r = str(t).rsplit(':', 1)[0]
|
|
return {'full_text': r, 'cached_until': self.py3.time_in(60)}
|