def _check_case_group(self):
        msg = _("ERROR: Invalid case group selection")
        if not self._options['casegroup']:
            if common.is_interactive():
                line = raw_input(
                    _('Would you like to assign a case'
                      ' group to this case (y/N)? '))
                if str(line).strip().lower() == 'y':
                    groupsAry = common.get_groups()
                    common.print_groups(groupsAry)
                    while True:
                        line = raw_input(
                            _('Please select a severity (or \'q\' '
                              'to exit): '))
                        if str(line).strip() == 'q':
                            raise Exception()
                        try:
                            line = int(line)
                        # pylint: disable=W0702
                        except:
                            print _("ERROR: Invalid severity selection.")

                        if line in range(1, len(groupsAry) + 1) and line != '':
                            self._options['casegroup'] = groupsAry[line - 1]
                            self._options['casegroupnumber'] = \
                                    groupsAry[line - 1].get_number()
                            logger.log(
                                logging.INFO,
                                'Casegroup(%s) casegroupnumber(%s)' %
                                (self._options['casegroup'].get_name(),
                                 self._options['casegroupnumber']))
                            break
                        else:
                            print _("ERROR: Invalid case group selection.")
        else:
            match = False
            for group in common.get_groups():
                if self._options['casegroup'].lower() in \
                                        group.get_name().lower():
                    match = True
                    self._options['casegroup'] = group.get_name()
                    self._options['casegroupnumber'] = group.get_number()
                    logger.log(
                        logging.INFO, 'Casegroup(%s) casegroupnumber(%s)' %
                        (self._options['casegroup'],
                         self._options['casegroupnumber']))
                    break
            if (not match):
                msg = _("ERROR: Invalid case group specified.")
                print msg
示例#2
0
    def _check_case_group(self):
        if self._options['casegroup']:
            valid_groups = []
            given_groupAry = str(self._options['casegroup']).split(',')
            real_groupAry = common.get_groups()

            for i in given_groupAry:
                match = False
                for j in real_groupAry:
                    if i.lower() == j.get_name().lower() or \
                       i == str(j.get_number()):
                        valid_groups.append(j.get_number())
                        match = True
                if(not match):
                    msg = _("Unable to find case group %s" % i)
                    print msg
                    raise Exception(msg)

            if len(valid_groups) > 0:
                self._caseGroupNumbers = valid_groups

            logger.log(logging.INFO,
                       'Casegroup(%s) casegroupnumber(%s)' % (
                       given_groupAry,
                       self._caseGroupNumbers))
示例#3
0
    def _check_case_group(self):
        msg = _("ERROR: Invalid case group selection")
        if not self._options['casegroup']:
            if common.is_interactive():
                line = raw_input(_('Would you like to assign a case'
                                   ' group to this case (y/N)? '))
                if str(line).strip().lower() == 'y':
                    groupsAry = common.get_groups()
                    common.print_groups(groupsAry)
                    while True:
                        line = raw_input(_('Please select a severity (or \'q\' '
                                           'to exit): '))
                        if str(line).strip() == 'q':
                            raise Exception()
                        try:
                            line = int(line)
                        # pylint: disable=W0702
                        except:
                            print _("ERROR: Invalid severity selection.")

                        if line in range(1, len(groupsAry) + 1) and line != '':
                            self._options['casegroup'] = groupsAry[line - 1]
                            self._options['casegroupnumber'] = \
                                    groupsAry[line - 1].get_number()
                            logger.log(logging.INFO,
                                       'Casegroup(%s) casegroupnumber(%s)' % (
                                       self._options['casegroup'].get_name(),
                                       self._options['casegroupnumber']))
                            break
                        else:
                            print _("ERROR: Invalid case group selection.")
        else:
            match = False
            for group in common.get_groups():
                if self._options['casegroup'].lower() in \
                                        group.get_name().lower():
                    match = True
                    self._options['casegroup'] = group.get_name()
                    self._options['casegroupnumber'] = group.get_number()
                    logger.log(logging.INFO,
                               'Casegroup(%s) casegroupnumber(%s)' % (
                               self._options['casegroup'],
                               self._options['casegroupnumber']))
                    break
            if(not match):
                msg = _("ERROR: Invalid case group specified.")
                print msg
    def _check_case_group(self):
        if self._options['casegroup']:
            valid_groups = []
            given_groupAry = str(self._options['casegroup']).split(',')
            real_groupAry = common.get_groups()

            for i in given_groupAry:
                match = False
                for j in real_groupAry:
                    if i.lower() == j.get_name().lower() or \
                       i == str(j.get_number()):
                        valid_groups.append(j.get_number())
                        match = True
                if (not match):
                    msg = _("Unable to find case group %s" % i)
                    print msg
                    raise Exception(msg)

            if len(valid_groups) > 0:
                self._caseGroupNumbers = valid_groups

            logger.log(
                logging.INFO, 'Casegroup(%s) casegroupnumber(%s)' %
                (given_groupAry, self._caseGroupNumbers))
示例#5
0
 def non_interactive_action(self):
     ary = get_groups()
     for p in ary:
         print p.get_name()
 def non_interactive_action(self):
     ary = get_groups()
     for p in ary:
         print p.get_name()