-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhealthy programmer.py
More file actions
65 lines (53 loc) · 2.1 KB
/
healthy programmer.py
File metadata and controls
65 lines (53 loc) · 2.1 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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
import time
import pygame
# Music did not played hence I have printed it as well.
def playMusic(file):
print(file)
pygame.init()
pygame.mixer.init()
pygame.mixer.music.load(file)
pygame.mixer.music.play()
def IsOfficeTime(currenttime):
if currenttime > '09:00:00' and currenttime < '17:00:01':
return True
else:
return False
NumberofWaterRemaining = 18
WaterAfterEvery = 1200 # Seconds - 20 minutes
EyeExerciseAfterEvery = 1800 # Seconds - 30 minutes
PhysicalExerciseAfterEvery = 2700 # Seconds - 45 minutes
waterMp3 = 'water.mp3'
eyesMp3 = 'eyes.mp3'
PhysicalMp3 = 'physical.mp3'
currenttime = time.strftime('%H:%M:%S')
WaterTakenAt = time.time()
EyeExerciseAt = time.time()
PhysicalExerciseAt = time.time()
SleepTime = 60 # Sleep time in seconds It will check after every 60 seconds.
while (IsOfficeTime(currenttime)):
# Check for water
if NumberofWaterRemaining > 0:
if (time.time() - WaterTakenAt) > WaterAfterEvery: # water after every 20 minutes
print("Time to drink water")
while True:
playMusic(waterMp3)
if input("Enter Done if you had water: ").lower() == "done":
WaterTakenAt = time.time()
NumberofWaterRemaining -= 1
break
if time.time() - EyeExerciseAt > EyeExerciseAfterEvery:
print("Time to do eye exercise")
while True:
playMusic(eyesMp3)
if input("Enter Done if you done eye exercise : ").lower() == "done":
EyeExerciseAt = time.time()
break
if time.time() - PhysicalExerciseAt > PhysicalExerciseAfterEvery:
print("Time to do Physical exercise")
while True:
playMusic(PhysicalMp3)
if input("Enter Done if you done Physical exercise : ").lower() == "done":
PhysicalExerciseAt = time.time()
break
time.sleep(SleepTime)
currenttime = time.strftime('%H:%M:%S')