Exemplo n.º 1
0
    def do_GET_SEVERITY(self):
        print ''
        SEVERITIES = ('Blocker', 'Critical', 'Major', 'Normal', 'Minor',
                      'Enhancement')
        DESCRIPTIONS = (
            'Blocker - blocks development and/or testing work',
            'Critical - crash, loss of data, corruption of data, severe memory leak',
            'Major - major loss of function',
            'Normal - regular issue, some loss of functionality under specific circumstances',
            'Minor - issue that can be viewed as trivial (e.g. cosmetic, UI, easily documented',
            'Enhancement - request for enhancement (do not use it, use features.opensuse.org !)'
        )

        print 'Please describe the impact of the bug, choose a severity for the issue.'
        console.print_list(DESCRIPTIONS, msg='Available severities:')

        idx = console.get_index(len(SEVERITIES), 'Which one?')

        sev = SEVERITIES[idx]
        if sev == 'Enhancement':
            print 'Enhancement is tracked in features.opensuse.org!'
            return 'GET_SEVERITY'

        self.data['severity'] = sev
        return 'GET_DESCRIPTION'
Exemplo n.º 2
0
    def do_LOAD_ASSIGNEE(self):
        print ''
        print 'Getting assignee & cc list, please wait...'
        assignee, cc = packageInfo.getAssignedPersons(self.pkg_info)

        if self.data['component'] == 'Security':
            cc.append('*****@*****.**')

        if not self.interact:
            assignee = console.custom_input(msg='Assignee: ',
                                            preselect=assignee)
            cc = re.split(
                r',* *',
                console.custom_input(msg="CC (separated by ','): ",
                                     preselect=", ".join(cc)))
            self.data['assigned_to'] = assignee
            self.data['cc'] = cc
            return 'TEST_SUMMARY'

        print 'This/these address(es) were found:'
        print 'assignee: ' + assignee
        print 'cc: ',
        pprint.pprint(cc)

        yes = console.yes_no('Do you want to change the assignee? Yes/No')
        if yes:
            assignee = console.custom_input('New assignee: ',
                                            preselect=assignee)
            print 'Chose %s as assignee.' % assignee

        print ''
        if len(cc) > 0:
            yes = console.yes_no('Do you want to remove anybody from the cc list'\
                                 ' (one at a time)? Yes/No')
            while yes:
                console.print_list(cc, msg='Available choices')
                idx = console.get_index(len(cc), msg='Which one?')
                del cc[idx]
                print ''
                yes = console.yes_no(
                    'Do you want to remove another person? Yes/No')

        print ''
        yes = console.yes_no('Do you want to add another cc(s)? Yes/No')
        if yes:
            print ''
            print 'Enter their e-mail addresses, one at a time.'
            print "To stop, enter something that does not contain '@'."
            ans = raw_input('Cc: ')
            while '@' in ans:
                cc.append(ans)
                ans = raw_input('Cc: ')
            print 'new cc list: '
            pprint.pprint(cc)

        self.data['assigned_to'] = assignee
        self.data['cc'] = cc

        return 'TEST_SUMMARY'
Exemplo n.º 3
0
    def do_LOAD_ASSIGNEE(self):
        print ''
        print 'Getting assignee & cc list, please wait...'
        assignee, cc = packageInfo.getAssignedPersons(self.pkg_info)

        if self.data['component'] == 'Security':
            cc.append('*****@*****.**')
        
        if not self.interact:
            assignee = console.custom_input(msg='Assignee: ', preselect=assignee)
            cc = re.split(r',* *', console.custom_input(msg="CC (separated by ','): ", preselect=", ".join(cc)))
            self.data['assigned_to'] = assignee
            self.data['cc'] = cc
            return 'TEST_SUMMARY'
        
        print 'This/these address(es) were found:'
        print 'assignee: ' + assignee
        print 'cc: ',
        pprint.pprint(cc)

        yes = console.yes_no('Do you want to change the assignee? Yes/No')
        if yes:
            assignee = console.custom_input('New assignee: ', preselect=assignee)
            print 'Chose %s as assignee.' % assignee

        print ''
        if len(cc) > 0:
            yes = console.yes_no('Do you want to remove anybody from the cc list'\
                                 ' (one at a time)? Yes/No')
            while yes:
                console.print_list(cc, msg='Available choices')
                idx = console.get_index(len(cc), msg='Which one?')
                del cc[idx]
                print ''
                yes = console.yes_no('Do you want to remove another person? Yes/No')

        print ''
        yes = console.yes_no('Do you want to add another cc(s)? Yes/No')
        if yes:
            print ''
            print 'Enter their e-mail addresses, one at a time.'
            print "To stop, enter something that does not contain '@'."
            ans = raw_input('Cc: ')
            while '@' in ans:
                cc.append(ans)
                ans = raw_input('Cc: ')
            print 'new cc list: '
            pprint.pprint(cc)

        self.data['assigned_to'] = assignee
        self.data['cc'] = cc

        return 'TEST_SUMMARY'
