Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

butler : still not ok with utf8 inputs #172

Closed
fritz-smh opened this issue Nov 12, 2015 · 12 comments
Closed

butler : still not ok with utf8 inputs #172

fritz-smh opened this issue Nov 12, 2015 · 12 comments
Labels

Comments

@fritz-smh
Copy link
Contributor

Example with : "свет"
Butler responds : ERR: No Reply Matched

@fritz-smh fritz-smh added the bug label Nov 12, 2015
@fritz-smh fritz-smh added this to the 0.4.2 users issue milestone Nov 12, 2015
@axboct
Copy link

axboct commented Nov 19, 2015

@fritz-smh
Copy link
Contributor Author

Interesting. I will include the newly rivescript release in Domogik 0.5.

@fritz-smh
Copy link
Contributor Author

Should be ok now:
cf76939
a8bf40d

But I have still to do some improvments on latin charset

@axboct tell me if the fix is ok on your side (and make sure to also use utf8 russian responses from the butler)

@fritz-smh
Copy link
Contributor Author

Notice : rivescript 1.8.0 introduces a new way to handle [...] blocks... some triggers (a lot sadly) are not ok anymore...

More informations here : aichaos/rivescript-js#48
(with a comment from me to describe the issue)

@kirsle
Copy link

kirsle commented Nov 20, 2015

RiveScript v1.8.1 fixes the issue described in aichaos/rivescript-js#48

@axboct
Copy link

axboct commented Nov 20, 2015

without changes :(
The example uses a request temperature device named "дом"

2015-11-20 21:25:13,968 domogik-butler INFO Received message : {u'text': u'\u0442\u0435\u043c\u043f\u0435\u0440\u0430\u0442\u0443\u0440\u0430 \u0434\u043e\u043c', u'media': u'chat', u'identity': u'admin', u'source': u'core-butler.skyworker'}
2015-11-20 21:25:13,969 domogik-butler DEBUG Before transforming query : температура дом
2015-11-20 21:25:13,969 domogik-butler DEBUG After transforming query : температура дом
2015-11-20 21:25:13,969 domogik-butler DEBUG Before calling Rivescript brain for processing : температура дом (type=<type 'unicode'>)
2015-11-20 21:25:13,977 domogik-butler DEBUG Processing finished. The reply is : температура дом  [ERR: Error when executing Python object]
2015-11-20 21:25:13,978 domogik-butler INFO Send response over MQ : {'mood': None, 'media': u'chat', 'sex': 'female', 'location': None, 'text': u'\u0442\u0435\u043c\u043f\u0435\u0440\u0430\u0442\u0443\u0440\u0430 \u0434\u043e\u043c  [ERR: Error when executing Python object]', 'reply_to': u'core-butler.skyworker', 'identity': 'Aria'}

fore test I use simple script (from python_get_sensor_value.rive)

# -*- coding: utf-8 -*-
from domogik.butler.brain import get_sensor_value
dt_type = 'DT_Temp'
unit = 'degres'
args=raw_input('key_input: ')
device_name = args
value = get_sensor_value(dt_type, device_name)
#    if value == None:
 #       print (u"неизвестнo")
print (u"{0} {1}".format(value, unit))

response is OK

key_input: дом
Device name = дом
Preferences found for datatype 'DT_Temp' : sensor 'current_temperature'
Candidates for the appropriate datatype : [{'sensor_name': u'Temperature', 'device_name': u'\u0434\u043e\u043c', 'sensor_id': 13, 'sensor_reference': u'current_temperature', 'last_value': u'7', 'device_id': 2}, {'sensor_name': u'Temperature', 'device_name': u'disk', 'sensor_id': 69, 'sensor_reference': u'temperature', 'last_value': u'40', 'device_id': 14}]
The sensor is : {'sensor_name': u'Temperature', 'device_name': u'\u0434\u043e\u043c', 'sensor_id': 13, 'sensor_reference': u'current_temperature', 'last_value': u'7', 'device_id': 2}
7 degres

@kirsle
Copy link

kirsle commented Nov 20, 2015

@fritz-smh in the default Python RiveScript module when an object raises an exception at run-time, the exception message is printed to standard error. I'm not sure what your app does with this but it may be something to look into making more visible to the user.

For example

> object test python
    return 5/0
< object

+ test
- <call>test</call>
You> test
[RS] Error executing Python object: division by zero
Bot> [ERR: Error when executing Python object]

@fritz-smh
Copy link
Contributor Author

@kirsle indeed, I have in my todo to find a way to properly log rivescript side issues in our application logs (and the application runs in background). I use a lot of python functions for advanced usages and it may happen that for some reasons it crashes and sadly we have to restart the component in a terminal to check what is not going fine.

If you have any idea I would be glad to ear them :)

The only option I have in mind for now is to tweak rivescript.py file to use my application logger when an error occurs (as we can add some item to rivescript object easily I can easily add my logger in it.

By the way, another question : is there a roadmap about the next rivescript releases ?

fritz-smh added a commit that referenced this issue Nov 20, 2015
@fritz-smh
Copy link
Contributor Author

@axboct it should be ok now. Please check.

@axboct
Copy link

axboct commented Nov 24, 2015

missed unicode

diff --git a/src/domogik/butler/brain.py b/src/domogik/butler/brain.py
index 6a016f4..e8ade4f 100644
--- a/src/domogik/butler/brain.py
+++ b/src/domogik/butler/brain.py
@@ -283,13 +283,13 @@ def filter_sensors_by_reference_and_device_name(candidates, reference, device_na
 def filter_sensors_by_device_name(candidates, device_name, log):
     """ for each given sensor, check the most appropriate choice depending on device_name
     """
-    log.info("Filter sensors by device name ({0})...".format(device_name))
+    log.info(u"Filter sensors by device name ({0})...".format(device_name))
     device_name = clean_input(device_name)

     # first, check if we got an exact match !
     for a_sensor in candidates:
         try:
-            if clean_input(a_sensor["device_name"]) == device_name:
+            if clean_input(a_sensor[u"device_name"]) == device_name:
                 return a_sensor
         except:
             log.error(u"ERROR : {0}".format(traceback.format_exc()))

@axboct
Copy link

axboct commented Dec 10, 2015

can be closed. everything is working

@fritz-smh
Copy link
Contributor Author

Great :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants