from pygame import mixer
from datetime import datetime
from time import time
def song(file,stop):
mixer.init()
mixer.music.load(file)
mixer.music.play()
while True:
a = input()
if a == stop:
mixer.music.stop()
break
def log_now(msg):
with open("mylog.txt", "a") as f:
f.write(f"{msg} {datetime.now()}\n")
print("\n")
if __name__ == '__main__':
init_water = time()
init_eye = time()
init_exe = time()
watersecs = 5
exsecs = 10
eyesecs = 15
while True:
if time() - init_water > watersecs:
print("It's time to drink Water. Enter 'stop' to stop the alarm")
song('Python\Luke-Bergs-Bliss.mp3', 'stop')
init_water = time()
log_now("Drank water at")
if time() - init_eye > eyesecs:
print("It's time to do eye Exercise. Enter 'stop' to stop the alarm")
song('Python\Luke-Bergs-Bliss.mp3', 'stop')
init_eye = time()
log_now("Eye relaxed at")
if time() - init_exe > eyesecs:
print("It's time to do Physical Exercise. Enter 'stop' to stop the alarm")
song('Python\Luke-Bergs-Bliss.mp3', 'stop')
init_exe = time()
log_now("Exercise done at")
break
Comments
Post a Comment