Browse Source

Merge pull request #250 from jschueller/py3k-dev

Python 3 support
Monf 8 years ago
parent
commit
d1c8a88612
64 changed files with 208 additions and 225 deletions
  1. 2 0
      .travis.yml
  2. 10 10
      Tests/__init__.py
  3. 24 24
      Tests/test_brain_loader.py
  4. 1 1
      Tests/test_dynamic_loading.py
  5. 3 3
      Tests/test_file_manager.py
  6. 17 59
      Tests/test_models.py
  7. 6 6
      Tests/test_neuron_parameter_loader.py
  8. 3 3
      Tests/test_order_listener.py
  9. 9 8
      Tests/test_rest_api.py
  10. 1 1
      Tests/test_settings_loader.py
  11. 3 3
      Tests/test_singleton.py
  12. 6 6
      Tests/test_tts_module.py
  13. 15 15
      Tests/test_utils.py
  14. 1 1
      install/files/python_requirements.txt
  15. 2 2
      kalliope/__init__.py
  16. 6 5
      kalliope/core/ConfigurationManager/BrainLoader.py
  17. 1 1
      kalliope/core/ConfigurationManager/ConfigurationChecker.py
  18. 11 11
      kalliope/core/ConfigurationManager/SettingLoader.py
  19. 4 2
      kalliope/core/ConfigurationManager/YAMLLoader.py
  20. 3 3
      kalliope/core/ConfigurationManager/__init__.py
  21. 1 1
      kalliope/core/Models/Neuron.py
  22. 7 7
      kalliope/core/Models/__init__.py
  23. 2 2
      kalliope/core/NeuronLauncher.py
  24. 8 6
      kalliope/core/NeuronModule.py
  25. 3 1
      kalliope/core/OrderAnalyser.py
  26. 1 1
      kalliope/core/Players/__init__.py
  27. 1 1
      kalliope/core/ShellGui.py
  28. 3 1
      kalliope/core/TTS/TTSModule.py
  29. 1 1
      kalliope/core/TTS/__init__.py
  30. 1 1
      kalliope/core/Utils/FileManager.py
  31. 8 4
      kalliope/core/Utils/Utils.py
  32. 1 1
      kalliope/neurons/ansible_playbook/__init__.py
  33. 1 1
      kalliope/neurons/kill_switch/__init__.py
  34. 1 1
      kalliope/neurons/neurotransmitter/__init__.py
  35. 1 1
      kalliope/neurons/say/__init__.py
  36. 1 1
      kalliope/neurons/script/__init__.py
  37. 1 1
      kalliope/neurons/script/script.py
  38. 2 2
      kalliope/neurons/script/tests/test_script.py
  39. 1 1
      kalliope/neurons/shell/__init__.py
  40. 1 1
      kalliope/neurons/shell/shell.py
  41. 1 1
      kalliope/neurons/sleep/__init__.py
  42. 2 1
      kalliope/neurons/sleep/sleep.py
  43. 1 1
      kalliope/neurons/systemdate/__init__.py
  44. 3 3
      kalliope/neurons/uri/tests/test_uri_neuron.py
  45. 3 3
      kalliope/neurons/uri/uri.py
  46. 1 1
      kalliope/stt/apiai/__init__.py
  47. 1 1
      kalliope/stt/bing/__init__.py
  48. 1 1
      kalliope/stt/cmusphinx/__init__.py
  49. 1 1
      kalliope/stt/google/__init__.py
  50. 1 1
      kalliope/stt/houndify/__init__.py
  51. 1 1
      kalliope/stt/wit/__init__.py
  52. 1 1
      kalliope/trigger/snowboy/__init__.py
  53. 0 0
      kalliope/trigger/snowboy/armv7l/python27/_snowboydetect.so
  54. 1 1
      kalliope/trigger/snowboy/snowboydecoder.py
  55. 1 1
      kalliope/trigger/snowboy/snowboydetect.py
  56. 0 0
      kalliope/trigger/snowboy/x86_64/python27/_snowboydetect.so
  57. BIN
      kalliope/trigger/snowboy/x86_64/python34/_snowboydetect.so
  58. BIN
      kalliope/trigger/snowboy/x86_64/python35/_snowboydetect.so
  59. BIN
      kalliope/trigger/snowboy/x86_64/python36/_snowboydetect.so
  60. 1 1
      kalliope/tts/acapela/__init__.py
  61. 1 1
      kalliope/tts/googletts/__init__.py
  62. 1 1
      kalliope/tts/pico2wave/__init__.py
  63. 1 1
      kalliope/tts/voicerss/__init__.py
  64. 11 3
      setup.py

+ 2 - 0
.travis.yml

@@ -5,6 +5,7 @@ services:
 
 
 python:
 python:
   - "2.7"
   - "2.7"
+  - "3.4"
 
 
 # command to install dependencies
 # command to install dependencies
 before_install:
 before_install:
@@ -21,6 +22,7 @@ before_install:
 
 
 install:
 install:
   - pip install -r install/files/python_requirements.txt
   - pip install -r install/files/python_requirements.txt
+  - pip install python2-pythondialog || pip install pythondialog
   - pip install coveralls
   - pip install coveralls
 
 
 # command to run tests
 # command to run tests

+ 10 - 10
Tests/__init__.py

@@ -1,10 +1,10 @@
-from test_brain_loader import TestBrainLoader
+from .test_brain_loader import TestBrainLoader
-from test_configuration_checker import TestConfigurationChecker
+from .test_configuration_checker import TestConfigurationChecker
-from test_dynamic_loading import TestDynamicLoading
+from .test_dynamic_loading import TestDynamicLoading
-from test_file_manager import TestFileManager
+from .test_file_manager import TestFileManager
-from test_rest_api import TestRestAPI
+from .test_rest_api import TestRestAPI
-from test_settings_loader import TestSettingLoader
+from .test_settings_loader import TestSettingLoader
-from test_singleton import TestSingleton
+from .test_singleton import TestSingleton
-from test_tts_module import TestTTSModule
+from .test_tts_module import TestTTSModule
-from test_yaml_loader import TestYAMLLoader
+from .test_yaml_loader import TestYAMLLoader
-from test_neuron_module import TestNeuronModule
+from .test_neuron_module import TestNeuronModule

+ 24 - 24
Tests/test_brain_loader.py

@@ -183,10 +183,10 @@ class TestBrainLoader(unittest.TestCase):
             'var1': 'test'
             'var1': 'test'
         }
         }
 
 
-        self.assertEquals(BrainLoader._replace_global_variables(parameter=parameters,
+        self.assertEqual(BrainLoader._replace_global_variables(parameter=parameters,
                                                                 settings=st),
                                                                 settings=st),
-                          expected_parameters,
+                         expected_parameters,
-                          "Fail to assign a single global variable to parameters")
+                         "Fail to assign a single global variable to parameters")
 
 
         # 2/ global variable with string after
         # 2/ global variable with string after
         parameters = {
         parameters = {
@@ -202,10 +202,10 @@ class TestBrainLoader(unittest.TestCase):
             'var1': 'test Sispheor'
             'var1': 'test Sispheor'
         }
         }
 
 
-        self.assertEquals(BrainLoader._replace_global_variables(parameter=parameters,
+        self.assertEqual(BrainLoader._replace_global_variables(parameter=parameters,
                                                                 settings=st),
                                                                 settings=st),
-                          expected_parameters,
+                         expected_parameters,
-                          "Fail to assign a global variable with string after to parameters")
+                         "Fail to assign a global variable with string after to parameters")
 
 
         # 3/ global variable with int after
         # 3/ global variable with int after
         parameters = {
         parameters = {
@@ -221,10 +221,10 @@ class TestBrainLoader(unittest.TestCase):
             'var1': '600'
             'var1': '600'
         }
         }
 
 
-        self.assertEquals(BrainLoader._replace_global_variables(parameter=parameters,
+        self.assertEqual(BrainLoader._replace_global_variables(parameter=parameters,
                                                                 settings=st),
                                                                 settings=st),
-                          expected_parameters,
+                         expected_parameters,
-                          "Fail to assign global variable with int after to parameters")
+                         "Fail to assign global variable with int after to parameters")
 
 
         # 4/ multiple global variables
         # 4/ multiple global variables
         parameters = {
         parameters = {
@@ -240,10 +240,10 @@ class TestBrainLoader(unittest.TestCase):
             'var1': 'hello LaMonf'
             'var1': 'hello LaMonf'
         }
         }
 
 
-        self.assertEquals(BrainLoader._replace_global_variables(parameter=parameters,
+        self.assertEqual(BrainLoader._replace_global_variables(parameter=parameters,
                                                                 settings=st),
                                                                 settings=st),
-                          expected_parameters,
+                         expected_parameters,
-                          "Fail to assign multiple global variables to parameters")
+                         "Fail to assign multiple global variables to parameters")
 
 
         # 5/ parameter value is a list
         # 5/ parameter value is a list
         parameters = {
         parameters = {
@@ -259,10 +259,10 @@ class TestBrainLoader(unittest.TestCase):
             'var1': '[hello LaMonf, bonjour LaMonf]'
             'var1': '[hello LaMonf, bonjour LaMonf]'
         }
         }
 
 
-        self.assertEquals(BrainLoader._replace_global_variables(parameter=parameters,
+        self.assertEqual(BrainLoader._replace_global_variables(parameter=parameters,
                                                                 settings=st),
                                                                 settings=st),
-                          expected_parameters,
+                         expected_parameters,
-                          "Fail to assign a single global when parameter value is a list to neuron")
+                         "Fail to assign a single global when parameter value is a list to neuron")
 
 
         # 6/ parameter is a dict
         # 6/ parameter is a dict
         parameters = {'from_answer_link': [{'synapse': 'synapse2', 'answers': ['absolument', '{{ name }}']},
         parameters = {'from_answer_link': [{'synapse': 'synapse2', 'answers': ['absolument', '{{ name }}']},
@@ -279,10 +279,10 @@ class TestBrainLoader(unittest.TestCase):
                 {'synapse': 'synapse3', 'answers': ['nico']}], 'default': 'synapse4'
                 {'synapse': 'synapse3', 'answers': ['nico']}], 'default': 'synapse4'
         }
         }
 
 
-        self.assertEquals(BrainLoader._replace_global_variables(parameter=parameters,
+        self.assertEqual(BrainLoader._replace_global_variables(parameter=parameters,
                                                                 settings=st),
                                                                 settings=st),
-                          expected_parameters,
+                         expected_parameters,
-                          "Fail to assign a single global when parameter value is a list to neuron")
+                         "Fail to assign a single global when parameter value is a list to neuron")
 
 
     def test_get_global_variable(self):
     def test_get_global_variable(self):
         """
         """
@@ -299,25 +299,25 @@ class TestBrainLoader(unittest.TestCase):
 
 
         expected_result = "i am kalliope"
         expected_result = "i am kalliope"
 
 
-        self.assertEquals(BrainLoader._get_global_variable(sentence=sentence,
+        self.assertEqual(BrainLoader._get_global_variable(sentence=sentence,
                                                            settings=st),
                                                            settings=st),
-                          expected_result)
+                         expected_result)
 
 
         # test with accent
         # test with accent
         sentence = "i am {{name3}}"
         sentence = "i am {{name3}}"
         expected_result = u"i am kalliopé"
         expected_result = u"i am kalliopé"
 
 
-        self.assertEquals(BrainLoader._get_global_variable(sentence=sentence,
+        self.assertEqual(BrainLoader._get_global_variable(sentence=sentence,
                                                            settings=st),
                                                            settings=st),
-                          expected_result)
+                         expected_result)
 
 
         # test with int
         # test with int
         sentence = "i am {{name4}}"
         sentence = "i am {{name4}}"
         expected_result = "i am 1"
         expected_result = "i am 1"
 
 
-        self.assertEquals(BrainLoader._get_global_variable(sentence=sentence,
+        self.assertEqual(BrainLoader._get_global_variable(sentence=sentence,
                                                            settings=st),
                                                            settings=st),
-                          expected_result)
+                         expected_result)
 
 
 
 
 if __name__ == '__main__':
 if __name__ == '__main__':

+ 1 - 1
Tests/test_dynamic_loading.py

@@ -98,7 +98,7 @@ class TestDynamicLoading(unittest.TestCase):
         # we keep only package. Because we have _init_.py or other stuff in what listdir returned
         # we keep only package. Because we have _init_.py or other stuff in what listdir returned
         packages_in_folder = list()
         packages_in_folder = list()
         for el in el_folder:
         for el in el_folder:
-            if os.path.isdir(folder + os.sep + el):
+            if os.path.isdir(folder + os.sep + el) and not '__pycache__' in el:
                 packages_in_folder.append(el)
                 packages_in_folder.append(el)
         return packages_in_folder
         return packages_in_folder
 
 

+ 3 - 3
Tests/test_file_manager.py

@@ -81,7 +81,7 @@ class TestFileManager(unittest.TestCase):
 
 
         # Test FileManager.file_is_empty
         # Test FileManager.file_is_empty
         with open(file_path, "wb") as file_open:
         with open(file_path, "wb") as file_open:
-            file_open.write("")
+            file_open.write(b"")
             file_open.close()
             file_open.close()
         self.assertTrue(FileManager.file_is_empty(file_path=file_path),
         self.assertTrue(FileManager.file_is_empty(file_path=file_path),
                         "Fail matching to verify that file is empty ")
                         "Fail matching to verify that file is empty ")
@@ -107,7 +107,7 @@ class TestFileManager(unittest.TestCase):
         # Test to remove the file
         # Test to remove the file
         # FileManager.remove_file
         # FileManager.remove_file
         with open(file_path, "wb") as file_open:
         with open(file_path, "wb") as file_open:
-            file_open.write("")
+            file_open.write(b"")
             file_open.close()
             file_open.close()
         FileManager.remove_file(file_path=file_path)
         FileManager.remove_file(file_path=file_path)
         self.assertFalse(os.path.exists(file_path),
         self.assertFalse(os.path.exists(file_path),
@@ -157,7 +157,7 @@ class TestFileManager(unittest.TestCase):
 
 
         # Test the file exist and creatable : return True
         # Test the file exist and creatable : return True
         with open(file_path, "wb") as file_open:
         with open(file_path, "wb") as file_open:
-            file_open.write("[Kalliope] Test Running the test_is_path_exists_or_creatable method")
+            file_open.write(b"[Kalliope] Test Running the test_is_path_exists_or_creatable method")
             file_open.close()
             file_open.close()
         self.assertTrue(FileManager.is_path_exists_or_creatable(file_path),
         self.assertTrue(FileManager.is_path_exists_or_creatable(file_path),
                         "Fail to assert the file exist ")
                         "Fail to assert the file exist ")

+ 17 - 59
Tests/test_models.py

@@ -1,5 +1,5 @@
 import unittest
 import unittest
-
+import ast
 import mock
 import mock
 from kalliope.core.Models.Tts import Tts
 from kalliope.core.Models.Tts import Tts
 
 
@@ -75,12 +75,7 @@ class TestModels(unittest.TestCase):
                 'user_order': 'user order'
                 'user_order': 'user order'
         }
         }
 
 
-        self.assertEqual(expected_result_serialize, api_response.serialize())
+        self.assertDictEqual(expected_result_serialize, api_response.serialize())
-
-        expected_result_str = "{'status': None, 'matched_synapses': [{'matched_order': 'user order', " \
-                              "'neuron_module_list': [], 'synapse_name': 'Synapse1'}], 'user_order': 'user order'}"
-
-        self.assertEqual(expected_result_str, api_response.__str__())
 
 
     def test_Brain(self):
     def test_Brain(self):
         # test get synapse by name
         # test get synapse by name
@@ -113,11 +108,8 @@ class TestModels(unittest.TestCase):
             'name': 'dna1',
             'name': 'dna1',
             'author': 'kalliope'
             'author': 'kalliope'
         }
         }
-        expected_result_str = "{'kalliope_supported_version': '0.4.4', 'tags': 'test', 'type':" \
-                              " 'neuron', 'name': 'dna1', 'author': 'kalliope'}"
 
 
-        self.assertEqual(expected_result_serialize, dna1.serialize())
+        self.assertDictEqual(expected_result_serialize, dna1.serialize())
-        self.assertEqual(expected_result_str, dna1.__str__())
 
 
         self.assertTrue(dna1.__eq__(dna3))
         self.assertTrue(dna1.__eq__(dna3))
         self.assertFalse(dna1.__eq__(dna2))
         self.assertFalse(dna1.__eq__(dna2))
@@ -145,11 +137,8 @@ class TestModels(unittest.TestCase):
                 'month': 12
                 'month': 12
             }
             }
         }
         }
-        expected_result_str = "{'event': {'week': 53, 'second': 0, 'minute': 30, 'hour': 8, " \
-                              "'year': 2017, 'day': 31, 'day_of_week': 2, 'month': 12}}"
 
 
-        self.assertEqual(expected_result_serialize, event1.serialize())
+        self.assertDictEqual(expected_result_serialize, event1.serialize())
-        self.assertEqual(expected_result_str, event1.__str__())
 
 
         self.assertTrue(event1.__eq__(event3))
         self.assertTrue(event1.__eq__(event3))
         self.assertFalse(event1.__eq__(event2))
         self.assertFalse(event1.__eq__(event2))
@@ -165,10 +154,8 @@ class TestModels(unittest.TestCase):
             'neuron_module_list': [],
             'neuron_module_list': [],
             'synapse_name': 'Synapse1'
             'synapse_name': 'Synapse1'
         }
         }
-        expected_result_str = "{'matched_order': 'user order', 'neuron_module_list': [], 'synapse_name': 'Synapse1'}"
 
 
-        self.assertEqual(expected_result_serialize, matched_synapse1.serialize())
+        self.assertDictEqual(expected_result_serialize, matched_synapse1.serialize())
-        self.assertEqual(expected_result_str, matched_synapse1.__str__())
 
 
         self.assertTrue(matched_synapse1.__eq__(matched_synapse3))
         self.assertTrue(matched_synapse1.__eq__(matched_synapse3))
         self.assertFalse(matched_synapse1.__eq__(matched_synapse2))
         self.assertFalse(matched_synapse1.__eq__(matched_synapse2))
@@ -188,10 +175,8 @@ class TestModels(unittest.TestCase):
         neuron3 = Neuron(name="test", parameters={"key1": "val1", "key2": "val2"})
         neuron3 = Neuron(name="test", parameters={"key1": "val1", "key2": "val2"})
 
 
         expected_result_serialize = {'name': 'test', 'parameters': {'key2': 'val2', 'key1': 'val1'}}
         expected_result_serialize = {'name': 'test', 'parameters': {'key2': 'val2', 'key1': 'val1'}}
-        expected_result_str = "{'name': 'test', 'parameters': {'key2': 'val2', 'key1': 'val1'}}"
 
 
-        self.assertEqual(expected_result_serialize, neuron1.serialize())
+        self.assertDictEqual(expected_result_serialize, neuron1.serialize())
-        self.assertEqual(expected_result_str, neuron1.__str__())
 
 
         self.assertTrue(neuron1.__eq__(neuron3))
         self.assertTrue(neuron1.__eq__(neuron3))
         self.assertFalse(neuron1.__eq__(neuron2))
         self.assertFalse(neuron1.__eq__(neuron2))
@@ -207,9 +192,9 @@ class TestModels(unittest.TestCase):
         neuron.name = neuron_name
         neuron.name = neuron_name
         neuron.parameters = neuron_parameters
         neuron.parameters = neuron_parameters
 
 