Exemplo n.º 4
0
    def do_SELECT_PRODUCT_PLATFORM(self):
        print ''
        print 'Getting list of products from Bugzilla...'

        if self.products is None:
            tmp = self.bz.getproducts()
            self.products = [p['name'] for p in tmp]
            self.products.sort()

        console.print_list(self.products, columns=2, msg='Available products:')
        idx = console.get_index(len(self.products), msg='Which one?')

        self.data['product'] = self.products[idx]

        return 'GET_PLATFORM'
Exemplo n.º 5
0
    def do_SELECT_PRODUCT_PLATFORM(self):
        print ''
        print 'Getting list of products from Bugzilla...'

        if self.products is None:
            tmp = self.bz.getproducts()
            self.products = [p['name'] for p in tmp]
            self.products.sort()

        console.print_list(self.products, columns=2, msg='Available products:')
        idx = console.get_index(len(self.products), msg='Which one?')

        self.data['product'] = self.products[idx]

        return 'GET_PLATFORM'
Exemplo n.º 6
0
    def do_GET_VERSION(self):
        if not self.interact:
            ans = raw_input("Product version (or '?' for a list): ").strip()
            if ans != '?' and ans is not '':
                self.data['version'] = ans
                return 'LOAD_ASSIGNEE'
            if ans is '':
                print 'Version cannot be blank!'
        
        print ''
        VERSIONS = ('Final', 'Factory', 'unspecified')
        print 'Please select the version of the OS you are using.'

        console.print_list(VERSIONS, msg='Available choices:')
        idx = console.get_index(len(VERSIONS), msg='Which one?')

        self.data['version'] = VERSIONS[idx]
        
        return 'LOAD_ASSIGNEE'
Exemplo n.º 7
0
    def do_GET_VERSION(self):
        if not self.interact:
            ans = raw_input("Product version (or '?' for a list): ").strip()
            if ans != '?' and ans is not '':
                self.data['version'] = ans
                return 'LOAD_ASSIGNEE'
            if ans is '':
                print 'Version cannot be blank!'

        print ''
        VERSIONS = ('Final', 'Factory', 'unspecified')
        print 'Please select the version of the OS you are using.'

        console.print_list(VERSIONS, msg='Available choices:')
        idx = console.get_index(len(VERSIONS), msg='Which one?')

        self.data['version'] = VERSIONS[idx]

        return 'LOAD_ASSIGNEE'
Exemplo n.º 8
0
    def do_GET_COMPONENT(self, components=None):
        if not self.interact and self.components is None:
            ans = raw_input("Component (or '?' for a list): ").strip()
            if ans is '':
                print 'Component cannot be blank.'
            if ans != '?' and ans is not '':
                self.data['component'] = ans
                if self.data['component'] == 'Security':
                    return 'GET_SECURITY_PREFIX'
                return 'GET_VERSION'

        if self.components is None:
            try:
                print ''
                print 'Getting list of components from Bugzilla for product %s.' % self.data[
                    'product']
                self.components = getcomponents(self.bz, self.data['product'])
            except ValueError:
                print 'The product you have entered is invalid. Please select a correct one.'
                return 'SELECT_PRODUCT_PLATFORM'

        # list is already sorted
        console.print_list(self.components,
                           columns=2,
                           msg='Available components:')
        print ''
        try:
            idx = self.components.index('Security')
            print "If it's a security problem, please select index %d (Security)." % (
                idx + 1)
        except ValueError:
            pass
        idx = console.get_index(len(self.components), msg='Which one?')

        print 'Using component %s.' % self.components[idx]
        self.data['component'] = self.components[idx]

        if self.data['component'] == 'Security':
            return 'GET_SECURITY_PREFIX'

        if self.check_comp:
            return 'CHECK'
        return 'GET_VERSION'
