Browse Source

print loaded synapses in console

nico 8 years ago
parent
commit
4301e8c5bd
4 changed files with 13 additions and 7 deletions
  1. 2 0
      core/CrontabManager.py
  2. 1 1
      jarvis.py
  3. 4 4
      test.py
  4. 6 2
      test.yml

+ 2 - 0
core/CrontabManager.py

@@ -1,6 +1,7 @@
 from crontab import CronTab
 from crontab import CronSlices
 
+from core import Utils
 from core.ConfigurationManager.BrainLoader import BrainLoader
 from core.Models import Event
 import logging
@@ -47,6 +48,7 @@ class CrontabManager:
             raise InvalidCrontabPeriod("The crontab period %s is not valid" % period_string)
         # write the file
         my_user_cron.write()
+        Utils.print_info("Synapse \"%s\" added to the crontab" % event_id)
 
     def get_jobs(self):
         return self.my_user_cron.find_comment(CRONTAB_COMMENT)

+ 1 - 1
jarvis.py

@@ -69,7 +69,7 @@ def main():
     if args.action == "load-events":
         crontab_manager = CrontabManager(brain_file=brain_file)
         crontab_manager.load_events_in_crontab()
-        Utils.print_success("Event loaded in crontab")
+        Utils.print_success("Events loaded in crontab")
 
 if __name__ == '__main__':
     main()

+ 4 - 4
test.py

@@ -9,15 +9,15 @@ logger = logging.getLogger()
 logger.setLevel(logging.DEBUG)
 
 
-oa = OrderAnalyser("say hello")
+# oa = OrderAnalyser("wake up", brain_file="/home/nico/Documents/jarvis/test.yml")
 #
 # oa = OrderAnalyser("test", brain_file="brain_examples/fr/fr_systemdate.yml")
 #
-oa.start()
+# oa.start()
 
 # cmd = "python jarvis.py start --run-synapse \"say hello\" --brain-file /home/nico/Documents/jarvis/test.yml"
 #
 # os.system(cmd)
 
-# crontab_manager = CrontabManager(brain_file="/home/nico/Documents/jarvis/test.yml")
-# crontab_manager.load_events_in_crontab()
+crontab_manager = CrontabManager(brain_file="/home/nico/Documents/jarvis/test.yml")
+crontab_manager.load_events_in_crontab()

+ 6 - 2
test.yml

@@ -1,8 +1,12 @@
 ---
-  - name: "say hello"
+  - 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: "23 23 * * *"
+      - event: "20 12 * * *"