-        expected_result = "{'name': 'test', 'parameters': {'password': '*****', 'parameter': 'test'}}"
+        expected_result_str = "{'name': 'test', 'parameters': {'password': '*****', 'parameter': 'test'}}"
 
 
-        self.assertEqual(neuron.__str__(), expected_result)
+        self.assertDictEqual(ast.literal_eval(neuron.__str__()), ast.literal_eval(expected_result_str))
 
 
         neuron_name = "test"
         neuron_name = "test"
         neuron_parameters = {
         neuron_parameters = {
@@ -221,9 +206,9 @@ class TestModels(unittest.TestCase):
         neuron.name = neuron_name
         neuron.name = neuron_name
         neuron.parameters = neuron_parameters
         neuron.parameters = neuron_parameters
 
 
-        expected_result = "{'name': 'test', 'parameters': {'parameter': 'test', 'password_parameter': '*****'}}"
+        expected_result_str = "{'name': 'test', 'parameters': {'parameter': 'test', 'password_parameter': '*****'}}"
 
 
-        self.assertEqual(neuron.__str__(), expected_result)
+        self.assertDictEqual(ast.literal_eval(neuron.__str__()), ast.literal_eval(expected_result_str))
 
 
     def test_Order(self):
     def test_Order(self):
         order1 = Order(sentence="this is an order")
         order1 = Order(sentence="this is an order")
@@ -255,11 +240,8 @@ class TestModels(unittest.TestCase):
             'stt_folder': '/path/stt',
             'stt_folder': '/path/stt',
             'trigger_folder': '/path/trigger'
             'trigger_folder': '/path/trigger'
         }
         }
-        expected_result_str = "{'tts_folder': '/path/tts', 'neuron_folder': '/path/neuron', " \
-                              "'stt_folder': '/path/stt', 'trigger_folder': '/path/trigger'}"
 
 
-        self.assertEqual(expected_result_serialize, resource1.serialize())
+        self.assertDictEqual(expected_result_serialize, resource1.serialize())
-        self.assertEqual(expected_result_str, resource1.__str__())
 
 
         self.assertTrue(resource1.__eq__(resource3))
         self.assertTrue(resource1.__eq__(resource3))
         self.assertFalse(resource1.__eq__(resource2))
         self.assertFalse(resource1.__eq__(resource2))
@@ -283,11 +265,8 @@ class TestModels(unittest.TestCase):
             'password': 'password',
             'password': 'password',
             'login': 'admin'
             'login': 'admin'
         }
         }
-        expected_result_str = "{'password_protected': True, 'port': 5000, 'active': True, 'allowed_cors_origin': '*', " \
-                              "'password': 'password', 'login': 'admin'}"
 
 
-        self.assertEqual(expected_result_serialize, rest_api1.serialize())
+        self.assertDictEqual(expected_result_serialize, rest_api1.serialize())
-        self.assertEqual(expected_result_str, rest_api1.__str__())
 
 
         self.assertTrue(rest_api1.__eq__(rest_api3))
         self.assertTrue(rest_api1.__eq__(rest_api3))
         self.assertFalse(rest_api1.__eq__(rest_api2))
         self.assertFalse(rest_api1.__eq__(rest_api2))
@@ -377,17 +356,7 @@ class TestModels(unittest.TestCase):
                 'triggers': ['snowboy']
                 'triggers': ['snowboy']
             }
             }
 
 
-            expected_result_str = "{'default_synapse': 'default_synapse', 'default_tts_name': 'pico2wav', 'rest_api': " \
+            self.assertDictEqual(expected_result_serialize, setting1.serialize())
-                                  "{'password_protected': True, 'port': 5000, 'active': True, 'allowed_cors_origin': " \
-                                  "'*', 'password': 'password', 'login': 'admin'}, 'play_on_ready_notification': " \
-                                  "False, 'default_stt_name': 'google', 'kalliope_version': '0.4.4b', " \
-                                  "'random_wake_up_sounds': None, 'on_ready_answers': None, 'default_trigger_name': " \
-                                  "'swoyboy', 'cache_path': '/tmp/kalliope', 'stts': ['stts'], 'machine': 'pumpkins', " \
-                                  "'random_wake_up_answers': ['yes'], 'on_ready_sounds': None, 'ttss': ['ttts'], " \
-                                  "'variables': {'key1': 'val1'}, 'resources': None, 'triggers': ['snowboy']}"
-
-            self.assertEqual(expected_result_serialize, setting1.serialize())
-            self.assertEqual(expected_result_str, setting1.__str__())
 
 
             self.assertTrue(setting1.__eq__(setting3))
             self.assertTrue(setting1.__eq__(setting3))
             self.assertFalse(setting1.__eq__(setting2))
             self.assertFalse(setting1.__eq__(setting2))
@@ -398,10 +367,8 @@ class TestModels(unittest.TestCase):
         stt3 = Stt(name="stt1", parameters={"key1": "val1"})
         stt3 = Stt(name="stt1", parameters={"key1": "val1"})
 
 
         expected_result_serialize = {'name': 'stt1', 'parameters': {'key1': 'val1'}}
         expected_result_serialize = {'name': 'stt1', 'parameters': {'key1': 'val1'}}
-        expected_result_str = "{'name': 'stt1', 'parameters': {'key1': 'val1'}}"
 
 
-        self.assertEqual(expected_result_serialize, stt1.serialize())
+        self.assertDictEqual(expected_result_serialize, stt1.serialize())
-        self.assertEqual(expected_result_str, stt1.__str__())
 
 
         self.assertTrue(stt1.__eq__(stt3))
         self.assertTrue(stt1.__eq__(stt3))
         self.assertFalse(stt1.__eq__(stt2))
         self.assertFalse(stt1.__eq__(stt2))
@@ -443,12 +410,7 @@ class TestModels(unittest.TestCase):
             'name': 'Synapse1'
             'name': 'Synapse1'
         }
         }
 
 
-        expected_result_str = "{'signals': [{'order': 'this is the sentence'}], 'neurons': [{'name': 'neurone1', " \
+        self.assertDictEqual(expected_result_serialize, synapse1.serialize())
-                              "'parameters': {'var1': 'val1'}}, {'name': 'neurone2', 'parameters': {'var2': " \
-                              "'val2'}}], 'name': 'Synapse1'}"
-
-        self.assertEqual(expected_result_serialize, synapse1.serialize())
-        self.assertEqual(expected_result_str, synapse1.__str__())
 
 
         self.assertTrue(synapse1.__eq__(synapse3))
         self.assertTrue(synapse1.__eq__(synapse3))
         self.assertFalse(synapse1.__eq__(synapse2))
         self.assertFalse(synapse1.__eq__(synapse2))
@@ -459,10 +421,8 @@ class TestModels(unittest.TestCase):
         trigger3 = Trigger(name="trigger1", parameters={"key1": "val1"})
         trigger3 = Trigger(name="trigger1", parameters={"key1": "val1"})
 
 
         expected_result_serialize = {'name': 'trigger1', 'parameters': {'key1': 'val1'}}
         expected_result_serialize = {'name': 'trigger1', 'parameters': {'key1': 'val1'}}
-        expected_result_str = "{'name': 'trigger1', 'parameters': {'key1': 'val1'}}"
 
 
-        self.assertEqual(expected_result_serialize, trigger1.serialize())
+        self.assertDictEqual(expected_result_serialize, trigger1.serialize())
-        self.assertEqual(expected_result_str, trigger1.__str__())
 
 
         self.assertTrue(trigger1.__eq__(trigger3))
         self.assertTrue(trigger1.__eq__(trigger3))
         self.assertFalse(trigger1.__eq__(trigger2))
         self.assertFalse(trigger1.__eq__(trigger2))
@@ -473,10 +433,8 @@ class TestModels(unittest.TestCase):
         tts3 = Tts(name="tts1", parameters={"key1": "val1"})
         tts3 = Tts(name="tts1", parameters={"key1": "val1"})
 
 
         expected_result_serialize = {'name': 'tts1', 'parameters': {'key1': 'val1'}}
         expected_result_serialize = {'name': 'tts1', 'parameters': {'key1': 'val1'}}
-        expected_result_str = "{'name': 'tts1', 'parameters': {'key1': 'val1'}}"
 
 
-        self.assertEqual(expected_result_serialize, tts1.serialize())
+        self.assertDictEqual(expected_result_serialize, tts1.serialize())
-        self.assertEqual(expected_result_str, tts1.__str__())
 
 
         self.assertTrue(tts1.__eq__(tts3))
         self.assertTrue(tts1.__eq__(tts3))
         self.assertFalse(tts1.__eq__(tts2))
         self.assertFalse(tts1.__eq__(tts2))

+ 6 - 6
Tests/test_neuron_parameter_loader.py

@@ -11,9 +11,9 @@ class TestNeuronParameterLoader(unittest.TestCase):
         user_order = "this is the value"
         user_order = "this is the value"
         expected_result = {'sentence': 'value'}
         expected_result = {'sentence': 'value'}
 
 
-        self.assertEquals(NeuronParameterLoader.get_parameters(synapse_order=synapse_order, user_order=user_order),
+        self.assertEqual(NeuronParameterLoader.get_parameters(synapse_order=synapse_order, user_order=user_order),
-                          expected_result,
+                         expected_result,
-                          "Fail to retrieve 'the params' of the synapse_order from the order")
+                         "Fail to retrieve 'the params' of the synapse_order from the order")
 
 
         # Multiple match
         # Multiple match
         synapse_order = "this is the {{ sentence }}"
         synapse_order = "this is the {{ sentence }}"
