Selaa lähdekoodia

[Doc] Rename gmail_checker into Gmail + doc neuron Gmail

monf 8 vuotta sitten
vanhempi
commit
cc1588d050

+ 4 - 4
Docs/neuron_list.md

@@ -5,14 +5,14 @@ A neuron is a module that will perform some actions attached to an order. You ca
 | Name                                               | Description                                                                             | Used to sort      |
 |----------------------------------------------------|-----------------------------------------------------------------------------------------|-------------------|
 | [ansible_task](../neurons/ansible_task/)           | Run an ansible playbook                                                                 | ansible_task      |
-| [gmail_checker](../neurons/gmail_checker/)         | Get the number of unread email and their subjects from a gmail account                  | gmail_checker     |
-| [kill_switch](../neurons/kill_switch/)             | Stop Kalliope process                                                                     | kill_switch       |
+| [gmail](../neurons/gmail/)                         | Get the number of unread email and their subjects from a gmail account                  | gmail             |
+| [kill_switch](../neurons/kill_switch/)             | Stop Kalliope process                                                                   | kill_switch       |
 | [neurotransmitter](../neurons/neurotransmitter/)   | Link synapse together                                                                   | neurotransmitter  |
 | [push_message](../neurons/push_message/)           | Send a push message to a remote device like Android/iOS/Windows Phone or Chrome browser | push_message      |
-| [say](../neurons/say/)                             | Make Kalliope talk by using TTS                                                           | say               |
+| [say](../neurons/say/)                             | Make Kalliope talk by using TTS                                                         | say               |
 | [script](../neurons/script/)                       | Run an executable script                                                                | script            |
 | [shell](../neurons/command/)                       | Run a shell command                                                                     | shell             |
-| [sleep](../neurons/sleep/)                         | Make Kalliope sleep for a while before continuing                                         | sleep             |
+| [sleep](../neurons/sleep/)                         | Make Kalliope sleep for a while before continuing                                       | sleep             |
 | [systemdate](../neurons/systemdate/)               | Give the local system date and time                                                     | systemdate        |
 | [tasker_autoremote](../neurons/tasker_autoremote/) | Send a message to Android tasker app                                                    | tasker_autoremote |
 | [twitter](../neurons/twitter/)                     | Send a Twit from kalliope                                                               | twitter           |

+ 1 - 1
brain.yml

@@ -1,7 +1,7 @@
 ---
 - includes:
   - brains/ansible_playbook.yml
-  - brains/gmail_checker.yml
+  - brains/gmail.yml
   - brains/kill_switch.yml
   - brains/openweathermap.yml
   - brains/push_message.yml

+ 1 - 1
brains/gmail_checker.yml → brains/gmail.yml

@@ -2,7 +2,7 @@
 
   - name: "check-email"
     neurons:
-      - gmail_checker:
+      - gmail:
           username: "me@gmail.com"
           password: "my_password"
           file_template: fr_gmail.j2

+ 1 - 1
neurons/__init__.py

@@ -5,7 +5,7 @@ from say import Say
 from script import Script
 from sleep import Sleep
 from systemdate import Systemdate
-from gmail_checker import Gmail_checker
+from gmail import Gmail
 from push_message import Push_message
 from openweathermap import Openweathermap
 from tasker_autoremote import Tasker_autoremote

+ 39 - 0
neurons/gmail/README.md

@@ -0,0 +1,39 @@
+# gmail
+
+## Synopsis
+
+This neuron access to Gmail and gives the number of unread mails and their titles.
+
+## Options
+
+| parameter | required | default | choices | comment    |
+|-----------|----------|---------|---------|------------|
+| username  | YES      |         |         | User info. |
+| password  | YES      |         |         | User info. |
+
+## Return Values
+
+| Name     | Description                                  | Type | sample                                                       |
+|----------|----------------------------------------------|------|--------------------------------------------------------------|
+| unread   | Number of unread messages                    | int  | 5                                                            |
+| subjects | A List with all the unread messages subjects | list | ['Kalliope commit', 'Beer tonight?', 'cats have superpower'] |
+
+## Synapses example
+
+Simple example : 
+
+```
+  - name: "check-email"
+    neurons:
+      - gmail:
+          username: "me@gmail.com"
+          password: "my_password"
+          say_template: 
+            -  "You have {{ unread }} new emails"
+    signals:
+      - order: "Do I have emails"
+```
+
+
+## Notes
+

+ 1 - 0
neurons/gmail/__init__.py

@@ -0,0 +1 @@
+from gmail import Gmail

+ 4 - 4
neurons/gmail_checker/gmail_checker.py → neurons/gmail/gmail.py

@@ -1,7 +1,7 @@
 # -*- coding: utf-8 -*-
 import logging
 
-from gmail import Gmail
+from gmail import Gmail as Gmail_lib
 from email.header import decode_header
 from core.NeuronModule import NeuronModule, MissingParameterException
 
@@ -9,9 +9,9 @@ logging.basicConfig()
 logger = logging.getLogger("kalliope")
 
 
-class Gmail_checker(NeuronModule):
+class Gmail(NeuronModule):
     def __init__(self, **kwargs):
-        super(Gmail_checker, self).__init__(**kwargs)
+        super(Gmail, self).__init__(**kwargs)
 
         # check if parameters have been provided
         username = kwargs.get('username', None)
@@ -26,7 +26,7 @@ class Gmail_checker(NeuronModule):
         # prepare a returned dict
         returned_dict = dict()
 
-        g = Gmail()
+        g = Gmail_lib()
         g.login(username, password)
 
         # check if login succeed

+ 0 - 1
neurons/gmail_checker/__init__.py

@@ -1 +0,0 @@
-from gmail_checker import Gmail_checker