Created
October 3, 2012 01:47
-
-
Save uchan-nos/3824452 to your computer and use it in GitHub Desktop.
OS X Mountain Lionの通知センターをPythonから使う
This file contains 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 pyNotificationCenter as nc | |
import sys | |
def runtimer(objective): | |
nc.notify('25 min timer started', None, objective, delay=0, sound=False) | |
nc.notify('25 min timer timeup', None, objective, delay=10, sound=True) | |
def makelogtemplate(objective): | |
import datetime | |
import locale | |
today = datetime.datetime.today() | |
return \ | |
"""%s, Job started | |
Objective: %s | |
Note: | |
""" % (today.strftime('%c'), objective) | |
def writelog(file_name, objective): | |
f = open(file_name, 'a') | |
f.write(makelogtemplate(objective).encode('utf-8')) | |
f.close() | |
if __name__ == '__main__': | |
if len(sys.argv) != 2: | |
print 'Usage: python timer.py "Objective description"' | |
else: | |
objective = sys.argv[1].decode('utf-8') | |
runtimer(objective) | |
writelog('timer.log', objective) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment