Bläddra i källkod

Merge pull request #12 from kalliope-project/dev

Dev
Monf 8 år sedan
förälder
incheckning
75693083d8

+ 22 - 0
Docs/brain.md

@@ -97,3 +97,25 @@ signals:
   - order: "say"
 ```
 When you will pronounce "say hello", it will trigger both synapses. 
+
+
+## Split the brain
+
+If you want a better visibly, or simply sort your actions with different file, you can split the main brain file into multiple one.
+
+To do that, use the import statement in the entry brain.yml file with the following syntax:
+
+```
+---
+  - !include path/to/sub_brain.yml
+  - !include path/to/another_sub_brain.yml
+```
+
+E.g:
+```
+---
+  - !include brains/rolling_shutter_commands.yml
+  - !include brains/find_my_phone.yml
+```
+
+>**Note:** You can only use the `!include` statement in the main brain file. 

+ 3 - 1
Docs/dev_env_install.md

@@ -12,7 +12,7 @@ Tested env
 ### Packages installation
 On Ubuntu distribution:
 ```
-sudo apt-get install python-pip python-dev libsmpeg0 libttspico-utils libsmpeg0 flac dialog libffi-dev portaudio19-dev build-essential libssl-dev libffi-dev sox
+sudo apt-get install python-pip python-dev libsmpeg0 libttspico-utils libsmpeg0 flac dialog libffi-dev portaudio19-dev build-essential libssl-dev libffi-dev sox libatlas3-base
 ```
 
 ### Python lib
@@ -29,6 +29,8 @@ pip install python-crontab
 pip install cffi
 pip install pygmail
 pip install pushetta
+pip install wakeonlan
+pip install ipaddress
 pip install pyowm
 ```
 

+ 11 - 197
brain.yml

@@ -1,199 +1,13 @@
 ---
-  - name: "Send push message"
-    neurons:
-      - push_message:
-           message: "Message to send"
-           api_key: "my_token_key"
-           channel_name: "my_chanel_name"
-    signals:
-      - order: "push message"
 
