import click import json from app.search.video import export_video_final from app.utils.cortex_utils import upload_file_to_cortex @click.command('') @click.option('-i', '--input', 'opt_fp_in', help='Path to input image') @click.option('-f', '--folder_id', 'opt_folder_id', required=True, help='ID of folder on Cortex') @click.pass_context def cli(ctx, opt_fp_in, opt_folder_id): """ Test uploading a file to Cortex """ # export_video_final 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))