forked from sukeesh/Jarvis
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
110 lines (82 loc) · 2.75 KB
/
main.py
File metadata and controls
110 lines (82 loc) · 2.75 KB
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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
import os, sys, json
from time import ctime
from pprint import pprint
import pyowm, requests
from colorama import init
from colorama import Fore, Back, Style
import newws, mapps, picshow, evaluator, audioHandler
#reload(sys)
#sys.setdefaultencoding('utf-8')
isSpeech = 0
def go(data):
if isSpeech:
audioHandler.speak(data)
else:
print(data)
def Jarvis(data):
data = str.lower(data)
if "how are you" in data:
go(Fore.BLUE + "I am fine, How about you" + Fore.RESET)
if "what time is it" in data:
go(Fore.BLUE + ctime() + Fore.RESET)
if "open camera" in data:
go("Opening Cheese ...... ")
os.system("cheese")
if "where am i" in data:
mapps.locateme()
if "weather" in data:
mapps.weatherr()
if "near me" in data:
mapps.nearme(data)
if "movies" in data:
try:
movie_name = raw_input(Fore.RED + "What do you want to watch?\n" + Fore.RESET)
except:
movie_name = input(Fore.RED + "What do you want to watch?\n" + Fore.RESET)
os.system("ims " + movie_name)
if "music" in data:
os.system("instantmusic")
if "increase volume" in data:
os.system("pactl -- set-sink-volume 0 +3%")
if "decrease volume" in data:
os.system("pactl -- set-sink-volume 0 -10%")
if "hotspot start" in data:
os.system("sudo ap-hotspot start")
if "hotspot stop" in data:
os.system("sudo ap-hotspot stop")
if "search for a string in file" in data:
try:
file_name = raw_input(Fore.RED + "Enter file name?:\n" + Fore.RESET)
stringg = raw_input(Fore.GREEN + "Enter string:\n" + Fore.RESET)
except:
file_name = input(Fore.RED + "Enter file name?:\n" + Fore.RESET)
stringg = input(Fore.GREEN + "Enter string:\n" + Fore.RESET)
os.system("grep '" + stringg + "' " + file_name)
if "check ram" in data:
os.system("free -lm")
if "todo" in data:
todo.todoHandler(data)
if "news" in data:
newws.show_news()
if "show me pics of" in data:
picshow.showpics(data)
if "evaluate" in data:
tempt = data.split(" ", 1) or ""
if len(tempt) > 1:
evaluator.calc(tempt[1])
else:
print(Fore.RED + "Error : Not in correct format" + Fore.RESET)
if "show me directions from" in data:
mapps.directions(data)
while 1:
if isSpeech:
speak(Fore.RED + "Hi, What can I do for you?" + Fore.RESET)
some = audioHandler.recordAudio()
Jarvis(some)
else:
print(Fore.RED + "Hi, What can I do for you?" + Fore.RESET)
try:
some = raw_input()
except:
some = input()
Jarvis(some)