Exemplo n.º 9
0
    def do_GET_COMPONENT(self, components=None):
        if not self.interact and self.components is None:
            ans = raw_input("Component (or '?' for a list): ").strip()
            if ans is '':
                print 'Component cannot be blank.'
            if ans != '?' and ans is not '':
                self.data['component'] = ans
                if self.data['component'] == 'Security':
                    return 'GET_SECURITY_PREFIX'
                return 'GET_VERSION'

        if self.components is None:
            try:
                print ''
                print 'Getting list of components from Bugzilla for product %s.' % self.data['product']
                self.components = getcomponents(self.bz, self.data['product'])
            except ValueError:
                print 'The product you have entered is invalid. Please select a correct one.'
                return 'SELECT_PRODUCT_PLATFORM'

        # list is already sorted
        console.print_list(self.components, columns=2, msg='Available components:')
        print ''
        try:
            idx = self.components.index('Security')
            print "If it's a security problem, please select index %d (Security)." % (idx + 1)
        except ValueError:
            pass
        idx = console.get_index(len(self.components), msg='Which one?')

        print 'Using component %s.' % self.components[idx]
        self.data['component'] = self.components[idx]

        if self.data['component'] == 'Security':
            return 'GET_SECURITY_PREFIX'

        if self.check_comp:
            return 'CHECK'
        return 'GET_VERSION'
Exemplo n.º 10
0
    def do_GET_SEVERITY(self):
        print ''
        SEVERITIES = ('Blocker', 'Critical', 'Major', 'Normal', 'Minor', 'Enhancement')
        DESCRIPTIONS = ('Blocker - blocks development and/or testing work',
                'Critical - crash, loss of data, corruption of data, severe memory leak',
                'Major - major loss of function',
                'Normal - regular issue, some loss of functionality under specific circumstances',
                'Minor - issue that can be viewed as trivial (e.g. cosmetic, UI, easily documented',
                'Enhancement - request for enhancement (do not use it, use features.opensuse.org !)'
                )

        print 'Please describe the impact of the bug, choose a severity for the issue.'
        console.print_list(DESCRIPTIONS, msg='Available severities:')

        idx = console.get_index(len(SEVERITIES), 'Which one?')

        sev = SEVERITIES[idx]
        if sev == 'Enhancement':
            print 'Enhancement is tracked in features.opensuse.org!'
            return 'GET_SEVERITY'

        self.data['severity'] = sev
        return 'GET_DESCRIPTION'
Exemplo n.º 11
0
def getInfo(package):
    ''' returns a tuple associated to the package selected by the user
    the tuple is like this: (version, apiurl, project, package) 
    !! supports globbing. if called with 'python*', it will search all the
    packages that match python*. if called with 'python', it will do exact
    matching 
    !! if there is more than one package matched, the user must choose one '''

    #check to see if the user wants globbing
    glob = 0
    if package[-1] == '*':
        glob = 1

    ts = rpm.TransactionSet()

    ret = {}

    #regex stuff for parsing the disturl
    bs_re = re.compile(r"^(?P<bs>.*)://(?P<apiurl>.*?)/(?P<project>.*?)/"\
            "(?P<repository>.*?)/(?P<md5>[a-f0-9]*)-(?P<source>.*)$")
    srcrep_re = re.compile(r"^srcrep:(?P<md5>[a-f0-9]*)-(?P<source>.*)$")

    for symbol in ('name', 'provides', 'basenames'):

        if symbol == 'basenames':
            if len(ret.keys()) > 0:
                # a package was already found, no need to look for owner of executable
                break

            if '/' not in package:
                abs = which(package)
                if abs is None:
                    break

                package = abs

        #to match all packages, with globbing!
        if not glob:
            match = ts.dbMatch(symbol, package)
        else:
            match = ts.dbMatch()
            match.pattern(symbol, rpm.RPMMIRE_GLOB, package)

        for header in match:
            disturl = header['disturl']
            version = getVersion(header)

            if '.pm.' in version:
                apiurl = None
                project = 'Packman'
                ret[header['name']] = (version, apiurl, project,
                                       header['name'])
                continue

            if disturl:
                m = srcrep_re.match(disturl)
                if m:
                    ret[header['name']] = (
                        version, apiurl,
                        header['distribution'].split('/')[0].strip(),
                        m.group('source'))

                m = bs_re.match(disturl)
                if m:
                    apiurl = m.group('apiurl')
                    if apiurl.split('.')[0] != 'api':
                        apiurl = apiurl.split('.')
                        apiurl = 'https://api.' + '.'.join(apiurl[1:])
                    ret[header['name']] = (version, apiurl, m.group('project'),
                                           m.group('source'))
            else:
                ret[header['name']] = (
                    version, None, header['distribution'].split('/').strip(),
                    header['name'])

    ts.clean()
    ts.closeDB()

    keys = ret.keys()
    length = len(keys)
    if length == 0:
        return None

    elif length == 1:
        ret = ret[keys[0]]

    elif length > 1:
        # there are more than one packages that match, the user must pick one
        msg = 'There are more than one packages that match your search'\
                ', please pick one'
        print_list(keys, msg=msg, columns=2)
        print ''
        idx = get_index(length, 'Which one?')
        ret = ret[keys[idx]]

    return ret