-  - name: "get the weather"
-    neurons:
-      - openweathermap:
-          api_key: "fdfba4097c318aed7836b2a85a6a05ef"
-          lang: "fr"
-          temp_unit: "celsius"
-          location : "grenoble"
-          country: "FR"
-          say_template:
-          - "Aujourd'hui a {{ location }} le temps est {{ weather_today }} avec une température de {{ temp_today_temp }} degrés et demain le temps sera {{ weather_tomorrow }} avec une température de {{ temp_tomorrow_temp }} degrés"
-    signals:
-      - order: "quel temps fait-il "
-
-  - name: "say hello"
-    neurons:
-      - say:
-          message:
-            - "Bonjour monsieur"
-    signals:
-      - order: "dis bonjour"
-
-  - name: "Meaning of life"
-    neurons:
-      - say:
-          message:
-            - "42"
-          tts: "voxygen"
-    signals:
-      - order: "sens de la vie"
-
-  - name: "Run a simple script"
-    neurons:
-      - script:
-          path: "/home/nico/test.sh"
-      - say:
-          message: "Script lancé, monsieur"
-    signals:
-      - order: "lance le script"
-
-  - name: "Say local date"
-    neurons:
-      - systemdate:
-          tts: "voxygen"
-          say_template:
-            - "il est {{ hours }} heure et {{ minutes }} minute"
-    signals:
-      - order: "quelle heure est-il"
-
-  - name: "Say local date from template"
-    neurons:
-      - systemdate:
-          file_template: en_systemdate_template_example.j2
-    signals:
-      - order: "test heure"
-
-  - name: "Close rolling shutter"
-    neurons:
-      - shell:
-          cmd: "curl http://192.168.0.22:5000/fermeture -d \"password=monpass\" -X POST"
-      - say:
-          message: "Fermeture en cours, monsieur"
-    signals:
-      - order: "ferme les volets"
-
-  - name: "Open rolling shutter"
-    neurons:
-      - shell:
-          cmd: "curl http://192.168.0.22:5000/ouverture -d \"password=monpass\" -X POST"
-      - say:
-          message: "Ouverture en cours, monsieur"
-    signals:
-      - order: "ouvre les volets"
-
-  - name: "Start steam"
-    neurons:
-      - shell:
-          cmd: "curl -i --user admin:secret -H \"Content-Type: application/json\" -X POST -d '{\"app_name\":\"kodi\",\"state\":\"stop\"}' http://192.168.0.17:8000/app"
-      - shell:
-          cmd: "curl -i --user admin:secret -H \"Content-Type: application/json\" -X POST -d '{\"app_name\":\"steam\",\"state\":\"start\"}' http://192.168.0.17:8000/app"
-      - say:
-          message: "Lancement en cours, monsieur"
-    signals:
-      - order: "lance Steam"
-
-  - name: "Start Kodi"
-    neurons:
-      - shell:
-          cmd: "curl -i --user admin:secret -H \"Content-Type: application/json\" -X POST -d '{\"app_name\":\"steam\",\"state\":\"stop\"}' http://192.168.0.17:8000/app"
-      - shell:
-          cmd: "curl -i --user admin:secret -H \"Content-Type: application/json\" -X POST -d '{\"app_name\":\"kodi\",\"state\":\"start\"}' http://192.168.0.17:8000/app"
-      - say:
-          message: "Lancement en cours, monsieur"
-    signals:
-      - order: "lance Cody"
-
-  - name: "Start music"
-    neurons:
-      - shell:
-          cmd: "curl -i --user admin:secret -H \"Content-Type: application/json\" -X POST -d '{\"app_name\":\"music\",\"state\":\"start\"}' http://192.168.0.17:8000/app"
-      - say:
-          message: "Musique lancé, monsieur"
-    signals:
-      - order: "mais nous de la musique"
-      - order: "musique rock"
-
-  - name: "Stop music"
-    neurons:
-      - shell:
-          cmd: "curl -i --user admin:secret -H \"Content-Type: application/json\" -X POST -d '{\"app_name\":\"music\",\"state\":\"stop\"}' http://192.168.0.17:8000/app"
-      - say:
-          message: "musique stoppé, monsieur"
-    signals:
-      - order: "arrête la musique"
-      - order: "stop la musique"
-      - order: "éteins la musique"
-
-  - name: "Ansible test"
-    neurons:
-      - ansible_tasks: "tasks.yml"
-      - say:
-          message: "Tache terminée"
-    signals:
-      - order: "playbook"
-
-  - name: "Stop kalliope"
-    neurons:
-      - say:
-          message: "Aurevoir"
-      - kill_switch
-    signals:
-      - order: "ferme-toi"
-
-  - name: "check email"
-    neurons:
-      - gmail_checker:
-          username: "me@gmail.com"
-          password: "my_password"
-          file_template: fr_gmail.j2
-    signals:
-      - order: "est-ce que j'ai des emails"
-
-  - name: "run soundcloud"
-    neurons:
-      - soundcloud:
-          username: "me@gmail.com"
-          password: "my_password"
-          args:
-            - artist_name
-            - music_name
-    signals:
-      - order: "I would like to hear the song {{ music_name }}"
-      - order: "I would like to hear {{ artist_name }}"
-
-  - name: "find my phone"
-    neurons:
-      - say:
-          message: "Je fais sonner le téléphone, monsieur"
-      - tasker_autoremote:
-          key: "APA91bqmY"
-          message: "lost"
-    signals:
-      - order: "où est mon téléphone"
-
-  - name: "test command"
-    neurons:
-      - shell:
-          cmd: "mplayer http://192.99.17.12:6410/"
-          async: True
-      - say:
-          message: "lancé"
-    signals:
-      - order: "test commande"
-
-  - name: "test stop"
-    neurons:
-      - shell:
-          cmd: "pkill mplayer"
-      - say:
-          message: "stopé"
-    signals:
-      - order: "test stop"
-
-  - name: "remove a file"
-    neurons:
-      - shell:
-          cmd: "rm ~/test.txt"
-          file_template: remove_file.j2
-    signals:
-      - order: "rm file"
+  - !include brains/ansible_playbook.yml
+  - !include brains/gmail_checker.yml
+  - !include brains/kill_switch.yml
+  - !include brains/openweathermap.yml
+  - !include brains/push_message.yml
+  - !include brains/say.yml
+  - !include brains/script.yml
+  - !include brains/shell.yml
+  - !include brains/systemdate.yml
+  - !include brains/tasker_autoremote.yml
+  - !include brains/wake_on_lan.yml

