-
Notifications
You must be signed in to change notification settings - Fork 0
/
getToday.py
executable file
·61 lines (49 loc) · 1.71 KB
/
getToday.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
#!/usr/bin/env python
from rtm import *
import sys
import Growl
from rtmconfig import * # load api key and token from rtmconfig
def sendNotify(ts):
if type(ts.task) == list:
for j in range(len(ts.task)):
notifier.notify("today","Task Due: "+ts.task[j].due[:10],ts.name,sticky=True,icon=gIcon)
else:
notifier.notify("today","Task Due: "+ts.task.due[:10],ts.name,sticky=True,icon=gIcon)
if len(sys.argv) == 2:
command = sys.argv[1]
else:
command = "today"
name = "RTMDue"
notifications = ["today","tomorrow"]
notifier = Growl.GrowlNotifier(name,notifications)
notifier.register()
gIcon = Growl.Image.imageFromPath("/Users/bmiller/Projects/RTM/GrowlLogo.png")
if command[:3] == "tod" or command == '':
cutoff = 'today'
elif command[:3] == "tom":
cutoff = 'tomorrow'
else:
cutoff = None
rtm = createRTM(apiKey, secret, token)
if cutoff:
filterString = 'status:incomplete and (due:%s or dueBefore:%s)'%(cutoff,cutoff)
else:
filterString = 'status:incomplete'
theTasks = rtm.tasks.getList(filter=filterString)
if type(theTasks.tasks.list) == list:
for i in range(len(theTasks.tasks.list)):
if type(theTasks.tasks.list[i].taskseries) == list:
for j in range(len(theTasks.tasks.list[i].taskseries)):
ts = theTasks.tasks.list[i].taskseries[j]
sendNotify(ts)
else:
ts = theTasks.tasks.list[i].taskseries
sendNotify(ts)
else:
if type(theTasks.tasks.list.taskseries) == list:
for i in range(len(theTasks.tasks.list.taskseries)):
ts = theTasks.tasks.list.taskseries[i]
sendNotify(ts)
else:
ts = theTasks.tasks.list.taskseries
sendNotify(ts)