瀏覽代碼

use **kwargs for plugin management

Nicolas Marcq 8 年之前
父節點
當前提交
94cd35d7a0

+ 2 - 1
README.md

@@ -4,7 +4,7 @@ apt-get install libtts-pico-utils
 ```
 ```
 
 
 
 
-instal flac
+install audio utils
 ```
 ```
 apt-get install flac
 apt-get install flac
 ```
 ```
@@ -13,4 +13,5 @@ Python lib
 ```
 ```
 pip install SpeechRecognition
 pip install SpeechRecognition
 pip install pyaudio
 pip install pyaudio
+pip install ansible
 ```
 ```

+ 20 - 10
brain.yml

@@ -1,14 +1,17 @@
 ---
 ---
   - name: "Say hello"
   - name: "Say hello"
     neurons:
     neurons:
-      - say: "Bonjour monsieur"
+      - say:
+          message: "Bonjour monsieur"
     when:
     when:
       - order: "dis bonjour"
       - order: "dis bonjour"
 
 
   - name: "Run a simple script"
   - name: "Run a simple script"
     neurons:
     neurons:
-      - script: "/home/nico/test.sh"
-      - say: "Script lancé, monsieur"
+      - script:
+        path: "/home/nico/test.sh"
+      - say:
+          message: "Script lancé, monsieur"
     when:
     when:
       - order: "lance le script"
       - order: "lance le script"
 
 
@@ -21,14 +24,16 @@
   - name: "Close rolling shutter"
   - name: "Close rolling shutter"
     neurons:
     neurons:
       - command: "curl http://192.168.0.22:5000/fermeture -d \"password=monpass\" -X POST"
       - command: "curl http://192.168.0.22:5000/fermeture -d \"password=monpass\" -X POST"
-      - say: "Fermeture en cours, monsieur"
+      - say:
+          message: "Fermeture en cours, monsieur"
     when:
     when:
       - order: "ferme les volets"
       - order: "ferme les volets"
 
 
   - name: "Open rolling shutter"
   - name: "Open rolling shutter"
     neurons:
     neurons:
       - command: "curl http://192.168.0.22:5000/ouverture -d \"password=monpass\" -X POST"
       - command: "curl http://192.168.0.22:5000/ouverture -d \"password=monpass\" -X POST"
-      - say: "Ouverture en cours, monsieur"
+      - say:
+          message: "Ouverture en cours, monsieur"
     when:
     when:
       - order: "ouvre les volets"
       - order: "ouvre les volets"
 
 
@@ -36,7 +41,8 @@
     neurons:
     neurons:
       - command: "curl -i --user admin:secret -H \"Content-Type: application/json\" -X POST -d '{\"app_name\":\"kodi\",\"state\":\"stop\"}' http://192.168.0.17:5000/app"
       - command: "curl -i --user admin:secret -H \"Content-Type: application/json\" -X POST -d '{\"app_name\":\"kodi\",\"state\":\"stop\"}' http://192.168.0.17:5000/app"
       - command: "curl -i --user admin:secret -H \"Content-Type: application/json\" -X POST -d '{\"app_name\":\"steam\",\"state\":\"start\"}' http://192.168.0.17:5000/app"
       - command: "curl -i --user admin:secret -H \"Content-Type: application/json\" -X POST -d '{\"app_name\":\"steam\",\"state\":\"start\"}' http://192.168.0.17:5000/app"
-      - say: "Lancement en cours, monsieur"
+      - say:
+          message: "Lancement en cours, monsieur"
     when:
     when:
       - order: "lance steam"
       - order: "lance steam"
 
 
@@ -44,14 +50,16 @@
     neurons:
     neurons:
       - command: "curl -i --user admin:secret -H \"Content-Type: application/json\" -X POST -d '{\"app_name\":\"steam\",\"state\":\"stop\"}' http://192.168.0.17:5000/app"
       - command: "curl -i --user admin:secret -H \"Content-Type: application/json\" -X POST -d '{\"app_name\":\"steam\",\"state\":\"stop\"}' http://192.168.0.17:5000/app"
       - command: "curl -i --user admin:secret -H \"Content-Type: application/json\" -X POST -d '{\"app_name\":\"kodi\",\"state\":\"start\"}' http://192.168.0.17:5000/app"
       - command: "curl -i --user admin:secret -H \"Content-Type: application/json\" -X POST -d '{\"app_name\":\"kodi\",\"state\":\"start\"}' http://192.168.0.17:5000/app"
-      - say: "Lancement en cours, monsieur"
+      - say:
+          message: "Lancement en cours, monsieur"
     when:
     when:
       - order: "lance Cody"
       - order: "lance Cody"
 
 
   - name: "Start music"
   - name: "Start music"
     neurons:
     neurons:
       - command: "curl -i --user admin:secret -H \"Content-Type: application/json\" -X POST -d '{\"app_name\":\"music\",\"state\":\"start\"}' http://192.168.0.17:5000/app"
       - command: "curl -i --user admin:secret -H \"Content-Type: application/json\" -X POST -d '{\"app_name\":\"music\",\"state\":\"start\"}' http://192.168.0.17:5000/app"
-      - say: "Musique lancée, monsieur"
+      - say:
+          message: "Musique lancée, monsieur"
     when:
     when:
       - order: "mais nous de la musique"
       - order: "mais nous de la musique"
       - order: "musique rock"
       - order: "musique rock"
