| """Install pinned pgTAP SQL into the local disposable test container only.""" | |
| import hashlib | |
| from io import BytesIO | |
| from pathlib import Path | |
| import subprocess | |
| import tempfile | |
| import urllib.request | |
| from zipfile import ZipFile | |
| URL = "https://api.pgxn.org/dist/pgtap/1.3.4/pgtap-1.3.4.zip" | |
| SHA = "2570574a9321082e82433768feb5bffe472ef2ced6b22608a86bfd25f2b88e40" | |
| with urllib.request.urlopen(URL, timeout=40) as response: | |
| data = response.read() | |
| if hashlib.sha256(data).hexdigest() != SHA: | |
| raise RuntimeError("pgTAP download checksum mismatch") | |
| with tempfile.TemporaryDirectory() as directory: | |
| archive = ZipFile(BytesIO(data)) | |
| sql = ( | |
| archive.read("pgtap-1.3.4/sql/pgtap.sql.in") | |
| .decode() | |
| .replace("__OS__", "linux") | |
| .replace("__VERSION__", "1.3") | |
| .replace("MODULE_PATHNAME", "pgtap") | |
| ) | |
| files = {"pgtap--1.3.4.sql": sql, "pgtap.control": archive.read("pgtap-1.3.4/pgtap.control").decode()} | |
| for name, content in files.items(): | |
| source = Path(directory) / name | |
| source.write_text(content) | |
| source.chmod(0o644) | |
| subprocess.run( | |
| [ | |
| "docker", | |
| "--host=unix:///var/run/docker.sock", | |
| "cp", | |
| str(source), | |
| "ip-buckets-postgres:/usr/local/share/postgresql/extension/" + name, | |
| ], | |
| check=True, | |
| ) | |
| subprocess.run( | |
| [ | |
| "docker", | |
| "--host=unix:///var/run/docker.sock", | |
| "exec", | |
| "ip-buckets-postgres", | |
| "psql", | |
| "-U", | |
| "postgres", | |
| "-d", | |
| "buckets", | |
| "-c", | |
| "create extension if not exists pgtap", | |
| ], | |
| check=True, | |
| ) | |
Xet Storage Details
- Size:
- 1.77 kB
- Xet hash:
- 8efc390f652baf676225b2af00cf76936494b64e8687182b8de67fbda33f3df5
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.