-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
49 lines (40 loc) · 1.35 KB
/
main.py
File metadata and controls
49 lines (40 loc) · 1.35 KB
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
# Healthy Programmer
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:
input_of_user = input()
if input_of_user == 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__':
# musiconloop("water.mp3", "stop")
init_water = time()
init_eyes = time()
init_exercise = time()
watersecs = 4*60
exsecs = 6*60
eyessecs = 7*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 >eyessecs:
print("Eye exercise time. Enter 'doneeyes' to stop the alarm.")
musiconloop('Eye.mp3', 'doneeyes')
init_eyes = time()
log_now("Eyes Relaxed at")
if time() - init_exercise > exsecs:
print("Physical Activity Time. Enter 'donephy' to stop the alarm.")
musiconloop('Exercise.mp3', 'donephy')
init_exercise = time()
log_now("Physical Activity done at")