@@ -30,7 +30,7 @@ class TestNeuronParameterLoader(unittest.TestCase):
 
 
         user_order = "this is the value with multiple words"
         user_order = "this is the value with multiple words"
         expected_result = {'sentence': 'value',
         expected_result = {'sentence': 'value',
-                            'params':'words'}
+                           'params':'words'}
 
 
         self.assertEqual(NeuronParameterLoader.get_parameters(synapse_order=synapse_order, user_order=user_order),
         self.assertEqual(NeuronParameterLoader.get_parameters(synapse_order=synapse_order, user_order=user_order),
                          expected_result,
                          expected_result,
@@ -101,14 +101,14 @@ class TestNeuronParameterLoader(unittest.TestCase):
         order_brain = "This is the {variable}"
         order_brain = "This is the {variable}"
         order_user = "This is the value"
         order_user = "This is the value"
         expected_result = {'variable': 'value'}
         expected_result = {'variable': 'value'}
-        self.assertNotEquals(NeuronParameterLoader._associate_order_params_to_values(order_user, order_brain),
+        self.assertNotEqual(NeuronParameterLoader._associate_order_params_to_values(order_user, order_brain),
                              expected_result)
                              expected_result)
 
 
         # Fail
         # Fail
         order_brain = "This is the { variable}}"
         order_brain = "This is the { variable}}"
         order_user = "This is the value"
         order_user = "This is the value"
         expected_result = {'variable': 'value'}
         expected_result = {'variable': 'value'}
-        self.assertNotEquals(NeuronParameterLoader._associate_order_params_to_values(order_user, order_brain),
+        self.assertNotEqual(NeuronParameterLoader._associate_order_params_to_values(order_user, order_brain),
                              expected_result)
                              expected_result)
 
 
         ##
         ##

+ 3 - 3
Tests/test_order_listener.py

@@ -39,9 +39,9 @@ class TestOrderListener(unittest.TestCase):
 
 
         with mock.patch("kalliope.core.Utils.get_dynamic_class_instantiation") as mock_get_dynamic_class_instantiation:
         with mock.patch("kalliope.core.Utils.get_dynamic_class_instantiation") as mock_get_dynamic_class_instantiation:
             mock_get_dynamic_class_instantiation.return_value = 'class_instance'
             mock_get_dynamic_class_instantiation.return_value = 'class_instance'
-            self.assertEquals(ol.load_stt_plugin(),
+            self.assertEqual(ol.load_stt_plugin(),
-                              "class_instance",
+                             "class_instance",
-                              "Fail getting the proper value")
+                             "Fail getting the proper value")
 
 
             mock_get_dynamic_class_instantiation.assert_called_once_with(package_name= "stt",
             mock_get_dynamic_class_instantiation.assert_called_once_with(package_name= "stt",
                                                                          module_name= "Default-stt",
                                                                          module_name= "Default-stt",

+ 9 - 8
Tests/test_rest_api.py

@@ -1,6 +1,7 @@
 import json
 import json
 import os
 import os
 import unittest
 import unittest
+import ast
 
 
 from flask import Flask
 from flask import Flask
 from flask_testing import LiveServerTestCase
 from flask_testing import LiveServerTestCase
@@ -64,7 +65,7 @@ class TestRestAPI(LiveServerTestCase):
         expected_content = {
         expected_content = {
             "Kalliope version": "%s" % version_str
             "Kalliope version": "%s" % version_str
         }
         }
-        self.assertEqual(json.dumps(expected_content), json.dumps(json.loads(response.get_data())))
+        self.assertEqual(json.dumps(expected_content, sort_keys=True), json.dumps(json.loads(response.get_data().decode('utf-8')), sort_keys=True))
 
 
     def test_get_all_synapses(self):
     def test_get_all_synapses(self):
         url = self.get_server_url()+"/synapses"
         url = self.get_server_url()+"/synapses"
@@ -131,7 +132,7 @@ class TestRestAPI(LiveServerTestCase):
         # a lot of char ti process
         # a lot of char ti process
         self.maxDiff = None
         self.maxDiff = None
         self.assertEqual(response.status_code, 200)
         self.assertEqual(response.status_code, 200)
-        self.assertEqual(json.dumps(expected_content), json.dumps(json.loads(response.get_data())))
+        self.assertEqual(json.dumps(expected_content, sort_keys=True), json.dumps(json.loads(response.get_data().decode('utf-8')), sort_keys=True))
 
 
     def test_get_one_synapse(self):
     def test_get_one_synapse(self):
         url = self.get_server_url() + "/synapses/test"
         url = self.get_server_url() + "/synapses/test"
@@ -157,7 +158,7 @@ class TestRestAPI(LiveServerTestCase):
                 ]
                 ]
             }
             }
         }
         }
-        self.assertEqual(json.dumps(expected_content), json.dumps(json.loads(response.get_data())))
+        self.assertEqual(json.dumps(expected_content, sort_keys=True), json.dumps(json.loads(response.get_data().decode('utf-8')), sort_keys=True))
 
 
     def test_get_synapse_not_found(self):
     def test_get_synapse_not_found(self):
         url = self.get_server_url() + "/synapses/test-none"
         url = self.get_server_url() + "/synapses/test-none"
@@ -169,7 +170,7 @@ class TestRestAPI(LiveServerTestCase):
             }
             }
         }
         }
 
 
-        self.assertEqual(expected_content, json.loads(result.get_data()))
+        self.assertEqual(expected_content, json.loads(result.get_data().decode('utf-8')))
         self.assertEqual(result.status_code, 404)
         self.assertEqual(result.status_code, 404)
 
 
     def test_run_synapse_by_name(self):
     def test_run_synapse_by_name(self):
@@ -184,7 +185,7 @@ class TestRestAPI(LiveServerTestCase):
                                   'synapse_name': 'test'}],
                                   'synapse_name': 'test'}],
                             'user_order': None
                             'user_order': None
                             }
                             }
-        self.assertEqual(json.dumps(expected_content), json.dumps(json.loads(result.get_data())))
+        self.assertEqual(json.dumps(expected_content, sort_keys=True), json.dumps(json.loads(result.get_data().decode('utf-8')), sort_keys=True))
         self.assertEqual(result.status_code, 201)
         self.assertEqual(result.status_code, 201)
 
 
     def test_post_synapse_not_found(self):
     def test_post_synapse_not_found(self):
@@ -197,7 +198,7 @@ class TestRestAPI(LiveServerTestCase):
             }
             }
         }
         }
 
 
-        self.assertEqual(json.dumps(expected_content), json.dumps(json.loads(result.get_data())))
+        self.assertEqual(json.dumps(expected_content, sort_keys=True), json.dumps(json.loads(result.get_data().decode('utf-8')), sort_keys=True))
         self.assertEqual(result.status_code, 404)
         self.assertEqual(result.status_code, 404)
 
 
     def test_run_synapse_with_order(self):
     def test_run_synapse_with_order(self):
@@ -222,7 +223,7 @@ class TestRestAPI(LiveServerTestCase):
                                 ],
                                 ],
                             'user_order': "test_order"
                             'user_order': "test_order"
                             }
                             }
-        self.assertEqual(json.dumps(expected_content), json.dumps(json.loads(result.get_data())))
+        self.assertEqual(json.dumps(expected_content, sort_keys=True), json.dumps(json.loads(result.get_data().decode('utf-8')), sort_keys=True))
         self.assertEqual(result.status_code, 201)
         self.assertEqual(result.status_code, 201)
 
 
     def test_post_synapse_by_order_not_found(self):
     def test_post_synapse_by_order_not_found(self):
@@ -235,7 +236,7 @@ class TestRestAPI(LiveServerTestCase):
 
 
         expected_content = {'status': None, 'matched_synapses': [], 'user_order': u'non existing order'}
         expected_content = {'status': None, 'matched_synapses': [], 'user_order': u'non existing order'}
 
 
-        self.assertEqual(json.dumps(expected_content), json.dumps(json.loads(result.get_data())))
+        self.assertEqual(json.dumps(expected_content, sort_keys=True), json.dumps(json.loads(result.get_data().decode('utf-8')), sort_keys=True))
         self.assertEqual(result.status_code, 201)
         self.assertEqual(result.status_code, 201)
 
 
         # TODO this doesn't work on travis but works locally with python -m unittest discover
         # TODO this doesn't work on travis but works locally with python -m unittest discover

+ 1 - 1
Tests/test_settings_loader.py

@@ -191,7 +191,7 @@ class TestSettingLoader(unittest.TestCase):
                               trigger_folder="/tmp/kalliope/tests/kalliope_resources_dir/trigger")
                               trigger_folder="/tmp/kalliope/tests/kalliope_resources_dir/trigger")
         expected_resource = resources
         expected_resource = resources
         sl = SettingLoader(file_path=self.settings_file_to_test)
         sl = SettingLoader(file_path=self.settings_file_to_test)
-        self.assertEquals(expected_resource, sl._get_resources(self.settings_dict))
+        self.assertEqual(expected_resource, sl._get_resources(self.settings_dict))
 
 
     def test_get_variables(self):
     def test_get_variables(self):
         expected_result = {
         expected_result = {

+ 3 - 3
Tests/test_singleton.py

@@ -1,15 +1,15 @@
 import unittest
 import unittest
+import sys
+from six import with_metaclass
 
 
 from kalliope.core.Models import Singleton
 from kalliope.core.Models import Singleton
 
 
 
 
-class MyClass(object):
+class MyClass(with_metaclass(Singleton, object)):
-    __metaclass__ = Singleton
 
 
     def __init__(self):
     def __init__(self):
         self.value = "test"
         self.value = "test"
 
 
-
 class TestSingleton(unittest.TestCase):
 class TestSingleton(unittest.TestCase):
 
 
     def setUp(self):
     def setUp(self):

+ 6 - 6
Tests/test_tts_module.py

@@ -25,9 +25,9 @@ class TestTTSModule(unittest.TestCase):
         word = "kalliope"
         word = "kalliope"
         expected_result = "5c186d1e123be2667fb5fd54640e4fd0"
         expected_result = "5c186d1e123be2667fb5fd54640e4fd0"
 
 
-        self.assertEquals(TTSModule.generate_md5_from_words(words=word),
+        self.assertEqual(TTSModule.generate_md5_from_words(words=word),
-                          expected_result,
+                         expected_result,
-                          "Fail md5")
+                         "Fail md5")
 
 
     def test_get_path_to_store_audio(self):
     def test_get_path_to_store_audio(self):
         """
         """
@@ -40,9 +40,9 @@ class TestTTSModule(unittest.TestCase):
 
 
         expected_result = "/tmp/kalliope/tests/TTSModule/tests/default/5c186d1e123be2667fb5fd54640e4fd0.tts"
         expected_result = "/tmp/kalliope/tests/TTSModule/tests/default/5c186d1e123be2667fb5fd54640e4fd0.tts"
 
 
-        self.assertEquals(self.TTSMod._get_path_to_store_audio(),
+        self.assertEqual(self.TTSMod._get_path_to_store_audio(),
-                          expected_result,
+                         expected_result,
-                          "fail test_get_path_to_store_audio, expected path not corresponding to result")
+                         "fail test_get_path_to_store_audio, expected path not corresponding to result")
 
 
     def test_generate_and_play(self):
     def test_generate_and_play(self):
         """
         """

+ 15 - 15
Tests/test_utils.py

@@ -26,9 +26,9 @@ class TestUtils(unittest.TestCase):
         path_to_test = "../kalliope/core/Utils"
         path_to_test = "../kalliope/core/Utils"
         expected_result = os.path.normpath("../kalliope/core")
         expected_result = os.path.normpath("../kalliope/core")
 
 
-        self.assertEquals(Utils.get_current_file_parent_path(path_to_test),
+        self.assertEqual(Utils.get_current_file_parent_path(path_to_test),
-                          expected_result,
+                         expected_result,
-                          "fail getting the parent parent path from the given path")
+                         "fail getting the parent parent path from the given path")
 
 
     def test_get_current_file_parent_parent_path(self):
     def test_get_current_file_parent_parent_path(self):
         """
         """
@@ -37,9 +37,9 @@ class TestUtils(unittest.TestCase):
         path_to_test = "../kalliope/core/Utils"
         path_to_test = "../kalliope/core/Utils"
         expected_result = os.path.normpath("../kalliope")
         expected_result = os.path.normpath("../kalliope")
 
 
-        self.assertEquals(Utils.get_current_file_parent_parent_path(path_to_test),
+        self.assertEqual(Utils.get_current_file_parent_parent_path(path_to_test),
-                          expected_result,
+                         expected_result,
-                          "fail getting the parent parent path from the given path")
+                         "fail getting the parent parent path from the given path")
 
 
     def test_get_real_file_path(self):
     def test_get_real_file_path(self):
         """
         """
@@ -61,9 +61,9 @@ class TestUtils(unittest.TestCase):
         # touch the file
         # touch the file
         open(absolute_path_to_test, 'a').close()
         open(absolute_path_to_test, 'a').close()
 
 
-        self.assertEquals(Utils.get_real_file_path(absolute_path_to_test),
+        self.assertEqual(Utils.get_real_file_path(absolute_path_to_test),
-                          expected_result,
+                         expected_result,
-                          "Fail to match the given absolute path ")
+                         "Fail to match the given absolute path ")
         # Clean up
         # Clean up
         if os.path.exists(absolute_path_to_test):
         if os.path.exists(absolute_path_to_test):
             os.remove(absolute_path_to_test)
             os.remove(absolute_path_to_test)
@@ -76,9 +76,9 @@ class TestUtils(unittest.TestCase):
         # touch the file
         # touch the file
         open(file_name, 'a').close()
         open(file_name, 'a').close()
 
 
-        self.assertEquals(Utils.get_real_file_path(file_name),
+        self.assertEqual(Utils.get_real_file_path(file_name),
-                          expected_result,
+                         expected_result,
-                          "Fail to match the Current path ")
+                         "Fail to match the Current path ")
         # Clean up
         # Clean up
         if os.path.exists(file_name):
         if os.path.exists(file_name):
             os.remove(file_name)
             os.remove(file_name)
@@ -115,9 +115,9 @@ class TestUtils(unittest.TestCase):
         # touch the file
         # touch the file
         open(path_to_test, 'a').close()
         open(path_to_test, 'a').close()
 
 
-        self.assertEquals(Utils.get_real_file_path(file_name),
+        self.assertEqual(Utils.get_real_file_path(file_name),
-                          expected_result,
+                         expected_result,
-                          "Fail to match the /an/unknown/path/kalliope path")
+                         "Fail to match the /an/unknown/path/kalliope path")
         # Clean up
         # Clean up
         if os.path.exists(expected_result):
         if os.path.exists(expected_result):
             os.remove(expected_result)
             os.remove(expected_result)

+ 1 - 1
install/files/python_requirements.txt

@@ -4,7 +4,7 @@ markupsafe==0.23
 pyaudio==0.2.9
 pyaudio==0.2.9
 pyasn1>=0.1.8
 pyasn1>=0.1.8
 ansible==2.2.0.0
 ansible==2.2.0.0
-python2-pythondialog==3.4.0
+#python2-pythondialog==3.4.0
 jinja2==2.8
 jinja2==2.8
 cffi==1.9.1
 cffi==1.9.1
 ipaddress==1.0.17
 ipaddress==1.0.17

+ 2 - 2
kalliope/__init__.py

@@ -10,7 +10,7 @@ from kalliope.core.ConfigurationManager.BrainLoader import BrainLoader
 from kalliope.core.EventManager import EventManager
 from kalliope.core.EventManager import EventManager
 from kalliope.core.MainController import MainController
 from kalliope.core.MainController import MainController
 
 
-from _version import version_str
+from ._version import version_str
 import signal
 import signal
 import sys
 import sys
 
 
@@ -30,7 +30,7 @@ def signal_handler(signal, frame):
     :param frame: execution frame
     :param frame: execution frame
 
 
     """
     """
-    print "\n"
+    print("\n")
     Utils.print_info("Ctrl+C pressed. Killing Kalliope")
     Utils.print_info("Ctrl+C pressed. Killing Kalliope")
     sys.exit(0)
     sys.exit(0)
 
 

+ 6 - 5
kalliope/core/ConfigurationManager/BrainLoader.py

@@ -1,8 +1,10 @@
 import inspect
 import inspect
 import logging
 import logging
 import os
 import os
+from six import with_metaclass
+import six
 
 
-from YAMLLoader import YAMLLoader
+from .YAMLLoader import YAMLLoader
 from kalliope.core.Utils import Utils
 from kalliope.core.Utils import Utils
 from kalliope.core.ConfigurationManager import SettingLoader
 from kalliope.core.ConfigurationManager import SettingLoader
 from kalliope.core.ConfigurationManager.ConfigurationChecker import ConfigurationChecker
 from kalliope.core.ConfigurationManager.ConfigurationChecker import ConfigurationChecker
@@ -23,11 +25,10 @@ class BrainNotFound(Exception):
     pass
     pass
 
 
 
 
-class BrainLoader(object):
+class BrainLoader(with_metaclass(Singleton, object)):
     """
     """
     This Class is used to get the brain YAML and the Brain as an object
     This Class is used to get the brain YAML and the Brain as an object
     """
     """
-    __metaclass__ = Singleton
 
 
     def __init__(self, file_path=None):
     def __init__(self, file_path=None):
         sl = SettingLoader()
         sl = SettingLoader()
@@ -252,7 +253,7 @@ class BrainLoader(object):
         """
         """
 
 
         if isinstance(parameter, dict):
         if isinstance(parameter, dict):
-            for key, value in parameter.iteritems():
+            for key, value in parameter.items():
                 parameter[key] = cls._replace_global_variables(value, settings=settings)
                 parameter[key] = cls._replace_global_variables(value, settings=settings)
             return parameter
             return parameter
         if isinstance(parameter, list):
         if isinstance(parameter, list):
@@ -260,7 +261,7 @@ class BrainLoader(object):
             for el in parameter:
             for el in parameter:
                 new_parameter_list.append(cls._replace_global_variables(el, settings=settings))
                 new_parameter_list.append(cls._replace_global_variables(el, settings=settings))
             return new_parameter_list
             return new_parameter_list
-        if isinstance(parameter, str) or isinstance(parameter, unicode) or isinstance(parameter, int):
+        if isinstance(parameter, str) or isinstance(parameter, six.text_type) or isinstance(parameter, int):
             if Utils.is_containing_bracket(parameter):
             if Utils.is_containing_bracket(parameter):
                 return cls._get_global_variable(sentence=parameter, settings=settings)
                 return cls._get_global_variable(sentence=parameter, settings=settings)
             return parameter
             return parameter

+ 1 - 1
kalliope/core/ConfigurationManager/ConfigurationChecker.py

@@ -288,6 +288,6 @@ class ConfigurationChecker:
             synapse_name = synapse.name.encode('utf-8')
             synapse_name = synapse.name.encode('utf-8')
             if synapse_name in seen:
             if synapse_name in seen:
                 raise MultipleSameSynapseName("Multiple synapse found with the same name: %s" % synapse_name)
                 raise MultipleSameSynapseName("Multiple synapse found with the same name: %s" % synapse_name)
-            seen.add(synapse.name)
+            seen.add(synapse_name)
 
 
         return True
         return True

+ 11 - 11
kalliope/core/ConfigurationManager/SettingLoader.py

@@ -1,7 +1,8 @@
 import logging
 import logging
 import os
 import os
+from six import with_metaclass
 
 
-from YAMLLoader import YAMLLoader
+from .YAMLLoader import YAMLLoader
 from kalliope.core.Models.Resources import Resources
 from kalliope.core.Models.Resources import Resources
 from kalliope.core.Utils.Utils import Utils
 from kalliope.core.Utils.Utils import Utils
 from kalliope.core.Models import Singleton
 from kalliope.core.Models import Singleton
@@ -45,11 +46,10 @@ class SettingNotFound(Exception):
     pass
     pass
 
 
 
 
-class SettingLoader(object):
+class SettingLoader(with_metaclass(Singleton, object)):
     """
     """
     This Class is used to get the Settings YAML and the Settings as an object
     This Class is used to get the Settings YAML and the Settings as an object
     """
     """
-    __metaclass__ = Singleton
 
 
     def __init__(self, file_path=None):
     def __init__(self, file_path=None):
         self.file_path = file_path
         self.file_path = file_path
@@ -159,7 +159,7 @@ class SettingLoader(object):
                 raise NullSettingException("Attribute default_speech_to_text is null")
                 raise NullSettingException("Attribute default_speech_to_text is null")
             logger.debug("Default STT: %s" % default_speech_to_text)
             logger.debug("Default STT: %s" % default_speech_to_text)
             return default_speech_to_text
             return default_speech_to_text
-        except KeyError, e:
+        except KeyError as e:
             raise SettingNotFound("%s setting not found" % e)
             raise SettingNotFound("%s setting not found" % e)
 
 
     @staticmethod
     @staticmethod
@@ -187,7 +187,7 @@ class SettingLoader(object):
                 raise NullSettingException("Attribute default_text_to_speech is null")
                 raise NullSettingException("Attribute default_text_to_speech is null")
             logger.debug("Default TTS: %s" % default_text_to_speech)
             logger.debug("Default TTS: %s" % default_text_to_speech)
             return default_text_to_speech
             return default_text_to_speech
-        except KeyError, e:
+        except KeyError as e:
             raise SettingNotFound("%s setting not found" % e)
             raise SettingNotFound("%s setting not found" % e)
 
 
     @staticmethod
     @staticmethod
@@ -214,7 +214,7 @@ class SettingLoader(object):
                 raise NullSettingException("Attribute default_trigger is null")
                 raise NullSettingException("Attribute default_trigger is null")
             logger.debug("Default Trigger name: %s" % default_trigger)
             logger.debug("Default Trigger name: %s" % default_trigger)
             return default_trigger
             return default_trigger
-        except KeyError, e:
+        except KeyError as e:
             raise SettingNotFound("%s setting not found" % e)
             raise SettingNotFound("%s setting not found" % e)
 
 
     @staticmethod
     @staticmethod
@@ -277,7 +277,7 @@ class SettingLoader(object):
 
 
         try:
         try:
             text_to_speech_list = settings["text_to_speech"]
             text_to_speech_list = settings["text_to_speech"]
-        except KeyError, e:
+        except KeyError as e:
             raise SettingNotFound("%s setting not found" % e)
             raise SettingNotFound("%s setting not found" % e)
 
 
         ttss = list()
         ttss = list()
@@ -315,7 +315,7 @@ class SettingLoader(object):
 
 
         try:
         try:
             triggers_list = settings["triggers"]
             triggers_list = settings["triggers"]
-        except KeyError, e:
+        except KeyError as e:
             raise SettingNotFound("%s setting not found" % e)
             raise SettingNotFound("%s setting not found" % e)
 
 
         triggers = list()
         triggers = list()
@@ -419,7 +419,7 @@ class SettingLoader(object):
 
 
         try:
         try:
             rest_api = settings["rest_api"]
             rest_api = settings["rest_api"]
-        except KeyError, e:
+        except KeyError as e:
             raise SettingNotFound("%s setting not found" % e)
             raise SettingNotFound("%s setting not found" % e)
 
 
         if rest_api is not None:
         if rest_api is not None:
@@ -454,7 +454,7 @@ class SettingLoader(object):
                 if "allowed_cors_origin" in rest_api:
                 if "allowed_cors_origin" in rest_api:
                      allowed_cors_origin = rest_api["allowed_cors_origin"]
                      allowed_cors_origin = rest_api["allowed_cors_origin"]
 
 
-            except KeyError, e:
+            except KeyError as e:
                 raise SettingNotFound("%s settings not found" % e)
                 raise SettingNotFound("%s settings not found" % e)
 
 
             # config ok, we can return the rest api object
             # config ok, we can return the rest api object
@@ -485,7 +485,7 @@ class SettingLoader(object):
 
 
         try:
         try:
             cache_path = settings["cache_path"]
             cache_path = settings["cache_path"]
-        except KeyError, e:
+        except KeyError as e:
             raise SettingNotFound("%s setting not found" % e)
             raise SettingNotFound("%s setting not found" % e)
 
 
         if cache_path is None:
         if cache_path is None:

+ 4 - 2
kalliope/core/ConfigurationManager/YAMLLoader.py

@@ -72,7 +72,8 @@ class IncludeImport(object):
         parent_dir = os.path.normpath(file_path + os.sep + os.pardir)
         parent_dir = os.path.normpath(file_path + os.sep + os.pardir)
 
 
         # load the yaml file
         # load the yaml file
-        self.data = yaml.load(open(file_path, 'r'))
+        with open(file_path, "r") as f:
+            self.data = yaml.load(f)
 
 
         if self.data is None:
         if self.data is None:
             raise YAMLFileEmpty("File %s is empty" % file_path)
             raise YAMLFileEmpty("File %s is empty" % file_path)
@@ -86,7 +87,8 @@ class IncludeImport(object):
                             # logger.debug("File path %s is relative, adding the root path" % inc)
                             # logger.debug("File path %s is relative, adding the root path" % inc)
                             inc = os.path.join(parent_dir, inc)
                             inc = os.path.join(parent_dir, inc)
                             # logger.debug("New path: %s" % inc)
                             # logger.debug("New path: %s" % inc)
-                        self.update(yaml.load(open(inc)))
+                        with open(inc, "r") as f:
+                            self.update(yaml.load(f))
 
 
     def get_data(self):
     def get_data(self):
         """
         """

+ 3 - 3
kalliope/core/ConfigurationManager/__init__.py

@@ -1,3 +1,3 @@
-from YAMLLoader import YAMLLoader
+from .YAMLLoader import YAMLLoader
-from SettingLoader import SettingLoader
+from .SettingLoader import SettingLoader
-from BrainLoader import BrainLoader
+from .BrainLoader import BrainLoader

+ 1 - 1
kalliope/core/Models/Neuron.py

@@ -33,7 +33,7 @@ class Neuron(object):
         }
         }
 
 
         cleaned_parameters = dict()
         cleaned_parameters = dict()
