1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
import click
import json
from app.search.video import export_video_final
from app.utils.cortex_utils import results_folder, upload_file_to_cortex
@click.command('')
@click.option('-i', '--input', 'opt_fp_in',
help='Path to input folder (default: most recent folder in results)')
@click.option('-f', '--folder_id', 'opt_folder_id',
help='ID of folder on Cortex (default: results folder)')
@click.pass_context
def cli(ctx, opt_fp_in, opt_folder_id):
"""
Test uploading a file to Cortex
"""
if opt_folder_id is None:
folder = results_folder()
opt_folder_id = folder['id']
if opt_fp_in is None:
results_dir = os.path.join(app_cfg.RESULTS_DIR)
for fn in sorted(os.listdir(app_cfg.RESULTS_DIR), reverse=True):
fp_frames = os.path.join(app_cfg.RESULTS_DIR, fn)
if os.path.isdir(f):
break
fp_out = os.path.join(app_cfg.DIR_RENDERS, fn + '.mp4')
export_video_final(fp_frames, fp_out)
else:
fp_out = opt_fp_in
if not os.path.exists(fp_out):
print("No video found")
return
print("Uploading {}".format(fp_out))
data = upload_file_to_cortex(opt_folder_id, fp_out, datatype='video', activity='live')
print(json.dumps(data, indent=2))
|