+ 9 - 0
brains/ansible_playbook.yml

@@ -0,0 +1,9 @@
+---
+
+  - name: "Ansible test"
+    neurons:
+      - ansible_playbook: "tasks.yml"
+      - say:
+          message: "Tache terminée"
+    signals:
+      - order: "playbook"

+ 10 - 0
brains/gmail_checker.yml

@@ -0,0 +1,10 @@
+---
+
+  - name: "check email"
+    neurons:
+      - gmail_checker:
+          username: "me@gmail.com"
+          password: "my_password"
+          file_template: fr_gmail.j2
+    signals:
+      - order: "est-ce que j'ai des emails"

+ 9 - 0
brains/kill_switch.yml

@@ -0,0 +1,9 @@
+---
+
+  - name: "Stop kalliope"
+    neurons:
+      - say:
+          message: "Aurevoir"
+      - kill_switch
+    signals:
+      - order: "ferme-toi"

+ 13 - 0
brains/openweathermap.yml

@@ -0,0 +1,13 @@
+---
+  - name: "get the weather"
+    neurons:
+      - openweathermap:
+          api_key: "your-api"
+          lang: "fr"
+          temp_unit: "celsius"
+          location : "grenoble"
+          country: "FR"
+          say_template:
+          - "Aujourd'hui a {{ location }} le temps est {{ weather_today }} avec une température de {{ temp_today_temp }} degrés et demain le temps sera {{ weather_tomorrow }} avec une température de {{ temp_tomorrow_temp }} degrés"
+    signals:
+      - order: "quel temps fait-il "

+ 9 - 0
brains/push_message.yml

@@ -0,0 +1,9 @@
+---
+  - name: "Send push message"
+    neurons:
+      - push_message:
+           message: "Message to send"
+           api_key: "my_token_key"
+           channel_name: "my_chanel_name"
+    signals:
+      - order: "push message"

+ 8 - 0
brains/say.yml

@@ -0,0 +1,8 @@
+---
+  - name: "say hello"
+    neurons:
+      - say:
+          message:
+            - "Bonjour monsieur"
+    signals:
+      - order: "bonjour"

+ 9 - 0
brains/script.yml

@@ -0,0 +1,9 @@
+---
+  - name: "Run a simple script"
+    neurons:
+      - script:
+          path: "/home/nico/test.sh"
+      - say:
+          message: "Script lancé, monsieur"
+    signals:
+      - order: "lance le script"

+ 63 - 0
brains/shell.yml