-        for key, value in self.parameters.iteritems():
+        for key, value in self.parameters.items():
             if "password" in key:
             if "password" in key:
                 cleaned_parameters[key] = "*****"
                 cleaned_parameters[key] = "*****"
             else:
             else:

+ 7 - 7
kalliope/core/Models/__init__.py

@@ -1,8 +1,8 @@
-from Singleton import Singleton
+from .Singleton import Singleton
-from Event import Event
+from .Event import Event
-from Resources import Resources
+from .Resources import Resources
-from Brain import Brain
+from .Brain import Brain
-from Order import Order
+from .Order import Order
-from Synapse import Synapse
+from .Synapse import Synapse
-from Neuron import Neuron
+from .Neuron import Neuron
 
 

+ 2 - 2
kalliope/core/NeuronLauncher.py

@@ -1,5 +1,5 @@
 import logging
 import logging
-
+import six
 import jinja2
 import jinja2
 
 
 from kalliope.core.Utils.Utils import Utils
 from kalliope.core.Utils.Utils import Utils
@@ -66,7 +66,7 @@ class NeuronLauncher:
         :param loaded_parameters: dict of parameters
         :param loaded_parameters: dict of parameters
         """
         """
         logger.debug("[NeuronLauncher] replacing brackets from %s, using %s" % (neuron_parameters, loaded_parameters))
         logger.debug("[NeuronLauncher] replacing brackets from %s, using %s" % (neuron_parameters, loaded_parameters))
-        if isinstance(neuron_parameters, str) or isinstance(neuron_parameters, unicode):
+        if isinstance(neuron_parameters, str) or isinstance(neuron_parameters, six.text_type):
             # replace bracket parameter only if the str contains brackets
             # replace bracket parameter only if the str contains brackets
             if Utils.is_containing_bracket(neuron_parameters):
             if Utils.is_containing_bracket(neuron_parameters):
                 # check that the parameter to replace is available in the loaded_parameters dict
                 # check that the parameter to replace is available in the loaded_parameters dict

+ 8 - 6
kalliope/core/NeuronModule.py

@@ -2,6 +2,7 @@
 import logging
 import logging
 import random
 import random
 import sys
 import sys
+import six
 
 
 from jinja2 import Template
 from jinja2 import Template
 
 
@@ -79,10 +80,9 @@ class NeuronModule(object):
             # we get the default TTS
             # we get the default TTS
             self.tts = self._get_tts_object(settings=self.settings)
             self.tts = self._get_tts_object(settings=self.settings)
         else:
         else:
-            for key, value in self.override_tts_parameters.iteritems():
+            for key, value in self.override_tts_parameters.items():
                 tts_name = key
                 tts_name = key
                 tts_parameters = value
                 tts_parameters = value
-                print tts_parameters
                 self.tts = self._get_tts_object(tts_name=tts_name,
                 self.tts = self._get_tts_object(tts_name=tts_name,
                                                 override_parameter=tts_parameters,
                                                 override_parameter=tts_parameters,
                                                 settings=self.settings)
                                                 settings=self.settings)
@@ -133,10 +133,11 @@ class NeuronModule(object):
 
 
         tts_message = None
         tts_message = None
 
 
-        if isinstance(message, str) or isinstance(message, unicode):
+        if isinstance(message, str) or isinstance(message, six.text_type):
             logger.debug("message is string")
             logger.debug("message is string")
             tts_message = message
             tts_message = message
 
 
+
         if isinstance(message, list):
         if isinstance(message, list):
             logger.debug("message is list")
             logger.debug("message is list")
             tts_message = random.choice(message)
             tts_message = random.choice(message)
@@ -176,8 +177,9 @@ class NeuronModule(object):
             returned_message = self._get_say_template(self.say_template, message_dict)
             returned_message = self._get_say_template(self.say_template, message_dict)
 
 
         # trick to remove unicode problem when loading jinja template with non ascii char
         # trick to remove unicode problem when loading jinja template with non ascii char
-        reload(sys)
+        if sys.version_info[0] == 2:
-        sys.setdefaultencoding('utf-8')
+            reload(sys)
+            sys.setdefaultencoding('utf-8')
 
 
         # the user chooses a file_template option
         # the user chooses a file_template option
         if self.file_template is not None:  # the user choose a file_template option
         if self.file_template is not None:  # the user choose a file_template option
