Browse Source

[Feature] #138 split neurons

monf 8 years ago
parent
commit
a4141ae978
39 changed files with 0 additions and 1222 deletions
  1. 0 68
      kalliope/neurons/gmail_checker/README.md
  2. 0 1
      kalliope/neurons/gmail_checker/__init__.py
  3. 0 92
      kalliope/neurons/gmail_checker/gmail_checker.py
  4. 0 0
      kalliope/neurons/gmail_checker/tests/__init__.py
  5. 0 37
      kalliope/neurons/gmail_checker/tests/test_gmail_checker.py
  6. 0 93
      kalliope/neurons/openweathermap/README.md
  7. 0 1
      kalliope/neurons/openweathermap/__init__.py
  8. 0 127
      kalliope/neurons/openweathermap/openweathermap.py
  9. 0 0
      kalliope/neurons/openweathermap/tests/__init__.py
  10. 0 36
      kalliope/neurons/openweathermap/tests/test_openweathermap.py
  11. 0 49
      kalliope/neurons/push_message/Readme.md
  12. 0 2
      kalliope/neurons/push_message/__init__.py
  13. 0 43
      kalliope/neurons/push_message/push_message.py
  14. 0 0
      kalliope/neurons/push_message/tests/__init__.py
  15. 0 46
      kalliope/neurons/push_message/tests/test_push_message.py
  16. 0 59
      kalliope/neurons/rss_reader/README.md
  17. 0 1
      kalliope/neurons/rss_reader/__init__.py
  18. 0 45
      kalliope/neurons/rss_reader/rss_reader.py
  19. 0 0
      kalliope/neurons/rss_reader/tests/__init__.py
  20. 0 23
      kalliope/neurons/rss_reader/tests/test_rss_reader.py
  21. 0 83
      kalliope/neurons/tasker_autoremote/Readme.md
  22. 0 1
      kalliope/neurons/tasker_autoremote/__init__.py
  23. BIN
      kalliope/neurons/tasker_autoremote/images/profile_auto_remote.png
  24. BIN
      kalliope/neurons/tasker_autoremote/images/profile_display_unlocked.png
  25. BIN
      kalliope/neurons/tasker_autoremote/images/task_play_music.png
  26. BIN
      kalliope/neurons/tasker_autoremote/images/task_stop_music.png
  27. 0 41
      kalliope/neurons/tasker_autoremote/tasker_autoremote.py
  28. 0 0
      kalliope/neurons/tasker_autoremote/tests/__init__.py
  29. 0 36
      kalliope/neurons/tasker_autoremote/tests/test_tasker_autoremote.py
  30. 0 51
      kalliope/neurons/twitter/README.md
  31. 0 1
      kalliope/neurons/twitter/__init__.py
  32. 0 0
      kalliope/neurons/twitter/tests/__init__.py
  33. 0 68
      kalliope/neurons/twitter/tests/test_twitter_neuron.py
  34. 0 53
      kalliope/neurons/twitter/twitter.py
  35. 0 50
      kalliope/neurons/wake_on_lan/README.md
  36. 0 1
      kalliope/neurons/wake_on_lan/__init__.py
  37. 0 0
      kalliope/neurons/wake_on_lan/tests/__init__.py
  38. 0 67
      kalliope/neurons/wake_on_lan/tests/test_wake_on_lan.py
  39. 0 47
      kalliope/neurons/wake_on_lan/wake_on_lan.py

+ 0 - 68
kalliope/neurons/gmail_checker/README.md

