Пример #1
0
    def handle(self, *args, **options):
        output_format = options["output_format"]
        displayname = bool(options["displayname"])
        unit_style = options["unit_style"]
        common.check_style(unit_style)

        filteropt = options["filter_by"]
        if filteropt is not None:
            filters = filteropt.split(",")
        else:
            filters = []

        QHQ, INITQ = Q(), Q()
        for flt in filters:
            q = filtering.make_query(flt, self.QHFLT)
            if q is not None:
                QHQ &= q
            q = filtering.make_query(flt, self.INITFLT)
            if q is not None:
                INITQ &= q

        overlimit = bool(options["overlimit"])
        if overlimit:
            QHQ &= Q(usage_max__gt=F("limit"))

        with_custom = options["with_custom"]
        if with_custom is not None:
            qeq = Q(capacity=F("resource__uplimit"))
            try:
                INITQ &= ~qeq if utils.parse_bool(with_custom) else qeq
            except ValueError as e:
                raise CommandError(e)

        users = AstakosUser.objects.accepted()
        qh_quotas, astakos_i = list_user_quotas(
            users, qhflt=QHQ, initflt=INITQ)

        if displayname:
            info = {}
            for user in users:
                info[user.uuid] = user.email
        else:
            info = None

        print_data, labels = common.show_quotas(
            qh_quotas, astakos_i, info, style=unit_style)
        utils.pprint_table(self.stdout, print_data, labels, output_format)
Пример #2
0
    def handle(self, *args, **options):
        output_format = options["output_format"]
        displayname = bool(options["display-mails"])
        unit_style = options["unit_style"]
        common.check_style(unit_style)

        filteropt = options["filter_by"]
        if filteropt is not None:
            filters = filteropt.split(",")
        else:
            filters = []

        QHQ = Q()
        for flt in filters:
            q = filtering.make_query(flt, self.QHFLT)
            if q is not None:
                QHQ &= q

        overlimit = bool(options["overlimit"])
        if overlimit:
            QHQ &= Q(usage_max__gt=F("limit"))

        users = AstakosUser.objects.accepted()
        qh_quotas = list_user_quotas(users, qhflt=QHQ)

        if displayname:
            info = {}
            for user in users:
                info[user.uuid] = user.email
        else:
            info = None

        print_data, labels = common.show_quotas(qh_quotas,
                                                info,
                                                style=unit_style)
        utils.pprint_table(self.stdout, print_data, labels, output_format)
Пример #3
0
    def handle(self, *args, **options):
        output_format = options["output_format"]
        displayname = bool(options["display-mails"])
        unit_style = options["unit_style"]
        common.check_style(unit_style)

        filteropt = options["filter_by"]
        if filteropt is not None:
            filters = filteropt.split(",")
        else:
            filters = []

        QHQ = Q()
        for flt in filters:
            q = filtering.make_query(flt, self.QHFLT)
            if q is not None:
                QHQ &= q

        overlimit = bool(options["overlimit"])
        if overlimit:
            QHQ &= Q(usage_max__gt=F("limit"))

        users = AstakosUser.objects.accepted()
        qh_quotas = list_user_quotas(
            users, qhflt=QHQ)

        if displayname:
            info = {}
            for user in users:
                info[user.uuid] = user.email
        else:
            info = None

        print_data, labels = common.show_quotas(
            qh_quotas, info, style=unit_style)
        utils.pprint_table(self.stdout, print_data, labels, output_format)