Skip to content

Instantly share code, notes, and snippets.

@uchan-nos
Created October 3, 2012 01:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save uchan-nos/3824452 to your computer and use it in GitHub Desktop.
Save uchan-nos/3824452 to your computer and use it in GitHub Desktop.
OS X Mountain Lionの通知センターをPythonから使う
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