@@ -0,0 +1,63 @@
+---
+
+  - name: "Close rolling shutter"
+    neurons:
+      - shell:
+          cmd: "curl http://192.168.0.22:5000/fermeture -d \"password=monpass\" -X POST"
+      - say:
+          message: "Fermeture en cours, monsieur"
+    signals:
+      - order: "ferme les volets"
+
+  - name: "Open rolling shutter"
+    neurons:
+      - shell:
+          cmd: "curl http://192.168.0.22:5000/ouverture -d \"password=monpass\" -X POST"
+      - say:
+          message: "Ouverture en cours, monsieur"
+    signals:
+      - order: "ouvre les volets"
+
+
+  - name: "Start steam"
+    neurons:
+      - shell:
+          cmd: "curl -i --user admin:secret -H \"Content-Type: application/json\" -X POST -d '{\"app_name\":\"kodi\",\"state\":\"stop\"}' http://192.168.0.17:8000/app"
+      - shell:
+          cmd: "curl -i --user admin:secret -H \"Content-Type: application/json\" -X POST -d '{\"app_name\":\"steam\",\"state\":\"start\"}' http://192.168.0.17:8000/app"
+      - say:
+          message: "Lancement en cours, monsieur"
+    signals:
+      - order: "lance Steam"
+
+  - name: "Start Kodi"
+    neurons:
+      - shell:
+          cmd: "curl -i --user admin:secret -H \"Content-Type: application/json\" -X POST -d '{\"app_name\":\"steam\",\"state\":\"stop\"}' http://192.168.0.17:8000/app"
+      - shell:
+          cmd: "curl -i --user admin:secret -H \"Content-Type: application/json\" -X POST -d '{\"app_name\":\"kodi\",\"state\":\"start\"}' http://192.168.0.17:8000/app"
+      - say:
+          message: "Lancement en cours, monsieur"
+    signals:
+      - order: "lance Cody"
+
+  - name: "Start music"
+    neurons:
+      - shell:
+          cmd: "curl -i --user admin:secret -H \"Content-Type: application/json\" -X POST -d '{\"app_name\":\"music\",\"state\":\"start\"}' http://192.168.0.17:8000/app"
+      - say:
+          message: "Musique lance, monsieur"
+    signals:
+      - order: "mais nous de la musique"
+      - order: "musique rock"
+
+  - name: "Stop music"
+    neurons:
+      - shell:
+          cmd: "curl -i --user admin:secret -H \"Content-Type: application/json\" -X POST -d '{\"app_name\":\"music\",\"state\":\"stop\"}' http://192.168.0.17:8000/app"
+      - say:
+          message: "musique stoppé, monsieur"
+    signals:
+      - order: "arrête la musique"
+      - order: "stop la musique"
+      - order: "éteins la musique"

+ 17 - 0
brains/systemdate.yml

@@ -0,0 +1,17 @@
+---
+
+  - name: "Say local date"
+    neurons:
+      - systemdate:
+          tts: "voxygen"
+          say_template:
+            - "il est {{ hours }} heure et {{ minutes }} minute"
+    signals:
+      - order: "quelle heure est-il"
+
+  - name: "Say local date from template"
+    neurons:
+      - systemdate:
+          file_template: en_systemdate_template_example.j2
+    signals:
+      - order: "test heure"

+ 11 - 0
brains/tasker_autoremote.yml

@@ -0,0 +1,11 @@
+---
+
+  - name: "find my phone"
+    neurons:
+      - say:
+          message: "Je fais sonner le téléphone, monsieur"
+      - tasker_autoremote:
+          key: "APA91bqmY"
+          message: "lost"
+    signals:
+      - order: "où est mon téléphone"

+ 8 - 0
brains/wake_on_lan.yml

@@ -0,0 +1,8 @@
+---
+
+  - name: "wake my PC"
+    neurons:
+      - wake_on_lan:
+          mac_address: "00-00-00-00-00-00"
+    signals:
+      - order: "wake my PC"

+ 3 - 0
core/ConfigurationManager/BrainLoader.py

@@ -42,6 +42,9 @@ class BrainLoader(object):
         synapses = list()
         for synapses_dict in dict_brain:
             # print synapses_dict
+            # if the synapse is a list, it come from an include
+            if isinstance(synapses_dict, list):
+                synapses_dict = synapses_dict[0]
             if ConfigurationChecker().check_synape_dict(synapses_dict):
                 # print "synapses_dict ok"
                 name = synapses_dict["name"]

+ 1 - 1
core/ConfigurationManager/SettingLoader.py

@@ -28,7 +28,7 @@ class SettingLoader(object):
     @classmethod
     def get_yaml_config(cls, file_path=None):
         if file_path is None:
