-
Notifications
You must be signed in to change notification settings - Fork 0
/
uptime.py
48 lines (35 loc) · 1.1 KB
/
uptime.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
"""This script converts minutes to the appropriate weeks, days, hours,
and minutes and also calculates yearly uptime.
It uses the BigFloat package http://pythonhosted.org/bigfloat/ and
can be installed using 'sudo pip install bigfloat'
"""
from sys import argv
from bigfloat import div
MINUTES_PER_YEAR = 525949
MINUTES_PER_WEEK = 10080
MINUTES_PER_DAY = 1440
MINUTES_PER_HOUR = 60
script, minutes = argv
minutes = int(minutes)
original_minutes = minutes
if minutes > MINUTES_PER_WEEK:
weeks = minutes / MINUTES_PER_WEEK
minutes -= weeks * MINUTES_PER_WEEK
else:
weeks = 0
print minutes
if minutes > MINUTES_PER_DAY:
days = minutes / MINUTES_PER_DAY
minutes -= days * MINUTES_PER_DAY
else:
days = 0
print minutes
if minutes > MINUTES_PER_HOUR:
hours = minutes / MINUTES_PER_HOUR
minutes -= hours * MINUTES_PER_HOUR
else:
hours = 0
print "%i weeks %i days %i hours %i minutes" % (weeks, days, hours, minutes)
uptime = div((MINUTES_PER_YEAR - original_minutes), (MINUTES_PER_YEAR))*100
print "If you entered total downtime per year in minutes, that's an uptime of "
print uptime