Fix permission error when importing a project on a remote server

Fix #2082
This commit is contained in:
Julien Duponchelle
2017-07-27 10:20:28 +02:00
parent 0c00e1309c
commit 5857d3709b
2 changed files with 25 additions and 4 deletions

View File

@@ -467,6 +467,22 @@ class HTTPClient(QtCore.QObject):
host = self._host
return host
def _paramsToQueryString(self, params):
"""
:param params: Dictionnary of query string parameters
:returns: String of the query string
"""
if params == {}:
query_string = ""
else:
query_string = "?"
params = params.copy()
for key, value in params.copy().items():
if value is None:
del params[key]
query_string += urllib.parse.urlencode(params)
return query_string
def _executeHTTPQuery(self, method, path, callback, body, context={}, downloadProgressCallback=None, showProgress=True, ignoreErrors=False, progressText=None, server=None, timeout=120, prefix="/v2", params={}, networkManager=None, **kwargs):
"""
Call the remote server
@@ -488,10 +504,7 @@ class HTTPClient(QtCore.QObject):
"""
host = self._getHostForQuery()
if params == {}:
query_string = ""
else:
query_string = "?" + urllib.parse.urlencode(params)
query_string = self._paramsToQueryString(params)
log.debug("{method} {protocol}://{host}:{port}{prefix}{path} {body}{query_string}".format(method=method, protocol=self._protocol, host=host, port=self._port, path=path, body=body, prefix=prefix, query_string=query_string))
if self._user:

View File

@@ -79,6 +79,14 @@ def test_get_connected(http_client, http_request, network_manager, response):
assert callback.called
def test_paramsToQueryString(http_client):
assert http_client._paramsToQueryString({}) == ""
res = http_client._paramsToQueryString({"a": 1, "b": 2})
assert res == "?a=1&b=2" or res == "?b=2&a=1"
res = http_client._paramsToQueryString({"a": 1, "b": 2, "c": None})
assert res == "?a=1&b=2" or res == "?b=2&a=1"
def test_get_connected_auth(http_client, http_request, network_manager, response):
http_client._connected = True