@@ -59,7 +67,8 @@
   - name: "Stop music"
   - name: "Stop music"
     neurons:
     neurons:
       - command: "curl -i --user admin:secret -H \"Content-Type: application/json\" -X POST -d '{\"app_name\":\"music\",\"state\":\"stop\"}' http://192.168.0.17:5000/app"
       - command: "curl -i --user admin:secret -H \"Content-Type: application/json\" -X POST -d '{\"app_name\":\"music\",\"state\":\"stop\"}' http://192.168.0.17:5000/app"
-      - say: "Musique stoppé, monsieur"
+      - say:
+          message: "Musique stoppé, monsieur"
     when:
     when:
       - order: "arrête la musique"
       - order: "arrête la musique"
       - order: "stop la musique"
       - order: "stop la musique"
@@ -68,6 +77,7 @@
   - name: "Ansible test"
   - name: "Ansible test"
     neurons:
     neurons:
       - ansible_tasks: "tasks.yml"
       - ansible_tasks: "tasks.yml"
-      - say: "Tache terminée"
+      - say:
+          message: "Tache terminée"
     when:
     when:
       - order: "playbook"
       - order: "playbook"

+ 1 - 2
core/__init__.py

@@ -1,5 +1,4 @@
-from Neurone import Neurone
+from core.ConfigurationManager.ConfigurationManager import ConfigurationManager
 from core.JarvisTrigger import JarvisTrigger
 from core.JarvisTrigger import JarvisTrigger
 from core.OrderAnalyser import OrderAnalyser
 from core.OrderAnalyser import OrderAnalyser
 from core.OrderListener import OrderListener
 from core.OrderListener import OrderListener
-from core.ConfigurationManager.ConfigurationManager import ConfigurationManager

+ 0 - 4
core/Neurone.py → neurons/Neurone.py

@@ -13,7 +13,3 @@ class Neurone:
         tts_backend = importlib.import_module("tts." + self.tts)
         tts_backend = importlib.import_module("tts." + self.tts)
         tts_backend.say(message)
         tts_backend.say(message)
 
 
-    def debug_kwargs(self, *args, **kwargs):
-        if kwargs is not None:
-            for key, value in kwargs.iteritems():
-                print "%s == %s" % (key, value)

+ 1 - 0
neurons/__init__.py

@@ -1,3 +1,4 @@
+from Neurone import Neurone
 from say import Say
 from say import Say
 from systemdate import Systemdate
 from systemdate import Systemdate
 from script import Script
 from script import Script

+ 1 - 4
neurons/ansible_tasks/ansible_tasks.py

@@ -1,13 +1,10 @@
-#!/usr/bin/env python
-
 from collections import namedtuple
 from collections import namedtuple
 from ansible.parsing.dataloader import DataLoader
 from ansible.parsing.dataloader import DataLoader
 from ansible.vars import VariableManager
 from ansible.vars import VariableManager
 from ansible.inventory import Inventory
 from ansible.inventory import Inventory
-from ansible.playbook import Playbook
 from ansible.executor.playbook_executor import PlaybookExecutor
 from ansible.executor.playbook_executor import PlaybookExecutor
 
 
-from core import Neurone
+from neurons import Neurone
 
 
 
 
 class Ansible_tasks(Neurone):
 class Ansible_tasks(Neurone):

+ 2 - 1
neurons/command/command.py

@@ -1,6 +1,7 @@
-from core import Neurone
 import subprocess
 import subprocess
 
 
+from neurons import Neurone
+
 
 
 class Command(Neurone):
 class Command(Neurone):
     def __init__(self, command):
     def __init__(self, command):

+ 1 - 1
neurons/say/say.py

@@ -1,4 +1,4 @@
-from core import Neurone
+from neurons import Neurone
 
 
 
 
 class Say(Neurone):
 class Say(Neurone):

+ 2 - 1
neurons/script/script.py

@@ -1,7 +1,8 @@
-from core import Neurone
 import subprocess
 import subprocess
 import os
 import os
 
 
+from neurons import Neurone
+
 
 
 class ScriptNotFound(Exception):
 class ScriptNotFound(Exception):
     pass
     pass

+ 2 - 1
neurons/systemdate/systemdate.py

@@ -1,6 +1,7 @@
 #!/usr/bin/python
 #!/usr/bin/python
 import time
 import time
-from core import Neurone
+
+from neurons import Neurone
 
 
 
 
 class Systemdate(Neurone):
 class Systemdate(Neurone):

+ 17 - 0
settings.yml

@@ -0,0 +1,17 @@
+---
+# JARVIS default settings
+# Use YAML syntax
+
+# This is the snowboy hotword file used to wake up jarvis and listen for a new order
+jarvis_trigger: "jarviss.pmdl"
+
+# Default Spreech to Text engine
+# Available engine are:
+# - google
+# -
+default_stt: "google"
+
+# Default Text to Spreech engine
+# Available engine are:
+# - pico2wave
+default_tts: "pico2wave"

+ 3 - 0
test.yml

@@ -1,7 +1,10 @@
 ---
 ---
   - name: "Say hello"
   - name: "Say hello"
     neurons:
     neurons:
+      - command: "/home/nico/tmp/test.sh"
       - systemdate
       - systemdate
+      - say:
+          message: "Commande terminée"
 
 
     when:
     when:
       - order: "dis bonjour"
       - order: "dis bonjour"