Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add auto inference of host scheme in CLI #2240

Merged
merged 3 commits into from
Oct 3, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ filters and searching the nearest frame without any annotations (<https://github
- Nuclio became an optional component of CVAT (<https://github.com/openvinotoolkit/cvat/pull/2192>)
- A key to remove a point from a polyshape [Ctrl => Alt] (<https://github.com/openvinotoolkit/cvat/pull/2204>)
- Updated `docker-compose` file version from `2.3` to `3.3`(<https://github.com/openvinotoolkit/cvat/pull/2235>)
- Added auto inference of url schema from host in CLI, if provided (<https://github.com/openvinotoolkit/cvat/pull/2240>)

### Deprecated
-
Expand Down
9 changes: 7 additions & 2 deletions utils/cli/core/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,8 +182,13 @@ class CVAT_API_V1():
""" Build parameterized API URLs """

def __init__(self, host, https=False):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You may drop the 'https' argument from function declaration, aren't you?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is a parameter in CLI to enforce https, which uses this function parameter.

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):
Expand Down