From 4bddf2826f69ada81261e5fcb04cea86f698e627 Mon Sep 17 00:00:00 2001 From: Max Belov Date: Mon, 2 Apr 2018 14:20:49 +0300 Subject: [PATCH] Fix for init-hub command --- VERSION | 2 +- apsconnectcli/hub.py | 12 ++++++++---- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/VERSION b/VERSION index b9268da..0bfbd57 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.8.1 \ No newline at end of file +1.8.2 \ No newline at end of file diff --git a/apsconnectcli/hub.py b/apsconnectcli/hub.py index 0989c80..7d9b6e3 100644 --- a/apsconnectcli/hub.py +++ b/apsconnectcli/hub.py @@ -48,7 +48,8 @@ def configure(hub_host, user='admin', pwd='1q2w3e', use_tls=False, port=8440, ap print("Connectivity with Hub RPC API [ok]") Hub._assert_supported_version(hub_version) print("Hub version {}".format(hub_version)) - aps = APS(Hub._get_user_token(hub, 1)) + aps_url = '{}://{}:{}'.format('https' if use_tls_aps else 'http', aps_host, aps_port) + aps = APS(Hub._get_user_token(hub, 1), aps_url) response = aps.get('aps/2/applications/') response.raise_for_status() print("Connectivity with Hub APS API [ok]") @@ -362,9 +363,12 @@ class APS(object): url = None token = None - def __init__(self, token): - config = get_config() - self.url = APS._get_aps_url(**{k: config[k] for k in APS_CONNECT_PARAMS}) + def __init__(self, token, url=None): + if url: + self.url = url + else: + config = get_config() + self.url = APS._get_aps_url(**{k: config[k] for k in APS_CONNECT_PARAMS}) self.token = token @staticmethod