def _check_product(self): msg = _("ERROR: %s requires a product.")\ % self.plugin_name self._productsAry = None beenVerified = False if not self._options['product']: if common.is_interactive(): self._productsAry = common.get_products() common.print_products(self._productsAry) while True: line = raw_input( _('Please select a product (or \'q\' ' 'to exit): ')) if str(line).strip() == 'q': raise Exception() try: line = int(line) # pylint: disable=W0702 except: print _("ERROR: Invalid product selection.") continue if line in range(1, len(self._productsAry) + 1) and \ line != '': self._options['product'] = self._productsAry[line - 1]\ .get_name() beenVerified = True break else: print _("ERROR: Invalid product selection.") else: print msg raise Exception(msg) else: # User supplied a product self._productsAry = common.get_products() if not beenVerified: inArray = False for product in self._productsAry: if product.get_name().lower() == self._options['product'].\ lower(): inArray = True self._options['product'] = product.get_name() break if not inArray: msg = _("ERROR: Invalid product provided.") print msg raise Exception(msg)
def _check_product(self): msg = _("ERROR: %s requires a product.")\ % self.plugin_name self._productsAry = None beenVerified = False if not self._options['product']: if common.is_interactive(): self._productsAry = common.get_products() common.print_products(self._productsAry) while True: line = raw_input(_('Please select a product (or \'q\' ' 'to exit): ')) if str(line).strip() == 'q': raise Exception() try: line = int(line) # pylint: disable=W0702 except: print _("ERROR: Invalid product selection.") continue if line in range(1, len(self._productsAry) + 1) and \ line != '': self._options['product'] = self._productsAry[line - 1]\ .get_name() beenVerified = True break else: print _("ERROR: Invalid product selection.") else: print msg raise Exception(msg) else: # User supplied a product self._productsAry = common.get_products() if not beenVerified: inArray = False for product in self._productsAry: if product.get_name().lower() == self._options['product'].\ lower(): inArray = True self._options['product'] = product.get_name() break if not inArray: msg = _("ERROR: Invalid product provided.") print msg raise Exception(msg)
def _get_prod(self): self._productsAry = common.get_products() common.print_products(self._productsAry) while True: line = raw_input(_('Please select a product (or \'q\' ' 'to exit): ')) if str(line).strip() == 'q': return False try: line = int(line) # pylint: disable=W0702 except: print _("ERROR: Invalid product selection.") if line in range(1, len(self._productsAry) + 1) and line != '': self._options['product'] = self._productsAry[line - 1]\ .get_name() break else: print _("ERROR: Invalid product selection.") return True
def _get_prod(self): self._productsAry = common.get_products() common.print_products(self._productsAry) while True: line = raw_input( _('Please select a product (or \'q\' ' 'to exit): ')) if str(line).strip() == 'q': return False try: line = int(line) # pylint: disable=W0702 except: print _("ERROR: Invalid product selection.") if line in range(1, len(self._productsAry) + 1) and line != '': self._options['product'] = self._productsAry[line - 1]\ .get_name() break else: print _("ERROR: Invalid product selection.") return True