From f138859c1a91214dc99527e496cc1e8a0855d820 Mon Sep 17 00:00:00 2001 From: Maxim Zhiltsov Date: Sat, 3 Oct 2020 07:46:22 +0300 Subject: [PATCH] Add auto inference of host scheme in CLI (#2240) * Add auto inference of host scheme in CLI * update changelog --- CHANGELOG.md | 1 + utils/cli/core/core.py | 9 +++++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 87dc74e1..edb12cc2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -30,6 +30,7 @@ filters and searching the nearest frame without any annotations () - A key to remove a point from a polyshape [Ctrl => Alt] () - Updated `docker-compose` file version from `2.3` to `3.3`() +- Added auto inference of url schema from host in CLI, if provided () ### Deprecated - diff --git a/utils/cli/core/core.py b/utils/cli/core/core.py index 78a2776c..78e1680a 100644 --- a/utils/cli/core/core.py +++ b/utils/cli/core/core.py @@ -182,8 +182,13 @@ class CVAT_API_V1(): """ Build parameterized API URLs """ def __init__(self, host, https=False): - prefix = 'https' if https else 'http' - self.base = '{}://{}/api/v1/'.format(prefix, host) + if host.startswith('https://'): + https = True + if host.startswith('http://') or host.startswith('https://'): + host = host.replace('http://', '') + host = host.replace('https://', '') + scheme = 'https' if https else 'http' + self.base = '{}://{}/api/v1/'.format(scheme, host) @property def tasks(self):