1
0
Fork 0
KALLIOPE_FRENCH_PERSONALISA.../resources/neurons/search/search.py

26 lines
931 B
Python

import subprocess
from kalliope.core import NeuronModule
from kalliope.core.NeuronModule import MissingParameterException, MissingParameterException
class Search(NeuronModule):
def __init__(self, **kwargs):
NeuronModule.__init__(self, **kwargs)
self.query = kwargs.get('search', None)
if self._is_parameters_ok():
command = "xdg-open \"https://www.google.fr/search?q="+self.query+"&ie=utf-8&oe=utf-8\""
p = subprocess.Popen(command, shell=True)
self.say("Youpiiiii")
def _is_parameters_ok(self):
"""
Check if received parameters are ok to perform operations in the neuron
:return: true if parameters are ok, raise an exception otherwise
.. raises:: MissingParameterException
"""
if self.query is None:
raise MissingParameterException("Query parameter is missing.")
return True