Merge pull request #35 from mbohlool/master

Fix exec command parameter expansion
This commit is contained in:
Mehdy Bohlool 2017-10-18 16:17:33 -07:00 committed by GitHub
commit 9213876f0b

View File

@ -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
# 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))
# 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']
# 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: