def get_remote_dir(remote_dir, local_dir='.', extension=None, verbose=False):

    if extension is not None:
        remote_dir = '{}/*.{}'.format(remote_dir, extension)

    gsutil = shutil.which('gsutil')

    cmd = [gsutil, '-m', 'cp', '-r', remote_dir, local_dir]

    if verbose:
        print(cmd)

    try:
        os.mkdir(local_dir)
    except __HOLE__ as e:
        warnings.warn("Can't create dir: {}".format(e))

    try:
        proc = subprocess.run(cmd, stdout=subprocess.PIPE, check=True)
        if verbose:
            print("Command completed: {}".format(proc.stdout))
    except Exception as e:
        warnings.warn("Can't run command: {}".format(e))
        sys.exit(1)
dataset/ETHPy150Open panoptes/POCS/scripts/gather_pec_data.py/get_remote_dir