forked from bliutwo/pomodoro
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtimedpomodoro.py
77 lines (67 loc) · 2.4 KB
/
timedpomodoro.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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
# Designed for when you have 8+ hours straight to work.
# TODO: Make this play the mp3 file included in the folder.
# http://stackoverflow.com/questions/307305/play-a-sound-with-python
import sys
from pygame_sound import * # TODO: include this when on Linux computer
sys.dont_write_bytecode = True
from Pomodoro import *
import time
def clear_screen():
for i in range(0, 100):
print ""
# TODO: comment or uncomment print \a vs playSound
# takes amount in seconds, sesh is a Pomodoro instance
def time_remaining(amount, sesh, globaltimer):
orig_amount = amount
while amount != 0:
clear_screen()
sesh.printProgress()
if (orig_amount == sesh.get_breaktime() or orig_amount == \
sesh.get_longbreak()):
for i in range(0,10):
print "ON BREAK ON BREAK ON BREAK ON BREAK ON BREAK ON BREAK"
print "\nBreak timer: %d minutes and %d seconds remaining." % ((amount / 60), (amount % 60))
else:
print "\nPomodoro timer: %d minutes and %d seconds remaining." % ((amount / 60), (amount % 60))
amount = amount - 1
if (globaltimer != None):
if globaltimer.done():
break
globaltimer.status()
globaltimer.decrement()
time.sleep(1)
def execute_pomodoro(session, globaltimer):
while session.done() == False:
time_remaining(session.get_pomodoro(), session, globaltimer)
if (globaltimer != None):
if globaltimer.done():
globaltimer.status()
break
playSound("./exclamation.mp3")
#print "\a"
session.add()
if session.done():
session.printProgress()
break
if ((session.get_number_pomo() % 4) == 0):
time_remaining(session.get_longbreak(), session, globaltimer)
else:
time_remaining(session.get_breaktime(), session, globaltimer)
if (globaltimer != None):
if globaltimer.done():
globaltimer.status()
break
playSound("./exclamation.mp3")
#print "\a"
session.printProgress()
playSound("./exclamation.mp3")
#print "\a"
print "\nExiting."
print "DONE!"
def main():
# 27 minutes and 30 seconds = 1650 seconds
sash = Pomodoro()
sash.printProgress()
execute_pomodoro(sash, None)
if __name__ == "__main__":
main()