Beispiel #1
0
    def identify_product(self, cvd, product_name, product_label, product_id):
        org_name = self.get_option('org')
        cvd_api = ContentViewDefinitionAPI()
        cvd_products = cvd_api.all_products(org_name, cvd["id"])

        products = [prod for prod in cvd_products if prod["id"] == product_id \
                             or prod["name"] == product_name or prod["label"] == product_label]

        if len(products) > 1:
            raise ApiDataError(_("More than 1 product found with the name or label provided, "\
                                 "recommend using product id.  The product id may be retrieved "\
                                 "using the 'product list' command."))
        elif len(products) == 0:
            raise ApiDataError(_("Could not find product [ %s ] within organization [ %s ] and definition [%s] ") %
                               ((product_name or product_label or product_id), org_name, cvd["name"]))

        return products[0]
Beispiel #2
0
    def identify_product(self, cvd, product_name, product_label, product_id):
        org_name = self.get_option('org')
        cvd_api = ContentViewDefinitionAPI()
        cvd_products = cvd_api.all_products(org_name, cvd["id"])

        products = [prod for prod in cvd_products if prod["id"] == product_id \
                             or prod["name"] == product_name or prod["label"] == product_label]

        if len(products) > 1:
            raise ApiDataError(_("More than 1 product found with the name or label provided, "\
                                 "recommend using product id.  The product id may be retrieved "\
                                 "using the 'product list' command."))
        elif len(products) == 0:
            raise ApiDataError(_("Could not find product [ %s ] within organization [ %s ] and definition [%s] ") %
                               ((product_name or product_label or product_id), org_name, cvd["name"]))

        return products[0]