Last active
December 31, 2017 06:00
-
-
Save Spuffynism/c3b085683f9139ee9eabb444b95046b0 to your computer and use it in GitHub Desktop.
very quick and dirty pomodoro timer
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
import time | |
import datetime | |
from enum import Enum | |
class TimerType(Enum): | |
POMODORO = (30, ) | |
PAUSE = (5, ) | |
LONG_PAUSE = 10 | |
# https://gist.github.com/dideler/2395703 | |
def getopts(argv): | |
opts = {} | |
while argv: | |
if argv[0][0] == '-': | |
opts[argv[0]] = argv[1] | |
argv = argv[1:] | |
return opts | |
def log(start, end, timer_type): | |
print 'log: ' + str(start) + ':' + str(end) + ':' + timer_type.name | |
def start_timer(timer_type): | |
start = datetime.datetime.now() | |
duration = timer_type.value[0] * 60 | |
end = start + datetime.timedelta(0, duration) | |
print 'Starting ' + timer_type.name + ' at ' + str(start) | |
time.sleep(duration) | |
print 'Done!' | |
log(start, end, timer_type) | |
if __name__ == '__main__': | |
from sys import argv | |
args = getopts(argv) | |
if '-p' in args: | |
start_timer(TimerType.PAUSE) | |
elif '-l' in args: | |
start_timer(TimerType.LONG_PAUSE) | |
else: | |
start_timer(TimerType.POMODORO) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment