-
Notifications
You must be signed in to change notification settings - Fork 1
/
actions.py
69 lines (66 loc) · 2.14 KB
/
actions.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
from elasticsearch import Elasticsearch
import platform
from subprocess import call
import datetime
import urllib
from elasticsearch import Elasticsearch
import time
p=platform.system()
L="Linux"
W="Windows"
M="Darwin"
es = Elasticsearch()
def open_google():
if p==L:
call(["google-chrome"])
elif p==M:
call(["open","/Applications/Google Chrome.app"])
elif p==W:
call(["start","Path to spotify"])
def open_word():
if p==M:
call(["open","[location of Word]"])
def open_spotify():
if p==M:
call(["open","/Applications/Spotify.app"])
time.sleep(5)
call(["osascript","-e",'tell application "Spotify" to play'])
elif p==W:
call(["start","Path to spotify"])
def computer_volume(vol):
if p==L:
call(["amixer", "-D", "pulse", "sset", "Master", str(vol)+"%"])
elif p==M:
call(["osascript","-e","\"set Volume "+str(vol//10)+"\""])
def computer_mute(bool):
if p==L:
if bool:
call(["amixer", "-D", "pulse", "sset", "Master", "mute"])
else:
call(["amixer", "-D", "pulse", "sset", "Master", "unmute"])
elif p==M:
call(["osascript","-e","\"set volume output muted "+bool.upper()])
def wait_five_sec():
time.sleep(5)
def print_time():
print(datetime.datetime.now())
def get_tweets(hashtag):
result = es.search(index="hacktjfinal", body={"query": {"match": {"message": hashtag}}})
text = ""
for tweet in result['hits']['hits']:
# print(tweet['_source']['user'])
# print(tweet['_source']['message'])
# print()
text += "@" + tweet['_source']['user'] + "\n" + tweet['_source']['message'] + "\n\n"
call(["curl", "-X", "GET", 'localhost:8004/input?text=' + urllib.parse.quote_plus(text)])
def get_tweets_global():
get_tweets('Global Warming')
def get_tweets_refugees():
get_tweets('Refugees')
def get_tweets_yext():
get_tweets('Yext')
if __name__=="__main__":
get_tweets("stock market")
#curl -X PUT localhost:9200/test3/_settings -d {\"index\" : {\"mapping\" : {\"total_fields\" : {\"limit\" : \"5000\"}}}}
#print(platform.system())
#"Linux","Windows","Darwin"