=== modified file 'lava/helper/command.py'
@@ -91,10 +91,10 @@
rpc_endpoint_parameter = Parameter("rpc_endpoint",
depends=server_name_parameter)
- server_url = self.config.get(server_name_parameter)
+ self.config.get(server_name_parameter)
endpoint = self.config.get(rpc_endpoint_parameter)
- rpc_url = verify_and_create_url(server_url, endpoint)
+ rpc_url = verify_and_create_url(endpoint)
server = AuthenticatingServerProxy(rpc_url,
auth_backend=KeyringAuthBackend())
return server
=== modified file 'lava_tool/tests/test_utils.py'
@@ -243,7 +243,7 @@
def test_verify_and_create_url_0(self):
expected = "https://www.example.org/"
- obtained = verify_and_create_url("www.example.org", "")
+ obtained = verify_and_create_url("www.example.org")
self.assertEquals(expected, obtained)
def test_verify_and_create_url_1(self):
@@ -253,12 +253,12 @@
def test_verify_and_create_url_2(self):
expected = "http://www.example.org/RPC/"
- obtained = verify_and_create_url("http://www.example.org", "RPC")
+ obtained = verify_and_create_url("http://www.example.org/RPC")
self.assertEquals(expected, obtained)
def test_verify_and_create_url_3(self):
expected = "https://www.example.org/RPC/"
- obtained = verify_and_create_url("www.example.org/", "/RPC/")
+ obtained = verify_and_create_url("www.example.org/RPC")
self.assertEquals(expected, obtained)
def test_create_dir_0(self):
=== modified file 'lava_tool/utils.py'
@@ -281,7 +281,7 @@
editor))
-def verify_and_create_url(server, endpoint=""):
+def verify_and_create_url(endpoint):
"""Checks that the provided values make a correct URL.
If the server address does not contain a scheme, by default it will use
@@ -291,25 +291,22 @@
:param server: A server URL to verify.
:return A URL.
"""
- scheme, netloc, path, params, query, fragment = \
- urlparse.urlparse(server)
- if not scheme:
- scheme = "https"
- if not netloc:
- netloc, path = path, ""
-
- if not netloc[-1:] == "/":
- netloc += "/"
-
+ url = ""
if endpoint:
- if endpoint[0] == "/":
- endpoint = endpoint[1:]
- if not endpoint[-1:] == "/":
- endpoint += "/"
- netloc += endpoint
-
- return urlparse.urlunparse(
- (scheme, netloc, path, params, query, fragment))
+ scheme, netloc, path, params, query, fragment = \
+ urlparse.urlparse(endpoint)
+ if not scheme:
+ scheme = "https"
+ if not netloc:
+ netloc, path = path, ""
+
+ url = urlparse.urlunparse(
+ (scheme, netloc, path, params, query, fragment))
+
+ if url[-1:] != "/":
+ url += "/"
+
+ return url
def create_dir(path, dir_name=None):