def METHOD_NAME(deployments):
    total = len(deployments)
    finished = 0
    while finished < total:
        for name, params in deployments.items():
            try:
                params['status'] = get_build_status(params['scm_uri'])
            except Exception:
                params['status'] = DeploymentStatus.Active
            if params['status'] == DeploymentStatus.Active:
                continue
            log.info("Remote build for %s finished with status %s.",
                     name, params['status'])
            finished += 1
        if finished < total:
            log.info("Waiting for all remote builds to finish... %i/%i finished.",
                     finished, total)
            time.sleep(30)