-
Notifications
You must be signed in to change notification settings - Fork 0
/
healthy programer.py
44 lines (38 loc) · 1.31 KB
/
healthy programer.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
from pygame import mixer
from datetime import datetime
from time import time
def musiconloop(file, stopper):
mixer.init()
mixer.music.load(file)
mixer.music.play()
while True:
user_input = input()
if user_input == stopper:
mixer.music.stop()
break
def log_now(msg):
with open("mylogs.txt", "a") as f:
f.write(f"{msg} {datetime.now()}\n")
if __name__ == '__main__':
init_water = time()
init_eyes = time()
init_exercise = time()
watersecs = 40*60
eyesecs = 30*60
exercisesecs = 45*60
while True:
if time() - init_water > watersecs:
print("Water Drinking Time. Enter 'drank' to stop the alarm.")
musiconloop("water.mp3" , "drank")
init_water = time()
log_now("Drank water at ")
if time() - init_eyes > eyesecs:
print("Eye exercise time. Enter 'eyedone' to stop the alarm.")
musiconloop("eye.mp3" , "eyedone")
init_eyes = time()
log_now("Eyes exercise done at ")
if time() - init_exercise > exercisesecs:
print("Physical activity Time. Enter 'exdone' to stop the alarm.")
musiconloop("exercise.mp3" , "exdone")
init_exercise = time()
log_now("Physical Activity done at ")