fix clean-s3-cache.py

This commit is contained in:
Charlotte 🦝 Delenk 2022-04-16 11:39:33 +01:00
parent b55385699c
commit e315306fa7
Signed by: darkkirb
GPG key ID: AB2BD8DAF2E37122
2 changed files with 9 additions and 6 deletions

View file

@ -1,6 +1,12 @@
{ writeTextFile }: writeTextFile {
{ writeTextFile, python3, python3Packages }:
let environment = python3.buildEnv.override {
extraLibs = with python3Packages; [
boto3
];
}; in
writeTextFile {
name = "clean-s3-cache.py";
executable = true;
destination = "/bin/clean-s3-cache.py";
text = builtins.readFile ./clean-s3-cache.py;
text = builtins.replaceStrings [ "#SHEBANG#" ] [ "${environment}/bin/python" ] (builtins.readFile ./clean-s3-cache.py);
}

View file

@ -1,5 +1,4 @@
#! /usr/bin/env nix-shell
#! nix-shell -i python3 -p python -p python3Packages.boto3
#!#SHEBANG#
import asyncio
from concurrent.futures import ThreadPoolExecutor
@ -91,13 +90,11 @@ async def list_old_cache_objects() -> AsyncIterable[str]:
) -> dict[str, Any]:
if ContinuationToken != None:
return s3.list_objects_v2(
Prefix="realisations/",
Bucket=BUCKET_NAME,
ContinuationToken=ContinuationToken
)
else:
return s3.list_objects_v2(
Prefix="realisations/",
Bucket=BUCKET_NAME
)
cont_token = None