-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathrtm-test.py
73 lines (54 loc) · 1.91 KB
/
rtm-test.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
#!/usr/bin/env python
import threading
import time
import signal
import curses.wrapper
import curses.ascii
import locale
import logging
import sys
import webbrowser
from rtmcurses.display.display import Display
from rtmcurses.parsers import *
from rtmcurses.rtmapi import Rtm
from rtmcurses import configuration as conf
def main(stdscr):
logging.basicConfig(level=logging.DEBUG)
locale.setlocale(locale.LC_ALL, '')
code = locale.getpreferredencoding()
display = Display(stdscr)
signal.signal(signal.SIGWINCH, display.resize)
systemParser = SystemParser(display)
keyParser = KeyboardShortcutParser(display)
display.statusline.set_status("connecting")
api = Rtm(conf.rtm_api_key, conf.rtm_shared_secret, "delete", conf.rtm_token)
if not api.token_valid():
# manage token retrieval
url, frob = api.authenticate_desktop()
# open webbrowser, wait until user authorized application
webbrowser.open(url)
raw_input("Continue?")
# get the token for the frob
api.retrieve_token(frob)
# print out new token, should be used to initialize the Rtm object next time
# (a real application should store the token somewhere)
print "New token: %s" % api.token
display.statusline.set_status("fetching lists")
result = api.rtm.lists.getList()
for l in result.lists:
display.addView(l.name.lower())
display.statusline.set_status("idle")
display.removeView(0)
display.first()
for i in range(15):
display.addView("testlen %d" % i)
while not display.inputline.stopflag:
input = display.inputline.listen()
if keyParser.canHandle(input):
input = keyParser.handle(input)
if systemParser.canHandle(input):
systemParser.handle(input)
else:
display.write(input)
if __name__ == '__main__':
curses.wrapper(main)