Exemplo n.º 1
0
    def autofix(self, bugs, dryrun):
        """Autofix the bugs according to what is returned by get_autofix_change"""
        ni_changes = self.set_needinfo(dryrun)
        change = self.get_autofix_change()

        if not ni_changes and not change:
            return bugs

        self.has_autofix = True
        new_changes = {}
        if not self.has_individual_autofix(change):
            bugids = self.get_list_bugs(bugs)
            for bugid in bugids:
                new_changes[bugid] = utils.merge_bz_changes(
                    change, ni_changes.get(bugid, {}))
        else:
            change = {str(k): v for k, v in change.items()}
            bugids = set(change.keys()) | set(ni_changes.keys())
            for bugid in bugids:
                mrg = utils.merge_bz_changes(change.get(bugid, {}),
                                             ni_changes.get(bugid, {}))
                if mrg:
                    new_changes[bugid] = mrg

        if dryrun or self.test_mode:
            for bugid, ch in new_changes.items():
                logger.info(
                    'The bugs: {}\n will be autofixed with:\n{}'.format(
                        bugid, ch))
        else:
            for bugid, ch in new_changes.items():
                Bugzilla([str(bugid)]).put(ch)

        return bugs
Exemplo n.º 2
0
    def autofix(self, bugs):
        """Autofix the bugs according to what is returned by get_autofix_change"""
        ni_changes = self.set_needinfo()
        change = self.get_autofix_change()

        if not ni_changes and not change:
            return bugs

        self.has_autofix = True
        new_changes = {}
        if not self.has_individual_autofix(change):
            bugids = self.get_list_bugs(bugs)
            for bugid in bugids:
                new_changes[bugid] = utils.merge_bz_changes(
                    change, ni_changes.get(bugid, {})
                )
        else:
            change = {str(k): v for k, v in change.items()}
            bugids = set(change.keys()) | set(ni_changes.keys())
            for bugid in bugids:
                mrg = utils.merge_bz_changes(
                    change.get(bugid, {}), ni_changes.get(bugid, {})
                )
                if mrg:
                    new_changes[bugid] = mrg

        if self.dryrun or self.test_mode:
            for bugid, ch in new_changes.items():
                logger.info(
                    "The bugs: {}\n will be autofixed with:\n{}".format(bugid, ch)
                )
        else:
            extra = self.get_db_extra()
            max_retries = utils.get_config("common", "bugzilla_max_retries", 3)
            for bugid, ch in new_changes.items():
                added = False
                for _ in range(max_retries):
                    failures = Bugzilla([str(bugid)]).put(ch)
                    if failures:
                        time.sleep(1)
                    else:
                        added = True
                        db.BugChange.add(self.name(), bugid, extra=extra.get(bugid, ""))
                        break
                if not added:
                    self.failure_callback(bugid)
                    logger.error(
                        "{}: Cannot put data for bug {} (change => {}).".format(
                            self.name(), bugid, ch
                        )
                    )

        return bugs
Exemplo n.º 3
0
    def autofix(self, bugs):
        """Autofix the bugs according to what is returned by get_autofix_change"""
        ni_changes = self.set_needinfo()
        change = self.get_autofix_change()

        if not ni_changes and not change:
            return bugs

        self.has_autofix = True
        new_changes = {}
        if not self.has_individual_autofix(change):
            bugids = self.get_list_bugs(bugs)
            for bugid in bugids:
                new_changes[bugid] = utils.merge_bz_changes(
                    change, ni_changes.get(bugid, {})
                )
        else:
            change = {str(k): v for k, v in change.items()}
            bugids = set(change.keys()) | set(ni_changes.keys())
            for bugid in bugids:
                mrg = utils.merge_bz_changes(
                    change.get(bugid, {}), ni_changes.get(bugid, {})
                )
                if mrg:
                    new_changes[bugid] = mrg

        if self.dryrun or self.test_mode:
            for bugid, ch in new_changes.items():
                logger.info(
                    'The bugs: {}\n will be autofixed with:\n{}'.format(bugid, ch)
                )
        else:
            extra = self.get_db_extra()
            for bugid, ch in new_changes.items():
                Bugzilla([str(bugid)]).put(ch)
                db.BugChange.add(self.name(), bugid, extra=extra.get(bugid, ''))

        return bugs