@@ -1,68 +0,0 @@
-# gmail_checker
-
-## 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"
-    signals:
-      - order: "Do I have emails"
-    neurons:
-      - gmail_checker:
-          username: "me@gmail.com"
-          password: "my_password"
-          say_template: 
-            -  "You have {{ unread }} new emails"    
-```
-
-A complex example that read subject emails. This is based on a file_template
-```
-  - name: "check-email"
-    signals:
-      - order: "Do I have emails"
-    neurons:
-      - gmail_checker:
-          username: "me@gmail.com"
-          password: "my_password"
-          file_template: /templates/my_email_template.j2
-```
-
-Here the content of the `my_email_template.j2`
-```
-You have {{ unread }} email
-
-{% set count = 1 %}
-{% if unread > 0 %}
-    {% for subject in subjects %}
-     email number {{ count }}. {{ subject }}
-     {% set count = count + 1 %}
-    {% endfor %}
-{% endif %}
-```
-## Notes
-
-Gmail now prevent some mailbox to be accessed from tier application. If you receive a mail like the following:
-```
-Sign-in attempt prevented ... Someone just tried to sign in to your Google Account mail@gmail.com from an app that doesn't meet modern security standards.
-```
-
-You can allow this neuron to get un access to your email in your [Gmail account settings](https://www.google.com/settings/security/lesssecureapps).

+ 0 - 1
kalliope/neurons/gmail_checker/__init__.py

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

+ 0 - 92
kalliope/neurons/gmail_checker/gmail_checker.py

@@ -1,92 +0,0 @@
-# -*- coding: utf-8 -*-
-import logging
-
-from gmail import Gmail
-from email.header import decode_header
-from kalliope.core.NeuronModule import NeuronModule, MissingParameterException
-
-logging.basicConfig()
-logger = logging.getLogger("kalliope")
-
-
-class Gmail_checker(NeuronModule):
-    def __init__(self, **kwargs):
-        super(Gmail_checker, self).__init__(**kwargs)
-
-        self.username = kwargs.get('username', None)
-        self.password = kwargs.get('password', None)
-
-        # check if parameters have been provided
-        if self._is_parameters_ok():
-
-            # prepare a returned dict
-            returned_dict = dict()
-
-            g = Gmail()
-            g.login(self.username, self.password)
-
-            # check if login succeed
-            logging.debug("Gmail loggin ok: %s" % g.logged_in)  # Should be True, AuthenticationError if login fails
-
-            # get unread mail
-            unread = g.inbox().mail(unread=True)
-
-            returned_dict["unread"] = len(unread)
-
-            if len(unread) > 0:
-                # add a list of subject
-                subject_list = list()
-                for email in unread:
-                    email.fetch()
-                    encoded_subject = email.subject
-                    subject = self._parse_subject(encoded_subject)
-                    subject_list.append(subject)
-
-                returned_dict["subjects"] = subject_list
-
-            logger.debug("gmail neuron returned dict: %s" % str(returned_dict))
-
-            # logout of gmail
-            g.logout()
-            self.say(returned_dict)
-
-    def _parse_subject(self, encoded_subject):
-        dh = decode_header(encoded_subject)
-
-        return ''.join([self.try_parse(t[0], t[1]) for t in dh])
-
-    @staticmethod
-    def try_parse(header, encoding):
-        """
-        Verifying the Encoding and return unicode
-
-        :param header: the header to decode
-        :param encoding: the targeted encoding
-        :return: either 'ASCII' or 'ISO-8859-1' or 'UTF-8'
-
-        .. raises:: UnicodeDecodeError
-        """
-        if encoding is None:
-            encoding = 'ASCII'
-        try:
-            return unicode(header, encoding)
-        except UnicodeDecodeError:
-            try:
-                return unicode(header, 'ISO-8859-1')
-            except UnicodeDecodeError:
-                return unicode(header, 'UTF-8')
-
-    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.username is None:
-            raise MissingParameterException("Username parameter required")
-
-        if self.password is None:
-            raise MissingParameterException("Password parameter required")
-
-        return True

+ 0 - 0
kalliope/neurons/gmail_checker/tests/__init__.py


+ 0 - 37
kalliope/neurons/gmail_checker/tests/test_gmail_checker.py

@@ -1,37 +0,0 @@
-import unittest
-
-from kalliope.core.NeuronModule import MissingParameterException
-from kalliope.neurons.gmail_checker.gmail_checker import Gmail_checker
-
-
-class TestGmail_Checker(unittest.TestCase):
-
-    def setUp(self):
-        self.username="username"
-        self.password="password"
-
-    def testParameters(self):
-        def run_test(parameters_to_test):
-            with self.assertRaises(MissingParameterException):
-                Gmail_checker(**parameters_to_test)
-
-        # empty
-        parameters = dict()
-        run_test(parameters)
-
-        # missing password
-        parameters = {
-            "username": self.username
-        }
-        run_test(parameters)
-
-        # missing username
-        parameters = {
-           "password": self.password
-        }
-        run_test(parameters)
-
-
-if __name__ == '__main__':
-    unittest.main()
-

+ 0 - 93
kalliope/neurons/openweathermap/README.md

@@ -1,93 +0,0 @@
-# OpenWeatherMap API
-
-## Synopsis 
-
-Give the today and tomorrow weather with the related data (humidity, temperature, etc ...) for a given location. 
-
-## Options
-
-| parameter | required | default | choices                     | comment                                                                                           |
-|-----------|----------|---------|-----------------------------|---------------------------------------------------------------------------------------------------|
-| api_key   | YES      | None    |                             | User API key of the OWM API                                                                       |
-| location  | YES      | None    |                             | The location                                                                                      |
-| lang      | No       | en      | multiple                    | First 2 letters cf : section Multilingual support in : [lang](https://openweathermap.org/current) |
-| temp_unit | No       | Kelvin  | Celsius, Kelvin, Fahrenheit |                                                                                                   |
-| country   | No       | US      | multiple                    |  Frist 2 letters of the country cf API doc                                                        |
-
-## Return Values
-
-| Name                        | Description                                | Type   | sample                 |
-|-----------------------------|--------------------------------------------|--------|------------------------|
-| location                    | The current location                       | String | Grenoble               |
-| weather_today               | Today : The weather sentence               | String | cloudy                 |
-| sunset_today_time           | Today : The sunset time (iso)              | String | 2016-10-15 20:07:57+00 |
-| sunrise_today_time          | Today : The sunrise time (iso)             | String | 2016-10-15 07:07:57+00 |
-| temp_today_temp             | Today : Average temperature                | float  | 25                     |
-| temp_today_temp_max         | Today : Max temperature                    | float  | 45                     |
-| temp_today_temp_min         | Today : Min temperatue                     | float  | 5                      |
-| pressure_today_press        | Today : Pressure                           | float  | 1009                   |
-| pressure_today_sea_level    | Today : Pressure at the Sea level          | float  | 1038.381               |
-| humidity_today              | Today : % of humidity                      | float  | 60                     |
-| wind_today_deg              | Today : Direction of the wind in degree    | float  | 45                     |
-| wind_today_speed            | Today : Wind speed                         | float  | 2.66                   |
-| snow_today                  | Today : Volume of snow                     | float  | 0                      |
-| rain_today                  | Today : Rain volume                        | float  | 0                      |
-| clouds_coverage_today       | Today : % Cloud coverage                   | float  | 65                     |
-| weather_tomorrow            | Tomorrow : The weather sentence            | String | sunny                  |
-| sunset_time_tomorrow        | Tomorrow : The sunset time (iso)           | String | 2016-10-16 20:07:57+00 |
-| sunrise_time_tomorrow       | Tomorrow : The sunrise time (iso)          | String | 2016-10-16 07:07:57+00 |
-| temp_tomorrow_temp          | Tomorrow : Average temperature             | float  | 25                     |
-| temp_tomorrow_temp_max      | Tomorrow : Max temperature                 | float  | 45                     |
-| temp_tomorrow_temp_min      | Tomorrow : Min temperatue                  | float  | 5                      |
-| pressure_tomorrow_press     | Tomorrow : Pressure                        | float  | 1009                   |
-| pressure_tomorrow_sea_level | Tomorrow : Pressure at the Sea level       | float  | 1038.381               |
-| humidity_tomorrow           | Tomorrow : % of humidity                   | float  | 60                     |
-| wind_tomorrow_deg           | Tomorrow : Direction of the wind in degree | float  | 45                     |
-| wind_tomorrow_speed         | Tomorrow : Wind speed                      | float  | 2.66                   |
-| snow_tomorrow               | Tomorrow : Volume of snow                  | float  | 0                      |
-| rain_tomorrow               | Tomorrow : Rain volume                     | float  | 0                      |
-| clouds_coverage_tomorrow    | Tomorrow : % Cloud coverage                | float  | 65                     |
-
-## Synapses example
-
-```
-  - name: "getthe-weather"
-    signals:
-      - order: "what is the weather in {{ location }}"
-    neurons:
-      - openweathermap:
-          api_key: "fdfba4097c318aed7836b2a85a6a05ef"
-          lang: "en"
-          temp_unit: "celsius"
-          say_template:
-          - "Today in {{ location }} the weather is {{ weather_today }} with a temperature of {{ temp_today_temp }} degree and tomorrow the weather will be {{ weather_tomorrow }} with a temperature of {{ temp_tomorrow_temp }} degree"
-          args:
-          - location
-```
-
-You also can define the "location" args directly in neuron argument list. 
-```
-  - name: "get-the-weather"
-    signals:
-      - order: "quel temps fait-il"
-    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"
-```
-
-## Templates example 
-
-```
-Today in {{ location }} the weather is {{ weather_today }} with a temperature of {{ temp_today_temp }} degree
-```
-
-
-## Notes
-
-> **Note:** You need to create a free account on [openweathermap.org](http://openweathermap.org/) to get your API key.

+ 0 - 1
kalliope/neurons/openweathermap/__init__.py

@@ -1 +0,0 @@
-from openweathermap import Openweathermap

+ 0 - 127
kalliope/neurons/openweathermap/openweathermap.py

@@ -1,127 +0,0 @@
-import pyowm
-
-from kalliope.core.NeuronModule import NeuronModule, MissingParameterException
-
-
-class Openweathermap(NeuronModule):
-    def __init__(self, **kwargs):
-        # get message to spell out loud
-        super(Openweathermap, self).__init__(**kwargs)
-
-        self.api_key = kwargs.get('api_key', None)
-        self.location = kwargs.get('location', None)
-        self.lang = kwargs.get('lang', 'en')
-        self.temp_unit = kwargs.get('temp_unit', 'celsius')
-        self.country = kwargs.get('country', None)
-
-        # check if parameters have been provided
-        if self._is_parameters_ok():
-            extended_location = self.location
-            if self.country is not None:
-                extended_location = self.location + "," + self.country
-
-
-            owm = pyowm.OWM(API_key=self.api_key, language=self.lang)
-
-            # Tomorrow
-            forecast = owm.daily_forecast(extended_location)
-            tomorrow = pyowm.timeutils.tomorrow()
-            weather_tomorrow = forecast.get_weather_at(tomorrow)
-            weather_tomorrow_status = weather_tomorrow.get_detailed_status()
-            sunset_time_tomorrow = weather_tomorrow.get_sunset_time('iso')
-            sunrise_time_tomorrow = weather_tomorrow.get_sunrise_time('iso')
-
-            temp_tomorrow = weather_tomorrow.get_temperature(unit=self.temp_unit)
-            temp_tomorrow_temp = temp_tomorrow['day']
-            temp_tomorrow_temp_max = temp_tomorrow['max']
-            temp_tomorrow_temp_min = temp_tomorrow['min']
-
-            pressure_tomorrow = weather_tomorrow.get_pressure()
-            pressure_tomorrow_press = pressure_tomorrow['press']
-            pressure_tomorrow_sea_level = pressure_tomorrow['sea_level']
-
-            humidity_tomorrow = weather_tomorrow.get_humidity()
-
-            wind_tomorrow = weather_tomorrow.get_wind()
-            # wind_tomorrow_deg = wind_tomorrow['deg']
-            wind_tomorrow_speed = wind_tomorrow['speed']
-
-            snow_tomorrow = weather_tomorrow.get_snow()
-            rain_tomorrow = weather_tomorrow.get_rain()
-            clouds_coverage_tomorrow = weather_tomorrow.get_clouds()
-
-            # Today
-            observation = owm.weather_at_place(extended_location)
-            weather_today = observation.get_weather()
-            weather_today_status = weather_today.get_detailed_status()
-            sunset_time_today = weather_today.get_sunset_time('iso')
-            sunrise_time_today = weather_today.get_sunrise_time('iso')
-
-            temp_today = weather_today.get_temperature(unit=self.temp_unit)
-            temp_today_temp = temp_today['temp']
-            temp_today_temp_max = temp_today['temp_max']
-            temp_today_temp_min = temp_today['temp_min']
-
-            pressure_today = weather_today.get_pressure()
-            pressure_today_press = pressure_today['press']
-            pressure_today_sea_level = pressure_today['sea_level']
-
-            humidity_today = weather_today.get_humidity()
-
-            wind_today= weather_today.get_wind()
-            wind_today_deg = wind_today['deg']
-            wind_today_speed = wind_today['speed']
-
-            snow_today = weather_today.get_snow()
-            rain_today = weather_today.get_rain()
-            clouds_coverage_today = weather_today.get_clouds()
-
-            message = {
-                "location": self.location,
-
-                "weather_today": weather_today_status,
-                "sunset_today_time": sunset_time_today,
-                "sunrise_today_time": sunrise_time_today,
-                "temp_today_temp": temp_today_temp,
-                "temp_today_temp_max": temp_today_temp_max,
-                "temp_today_temp_min": temp_today_temp_min,
-                "pressure_today_press": pressure_today_press,
-                "pressure_today_sea_level": pressure_today_sea_level,
-                "humidity_today": humidity_today,
-                "wind_today_deg": wind_today_deg,
-                "wind_today_speed": wind_today_speed,
-                "snow_today": snow_today,
-                "rain_today": rain_today,
-                "clouds_coverage_today": clouds_coverage_today,
-
-                "weather_tomorrow": weather_tomorrow_status,
-                "sunset_time_tomorrow": sunset_time_tomorrow,
-                "sunrise_time_tomorrow": sunrise_time_tomorrow,
-                "temp_tomorrow_temp": temp_tomorrow_temp,
-                "temp_tomorrow_temp_max": temp_tomorrow_temp_max,
-                "temp_tomorrow_temp_min": temp_tomorrow_temp_min,
-                "pressure_tomorrow_press": pressure_tomorrow_press,
-                "pressure_tomorrow_sea_level": pressure_tomorrow_sea_level,
-                "humidity_tomorrow": humidity_tomorrow,
-                # "wind_tomorrow_deg": wind_tomorrow_deg,
-                "wind_tomorrow_speed": wind_tomorrow_speed,
-                "snow_tomorrow": snow_tomorrow,
-                "rain_tomorrow": rain_tomorrow,
-                "clouds_coverage_tomorrow": clouds_coverage_tomorrow
-            }
-
-            self.say(message)
-
-    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:: NotImplementedError
-        """
-        if self.api_key is None:
-            raise MissingParameterException("OpenWeatherMap neuron needs an api_key")
-        if self.location is None:
-            raise MissingParameterException("OpenWeatherMap neuron needs a location")
-
-        return True

+ 0 - 0
kalliope/neurons/openweathermap/tests/__init__.py


+ 0 - 36
kalliope/neurons/openweathermap/tests/test_openweathermap.py

@@ -1,36 +0,0 @@
-import unittest
-
-from kalliope.core.NeuronModule import MissingParameterException
-from kalliope.neurons.openweathermap.openweathermap import Openweathermap
-
-
-class TestOpenWeatherMap(unittest.TestCase):
-
-    def setUp(self):
-        self.location="location"
-        self.api_key="api_key"
-
-    def testParameters(self):
-        def run_test(parameters_to_test):
-            with self.assertRaises(MissingParameterException):
-                Openweathermap(**parameters_to_test)
-
-        # empty
-        parameters = dict()
-        run_test(parameters)
-
-        # missing api_key
-        parameters = {
-            "location": self.location
-        }
-        run_test(parameters)
-
-        # missing location
-        parameters = {
-           "api_key": self.api_key
-        }
-        run_test(parameters)
-
-
-if __name__ == '__main__':
-    unittest.main()

+ 0 - 49
kalliope/neurons/push_message/Readme.md

@@ -1,49 +0,0 @@
-# Push notification
-
-## Synopsis
-
-Send broadcast communications to groups of subscribers.
-
-Available client are:
-- Android phone
-- iOS phone/
-- Windows Phone
-- Chrome Browser
-
-This neuron is based on [Pushetta API](http://www.pushetta.com/). 
-You need to [create a free account](http://www.pushetta.com/accounts/signup/) and a chanel before using it.
-You need to install a [client App](http://www.pushetta.com/pushetta-downloads/) on the target device.
-
-## Options
-
-| parameter    | requiered | default | choices | comment                                                                                               |
-|--------------|-----------|---------|---------|-------------------------------------------------------------------------------------------------------|
-| message      | yes       |         |         | Message that will be send to the android phone                                                        |
-| api_key      | yes       |         |         | Token API key availlable from [Pushetta dashboard](http://www.pushetta.com/my/dashboard/) |
-| channel_name | yes       |         |         | Name of the subscribed [channel](http://www.pushetta.com/pushetta-docs/#create)                       |
-
-
-## Return Values
-
-No returned value
-
-
-## Synapses example
-
-The following synapse will send a push message to device that have subscribed to the channel name "my_chanel_name" when you say "push message".
-```
- - name: "send-push-message"
-   signals:
-      - order: "push message"
-   neurons:
-     - android_pushetta:
-         message: "Message to send"
-         api_key: "TOEKENEXAMPLE1234"
-         channel_name: "my_chanel_name"    
-```
-
-## Notes
-
-> **Note:** You must install a [client App](http://www.pushetta.com/pushetta-downloads/) on the target device.
-
-> **Note:** You must create a channel an get a token key on [Pushetta website](http://www.pushetta.com/) before using the neuron.

+ 0 - 2
kalliope/neurons/push_message/__init__.py

@@ -1,2 +0,0 @@
-from push_message import Push_message
-

+ 0 - 43
kalliope/neurons/push_message/push_message.py

@@ -1,43 +0,0 @@
-from __future__ import absolute_import
-from pushetta import Pushetta
-
-from kalliope.core.NeuronModule import NeuronModule, MissingParameterException
-
-
-class Push_message(NeuronModule):
-    """
-    Neuron based on pushetta api. http://www.pushetta.com/
-    """
-    def __init__(self, **kwargs):
-        """
-        Send a push message to an android phone via Pushetta API
-        :param message: Message to send
-        :param api_key: The Pushetta service secret token
-        :param channel_name: Pushetta channel name
-        """
-        super(Push_message, self).__init__(**kwargs)
-
-        self.message = kwargs.get('message', None)
-        self.api_key = kwargs.get('api_key', None)
-        self.channel_name = kwargs.get('channel_name', None)
-
-        # check if parameters have been provided
-        if self._is_parameters_ok():
-            p = Pushetta(self.api_key)
-            p.pushMessage(self.channel_name, self.message)
-
-    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:: NotImplementedError
-        """
-        if self.message is None:
-            raise MissingParameterException("Pushetta neuron needs message to send")
-        if self.api_key is None:
-            raise MissingParameterException("Pushetta neuron needs api_key")
-        if self.channel_name is None:
-            raise MissingParameterException("Pushetta neuron needs channel_name")
-
-        return True

+ 0 - 0
kalliope/neurons/push_message/tests/__init__.py


+ 0 - 46
kalliope/neurons/push_message/tests/test_push_message.py

@@ -1,46 +0,0 @@
-import unittest
-
-from kalliope.core.NeuronModule import MissingParameterException
-from kalliope.neurons.push_message.push_message import Push_message
-
-
-class TestPush_Message(unittest.TestCase):
-
-    def setUp(self):
-        self.message="message"
-        self.api_key="api_key"
-        self.channel_name = "channel_name"
-
-    def testParameters(self):
-        def run_test(parameters_to_test):
-            with self.assertRaises(MissingParameterException):
-                Push_message(**parameters_to_test)
-
-        # empty
-        parameters = dict()
-        run_test(parameters)
-
-        # missing api_key
-        parameters = {
-            "message": self.message,
-            "channel_name": self.channel_name
-        }
-        run_test(parameters)
-
-        # missing channel_name
-        parameters = {
-           "api_key": self.api_key,
-            "message":self.message
-        }
-        run_test(parameters)
-
-        # missing message
-        parameters = {
-            "api_key": self.api_key,
-            "channel_name": self.channel_name
-        }
-        run_test(parameters)
-
-
-if __name__ == '__main__':
-    unittest.main()

+ 0 - 59
kalliope/neurons/rss_reader/README.md

@@ -1,59 +0,0 @@
-# rss_reader
-
-## Synopsis
-
-This neuron access to a RSS feed and gives their items.
-
-## Options
-
-| parameter | required | default | choices | comment               |
-|-----------|----------|---------|---------|-----------------------|
-| feed_url  | YES      |         |         | Url of the feed.      |
-| max_items | NO       | 30      |         | Max items to returns. |
-
-## Return Values
-
-| Name     | Description                                                                            | Type    | sample                          |
-|----------|----------------------------------------------------------------------------------------|---------|---------------------------------|
-| feed     | Title of the feed                                                                      | string  | The Verge                       |
-| items    | A List with feed items (see [RSS spec](https://validator.w3.org/feed/docs/rss2.html))  | list    |                                 |
-
-## Synapses example
-
-Simple example. This is based on a file_template
-
-```
-  - name: "news-theVerge"
-    signals:
-      - order: "What are the news from the verge ?"
-    neurons:
-      - rss_reader:
-          feed_url: "http://www.theverge.com/rss/index.xml"
-          file_template: templates/en_rss.j2
-          
-```
-
-A example with max items set to 10. This is based on a file_template
-```
-  - name: "news-sport"
-    signals:
-      - order: "What are the sport news ?"
-    neurons:
-      - rss_reader:
-          feed_url: "https://sports.yahoo.com/top/rss.xml"
-          max_items: 10
-          file_template: templates/en_rss.j2    
-```
-
-Here the content of the `en_rss.j2`
-```
-Here's the news from {{ feed }}
-
-{% set count = 1 %}
-{% for item in items %}
-News {{ count }}. {{ item.title }}.
-{% set count = count + 1 %}
-{% endfor %}
-```
-## Notes
-

+ 0 - 1
kalliope/neurons/rss_reader/__init__.py

@@ -1 +0,0 @@
-from rss_reader import Rss_reader

+ 0 - 45
kalliope/neurons/rss_reader/rss_reader.py

@@ -1,45 +0,0 @@
-# -*- coding: utf-8 -*-
-import logging
-import feedparser
-
-from kalliope.core.NeuronModule import NeuronModule, MissingParameterException
-
-logging.basicConfig()
-logger = logging.getLogger("kalliope")
-
-
-class Rss_reader(NeuronModule):
-    def __init__(self, **kwargs):
-        super(Rss_reader, self).__init__(**kwargs)
-
-        self.feedUrl = kwargs.get('feed_url', None)
-        self.limit = kwargs.get('max_items', 30)
-
-        # check if parameters have been provided
-        if self._is_parameters_ok():
-
-            # prepare a returned dict
-            returned_dict = dict()
-
-            logging.debug("Reading feed from: %s" % self.feedUrl)
-
-            feed = feedparser.parse( self.feedUrl )
-
-            logging.debug("Read title from feed: %s" % feed["channel"]["title"])
-
-            returned_dict["feed"] = feed["channel"]["title"]
-            returned_dict["items"] = feed["items"][:self.limit]
-            
-            self.say(returned_dict)
-
-    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.feedUrl is None:
-            raise MissingParameterException("feed url parameter required")
-
-        return True

+ 0 - 0
kalliope/neurons/rss_reader/tests/__init__.py


+ 0 - 23
kalliope/neurons/rss_reader/tests/test_rss_reader.py

@@ -1,23 +0,0 @@
-import unittest
-
-from kalliope.core.NeuronModule import MissingParameterException
-from kalliope.neurons.rss_reader.rss_reader import Rss_reader
-
-
-class TestRss_Reader(unittest.TestCase):
-
-    def setUp(self):
-        self.feedUrl="http://www.lemonde.fr/rss/une.xml"
-
-    def testParameters(self):
-        def run_test(parameters_to_test):
-            with self.assertRaises(MissingParameterException):
-                Rss_reader(**parameters_to_test)
-
-        # empty
-        parameters = dict()
-        run_test(parameters)
-
-if __name__ == '__main__':
-    unittest.main()
-

+ 0 - 83
kalliope/neurons/tasker_autoremote/Readme.md

@@ -1,83 +0,0 @@
-# Tasker autoremote
-
-## Synopsis
-
-[Tasker](https://play.google.com/store/apps/details?id=net.dinglisch.android.taskerm) is an application for Android which performs 
-tasks (sets of actions) based on contexts (application, time, date, location, event, gesture) in user-defined profiles or in 
-clickable or timer home screen widgets.
-
-[Tasker autoremote](https://play.google.com/store/apps/details?id=com.joaomgcd.autoremote&hl=fr) is a plugin for Tasker that allow 
-the program to receive push message from the cloud as profile.
-
-This is how it works:
-- Send an AutoRemote message from Kalliope
-- Setup an AutoRemote profile in Tasker to react to the message
-- Do whatever you like with that message!
-
-The example usage is a "find my phone" task. 
-You could send a "Where are you?" message to your phone, and have Tasker respond with a repetitive "I'm here! I'm here!" 
-or play a music.
-
-
-## Options
-
-| parameter | required | default | choices | comment                                                       |
-|-----------|----------|---------|---------|---------------------------------------------------------------|
-| key       | yes      |         |         | API key. Can be found in your personal URL given by the app.  |
-| message   | yes      |         |         | Message to send to your phone                                 |
-
-## Return Values
-
-None
-
-## Synapses example
-
-Description of what the synapse will do
-```
-- name: "find-my-phone"
-  signals:
-    - order: "where is my phone"
-  neurons:
-    - say:
-        message: "I'll make your phone ringing, sir"
-    - tasker_autoremote:
-        key: "MY_VERY_LONG_KEY"
-        message: "lost"
-```
-
-
-## Notes
-
-### How to create a find my phone task
-This walk through will show you how to send a message to your phone so that even if it is set to silent, 
-will play any music file at full volume so you can find your phone if you have lost it in the couch.
-
-First, create a task, that you could call "start_ringing" that will perform:
-- Disable the silent mode
-- Set media volume to the maximum value
-- Play a local music
-
-![task play music](images/task_play_music.png)
-
-Then, create a new task with just one action:
-- Stop the music
-
-![task stop music](images/task_stop_music.png)
-
-Create the input profile. 
-- create a context of type Event > Plugin > Autoremote
-- Set the word you want
-- Attach the event to the task "start_ringing"
-
-![task stop music](images/profile_auto_remote.png)
-
-Finally, create a event, to stop the music when we unlock the phone
-- create a context of type Event > Display > Display Unlocked
-- Attach the event to the stop that stop the music
-
-![task stop music](images/profile_display_unlocked.png)
-
-Exit Tasker with the exit menu to be sure all events and task have been saved.
-
-
- 

+ 0 - 1
kalliope/neurons/tasker_autoremote/__init__.py

@@ -1 +0,0 @@
-from tasker_autoremote import Tasker_autoremote

BIN
kalliope/neurons/tasker_autoremote/images/profile_auto_remote.png


BIN
kalliope/neurons/tasker_autoremote/images/profile_display_unlocked.png


BIN
kalliope/neurons/tasker_autoremote/images/task_play_music.png


BIN
kalliope/neurons/tasker_autoremote/images/task_stop_music.png


+ 0 - 41
kalliope/neurons/tasker_autoremote/tasker_autoremote.py

@@ -1,41 +0,0 @@
-import logging
-
-import requests
-
-from kalliope.core.NeuronModule import NeuronModule, MissingParameterException
-
-logging.basicConfig()
-logger = logging.getLogger("kalliope")
-
-
-class Tasker_autoremote(NeuronModule):
-    def __init__(self, **kwargs):
-        super(Tasker_autoremote, self).__init__(**kwargs)
-
-        # check if parameters have been provided
-        self.key = kwargs.get('key', None)
-        self.message = kwargs.get('message', None)
-
-        # check parameters
-        if self._is_parameters_ok():
-            # create the payload
-            data = {'key': self.key,
-                    'message': self.message}
-            url = "https://autoremotejoaomgcd.appspot.com/sendmessage"
-            # post
-            r = requests.post(url, data=data)
-            logging.debug("Post to tasker automore response: %s" % r.status_code)
-
-    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.key is None:
-            raise MissingParameterException("key parameter required")
-        if self.message is None:
-            raise MissingParameterException("message parameter required")
-
-        return True

+ 0 - 0
kalliope/neurons/tasker_autoremote/tests/__init__.py


+ 0 - 36
kalliope/neurons/tasker_autoremote/tests/test_tasker_autoremote.py

@@ -1,36 +0,0 @@
-import unittest
-
-from kalliope.core.NeuronModule import MissingParameterException
-from kalliope.neurons.sleep.sleep import Sleep
-
-
-class TestSleep(unittest.TestCase):
-
-    def setUp(self):
-        self.key="key"
-        self.message="message"
-
-    def testParameters(self):
-        def run_test(parameters_to_test):
-            with self.assertRaises(MissingParameterException):
-                Sleep(**parameters_to_test)
-
-        # empty
-        parameters = dict()
-        run_test(parameters)
-
-        # missing key
-        parameters = {
-            "message": self.message
-        }
-        run_test(parameters)
-
-        # missing message
-        parameters = {
-            "key": self.key
-        }
-        run_test(parameters)
-
-
-if __name__ == '__main__':
-    unittest.main()

+ 0 - 51
kalliope/neurons/twitter/README.md

@@ -1,51 +0,0 @@
-# Twitter 
-
-## Synopsis
-
-This neuron allows you to send a tweet on your timeline.
-
-## Options
-
-| parameter           | required | default | choices | comment                     |
-|---------------------|----------|---------|---------|-----------------------------|
-| consumer_key        | yes      | None    |         | User info                   |
-| consumer_secret     | yes      | None    |         | User info                   |
-| access_token_key    | yes      | None    |         | User info                   |
-| access_token_secret | yes      | None    |         | User info                   |
-| tweet               | yes      | None    |         | The sentence to be tweeted  |
-
-## Return Values
-
-| Name  | Description                     | Type   | sample          |
-|-------|---------------------------------|--------|-----------------|
-| tweet | The tweet which has been posted | string | coucou kalliopé |
-
-## Synapses example
-
-```
-- name: "post-tweet"
-  neurons:
-    - twitter:
-        consumer_key: ""
-        consumer_secret: ""
-        access_token_key: ""
-        access_token_secret: ""
-        args:
-          - tweet
-  signals:
-    - order: "post on Twitter {{ tweet }}"
-```
-
-## Notes
-
-In order to be able to post on Twitter, you need to grant access of your application on Twitter by creating your own app associate to your profile. 
-
-### How to create my Twitter app
-
-1. Sign in your [Twitter account](https://www.twitter.com)
-2. Let's create your app [apps.twitter.com](https://apps.twitter.com)
-3. click on the button "Create New App"
-4. Fill in your application details
-5. Create your access token (to post a tweet, you need at least "Read and Write" access)
-6. Get your consumer_key, consumer_secret, access_token_key and access_token_secret from the tab "Key and access token" (Keep them secret !)
-7. Post your first message with this neuron !

+ 0 - 1
kalliope/neurons/twitter/__init__.py

@@ -1 +0,0 @@
-from twitter import Twitter

+ 0 - 0
kalliope/neurons/twitter/tests/__init__.py


+ 0 - 68
kalliope/neurons/twitter/tests/test_twitter_neuron.py

@@ -1,68 +0,0 @@
-import unittest
-
-from kalliope.core.NeuronModule import MissingParameterException
-from kalliope.neurons.twitter.twitter import Twitter
-
-
-class TestTwitter(unittest.TestCase):
-
-    def setUp(self):
-        self.consumer_key="kalliokey"
-        self.consumer_secret = "kalliosecret"
-        self.access_token_key = "kalliotokenkey"
-        self.access_token_secret = "kalliotokensecret"
-        self.tweet = "kalliotweet"
-
-    def testParameters(self):
-        def run_test(parameters_to_test):
-            with self.assertRaises(MissingParameterException):
-                Twitter(**parameters_to_test)
-
-        # empty
-        parameters = dict()
-        run_test(parameters)
-
-        # missing tweet
-        parameters = {
-            "consumer_key": self.consumer_key,
-            "consumer_secret": self.consumer_secret,
-            "access_token_key": self.access_token_key,
-            "access_token_secret": self.access_token_secret
-        }
-        run_test(parameters)
-
-        # missing consumer_key
-        parameters = {
-            "consumer_secret": self.consumer_secret,
-            "access_token_key": self.access_token_key,
-            "access_token_secret": self.access_token_secret,
-            "tweet": self.tweet
-        }
-        run_test(parameters)
-
-        # missing consumer_secret
-        parameters = {
-            "consumer_key": self.consumer_key,
-            "access_token_key": self.access_token_key,
-            "access_token_secret": self.access_token_secret,
-            "tweet": self.tweet
-        }
-        run_test(parameters)
-
-        # missing access_token_key
-        parameters = {
-            "consumer_key": self.consumer_key,
-            "consumer_secret": self.consumer_secret,
-            "access_token_secret": self.access_token_secret,
-            "tweet": self.tweet
-        }
-        run_test(parameters)
-
-        # missing access_token_secret
-        parameters = {
-            "consumer_key": self.consumer_key,
-            "consumer_secret": self.consumer_secret,
-            "access_token_key": self.access_token_key,
-            "tweet": self.tweet
-        }
-        run_test(parameters)

+ 0 - 53
kalliope/neurons/twitter/twitter.py

@@ -1,53 +0,0 @@
-import twitter
-
-from kalliope.core.NeuronModule import NeuronModule, MissingParameterException
-
-
-class Twitter(NeuronModule):
-    def __init__(self, **kwargs):
-
-        super(Twitter, self).__init__(**kwargs)
-
-        self.consumer_key = kwargs.get('consumer_key', None)
-        self.consumer_secret = kwargs.get('consumer_secret', None)
-        self.access_token_key = kwargs.get('access_token_key', None)
-        self.access_token_secret = kwargs.get('access_token_secret', None)
-        self.tweet = kwargs.get('tweet', None)
-
-        # check parameters
-        if self._is_parameters_ok():
-            api = twitter.Api(consumer_key=self.consumer_key,
-                              consumer_secret=self.consumer_secret,
-                              access_token_key=self.access_token_key,
-                              access_token_secret=self.access_token_secret)
-
-            status = api.PostUpdate(self.tweet)
-            message = {
-                "tweet" : status.text
-            }
-
-            self.say(message)
-
-    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.consumer_key is None:
-            raise MissingParameterException("Twitter needs a consumer_key")
-        if self.consumer_secret is None:
-            raise MissingParameterException("Twitter needs a consumer_secret")
-        if self.access_token_key is None:
-            raise MissingParameterException("Twitter needs an access_token_key")
-        if self.access_token_secret is None:
-            raise MissingParameterException("Twitter needs and access_token_secret")
-        if self.tweet is None:
-            raise MissingParameterException("You need to provide something to tweet !")
-
-        return True
-
-
-
-

+ 0 - 50
kalliope/neurons/wake_on_lan/README.md

@@ -1,50 +0,0 @@
-# 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"
-  signals:
-    - order: "wake my PC"
-  neurons:
-    - wake_on_lan:
-        mac_address: "00-00-00-00-00-00"
-```
-
-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"
-  signals:
-    - order: "wake my PC"
-  neurons:
-    - wake_on_lan:
-        mac_address: "00-00-00-00-00-00"
-        broadcast_address: "172.16.255.255"
-        port: 7
-```
-
-## 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.

+ 0 - 1
kalliope/neurons/wake_on_lan/__init__.py

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

+ 0 - 0
kalliope/neurons/wake_on_lan/tests/__init__.py


+ 0 - 67
kalliope/neurons/wake_on_lan/tests/test_wake_on_lan.py

@@ -1,67 +0,0 @@
-import unittest
-import ipaddress
-
-from kalliope.core.NeuronModule import InvalidParameterException, MissingParameterException
-from kalliope.neurons.wake_on_lan.wake_on_lan import Wake_on_lan
-
-
-class TestWakeOnLan(unittest.TestCase):
-
-    def setUp(self):
-        self.mac_address="00:0a:95:9d:68:16"
-        self.broadcast_address = "255.255.255.255"
-        self.port = 42
-
-    def testParameters(self):
-        def run_test_invalidParam(parameters_to_test):
-            with self.assertRaises(InvalidParameterException):
-                Wake_on_lan(**parameters_to_test)
-
-        def run_test_missingParam(parameters_to_test):
-            with self.assertRaises(MissingParameterException):
-                Wake_on_lan(**parameters_to_test)
-
-        def run_test_valueError(parameters_to_test):
-            with self.assertRaises(ValueError):
-                Wake_on_lan(**parameters_to_test)
-
-        # empty
-        parameters = dict()
-        run_test_missingParam(parameters)
-
-        # missing mac_address
-        parameters = {
-            "broadcast_address": self.broadcast_address,
-            "port": self.port
-        }
-        run_test_missingParam(parameters)
-
-        # port is not an int
-        self.port = "port"
-        parameters = {
-            "broadcast_address": self.broadcast_address,
-            "mac_address": self.mac_address,
-            "port": self.port
-        }
-        run_test_invalidParam(parameters)
-        self.port = 42
-
-        # is broadcast not a valid format
-        self.broadcast_address = "broadcast"
-        parameters = {
-            "broadcast_address": self.broadcast_address,
-            "mac_address": self.mac_address,
-            "port": self.port
-        }
-        run_test_valueError(parameters)
-        self.broadcast_address = "255.255.255.255"
-
-        # is mac_address not a valid IPv4 or IPv6 format
-        self.mac_address = "mac_address"
-        parameters = {
-            "broadcast_address": self.broadcast_address,
-            "mac_address": self.mac_address,
-            "port": self.port
-        }
-        run_test_valueError(parameters)
-        self.mac_address = "00:0a:95:9d:68:16"

+ 0 - 47
kalliope/neurons/wake_on_lan/wake_on_lan.py

@@ -1,47 +0,0 @@
-import ipaddress
-import logging
-
-from kalliope.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)
-
-        self.mac_address = kwargs.get('mac_address', None)
-        self.broadcast_address = kwargs.get('broadcast_address', '255.255.255.255')
-        self.port = kwargs.get('port', 9)
-
-        # check parameters
-        if self._is_parameters_ok():
-            # convert to unicode for testing
-            broadcast_address_unicode = self.broadcast_address.decode('utf-8')
-            # check the ip address is a valid one
-            ipaddress.ip_address(broadcast_address_unicode)
-
-            logger.debug("Call Wake_on_lan_neuron with parameters: mac_address: %s, broadcast_address: %s, port: %s"
-                         % (self.mac_address, self.broadcast_address, self.port))
-
-            # send the magic packet, the mac address format will be check by the lib
-            wol.send_magic_packet(self.mac_address, ip_address=self.broadcast_address, port=self.port)
-
-    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:: InvalidParameterException, MissingParameterException
-        """
-        # check we provide a mac address
-        if self.mac_address is None:
-            raise MissingParameterException("mac_address parameter required")
-            # check the port
-        if type(self.port) is not int:
-            raise InvalidParameterException(
-                "port argument must be an integer. Remove quotes in your configuration.")
-
-        return True