Exemplo n.º 12
0
def getInfo(package):
    ''' returns a tuple associated to the package selected by the user
    the tuple is like this: (version, apiurl, project, package) 
    !! supports globbing. if called with 'python*', it will search all the
    packages that match python*. if called with 'python', it will do exact
    matching 
    !! if there is more than one package matched, the user must choose one '''

    #check to see if the user wants globbing
    glob = 0
    if package[-1] == '*':
        glob = 1;


    ts = rpm.TransactionSet()
    
    ret = {}

    #regex stuff for parsing the disturl
    bs_re = re.compile(r"^(?P<bs>.*)://(?P<apiurl>.*?)/(?P<project>.*?)/"\
            "(?P<repository>.*?)/(?P<md5>[a-f0-9]*)-(?P<source>.*)$")
    srcrep_re = re.compile(r"^srcrep:(?P<md5>[a-f0-9]*)-(?P<source>.*)$")


    for symbol in ('name', 'provides', 'basenames'):

        if symbol == 'basenames':
            if len(ret.keys()) > 0:
                # a package was already found, no need to look for owner of executable
                break

            if '/' not in package:
                abs = which(package)
                if abs is None:
                    break
                
                package = abs

        #to match all packages, with globbing!
        if not glob:
            match = ts.dbMatch(symbol, package)
        else:
            match = ts.dbMatch()
            match.pattern(symbol, rpm.RPMMIRE_GLOB, package)

        for header in match:
            disturl = header['disturl']
            version = getVersion(header)

            if '.pm.' in version:
                apiurl = None
                project = 'Packman'
                ret[header['name']] = (version, apiurl, project, header['name'])
                continue

            if disturl:
                m = srcrep_re.match(disturl)
                if m:
                    ret[header['name']] = (version,
                            apiurl,
                            header['distribution'].split('/')[0].strip(),
                            m.group('source'))

                m = bs_re.match(disturl)
                if m:
                    apiurl = m.group('apiurl')
                    if apiurl.split('.')[0] != 'api':
                        apiurl = apiurl.split('.')
                        apiurl = 'https://api.' + '.'.join(apiurl[1:])
                    ret[header['name']] = (version,
                            apiurl,
                            m.group('project'),
                            m.group('source'))
            else:
                ret[header['name']] = (version,
                        None,
                        header['distribution'].split('/').strip(),
                        header['name'])

    ts.clean()
    ts.closeDB()

    keys = ret.keys()
    length = len(keys)
    if length == 0:
        return None
        
    elif length == 1:
        ret = ret[keys[0]]

    elif length > 1:
        # there are more than one packages that match, the user must pick one
        msg = 'There are more than one packages that match your search'\
                ', please pick one'
        print_list(keys, msg=msg, columns=2)
        print ''
        idx = get_index(length, 'Which one?')
        ret = ret[keys[idx]]

    return ret