update
This commit is contained in:
31
up_again.py
Normal file
31
up_again.py
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
import os
|
||||||
|
import requests
|
||||||
|
from obs import ObsClient
|
||||||
|
obsClient = ObsClient(
|
||||||
|
access_key_id='LHXJC7GIC2NNUUHHTNVI',
|
||||||
|
secret_access_key='sVWvEItrFKWPp5DxeMvX8jLFU69iXPpzkjuMX3iM',
|
||||||
|
server='https://obs.cn-east-3.myhuaweicloud.com'
|
||||||
|
)
|
||||||
|
bucketName = 'ieemoo-ai'
|
||||||
|
|
||||||
|
def upAgain(path, url):
|
||||||
|
for name in os.listdir(path):
|
||||||
|
try:
|
||||||
|
file_path = os.sep.join([path, name])
|
||||||
|
videoUuid = name.split('_')[1]
|
||||||
|
json_date = {'videoUuid': videoUuid}
|
||||||
|
resp = requests.post(url=url,
|
||||||
|
data=json_date)
|
||||||
|
status = resp.json()['data']
|
||||||
|
time = name.split('-')[0]
|
||||||
|
objectkey = 'videos/'+time+'/'+status+'/'+status+'_'+name
|
||||||
|
#print('>>>>>>>>>',objectkey)
|
||||||
|
resp = obsClient.putFile(bucketName, objectkey, file_path)
|
||||||
|
os.remove(file_path)
|
||||||
|
except Exception as e:
|
||||||
|
print(e)
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
path = '../module/ieemoo-ai-searchv2/videos'
|
||||||
|
url = 'https://api.ieemoo.com/emoo-api/intelligence/queryVideoCompareResult.do'
|
||||||
|
upAgain(path, url)
|
@ -27,7 +27,8 @@ def AddObs(file_path, status):
|
|||||||
shutil.move(file_path, f_dst)
|
shutil.move(file_path, f_dst)
|
||||||
|
|
||||||
def addobs(file_path, status): #save videos
|
def addobs(file_path, status): #save videos
|
||||||
ti.sleep(3)
|
T1 = ti.time()
|
||||||
|
ti.sleep(1)
|
||||||
num = 0
|
num = 0
|
||||||
videoUuid = os.path.basename(file_path).split('_')[1]
|
videoUuid = os.path.basename(file_path).split('_')[1]
|
||||||
json_data = {'videoUuid': videoUuid}
|
json_data = {'videoUuid': videoUuid}
|
||||||
@ -35,14 +36,16 @@ def addobs(file_path, status): #save videos
|
|||||||
data=json_data)
|
data=json_data)
|
||||||
status = resp.json()
|
status = resp.json()
|
||||||
if not 'data' in status:#延迟设置
|
if not 'data' in status:#延迟设置
|
||||||
while num < 20:
|
for _ in range(20):
|
||||||
ti.sleep(2)
|
ti.sleep(1)
|
||||||
num += 1
|
num += 1
|
||||||
resp = requests.post(url=cfg.Vre, data=json_data)
|
resp = requests.post(url=cfg.Vre, data=json_data)
|
||||||
status = resp.json()
|
status = resp.json()
|
||||||
if not 'data' in status:
|
if not 'data' in status:
|
||||||
continue
|
continue
|
||||||
else:break
|
else:break
|
||||||
|
T2 = ti.time()
|
||||||
|
print('videoUuid>>>{} get_status_time>>>{}'.format((videoUuid), (T2-T1)))
|
||||||
status = status['data']
|
status = status['data']
|
||||||
|
|
||||||
objectkey = os.path.basename(file_path)
|
objectkey = os.path.basename(file_path)
|
||||||
@ -72,7 +75,6 @@ def updateAgain():
|
|||||||
except Exception as e:
|
except Exception as e:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
def Addimg(uuid_barcode):
|
def Addimg(uuid_barcode):
|
||||||
time = uuid_barcode.split('-')[0].split('_')[-1]
|
time = uuid_barcode.split('-')[0].split('_')[-1]
|
||||||
objectkey = 'imgs/'+time+'/'+uuid_barcode+'.jpg'
|
objectkey = 'imgs/'+time+'/'+uuid_barcode+'.jpg'
|
||||||
|
Reference in New Issue
Block a user