Skip to content
This repository was archived by the owner on Mar 13, 2022. It is now read-only.

Fix exec command parameter expansion #35

Merged
merged 1 commit into from
Oct 18, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 8 additions & 19 deletions stream/ws_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -229,33 +229,22 @@ def websocket_call(configuration, *args, **kwargs):
apiClient.request method."""

url = args[1]
query_params = kwargs.get("query_params", {})
_request_timeout = kwargs.get("_request_timeout", 60)
_preload_content = kwargs.get("_preload_content", True)
headers = kwargs.get("headers")

# Extract the command from the list of tuples
commands = None
for key, value in query_params:
if key == 'command':
commands = value
break

# drop command from query_params as we will be processing it separately
query_params = [(key, value) for key, value in query_params if
key != 'command']
# Expand command parameter list to indivitual command params
query_params = []
for key, value in kwargs.get("query_params", {}):
if key == 'command' and isinstance(value, list):
for command in value:
query_params.append((key, command))
else:
query_params.append((key, value))

# if we still have query params then encode them
if query_params:
url += '?' + urlencode(query_params)

# tack on the actual command to execute at the end
if isinstance(commands, list):
for command in commands:
url += "&command=%s&" % quote_plus(command)
elif commands is not None:
url += '&command=' + quote_plus(commands)

try:
client = WSClient(configuration, get_websocket_url(url), headers)
if not _preload_content:
Expand Down