Skip to content
项目
群组
代码片段
帮助
正在加载...
登录
切换导航
E
evsuits
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
OpsTeam
evsuits
Commits
bde8a37b
提交
bde8a37b
authored
12月 30, 2019
作者:
blu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
video.ai
上级
2dbecdcd
显示空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
79 行增加
和
0 行删除
+79
-0
as.py
opencv-yolo/web/as.py
+79
-0
没有找到文件。
opencv-yolo/web/as.py
0 → 100644
浏览文件 @
bde8a37b
#!/usr/bin/env python
# coding: utf-8
from
azure.storage.fileshare.aio
import
ShareFileClient
from
azure.storage.fileshare
import
ShareDirectoryClient
,
ShareServiceClient
import
asyncio
,
re
,
datetime
,
queue
,
json
,
threading
from
concurrent.futures
import
ThreadPoolExecutor
CONNSTR
=
'DefaultEndpointsProtocol=https;AccountName=ilsvideostablediag;AccountKey=rWeA/cUiWAsDqGHO0lfDB5eDHNZxCChrH0pMvICdNJR6tt+hE2tHlSl9kUEjqyOY6cztPWaaRbbeoI47uNEeWA==;EndpointSuffix=core.chinacloudapi.cn'
SHARENAME
=
'pre-data'
event_loop
=
asyncio
.
get_event_loop
()
tasks
=
[]
videoQue
=
queue
.
Queue
()
async
def
downloadFile
(
ipcSn
,
dirName
,
fileName
,
q
):
async
with
ShareFileClient
.
from_connection_string
(
conn_str
=
CONNSTR
,
share_name
=
SHARENAME
,
file_path
=
ipcSn
+
'/'
+
dirName
+
'/'
+
fileName
)
as
fc
:
with
open
(
fileName
,
"wb"
)
as
f
:
data
=
await
fc
.
download_file
()
await
data
.
readinto
(
f
)
q
.
put
({
'f'
:
fileName
,
'sn'
:
ipcSn
,
'd'
:
dirName
})
def
analyzeFile
(
q
):
while
True
:
try
:
job
=
q
.
get
(
timeout
=
60
*
60
)
if
job
:
print
(
json
.
dumps
(
job
))
else
:
print
(
"none"
)
except
Exception
as
e
:
print
(
'timeout get job'
)
def
main
(
q
):
rootc
=
ShareDirectoryClient
.
from_connection_string
(
conn_str
=
CONNSTR
,
share_name
=
SHARENAME
,
directory_path
=
"."
)
rootd
=
rootc
.
list_directories_and_files
()
# download files
fileCnt
=
0
totalSize
=
0
totalTime
=
0
bBreak
=
False
for
ipc
in
rootd
:
if
bBreak
:
break
if
'is_directory'
in
ipc
and
ipc
[
'is_directory'
]
and
(
'-'
not
in
ipc
[
"name"
]):
ipcSn
=
ipc
[
"name"
]
ipcc
=
rootc
.
get_subdirectory_client
(
ipc
[
"name"
])
ipcd
=
ipcc
.
list_directories_and_files
()
for
d
in
ipcd
:
if
bBreak
:
break
if
'is_directory'
in
d
and
d
[
'is_directory'
]:
dirName
=
d
[
"name"
]
vf
=
ipcc
.
get_subdirectory_client
(
d
[
"name"
])
.
list_directories_and_files
()
for
e
in
vf
:
if
bBreak
:
break
m
=
re
.
match
(
r"(\d{13})-(\d{13}).mp4"
,
e
[
"name"
])
if
m
:
fileName
=
e
[
"name"
]
fileSize
=
e
[
"size"
]
ts
=
int
(
int
(
m
.
group
(
1
))
/
1000
)
te
=
int
(
int
(
m
.
group
(
2
))
/
1000
)
delta
=
te
-
ts
print
(
"{} {} {:.3f}MB"
.
format
(
ipcSn
,
fileName
,
fileSize
/
1024
/
1024
))
#datetime.datetime.fromtimestamp(te))
fileCnt
+=
1
if
fileCnt
>=
3
:
bBreak
=
True
;
now
=
datetime
.
datetime
.
now
()
tasks
.
append
(
asyncio
.
ensure_future
(
downloadFile
(
ipcSn
,
dirName
,
fileName
,
videoQue
),
loop
=
event_loop
))
event_loop
.
run_until_complete
(
asyncio
.
gather
(
*
tasks
))
with
ThreadPoolExecutor
(
max_workers
=
4
)
as
te
:
te
.
submit
(
main
,
videoQue
)
te
.
submit
(
analyzeFile
,
videoQue
)
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论