@@ -279,7 +281,7 @@ class NeuronModule(object):
 
 
         if override_parameter is not None:  # the user want to override the default TTS configuration
         if override_parameter is not None:  # the user want to override the default TTS configuration
             logger.debug("args for TTS plugin before update: %s" % str(tts_object.parameters))
             logger.debug("args for TTS plugin before update: %s" % str(tts_object.parameters))
-            for key, value in override_parameter.iteritems():
+            for key, value in override_parameter.items():
                 tts_object.parameters[key] = value
                 tts_object.parameters[key] = value
             logger.debug("args for TTS plugin after update: %s" % str(tts_object.parameters))
             logger.debug("args for TTS plugin after update: %s" % str(tts_object.parameters))
 
 

+ 3 - 1
kalliope/core/OrderAnalyser.py

@@ -1,6 +1,8 @@
 # coding: utf8
 # coding: utf8
 import collections
 import collections
 from collections import Counter
 from collections import Counter
+import sys
+import six
 
 
 from kalliope.core.Models.MatchedSynapse import MatchedSynapse
 from kalliope.core.Models.MatchedSynapse import MatchedSynapse
 from kalliope.core.Utils.Utils import Utils
 from kalliope.core.Utils.Utils import Utils
@@ -35,7 +37,7 @@ class OrderAnalyser:
         """
         """
         cls.brain = brain
         cls.brain = brain
         logger.debug("[OrderAnalyser] Received order: %s" % order)
         logger.debug("[OrderAnalyser] Received order: %s" % order)
-        if isinstance(order, str):
+        if isinstance(order, six.binary_type):
             order = order.decode('utf-8')
             order = order.decode('utf-8')
 
 
         # We use a namedtuple to associate the synapse and the signal of the synapse
         # We use a namedtuple to associate the synapse and the signal of the synapse

+ 1 - 1
kalliope/core/Players/__init__.py

@@ -1 +1 @@
-from Mplayer import Mplayer
+from .Mplayer import Mplayer

+ 1 - 1
kalliope/core/ShellGui.py

@@ -23,7 +23,7 @@ def signal_handler(signal, frame):
     :param signal: signal handler
     :param signal: signal handler
     :param frame: execution frame
     :param frame: execution frame
     """
     """
-    print "\n"
+    print("\n")
     Utils.print_info("Ctrl+C pressed. Killing Kalliope")
     Utils.print_info("Ctrl+C pressed. Killing Kalliope")
     sys.exit(0)
     sys.exit(0)
 
 

+ 3 - 1
kalliope/core/TTS/TTSModule.py

@@ -2,6 +2,8 @@
 import hashlib
 import hashlib
 import logging
 import logging
 import os
 import os
+import sys
+import six
 
 
 from kalliope.core.ConfigurationManager import SettingLoader
 from kalliope.core.ConfigurationManager import SettingLoader
 from kalliope.core.Players import Mplayer
 from kalliope.core.Players import Mplayer
@@ -132,7 +134,7 @@ class TTSModule(object):
         :param words: Text to convert into md5 hash
         :param words: Text to convert into md5 hash
         :return: String md5 hash from the received words
         :return: String md5 hash from the received words
         """
         """
-        if isinstance(words, unicode):
+        if isinstance(words, six.text_type):
             words = words.encode('utf-8')
             words = words.encode('utf-8')
         return hashlib.md5(words).hexdigest()
         return hashlib.md5(words).hexdigest()
 
 

+ 1 - 1
kalliope/core/TTS/__init__.py

@@ -1 +1 @@
-from TTSModule import TTSModule
+from .TTSModule import TTSModule

+ 1 - 1
kalliope/core/Utils/FileManager.py

@@ -36,7 +36,7 @@ class FileManager:
         """
         """
         try:
         try:
             with open(file_path, "wb") as file_open:
             with open(file_path, "wb") as file_open:
-                file_open.write(content)
+                file_open.write(content.encode())
                 file_open.close()
                 file_open.close()
             return not FileManager.file_is_empty(file_path)
             return not FileManager.file_is_empty(file_path)
         except IOError as e:
         except IOError as e:

+ 8 - 4
kalliope/core/Utils/Utils.py

@@ -2,14 +2,18 @@ import logging
 import os
 import os
 import inspect
 import inspect
 import imp
 import imp
+import sys
 import re
 import re
+import six
 
 
 logging.basicConfig()
 logging.basicConfig()
 logger = logging.getLogger("kalliope")
 logger = logging.getLogger("kalliope")
 
 
 
 
 def pipe_print(line):
 def pipe_print(line):
-    print(line.encode('utf-8'))
+    if sys.version_info[0] < 3:
+        line = line.encode('utf-8')
+    print(line)
 
 
 
 
 class ModuleNotFoundError(Exception):
 class ModuleNotFoundError(Exception):
@@ -240,7 +244,7 @@ class Utils(object):
         # print "sentence to test %s" % sentence
         # print "sentence to test %s" % sentence
         pattern = r"{{|}}"
         pattern = r"{{|}}"
         # prog = re.compile(pattern)
         # prog = re.compile(pattern)
-        if not isinstance(sentence, unicode):
+        if not isinstance(sentence, six.text_type):
             sentence = str(sentence)
             sentence = str(sentence)
         check_bool = re.search(pattern, sentence)
         check_bool = re.search(pattern, sentence)
         if check_bool is not None:
         if check_bool is not None:
@@ -257,7 +261,7 @@ class Utils(object):
 
 
         pattern = r"((?:{{\s*)[\w\.]+(?:\s*}}))"
         pattern = r"((?:{{\s*)[\w\.]+(?:\s*}}))"
         # find everything like {{ word }}
         # find everything like {{ word }}
-        if not isinstance(sentence, unicode):
+        if not isinstance(sentence, six.text_type):
             sentence = str(sentence)
             sentence = str(sentence)
         return re.findall(pattern, sentence)
         return re.findall(pattern, sentence)
 
 
@@ -271,7 +275,7 @@ class Utils(object):
 
 
         pattern = '\s+(?=[^\{\{\}\}]*\}\})'
         pattern = '\s+(?=[^\{\{\}\}]*\}\})'
         # Remove white spaces (if any) between the variable and the double brace then split
         # Remove white spaces (if any) between the variable and the double brace then split
-        if not isinstance(sentence, unicode):
+        if not isinstance(sentence, six.text_type):
             sentence = str(sentence)
             sentence = str(sentence)
         return re.sub(pattern, '', sentence)
         return re.sub(pattern, '', sentence)
 
 

+ 1 - 1
kalliope/neurons/ansible_playbook/__init__.py

@@ -1 +1 @@
-from ansible_playbook import Ansible_playbook
+from .ansible_playbook import Ansible_playbook

+ 1 - 1
kalliope/neurons/kill_switch/__init__.py

@@ -1 +1 @@
-from kill_switch import Kill_switch
+from .kill_switch import Kill_switch

+ 1 - 1
kalliope/neurons/neurotransmitter/__init__.py

@@ -1 +1 @@
-from neurotransmitter import Neurotransmitter
+from .neurotransmitter import Neurotransmitter

+ 1 - 1
kalliope/neurons/say/__init__.py

@@ -1 +1 @@
-from say import Say
+from .say import Say

+ 1 - 1
kalliope/neurons/script/__init__.py

@@ -1 +1 @@
-from script import Script
+from .script import Script

+ 1 - 1
kalliope/neurons/script/script.py

@@ -39,7 +39,7 @@ class Script(NeuronModule):
             if not self.async:
             if not self.async:
                 p = subprocess.Popen(self.path, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=False)
                 p = subprocess.Popen(self.path, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=False)
                 (output, err) = p.communicate()
                 (output, err) = p.communicate()