-            file_path = "../../" + FILE_NAME
+            file_path = FILE_NAME
         return YAMLLoader.get_config(file_path)
 
     @classmethod

+ 48 - 8
core/ConfigurationManager/YAMLLoader.py

@@ -1,6 +1,12 @@
+import logging
 import os
 import yaml
 
+from core.Utils import Utils
+
+logging.basicConfig()
+logger = logging.getLogger("kalliope")
+
 
 class YAMLFileNotFound(Exception):
     pass
@@ -17,11 +23,45 @@ class YAMLLoader:
         Load settings file
         :return: cfg : the configuration file
         """
-        # Load settings.
-        __location__ = os.path.realpath(os.path.join(os.getcwd(), os.path.dirname(__file__)))
-        try:
-            with open(os.path.join(__location__, yaml_file)) as ymlfile:
-                cfg = yaml.load(ymlfile)
-            return cfg
-        except IOError:
-            raise YAMLFileNotFound("The file path %s does not exist" % yaml_file)
+        # # Load settings.
+        # __location__ = os.path.realpath(os.path.join(os.getcwd(), os.path.dirname(__file__)))
+        # try:
+        #     with open(os.path.join(__location__, yaml_file)) as ymlfile:
+        #         cfg = yaml.load(ymlfile)
+        #     return cfg
+        # except IOError:
+        #     raise YAMLFileNotFound("The file path %s does not exist" % yaml_file)
+        current_dir = os.path.dirname(os.path.abspath(__file__))
+        logger.debug("Current dir: %s " % current_dir)
+        root_dir = os.path.join(current_dir, "../../")
+        root_dir = os.path.normpath(root_dir)
+        logger.debug("Root dir: %s " % root_dir)
+        file_path_to_load = os.path.join(root_dir, yaml_file)
+        logger.debug("File path to load: %s " % file_path_to_load)
+        if os.path.isfile(yaml_file):
+            data = IncludeLoader(open(file_path_to_load, 'r')).get_data()
+            # print Utils.print_yaml_nicely(data)
+            return data
+        else:
+            raise YAMLFileNotFound("File %s not found" % file_path_to_load)
+
+
+class IncludeLoader(yaml.Loader):
+
+    def __init__(self, *args, **kwargs):
+        super(IncludeLoader, self).__init__(*args, **kwargs)
+        self.add_constructor('!include', self._include)
+        if 'root' in kwargs:
+            self.root = kwargs['root']
+        elif isinstance(self.stream, file):
+            self.root = os.path.dirname(self.stream.name)
+        else:
+            self.root = os.path.curdir
+
+    def _include(self, loader, node):
+        oldRoot = self.root
+        filename = os.path.join(self.root, loader.construct_scalar(node))
+        self.root = os.path.dirname(filename)
+        data = yaml.load(open(filename, 'r'))
+        self.root = oldRoot
+        return data

+ 4 - 0
core/NeuronModule.py

@@ -13,6 +13,10 @@ logging.basicConfig()
 logger = logging.getLogger("kalliope")
 
 
+class InvalidParameterException(Exception):
+    pass
+
+
 class MissingParameterException(Exception):
     pass
 

+ 10 - 0
core/Utils.py

@@ -73,3 +73,13 @@ class Utils(object):
             else:
                 return klass(parameters)
         return None
+
+    @classmethod
+    def print_yaml_nicely(cls, to_print):
+        """
+        Used for debug
+        :param to_print: Dict to print nicely
+        :return:
+        """
+        import json
+        print json.dumps(to_print, indent=2)

+ 2 - 0
install/files/python_requirements.txt

@@ -8,4 +8,6 @@ python-crontab==2.1.1
 cffi==1.8.3
 pygmail==0.0.5.4
 pushetta==1.0.15
+wakeonlan==0.2.2
+ipaddress==1.0.16
 pyowm==2.5.0

+ 3 - 2
install/install.yml

@@ -3,7 +3,7 @@
   gather_facts: no
   connection: local
   vars:
-    - git_url: "git@gitlab.pwit.fr:millionsfortomorrow/kalliope.git"
+    - git_url: "git@github.com:kalliope-project/kalliope.git"
     - temp_local_repo: "/tmp/kalliope_repo"
 
   tasks:
@@ -19,7 +19,7 @@
   connection: local
   become: True
   vars:
-    - git_url: "git@gitlab.pwit.fr:millionsfortomorrow/kalliope.git"
+    - git_url: "git@github.com:kalliope-project/kalliope.git"
     - temp_local_repo: "/tmp/kalliope_repo"
     - install_path: "/usr/lib/kalliope"
   tasks:
@@ -39,6 +39,7 @@
         - libssl-dev
         - libffi-dev
         - sox
+        - libatlas3-base
 
     - name: Copy requirement
       copy:

+ 2 - 1
neurons/__init__.py

@@ -1,4 +1,4 @@
-from ansible_tasks import Ansible_tasks
+from ansible_playbook import Ansible_playbook
 from shell import Shell
 from kill_switch import Kill_switch
 from say import Say
@@ -9,3 +9,4 @@ from gmail_checker import Gmail_checker
 from push_message import Push_message
 from openweathermap import Openweathermap
 from tasker_autoremote import Tasker_autoremote
+from wake_on_lan import Wake_on_lan

+ 1 - 0
neurons/ansible_playbook/__init__.py

@@ -0,0 +1 @@
+from ansible_playbook import Ansible_playbook

+ 2 - 2
neurons/ansible_tasks/ansible_tasks.py → neurons/ansible_playbook/ansible_playbook.py

@@ -7,9 +7,9 @@ from ansible.executor.playbook_executor import PlaybookExecutor
 from core.NeuronModule import NeuronModule
 
 
-class Ansible_tasks(NeuronModule):
+class Ansible_playbook(NeuronModule):
     def __init__(self, task_file, **kwargs):
-        super(Ansible_tasks, self).__init__(**kwargs)
+        super(Ansible_playbook, self).__init__(**kwargs)
         Options = namedtuple('Options',
                              ['connection', 'forks', 'become', 'become_method', 'become_user', 'check', 'listhosts',
                               'listtasks', 'listtags', 'syntax', 'module_path'])

+ 0 - 1
neurons/ansible_tasks/__init__.py

@@ -1 +0,0 @@
-from ansible_tasks import Ansible_tasks

+ 1 - 1
neurons/openweathermap/Openweathermap.py

@@ -12,7 +12,7 @@ class Openweathermap(NeuronModule):
         location = kwargs.get('location', None)
         lang = kwargs.get('lang', 'en')
         temp_unit = kwargs.get('temp_unit', 'celsius')
-        country = kwargs.get('country', 'US')
+        country = kwargs.get('country', None)
 
         if api_key is None:
             raise NotImplementedError("OpenWeatherMap neuron needs an api_key")

+ 50 - 0
neurons/wake_on_lan/README.md

@@ -0,0 +1,50 @@
+# wake_on_lan
+
+## Synopsis
+
+Allows a computer to be turned on or awakened from the [WOL](https://en.wikipedia.org/wiki/Wake-on-LAN) protocol by Kalliope.
+
+## Options
+
+| parameter         | required | default         | choices  | comment                                                                                                                                               |
+|-------------------|----------|-----------------|----------|-------------------------------------------------------------------------------------------------------------------------------------------------------|
+| mac_address       | yes      |                 |          | Mac address of the target PC to wake up. Accepted format: 'ff.ff.ff.ff.ff.ff', '00-00-00-00-00-00', 'FFFFFFFFFFFF'                                    |
+| broadcast_address | no       | 255.255.255.255 |          | Broadcast address where the magic packet will bee sent. By default on most LAN is 255.255.255.255                                                     |
+| port              | no       | 9               |          | The magic packet is typically sent as a UDP datagram to port 0,6 7 or 9. This parameter must be an integer. Do not add 'quotes' in your configuration |
+
+
+## Return Values
+
+None
+
+
+## Synapses example
+
+Kalliope will send a magic packet to the mac address `00-00-00-00-00-00`
+```
+- name: "wake my PC"
+    neurons:
+      - wake_on_lan:
+          mac_address: "00-00-00-00-00-00"
+    signals:
+      - order: "wake my PC"
+```
+
+If your broadcast address is not 255.255.255.255, or if your ethernet card does not listen on the standard 9 port, you can override default parameters.
+In the following example, we suppose that kalliope is on a local areal network 172.16.0.0/16. The broadcast address would be 172.16.255.255.
+```
+- name: "wake my PC"
+    neurons:
+      - wake_on_lan:
+          mac_address: "00-00-00-00-00-00"
+          broadcast_address: "172.16.255.255"
+          port: 7
+    signals:
+      - order: "wake my PC"
+```
+
+## Notes
+
+> **Note:** The target computer must be on the same local area network as Kalliope.
+
+> **Note:** The target computer must has wake on lan activated in BIOS settings and my be in [OS settings](http://www.groovypost.com/howto/enable-wake-on-lan-windows-10/) too.

+ 36 - 0
neurons/wake_on_lan/Wake_on_lan.py

@@ -0,0 +1,36 @@
+import ipaddress
+import logging
+
+from core.NeuronModule import NeuronModule, MissingParameterException, InvalidParameterException
+from wakeonlan import wol
+
+logging.basicConfig()
+logger = logging.getLogger("kalliope")
+
+
+class Wake_on_lan(NeuronModule):
+    def __init__(self, **kwargs):
+        super(Wake_on_lan, self).__init__(**kwargs)
+
+        mac_address = kwargs.get('mac_address', None)
+        broadcast_address = kwargs.get('broadcast_address', '255.255.255.255')
+        port = kwargs.get('port', 9)
+
+        # check we provide a mac address
+        if mac_address is None:
+            raise MissingParameterException("mac_address parameter required")
+
+        # convert to unicode for testing
+        broadcast_address_unicode = broadcast_address.decode('utf-8')
+        # check the ip address is a valid one
+        ipaddress.ip_address(broadcast_address_unicode)
+
+        # check the port
+        if type(port) is not int:
+            raise InvalidParameterException("port argument must be an integer. Remove quotes in your configuration.")
+
+        logger.debug("Call Wake_on_lan_neuron with parameters: mac_address: %s, broadcast_address: %s, port: %s"
+                     % (mac_address, broadcast_address, port))
+
+        # send the magic packet, the mac address format will be check by the lib
+        # wol.send_magic_packet(mac_address, ip_address=broadcast_address, port=port)

+ 1 - 0
neurons/wake_on_lan/__init__.py

@@ -0,0 +1 @@
+from Wake_on_lan import Wake_on_lan

+ 4 - 5
test.py

@@ -4,6 +4,7 @@ import re
 from collections import Counter
 
 from core import OrderAnalyser
+from core.ConfigurationManager import YAMLLoader
 from neurons import Systemdate
 from neurons.tasker_autoremote.tasker_autoremote import Tasker_autoremote
 
@@ -11,11 +12,8 @@ logging.basicConfig()
 logger = logging.getLogger("kalliope")
 logger.setLevel(logging.DEBUG)
 
-
-# order = "musique rock"
-# order = "stop la musique"
-order = "rm file"
-oa = OrderAnalyser(order)
+order = "bonjour"
+oa = OrderAnalyser(order=order)
 oa.start()
 
 
@@ -24,3 +22,4 @@ oa.start()
 
 
 
+

+ 0 - 12
test.yml

@@ -1,12 +0,0 @@
----
-  - name: "wake up"
-    neurons:
-      - say:
-          message:
-            - "Bonjour monsieur"
-      - systemdate:
-          say_template:
-            - "Il est {{ hours }} heures et {{ minutes }} minutes"
-      - command: "mplayer http://192.99.17.12:6410/"
-    signals:
-      - event: "20 12 * * *"