MCPcopy Create free account
hub / github.com/geekcomputers/Python / on_release

Function on_release

JARVIS/JARVIS_2.0.py:169–223  ·  view source on GitHub ↗
(key)

Source from the content-addressed store, hash-verified

167# Run Application with Voice Command Function
168# only_jarvis
169def on_release(key):
170 print("{0} release".format(key))
171 if key == Key.esc():
172 # Stop listener
173 return False
174 """
175class Jarvis:
176 def __init__(self, Q):
177 self.query = Q
178
179 def sub_call(self, exe_file):
180 '''
181 This method can directly use call method of subprocess module and according to the
182 argument(exe_file) passed it returns the output.
183
184 exe_file:- must pass the exe file name as str object type.
185
186 '''
187 return subprocess.call([exe_file])
188
189 def get_dict(self):
190 '''
191 This method returns the dictionary of important task that can be performed by the
192 JARVIS module.
193
194 Later on this can also be used by the user itself to add or update their preferred apps.
195 '''
196 _dict = dict(
197 time=datetime.now(),
198 notepad='Notepad.exe',
199 calculator='calc.exe',
200 stickynot='StickyNot.exe',
201 shell='powershell.exe',
202 paint='mspaint.exe',
203 cmd='cmd.exe',
204 browser='C:\\Program Files\\Internet Explorer\\iexplore.exe',
205 )
206 return _dict
207
208 @property
209 def get_app(self):
210 task_dict = self.get_dict()
211 task = task_dict.get(self.query, None)
212 if task is None:
213 engine.say("Sorry Try Again")
214 engine.runAndWait()
215 else:
216 if 'exe' in str(task):
217 return self.sub_call(task)
218 print(task)
219 return
220
221
222# =======
223"""
224
225
226def get_app(Q):

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected