def _download_directory()

in robot_ws/src/rl_agent/markov/s3_boto_data_store.py [0:0]


    def _download_directory(self, s3_bucket, s3_prefix, local_path):
        s3_client = self._get_client()
        response = s3_client.list_objects_v2(Bucket=s3_bucket,
                                             Prefix=s3_prefix)

        if "Contents" not in response:
            return False

        if "Contents" in response:
            try:
                for obj in response["Contents"]:
                    filename = os.path.abspath(os.path.join(local_path,
                                                            obj["Key"].replace(s3_prefix, "")))
                    if s3_client.download_file(Bucket=s3_bucket, Key=obj["Key"], Filename=filename) == False:
                        print("Failed downloading object, Bucket: ", s3_bucket,
                              ", Key ", obj["key"])
                        return False
            except Exception as e:
                print("Got exception while downloading checkpoint", e)
                return False

        return True