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

27 lines
931 B
Python
Raw Normal View History

2022-04-30 19:22:10 +02:00
import subprocess
from kalliope.core import NeuronModule
2022-04-30 21:02:46 +02:00
from kalliope.core.NeuronModule import MissingParameterException, MissingParameterException
2022-04-30 19:22:10 +02:00
class Search(NeuronModule):
def __init__(self, **kwargs):
2022-04-30 21:02:46 +02:00
NeuronModule.__init__(self, **kwargs)
2022-04-30 19:22:10 +02:00
self.query = kwargs.get('search', None)
2022-04-30 21:02:46 +02:00
if self._is_parameters_ok():
command = "xdg-open \"https://www.google.fr/search?q="+self.query+"&ie=utf-8&oe=utf-8\""
2022-04-30 19:22:10 +02:00
p = subprocess.Popen(command, shell=True)
2022-04-30 21:02:46 +02:00
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