-
Notifications
You must be signed in to change notification settings - Fork 1
/
main_legacy.py
56 lines (48 loc) · 1.41 KB
/
main_legacy.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
import twitteroauth
from logger import Logger
from tweet import Tweet
from tweetprocessor import TweetProcessor
from gui import Gui
import time
SEARCH_TERM = 'Chicago'
QUERY_FREQ = 5000
logger = Logger()
api = twitteroauth.getAuthenticatedApi()
tweetprocessor = TweetProcessor()
gui = None
start_time = 0.0
def searchEvent():
results = api.GetSearch(SEARCH_TERM, lang="en")
# Log tweets outside of timer
for result in results:
logger.logTweet(result)
start_time = time.time()
for result in results:
tweet = Tweet(result.text)
tweet.readTweet()
tweetprocessor.processTweet(tweet)
logger.logTiming("legacy", (time.time() - start_time), tweetprocessor.calcHighest())
countAndColor()
def countAndColor():
highest = tweetprocessor.calcHighest()
print '\n\n Highest emotion: ' + highest + '\n\n'
print 'Accumulated so far: '
print tweetprocessor.counts
print '\n\n'
if (highest == 'happy'):
gui.setColor('green')
elif (highest == 'angry'):
gui.setColor('red')
elif (highest == 'sad'):
gui.setColor('blue')
elif (highest == 'profane'):
gui.setColor('orange')
# Do process again after 15 sec
_job = gui.after(QUERY_FREQ, searchEvent)
def quitCallback():
print "Exited."
gui.stopGui()
if __name__ == '__main__':
gui = Gui(quitCallback)
_job = gui.after(QUERY_FREQ, searchEvent)
gui.mainloop()