from flask import current_app from flask_minio import Minio from minio.error import BucketAlreadyExists, BucketAlreadyOwnedByYou storage = Minio() def ensure_buckets(): for bucket_name in [current_app.config['MINIO_SVM_BUCKET_NAME'], current_app.config['MINIO_CNN_BUCKET_NAME']]: try: storage.connection.make_bucket(bucket_name) except BucketAlreadyOwnedByYou: pass except BucketAlreadyExists: pass # Everything else should be raised