Exemplo n.º 1
0
def index(project: Project):
    bucket_name = request.args.get("q", None)
    minio_client = MinioClient(project=project)
    buckets_list = minio_client.list_bucket()
    if not bucket_name or bucket_name not in buckets_list:
        return redirect(url_for("artifacts.index", q=buckets_list[0]))
    return render_template("artifacts/files.html",
                           files=minio_client.list_files(bucket_name),
                           buckets=buckets_list,
                           bucket=bucket_name)
Exemplo n.º 2
0
    def to_json(self, exclude_fields: tuple = ()) -> dict:
        json_dict = super().to_json()

        project = Project.query.get_or_404(json_dict["project_id"])
        minio_client = MinioClient(project=project)
        buckets_list = minio_client.list_bucket()
        storage_space = 0
        for bucket in buckets_list:
            for file in minio_client.list_files(bucket):
                storage_space += file["size"]
        json_dict["storage_space"] = round(storage_space/1000000, 2)

        tasks = Task.query.filter_by(project_id=json_dict["project_id"]).all()
        json_dict["tasks_count"] = len(tasks)

        return json_dict