def worker(scene):
    scene_dir = os.path.join(args.out, scene['dir'][:42])
    if (not os.path.isabs(scene_dir)):
        scene_dir = ('./' + scene_dir)
    if glob.glob((scene_dir + '*')):
        scene['dir'] = glob.glob((scene_dir + '*'))[0]
        return (scene, None, True)
    token = get_token(login, password)
    url = (THEIA_URL + '/resto2/collections/SENTINEL2/{}/download/?issuerId=theia'.format(scene['uuid']))
    resp = requests.get(url, headers={'Authorization': 'Bearer {}'.format(token)}, stream=True)
    if (resp is None):
        return (scene, None, False)
    zip_path = os.path.join(args.out, (scene['uuid'] + '.zip'))
    with open(zip_path, 'wb') as fp:
        progress = tqdm(unit='B', desc=scene['uuid'], total=int(resp.headers['Content-Length']))
        for chunk in resp.iter_content(chunk_size=16384):
            progress.update(16384)
            fp.write(chunk)
        return (scene, zip_path, True)
    return (scene, None, False)
def worker(scene):
    scene_dir = os.path.join(args.out, scene['dir'][:42])
    if (not os.path.isabs(scene_dir)):
        scene_dir = ('./' + scene_dir)
    if glob.glob((scene_dir + '*')):
        scene['dir'] = glob.glob((scene_dir + '*'))[0]
        return (scene, None, True)
    token = get_token(login, password)
    url = (THEIA_URL + '/resto2/collections/SENTINEL2/{}/download/?issuerId=theia'.format(scene['uuid']))
    resp = requests.get(url, headers={'Authorization': 'Bearer {}'.format(token)}, stream=True)
    if (resp is None):
        return (scene, None, False)
    zip_path = os.path.join(args.out, (scene['uuid'] + '.zip'))
    with open(zip_path, 'wb') as fp:
        progress = tqdm(unit='B', desc=scene['uuid'], total=int(resp.headers['Content-Length']))
        for chunk in resp.iter_content(chunk_size=16384):
            progress.update(16384)
            fp.write(chunk)
        return (scene, zip_path, True)
    return (scene, None, False)