Перенести рабочую базу lab4 в skeleton лабораторной 5.

Исходники, миграции, Dockerfile и стенд lab4 нужны как основа асинхронной обработки вложений.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-11-09 00:48:22 +03:00
co-authored by Cursor
parent 276dbdad8a
commit 9046d5206d
40 changed files with 4136 additions and 0 deletions
+48
View File
@@ -0,0 +1,48 @@
"""Create the private bucket if it is missing. Safe to run again."""
import os
import sys
import time
import boto3
from botocore.client import Config
from botocore.exceptions import BotoCoreError, ClientError
def main() -> None:
endpoint = os.environ["S3_ENDPOINT"]
bucket = os.environ["S3_BUCKET"]
client = boto3.client(
"s3",
endpoint_url=endpoint,
aws_access_key_id=os.environ["S3_ACCESS_KEY_ID"],
aws_secret_access_key=os.environ["S3_SECRET_ACCESS_KEY"],
region_name=os.environ.get("S3_REGION", "us-east-1"),
config=Config(signature_version="s3v4", s3={"addressing_style": "path"}, retries={"max_attempts": 2}),
)
last_error = "not attempted"
for _ in range(20):
try:
client.head_bucket(Bucket=bucket)
print("bucket ready")
return
except ClientError as exc:
code = exc.response.get("Error", {}).get("Code", "")
if code not in {"404", "NoSuchBucket", "NotFound"}:
last_error = code or "ClientError"
else:
try:
client.create_bucket(Bucket=bucket)
print("bucket created")
return
except ClientError as create_exc:
last_error = create_exc.response.get("Error", {}).get("Code", "create failed")
except BotoCoreError:
last_error = "connection failed"
time.sleep(1)
print("bucket bootstrap failed:", last_error, file=sys.stderr)
sys.exit(1)
if __name__ == "__main__":
main()