-                self.output = output
+                self.output = output.decode()
                 self.returncode = p.returncode
                 self.returncode = p.returncode
                 message = {
                 message = {
                     "output": self.output,
                     "output": self.output,

+ 2 - 2
kalliope/neurons/script/tests/test_script.py

@@ -48,7 +48,7 @@ class TestScript(unittest.TestCase):
         text_to_write = "[kalliope-test] TestScript - testParameters"
         text_to_write = "[kalliope-test] TestScript - testParameters"
         with open(tmp_file_path, 'w') as myFile:
         with open(tmp_file_path, 'w') as myFile:
             myFile.write(text_to_write)
             myFile.write(text_to_write)
-        os.chmod(tmp_file_path, 0600)
+        os.chmod(tmp_file_path, 0o600)
         # test the user does not have access
         # test the user does not have access
         self.path = tmp_file_path
         self.path = tmp_file_path
         parameters = {
         parameters = {
@@ -56,7 +56,7 @@ class TestScript(unittest.TestCase):
         }
         }
         run_test_invalid_param(parameters)
         run_test_invalid_param(parameters)
         # Remove the tmp file
         # Remove the tmp file
-        os.chmod(tmp_file_path, 0700)
+        os.chmod(tmp_file_path, 0o700)
         os.remove(tmp_file_path)
         os.remove(tmp_file_path)
 
 
     def test_script_execution(self):
     def test_script_execution(self):

+ 1 - 1
kalliope/neurons/shell/__init__.py

@@ -1 +1 @@
-from shell import Shell
+from .shell import Shell

+ 1 - 1
kalliope/neurons/shell/shell.py

@@ -50,7 +50,7 @@ class Shell(NeuronModule):
             if not self.async:
             if not self.async:
                 p = subprocess.Popen(self.cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)
                 p = subprocess.Popen(self.cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)
                 (output, err) = p.communicate()
                 (output, err) = p.communicate()
-                self.output = output
+                self.output = output.decode()
                 self.returncode = p.returncode
                 self.returncode = p.returncode
                 message = {
                 message = {
                     "output": self.output,
                     "output": self.output,

+ 1 - 1
kalliope/neurons/sleep/__init__.py

@@ -1 +1 @@
-from sleep import Sleep
+from .sleep import Sleep

+ 2 - 1
kalliope/neurons/sleep/sleep.py

@@ -1,4 +1,5 @@
 import time
 import time
+import six
 
 
 from kalliope.core.NeuronModule import NeuronModule,  MissingParameterException
 from kalliope.core.NeuronModule import NeuronModule,  MissingParameterException
 
 
@@ -12,7 +13,7 @@ class Sleep(NeuronModule):
         if self._is_parameters_ok():
         if self._is_parameters_ok():
 
 
             if isinstance(self.seconds, str) or \
             if isinstance(self.seconds, str) or \
-                    isinstance(self.seconds, unicode):
+                    isinstance(self.seconds, six.text_type):
                 self.seconds = float(self.seconds)
                 self.seconds = float(self.seconds)
 
 
             time.sleep(self.seconds)
             time.sleep(self.seconds)

+ 1 - 1
kalliope/neurons/systemdate/__init__.py

@@ -1 +1 @@
-from systemdate import Systemdate
+from .systemdate import Systemdate

+ 3 - 3
kalliope/neurons/uri/tests/test_uri_neuron.py

@@ -25,7 +25,7 @@ class TestUri(unittest.TestCase):
         self.assertEqual(uri_neuron.text, expected_content)
         self.assertEqual(uri_neuron.text, expected_content)
 
 
     def testGetRaw(self):
     def testGetRaw(self):
-        expected_content = 'raw line'
+        expected_content = b'raw line'
         httpretty.enable()
         httpretty.enable()
         httpretty.register_uri(httpretty.GET, self.test_url, body=expected_content)
         httpretty.register_uri(httpretty.GET, self.test_url, body=expected_content)
         parameters = {
         parameters = {
@@ -151,7 +151,7 @@ class TestUri(unittest.TestCase):
         :return:
         :return:
         """
         """
         def request_callback(request, url, headers):
         def request_callback(request, url, headers):
-            data = json.loads(request.body)
+            data = json.loads(request.body.decode())
             if "title" in data and "body" in data and "userId" in data:
             if "title" in data and "body" in data and "userId" in data:
                 return 200, headers, "all key received from URL %s" % url
                 return 200, headers, "all key received from URL %s" % url
 
 
@@ -178,7 +178,7 @@ class TestUri(unittest.TestCase):
         :return:
         :return:
         """
         """
         def request_callback(request, url, headers):
         def request_callback(request, url, headers):
-            data = json.loads(request.body)
+            data = json.loads(request.body.decode())
             if "title" in data and "body" in data and "userId" in data:
             if "title" in data and "body" in data and "userId" in data:
                 return 200, headers, "all key received from URL %s" % url
                 return 200, headers, "all key received from URL %s" % url
 
 

+ 3 - 3
kalliope/neurons/uri/uri.py

@@ -127,7 +127,7 @@ class Uri(NeuronModule):
         self.content = r.content
         self.content = r.content
         # we try to load into a json object the content. So Kalliope can use it to talk
         # we try to load into a json object the content. So Kalliope can use it to talk
         try:
         try:
-            self.content = json.loads(self.content)
+            self.content = json.loads(self.content.decode())
         except ValueError:
         except ValueError:
             logger.debug(self.neuron_name + "cannot get a valid json from returned content")
             logger.debug(self.neuron_name + "cannot get a valid json from returned content")
             pass
             pass
@@ -161,7 +161,7 @@ class Uri(NeuronModule):
         if self.data is not None:
         if self.data is not None:
             try:
             try:
                 json.loads(self.data)
                 json.loads(self.data)
-            except ValueError, e:
+            except ValueError as e:
                 raise InvalidParameterException("error in \"data\" parameter: %s" % e)
                 raise InvalidParameterException("error in \"data\" parameter: %s" % e)
 
 
         # data_from_file path must exist and data inside must be loadable by json
         # data_from_file path must exist and data inside must be loadable by json
@@ -172,7 +172,7 @@ class Uri(NeuronModule):
             # then try to load the json from the file
             # then try to load the json from the file
             try:
             try:
                 self.data_from_file = self.readfile(self.data_from_file)
                 self.data_from_file = self.readfile(self.data_from_file)
-            except ValueError, e:
+            except ValueError as e:
                 raise InvalidParameterException("error in \"data\" parameter: %s" % e)
                 raise InvalidParameterException("error in \"data\" parameter: %s" % e)
 
 
         # we cannot provide both data and data from file
         # we cannot provide both data and data from file

+ 1 - 1
kalliope/stt/apiai/__init__.py

@@ -1 +1 @@
-from apiai import Apiai
+from .apiai import Apiai

+ 1 - 1
kalliope/stt/bing/__init__.py

@@ -1 +1 @@
-from bing import Bing
+from .bing import Bing

+ 1 - 1
kalliope/stt/cmusphinx/__init__.py

@@ -1 +1 @@
-from cmusphinx import Cmusphinx
+from .cmusphinx import Cmusphinx

+ 1 - 1
kalliope/stt/google/__init__.py

@@ -1 +1 @@
-from google import Google
+from .google import Google

+ 1 - 1
kalliope/stt/houndify/__init__.py

@@ -1 +1 @@
-from houndify import Houndify
+from .houndify import Houndify

+ 1 - 1
kalliope/stt/wit/__init__.py

@@ -1 +1 @@
-from wit import Wit
+from .wit import Wit

+ 1 - 1
kalliope/trigger/snowboy/__init__.py

@@ -1 +1 @@
-from snowboy import Snowboy
+from .snowboy import Snowboy

+ 0 - 0
kalliope/trigger/snowboy/armv7l/_snowboydetect.so → kalliope/trigger/snowboy/armv7l/python27/_snowboydetect.so


+ 1 - 1
kalliope/trigger/snowboy/snowboydecoder.py

@@ -4,7 +4,7 @@ import collections
 from threading import Thread
 from threading import Thread
 
 
 import pyaudio
 import pyaudio
-import snowboydetect
+from . import snowboydetect
 import time
 import time
 import os
 import os
 import logging
 import logging

+ 1 - 1
kalliope/trigger/snowboy/snowboydetect.py

@@ -8,7 +8,7 @@ from sys import version_info
 
 
 sl = SettingLoader()
 sl = SettingLoader()
 settings = sl.settings
 settings = sl.settings
-module_file_path = "%s/_snowboydetect" % settings.machine
+module_file_path = "%s/python%d%d/_snowboydetect" % (settings.machine, version_info[0], version_info[1])
 
 
 
 
 if version_info >= (2, 6, 0):
 if version_info >= (2, 6, 0):

+ 0 - 0
kalliope/trigger/snowboy/x86_64/_snowboydetect.so → kalliope/trigger/snowboy/x86_64/python27/_snowboydetect.so


BIN
kalliope/trigger/snowboy/x86_64/python34/_snowboydetect.so


BIN
kalliope/trigger/snowboy/x86_64/python35/_snowboydetect.so


BIN
kalliope/trigger/snowboy/x86_64/python36/_snowboydetect.so


+ 1 - 1
kalliope/tts/acapela/__init__.py

@@ -1 +1 @@
-from acapela import Acapela
+from .acapela import Acapela

+ 1 - 1
kalliope/tts/googletts/__init__.py

@@ -1 +1 @@
-from googletts import Googletts
+from .googletts import Googletts

+ 1 - 1
kalliope/tts/pico2wave/__init__.py

@@ -1 +1 @@
-from pico2wave import Pico2wave
+from .pico2wave import Pico2wave

+ 1 - 1
kalliope/tts/voicerss/__init__.py

@@ -1 +1 @@
-from voicerss import Voicerss
+from .voicerss import Voicerss

+ 11 - 3
setup.py

@@ -1,6 +1,7 @@
 #! /usr/bin/env python
 #! /usr/bin/env python
 # -*- coding: utf-8 -*-
 # -*- coding: utf-8 -*-
 import re
 import re
+import sys
 from setuptools import setup, find_packages
 from setuptools import setup, find_packages
 from codecs import open
 from codecs import open
 from os import path
 from os import path
@@ -27,6 +28,10 @@ def read_version_py(file_name):
 VERSION_PY_FILENAME = 'kalliope/_version.py'
 VERSION_PY_FILENAME = 'kalliope/_version.py'
 version = read_version_py(VERSION_PY_FILENAME)
 version = read_version_py(VERSION_PY_FILENAME)
 
 
+py2_prefix = ''
+if sys.version_info[0] < 3:
+    py2_prefix = 'python2-'
+
 setup(
 setup(
     name='kalliope',
     name='kalliope',
     version=version,
     version=version,
@@ -63,7 +68,7 @@ setup(
         'pyaudio>=0.2.10',
         'pyaudio>=0.2.10',
         'pyasn1>=0.2.3',
         'pyasn1>=0.2.3',
         'ansible>=2.2',
         'ansible>=2.2',
-        'python2-pythondialog>=3.4.0',
+        py2_prefix + 'pythondialog>=3.4.0',
         'jinja2>=2.8,<=2.9.6',
         'jinja2>=2.8,<=2.9.6',
         'cffi>=1.9.1',
         'cffi>=1.9.1',
         'ipaddress>=1.0.17',
         'ipaddress>=1.0.17',
@@ -86,8 +91,11 @@ setup(
         'kalliope': [
         'kalliope': [
             'brain.yml',
             'brain.yml',
             'settings.yml',
             'settings.yml',
-            'trigger/snowboy/armv7l/_snowboydetect.so',
+            'trigger/snowboy/armv7l/python27/_snowboydetect.so',
-            'trigger/snowboy/x86_64/_snowboydetect.so',
+            'trigger/snowboy/x86_64/python27/_snowboydetect.so',
+            'trigger/snowboy/x86_64/python34/_snowboydetect.so',
+            'trigger/snowboy/x86_64/python35/_snowboydetect.so',
+            'trigger/snowboy/x86_64/python36/_snowboydetect.so',
             'trigger/snowboy/resources/*',
             'trigger/snowboy/resources/*',
             'sounds/*'
             'sounds/*'
          ],
          ],