Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
疯人忠
Cvat
提交
511f9706
C
Cvat
项目概览
疯人忠
/
Cvat
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
C
Cvat
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
511f9706
编写于
10月 09, 2022
作者:
M
Maxim Zhiltsov
提交者:
GitHub
10月 09, 2022
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Allow trailing slashes in SDK client url (#5057)
上级
b029bc9d
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
19 addition
and
2 deletion
+19
-2
CHANGELOG.md
CHANGELOG.md
+2
-0
cvat-sdk/cvat_sdk/core/client.py
cvat-sdk/cvat_sdk/core/client.py
+4
-2
tests/python/sdk/test_client.py
tests/python/sdk/test_client.py
+13
-0
未找到文件。
CHANGELOG.md
浏览文件 @
511f9706
...
...
@@ -37,6 +37,8 @@ non-ascii paths while adding files from "Connected file share" (issue #4428)
-
Fixed cvat-core ESlint problems (
<https://github.com/opencv/cvat/pull/5027>
)
-
Fixed task creation with non-local files via the SDK/CLI
(
<https://github.com/opencv/cvat/issues/4962>
)
-
A trailing slash in hostname does't allow SDK to send some requests
(
<https://github.com/opencv/cvat/pull/5057>
)
### Security
-
TDB
...
...
cvat-sdk/cvat_sdk/core/client.py
浏览文件 @
511f9706
...
...
@@ -98,6 +98,8 @@ class Client:
schema
=
""
base_url
=
url
base_url
=
base_url
.
rstrip
(
"/"
)
if
schema
and
schema
not
in
cls
.
ALLOWED_SCHEMAS
:
raise
InvalidHostException
(
f
"Invalid url schema '
{
schema
}
', expected "
...
...
@@ -279,7 +281,7 @@ class CVAT_API_V2:
"""Build parameterized API URLs"""
def
__init__
(
self
,
host
:
str
):
self
.
host
=
host
self
.
host
=
host
.
rstrip
(
"/"
)
self
.
base
=
self
.
host
+
"/api/"
self
.
git
=
self
.
host
+
"/git/repository/"
...
...
@@ -308,7 +310,7 @@ class CVAT_API_V2:
def
make_client
(
host
:
str
,
*
,
port
:
Optional
[
int
]
=
None
,
credentials
:
Optional
[
Tuple
[
int
,
int
]]
=
None
)
->
Client
:
url
=
host
url
=
host
.
rstrip
(
"/"
)
if
port
:
url
=
f
"
{
url
}
:
{
port
}
"
...
...
tests/python/sdk/test_client.py
浏览文件 @
511f9706
...
...
@@ -58,6 +58,19 @@ class TestClientUsecases:
assert
(
version
.
major
,
version
.
minor
)
>=
(
2
,
0
)
def
test_can_strip_trailing_slash_in_hostname_in_make_client
(
admin_user
:
str
):
host
,
port
=
BASE_URL
.
split
(
"://"
,
maxsplit
=
1
)[
1
].
rsplit
(
":"
,
maxsplit
=
1
)
with
make_client
(
host
=
host
+
"/"
,
port
=
port
,
credentials
=
(
admin_user
,
USER_PASS
))
as
client
:
assert
client
.
api_map
.
host
==
BASE_URL
def
test_can_strip_trailing_slash_in_hostname_in_client_ctor
(
admin_user
:
str
):
with
Client
(
url
=
BASE_URL
+
"/"
)
as
client
:
client
.
login
((
admin_user
,
USER_PASS
))
assert
client
.
api_map
.
host
==
BASE_URL
def
test_can_detect_server_schema_if_not_provided
():
host
,
port
=
BASE_URL
.
split
(
"://"
,
maxsplit
=
1
)[
1
].
rsplit
(
":"
,
maxsplit
=
1
)
client
=
make_client
(
host
=
host
,
port
=
int
(
port
))
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录