Skip to content

Commit b1a7f44

Browse files
authored
Merge branch 'master' into fix-docs
2 parents dfe8164 + 5b18a2b commit b1a7f44

File tree

9 files changed

+48
-9
lines changed

9 files changed

+48
-9
lines changed

.bumpversion.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[bumpversion]
2-
current_version = 2.2.0
2+
current_version = 2.2.5
33
commit = True
44

55
[bumpversion:file:watson_developer_cloud/version.py]

.travis.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ deploy:
3434
script: docs/publish.sh
3535
skip_cleanup: true
3636
on:
37+
python: '3.5'
3738
tags: true
3839
- provider: script
3940
script: npx semantic-release
@@ -48,4 +49,5 @@ deploy:
4849
repository: https://upload.pypi.org/legacy
4950
skip_cleanup: true
5051
on:
52+
python: '3.5'
5153
tags: true

examples/assistant_v2.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
# If service instance provides API key authentication
66
# assistant = AssistantV2(
7-
# version='2017-04-21',
7+
# version='2018-09-20',
88
# ## url is optional, and defaults to the URL below. Use the correct URL for your region.
99
# url='https://gateway.watsonplatform.net/assistant/api',
1010
# iam_apikey='iam_apikey')
@@ -14,7 +14,7 @@
1414
password='YOUR SERVICE PASSWORD',
1515
## url is optional, and defaults to the URL below. Use the correct URL for your region.
1616
url='https://gateway.watsonplatform.net/assistant/api',
17-
version='2017-04-21')
17+
version='2018-09-20')
1818

1919
#########################
2020
# Sessions

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
import os
2020
import sys
2121

22-
__version__ = '2.2.0'
22+
__version__ = '2.2.5'
2323

2424
if sys.argv[-1] == 'publish':
2525
# test server

test/unit/test_authorization_v1.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# coding: utf-8
2+
import responses
3+
import watson_developer_cloud
4+
5+
6+
@responses.activate
7+
def test_request_token():
8+
url = 'https://stream.watsonplatform.net/authorization/api/v1/token?url=https://stream.watsonplatform.net/speech-to-text/api'
9+
responses.add(responses.GET,
10+
url=url,
11+
body=b'mocked token',
12+
status=200)
13+
authorization = watson_developer_cloud.AuthorizationV1(username='xxx',
14+
password='yyy')
15+
authorization.get_token(url=watson_developer_cloud.SpeechToTextV1.default_url)
16+
assert responses.calls[0].request.url == url
17+
assert responses.calls[0].response.content.decode('utf-8') == 'mocked token'

watson_developer_cloud/authorization_v1.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,4 +52,4 @@ def get_token(self, url):
5252
self.url = urlparse.urlunsplit(parsed_url)
5353

5454
response = self.request(method='GET', url='/v1/token?url=' + url)
55-
return response.text
55+
return response.result.text

watson_developer_cloud/speech_to_text_v1_adapter.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,14 @@ def recognize_using_websocket(self,
199199
}
200200
options = _remove_null_values(options)
201201

202-
RecognizeListener(audio, options, recognize_callback, url, headers, http_proxy_host, http_proxy_port)
202+
RecognizeListener(audio,
203+
options,
204+
recognize_callback,
205+
url,
206+
headers,
207+
http_proxy_host,
208+
http_proxy_port,
209+
self.verify)
203210

204211
def add_corpus(self,
205212
customization_id,

watson_developer_cloud/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = '2.2.0'
1+
__version__ = '2.2.5'

watson_developer_cloud/websocket/recognize_listener.py

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
import websocket
1818
import json
1919
import time
20+
import ssl
2021
try:
2122
import thread
2223
except ImportError:
@@ -31,7 +32,15 @@
3132
STOP = "stop"
3233

3334
class RecognizeListener(object):
34-
def __init__(self, audio_source, options, callback, url, headers, http_proxy_host=None, http_proxy_port=None):
35+
def __init__(self,
36+
audio_source,
37+
options,
38+
callback,
39+
url,
40+
headers,
41+
http_proxy_host=None,
42+
http_proxy_port=None,
43+
verify=None):
3544
self.audio_source = audio_source
3645
self.options = options
3746
self.callback = callback
@@ -40,6 +49,7 @@ def __init__(self, audio_source, options, callback, url, headers, http_proxy_hos
4049
self.http_proxy_host = http_proxy_host
4150
self.http_proxy_port = http_proxy_port
4251
self.isListening = False
52+
self.verify = verify
4353

4454
# websocket.enableTrace(True)
4555

@@ -51,7 +61,10 @@ def __init__(self, audio_source, options, callback, url, headers, http_proxy_hos
5161
on_error=self.on_error,
5262
on_close=self.on_close,
5363
)
54-
self.ws_client.run_forever(http_proxy_host=self.http_proxy_host, http_proxy_port=self.http_proxy_port)
64+
65+
self.ws_client.run_forever(http_proxy_host=self.http_proxy_host,
66+
http_proxy_port=self.http_proxy_port,
67+
sslopt={"cert_reqs": ssl.CERT_NONE} if self.verify is not None else None)
5568

5669
@classmethod
5770
def build_start_message(cls, options):

0 commit comments

Comments
 (0)