Fix search can't be used two times
This commit is contained in:
parent
be1cd97916
commit
c8a2c0b634
2 changed files with 17 additions and 6 deletions
|
@ -6,4 +6,4 @@
|
|||
message:
|
||||
- "Recherche effectuée"
|
||||
- search:
|
||||
search: "{{search}}"
|
||||
search: "{{ search }}"
|
|
@ -1,15 +1,26 @@
|
|||
import logging
|
||||
import subprocess
|
||||
|
||||
from kalliope.core import NeuronModule
|
||||
from kalliope.core.NeuronModule import MissingParameterException
|
||||
from kalliope.core.NeuronModule import MissingParameterException, MissingParameterException
|
||||
|
||||
class Search(NeuronModule):
|
||||
def __init__(self, **kwargs):
|
||||
super(Search, self).__init__(**kwargs)
|
||||
NeuronModule.__init__(self, **kwargs)
|
||||
|
||||
self.query = kwargs.get('search', None)
|
||||
|
||||
if self.query is not None:
|
||||
command = "xdg-open \"https://www.google.fr/search?q="+self.query+"&ie=utf-8&oe=utf-8\" &"
|
||||
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
|
||||
|
|
Loading…
Reference in a new issue