Skip to content
GitLab
Explore
Projects
Groups
Topics
Snippets
Projects
Groups
Topics
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
VT2 Видеотехнологии
ONVIF-PTZ proxy
Commits
b9e33f40
Commit
b9e33f40
authored
1 year ago
by
Mikhail Sennikov
Browse files
Options
Download
Patches
Plain Diff
Fix warmup
parent
4c1f2531
main
No related merge requests found
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
Backend/node/swarm.py
+0
-4
Backend/node/swarm.py
ProxyNode/node_settings/node_settings.py
+4
-8
ProxyNode/node_settings/node_settings.py
ProxyNode/onvif_proxy/hot_cams.py
+2
-1
ProxyNode/onvif_proxy/hot_cams.py
database/api/cam_groups.py
+0
-8
database/api/cam_groups.py
database/api/cams.py
+0
-4
database/api/cams.py
database/api/nodes.py
+0
-4
database/api/nodes.py
database/api/roles.py
+0
-4
database/api/roles.py
database/api/users.py
+0
-4
database/api/users.py
with
6 additions
and
37 deletions
+6
-37
Backend/node/swarm.py
+
0
−
4
View file @
b9e33f40
...
@@ -66,10 +66,6 @@ class NodeSwarm:
...
@@ -66,10 +66,6 @@ class NodeSwarm:
async
with
db
.
get_session
()
as
session
:
async
with
db
.
get_session
()
as
session
:
group_repo
=
GroupRepository
(
session
)
group_repo
=
GroupRepository
(
session
)
group
=
await
group_repo
.
get
(
group_id
)
group
=
await
group_repo
.
get
(
group_id
)
if
group
is
None
:
raise
HTTPException
(
status_code
=
status
.
HTTP_404_NOT_FOUND
)
await
self
.
_set_group
(
group
,
session
)
await
self
.
_set_group
(
group
,
session
)
return
group
return
group
...
...
This diff is collapsed.
Click to expand it.
ProxyNode/node_settings/node_settings.py
+
4
−
8
View file @
b9e33f40
...
@@ -18,21 +18,17 @@ hot_cams: HotCams = HotCams()
...
@@ -18,21 +18,17 @@ hot_cams: HotCams = HotCams()
@node_router.post
(
"/set/{node_id}"
,
response_model
=
NodeFull
)
@node_router.post
(
"/set/{node_id}"
,
response_model
=
NodeFull
)
async
def
set_node_id
(
async
def
set_node_id
(
node_id
:
int
,
node_id
:
int
,
node_repo
:
NodeRepository
=
Depends
(
db
.
get_repository
(
NodeRepository
))
):
):
global
current_node
global
current_node
global
hot_cams
global
hot_cams
node
=
await
node_repo
.
get
(
node_id
)
with
db
.
get_session
()
as
session
:
if
node
is
None
:
node_repo
:
NodeRepository
=
NodeRepository
(
session
)
raise
HTTPException
(
current_node
=
await
node_repo
.
get
(
node_id
)
status_code
=
status
.
HTTP_404_NOT_FOUND
cams
=
await
node_repo
.
get_node_cams
(
current_node
)
)
current_node
=
node
# Warm up cams
# Warm up cams
del
hot_cams
del
hot_cams
hot_cams
=
HotCams
()
hot_cams
=
HotCams
()
cams
=
await
node_repo
.
get_node_cams
(
current_node
)
cams
=
[
int
(
getattr
(
cam
,
'id'
))
for
cam
in
cams
]
cams
=
[
int
(
getattr
(
cam
,
'id'
))
for
cam
in
cams
]
await
hot_cams
.
try_connect_cams_list
(
cams
)
await
hot_cams
.
try_connect_cams_list
(
cams
)
return
current_node
return
current_node
...
...
This diff is collapsed.
Click to expand it.
ProxyNode/onvif_proxy/hot_cams.py
+
2
−
1
View file @
b9e33f40
...
@@ -23,6 +23,7 @@ class HotCams:
...
@@ -23,6 +23,7 @@ class HotCams:
try
:
try
:
cam
=
Camera
(
_cam_id
,
**
kwargs
)
cam
=
Camera
(
_cam_id
,
**
kwargs
)
await
cam
.
update
()
await
cam
.
update
()
print
(
f
"Connection to camera
{
kwargs
[
'name'
]
}
established."
)
break
break
except
(
ONVIFError
,
httpx
.
ConnectTimeout
,
httpx
.
ConnectError
)
as
e
:
except
(
ONVIFError
,
httpx
.
ConnectTimeout
,
httpx
.
ConnectError
)
as
e
:
if
'name'
in
kwargs
:
if
'name'
in
kwargs
:
...
@@ -38,7 +39,7 @@ class HotCams:
...
@@ -38,7 +39,7 @@ class HotCams:
async
def
try_connect
(
self
,
cam_id
:
int
):
async
def
try_connect
(
self
,
cam_id
:
int
):
async
with
db
.
get_session
()
as
session
:
async
with
db
.
get_session
()
as
session
:
cam_repo
=
CamRepository
(
session
)
cam_repo
=
CamRepository
(
session
)
cam_db_obj
=
await
cam_repo
.
get
(
cam_id
)
cam_db_obj
=
await
cam_repo
.
get
_or_none
(
cam_id
)
if
cam_db_obj
is
None
:
if
cam_db_obj
is
None
:
raise
HTTPException
(
raise
HTTPException
(
status_code
=
status
.
HTTP_404_NOT_FOUND
status_code
=
status
.
HTTP_404_NOT_FOUND
...
...
This diff is collapsed.
Click to expand it.
database/api/cam_groups.py
+
0
−
8
View file @
b9e33f40
...
@@ -30,10 +30,6 @@ async def get_group(
...
@@ -30,10 +30,6 @@ async def get_group(
group_repo
:
GroupRepository
=
Depends
(
db
.
get_repository
(
GroupRepository
))
group_repo
:
GroupRepository
=
Depends
(
db
.
get_repository
(
GroupRepository
))
):
):
group
=
await
group_repo
.
get
(
group_id
)
group
=
await
group_repo
.
get
(
group_id
)
if
group
is
None
:
raise
HTTPException
(
status_code
=
status
.
HTTP_404_NOT_FOUND
)
return
group
return
group
...
@@ -84,10 +80,6 @@ async def list_cams_in_group(
...
@@ -84,10 +80,6 @@ async def list_cams_in_group(
group_repo
:
GroupRepository
=
Depends
(
db
.
get_repository
(
GroupRepository
))
group_repo
:
GroupRepository
=
Depends
(
db
.
get_repository
(
GroupRepository
))
):
):
group
=
await
group_repo
.
get
(
group_id
)
group
=
await
group_repo
.
get
(
group_id
)
if
group
is
None
:
raise
HTTPException
(
status_code
=
status
.
HTTP_404_NOT_FOUND
)
return
await
group_repo
.
list_cams_in_group
(
group
)
return
await
group_repo
.
list_cams_in_group
(
group
)
...
...
This diff is collapsed.
Click to expand it.
database/api/cams.py
+
0
−
4
View file @
b9e33f40
...
@@ -30,10 +30,6 @@ async def get_cam(
...
@@ -30,10 +30,6 @@ async def get_cam(
cam_repo
:
CamRepository
=
Depends
(
db
.
get_repository
(
CamRepository
))
cam_repo
:
CamRepository
=
Depends
(
db
.
get_repository
(
CamRepository
))
):
):
cam
=
await
cam_repo
.
get
(
cam_id
)
cam
=
await
cam_repo
.
get
(
cam_id
)
if
cam
is
None
:
raise
HTTPException
(
status_code
=
status
.
HTTP_404_NOT_FOUND
)
return
cam
return
cam
...
...
This diff is collapsed.
Click to expand it.
database/api/nodes.py
+
0
−
4
View file @
b9e33f40
...
@@ -27,10 +27,6 @@ async def get_node(
...
@@ -27,10 +27,6 @@ async def get_node(
node_repo
:
NodeRepository
=
Depends
(
db
.
get_repository
(
NodeRepository
))
node_repo
:
NodeRepository
=
Depends
(
db
.
get_repository
(
NodeRepository
))
):
):
node
=
await
node_repo
.
get
(
node_id
)
node
=
await
node_repo
.
get
(
node_id
)
if
node
is
None
:
raise
HTTPException
(
status_code
=
status
.
HTTP_404_NOT_FOUND
)
return
node
return
node
...
...
This diff is collapsed.
Click to expand it.
database/api/roles.py
+
0
−
4
View file @
b9e33f40
...
@@ -27,10 +27,6 @@ async def get_role(
...
@@ -27,10 +27,6 @@ async def get_role(
role_repo
:
RoleRepository
=
Depends
(
db
.
get_repository
(
RoleRepository
))
role_repo
:
RoleRepository
=
Depends
(
db
.
get_repository
(
RoleRepository
))
):
):
role
=
await
role_repo
.
get
(
role_id
)
role
=
await
role_repo
.
get
(
role_id
)
if
role
is
None
:
raise
HTTPException
(
status_code
=
status
.
HTTP_404_NOT_FOUND
)
return
role
return
role
...
...
This diff is collapsed.
Click to expand it.
database/api/users.py
+
0
−
4
View file @
b9e33f40
...
@@ -29,10 +29,6 @@ async def get_user(
...
@@ -29,10 +29,6 @@ async def get_user(
user_repo
:
UserRepository
=
Depends
(
db
.
get_repository
(
UserRepository
))
user_repo
:
UserRepository
=
Depends
(
db
.
get_repository
(
UserRepository
))
):
):
user
=
await
user_repo
.
get
(
user_id
)
user
=
await
user_repo
.
get
(
user_id
)
if
user
is
None
:
raise
HTTPException
(
status_code
=
status
.
HTTP_404_NOT_FOUND
)
return
user
return
user
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment
Menu
Explore
Projects
Groups
Topics
Snippets