You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kibble.apache.org by hu...@apache.org on 2017/10/24 20:42:12 UTC
[kibble-scanners] branch master updated: fail gracefully if watson
breaks
This is an automated email from the ASF dual-hosted git repository.
humbedooh pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/kibble-scanners.git
The following commit(s) were added to refs/heads/master by this push:
new 8514053 fail gracefully if watson breaks
8514053 is described below
commit 851405309e56ea4736495a52be1d50a06417cb50
Author: Daniel Gruno <hu...@apache.org>
AuthorDate: Tue Oct 24 22:42:04 2017 +0200
fail gracefully if watson breaks
let's do some better debug of this later on.
---
src/plugins/utils/tone.py | 19 +++++++++++--------
1 file changed, 11 insertions(+), 8 deletions(-)
diff --git a/src/plugins/utils/tone.py b/src/plugins/utils/tone.py
index f523c6a..1ca05cf 100644
--- a/src/plugins/utils/tone.py
+++ b/src/plugins/utils/tone.py
@@ -49,14 +49,17 @@ def getTone(KibbleBit, body):
js = {
'text': body
}
- rv = requests.post(
- "%s/v3/tone?version=2017-09-21&sentences=false" % KibbleBit.config['watson']['api'],
- headers = headers,
- data = json.dumps(js),
- auth = (KibbleBit.config['watson']['username'], KibbleBit.config['watson']['password'])
- )
- mood = {}
- jsout = rv.json()
+ try:
+ rv = requests.post(
+ "%s/v3/tone?version=2017-09-21&sentences=false" % KibbleBit.config['watson']['api'],
+ headers = headers,
+ data = json.dumps(js),
+ auth = (KibbleBit.config['watson']['username'], KibbleBit.config['watson']['password'])
+ )
+ mood = {}
+ jsout = rv.json()
+ except:
+ jsout = {} # borked Watson?
if 'document_tone' in jsout:
for tone in jsout['document_tone']['tones']:
mood[tone['tone_id']] = tone['score']
--
To stop receiving notification emails like this one, please contact
['"commits@kibble.apache.org" <co...@kibble.apache.org>'].