#!/usr/bin/env python3

import os
import argparse
import subprocess

def parse_args():
    parser = argparse.ArgumentParser()
    parser.add_argument("--date", "-d", type=str)
    return parser.parse_args()

def main():
    args = parse_args()
    remote_dir = f'/data/emblem-research/camera-frame'
    if args.date:
        remote_dir += f'/{args.date}'
    # we cannot rsync to data/json because we will update there after sync, and
    # the next sync will overwrite the updated files
    local_dir = f'data/raw/camera-frame'
    os.makedirs(local_dir, exist_ok=True)
    cmd = ['rsync', '-avz', f'zy:{remote_dir}', local_dir]
    subprocess.run(cmd)

if __name__ == "__main__":
    main()
