def _mark_remove(self, patterns): q = CompsQuery(self.base.comps, self.base.history, CompsQuery.GROUPS | CompsQuery.ENVIRONMENTS, CompsQuery.INSTALLED) solver = self.base._build_comps_solver() res = q.get(*patterns) for env_id in res.environments: assert dnf.util.is_string_type(env_id) solver._environment_remove(env_id) for grp_id in res.groups: assert dnf.util.is_string_type(grp_id) solver._group_remove(grp_id) if res.environments: logger.info( _('Environments marked removed: %s'), ','.join([ ucd(self.base.history.env.get(e_id).getTranslatedName()) for e_id in res.environments ])) if res.groups: logger.info( _('Groups marked removed: %s'), ','.join([ ucd(self.base.history.group.get(g_id).getTranslatedName()) for g_id in res.groups ])) if res.groups or res.environments: self._history_commit()
def _mark_install(self, patterns): prst = self.base._group_persistor q = CompsQuery(self.base.comps, prst, CompsQuery.GROUPS | CompsQuery.ENVIRONMENTS, CompsQuery.AVAILABLE | CompsQuery.INSTALLED) solver = self.base._build_comps_solver() res = q.get(*patterns) types = dnf.comps.DEFAULT | dnf.comps.MANDATORY | dnf.comps.OPTIONAL for env_id in res.environments: if not dnf.comps.install_or_skip(solver._environment_install, env_id, types): res.environments.remove(env_id) for group_id in res.groups: if not dnf.comps.install_or_skip(solver._group_install, group_id, types): res.groups.remove(group_id) if res.environments: logger.info(_('Environments marked installed: %s'), ','.join([prst.environment(g).ui_name for g in res.environments])) if res.groups: logger.info(_('Groups marked installed: %s'), ','.join([prst.group(g).ui_name for g in res.groups])) prst.commit()
def _mark_install(self, patterns): persistor = self.base.group_persistor q = CompsQuery(self.base.comps, persistor, CompsQuery.GROUPS | CompsQuery.ENVIRONMENTS, CompsQuery.AVAILABLE | CompsQuery.INSTALLED) solver = self.base.build_comps_solver() res = q.get(*patterns) types = dnf.comps.DEFAULT | dnf.comps.MANDATORY | dnf.comps.OPTIONAL def install_or_skip(install_fnc, grp_or_env): for grp in grp_or_env: try: install_fnc(grp, types, None) except dnf.comps.CompsError as e: logger.warning("%s, %s", str(e)[:-1], _("skipping.")) grp_or_env.remove(grp) install_or_skip(solver.environment_install, res.environments) if res.environments: logger.info(_('Environments marked installed: %s'), ','.join([g.ui_name for g in res.environments])) install_or_skip(solver.group_install, res.groups) if res.groups: logger.info(_('Groups marked installed: %s'), ','.join([g.ui_name for g in res.groups])) persistor.commit()
def _mark_install(self, patterns): persistor = self.base.group_persistor q = CompsQuery(self.base.comps, persistor, CompsQuery.GROUPS | CompsQuery.ENVIRONMENTS, CompsQuery.AVAILABLE | CompsQuery.INSTALLED) solver = self.base.build_comps_solver() res = q.get(*patterns) types = dnf.comps.DEFAULT | dnf.comps.MANDATORY | dnf.comps.OPTIONAL for env in res.environments: if not dnf.comps.install_or_skip(solver.environment_install, env, types): res.environments.remove(env) for group in res.groups: if not dnf.comps.install_or_skip(solver.group_install, group, types): res.groups.remove(group) if res.environments: logger.info(_('Environments marked installed: %s'), ','.join([g.ui_name for g in res.environments])) if res.groups: logger.info(_('Groups marked installed: %s'), ','.join([g.ui_name for g in res.groups])) persistor.commit()
def _mark_install(self, patterns): prst = self.base.history.group q = CompsQuery(self.base.comps, prst, CompsQuery.GROUPS | CompsQuery.ENVIRONMENTS, CompsQuery.AVAILABLE | CompsQuery.INSTALLED) solver = self.base._build_comps_solver() res = q.get(*patterns) types = dnf.comps.DEFAULT | dnf.comps.MANDATORY | dnf.comps.OPTIONAL for env_id in res.environments: if not dnf.comps.install_or_skip(solver._environment_install, env_id, types): res.environments.remove(env_id) for group_id in res.groups: if not dnf.comps.install_or_skip(solver._group_install, group_id, types): res.groups.remove(group_id) if res.environments: logger.info( _('Environments marked installed: %s'), ','.join([ ucd(prst.environment(g).ui_name) for g in res.environments ])) if res.groups: logger.info( _('Groups marked installed: %s'), ','.join([ucd(prst.group(g).ui_name) for g in res.groups])) prst.commit()
def test_all(self): status_all = CompsQuery.AVAILABLE | CompsQuery.INSTALLED kinds_all = CompsQuery.ENVIRONMENTS | CompsQuery.GROUPS q = CompsQuery(self.comps, self.prst, kinds_all, status_all) res = q.get('sugar*', '*er*') self.assertCountEqual(names(res.environments), ('Sugar Desktop Environment', )) self.assertCountEqual(names(res.groups), ("Pepper's", 'Solid Ground'))
def _upgrade(self, patterns): q = CompsQuery(self.base.comps, self.base.group_persistor, CompsQuery.GROUPS, CompsQuery.INSTALLED) res = q.get(*patterns) cnt = 0 for grp in res.groups: cnt += self.base.group_upgrade(grp) if not cnt: msg = _("No packages marked for upgrade.") raise dnf.cli.CliError(msg)
def test_all(self): status_all = CompsQuery.AVAILABLE | CompsQuery.INSTALLED kinds_all = CompsQuery.ENVIRONMENTS | CompsQuery.GROUPS q = CompsQuery(self.comps, self.prst, kinds_all, status_all) res = q.get('sugar*', '*er*') self.assertCountEqual(names(res.environments), ('Sugar Desktop Environment',)) self.assertCountEqual(names(res.groups), ("Pepper's", 'Solid Ground'))
def test_all(self): status_all = CompsQuery.AVAILABLE | CompsQuery.INSTALLED kinds_all = CompsQuery.ENVIRONMENTS | CompsQuery.GROUPS q = CompsQuery(self.comps, self.persistor, kinds_all, status_all) res = q.get('sugar*', '*er*') self.assertCountEqual(res.environments, ('sugar-desktop-environment',)) self.assertCountEqual(res.groups, ("Peppers", 'somerset'))
def test_all(self): status_all = CompsQuery.AVAILABLE | CompsQuery.INSTALLED kinds_all = CompsQuery.ENVIRONMENTS | CompsQuery.GROUPS q = CompsQuery(self.comps, self.prst, kinds_all, status_all) res = q.get('sugar*', '*er*') self.assertCountEqual(res.environments, ('sugar-desktop-environment', )) self.assertCountEqual(res.groups, ("Peppers", 'somerset'))
def test_installed(self): q = CompsQuery(self.comps, self.prst, CompsQuery.GROUPS, CompsQuery.INSTALLED) self.base.read_mock_comps(False) grp = self.base.comps.group_by_pattern('somerset') self.base.group_install(grp.id, ('mandatory',)) res = q.get('somerset') self.assertEmpty(res.environments) grp_ids = [grp.name_id for grp in res.groups] self.assertCountEqual(grp_ids, ('somerset',))
def test_installed(self): q = CompsQuery(self.comps, self.prst, CompsQuery.GROUPS, CompsQuery.INSTALLED) self.base.read_mock_comps(False) grp = self.base.comps.group_by_pattern('somerset') self.base.group_install(grp.id, ('mandatory', )) res = q.get('somerset') self.assertEmpty(res.environments) grp_ids = [grp.name_id for grp in res.groups] self.assertCountEqual(grp_ids, ('somerset', ))
def _upgrade(self, patterns): q = CompsQuery(self.base.comps, self.base.group_persistor, CompsQuery.GROUPS, CompsQuery.INSTALLED) res = q.get(*patterns) cnt = 0 for grp in res.groups: cnt += self.base.group_upgrade(grp) if not cnt: msg = _('No packages marked for upgrade.') raise dnf.cli.CliError(msg)
def _mark_remove(self, patterns): q = CompsQuery(self.base.comps, self.base.history, CompsQuery.GROUPS | CompsQuery.ENVIRONMENTS, CompsQuery.INSTALLED) solver = self.base._build_comps_solver() res = q.get(*patterns) for env_id in res.environments: assert dnf.util.is_string_type(env_id) solver._environment_remove(env_id) for grp_id in res.groups: assert dnf.util.is_string_type(grp_id) solver._group_remove(grp_id)
def test_installed(self): q = CompsQuery(self.comps, self.history, CompsQuery.GROUPS, CompsQuery.INSTALLED) self.base.read_mock_comps(False) grp = self.base.comps.group_by_pattern('somerset') self.base.group_install(grp.id, ('mandatory', )) self._swdb_commit() res = q.get('somerset') self.assertEmpty(res.environments) grp_ids = list(res.groups) self.assertCountEqual(grp_ids, ('somerset', ))
def test_installed(self): q = CompsQuery(self.comps, self.history, CompsQuery.GROUPS, CompsQuery.INSTALLED) self.base.read_mock_comps(False) grp = self.base.comps.group_by_pattern('somerset') self.base.group_install(grp.id, ('mandatory',)) self._swdb_commit() res = q.get('somerset') self.assertEmpty(res.environments) grp_ids = list(res.groups) self.assertCountEqual(grp_ids, ('somerset',))
def _mark_remove(self, patterns): persistor = self.base.group_persistor q = CompsQuery(self.base.comps, persistor, CompsQuery.GROUPS | CompsQuery.ENVIRONMENTS, CompsQuery.INSTALLED) solver = self.base.build_comps_solver() res = q.get(*patterns) for env in res.environments: solver.environment_remove(env) for grp in res.groups: solver.group_remove(grp) if res.environments: logger.info(_("Environments marked removed: %s"), ",".join([g.ui_name for g in res.environments])) if res.groups: logger.info(_("Groups marked removed: %s"), ",".join([g.ui_name for g in res.groups])) persistor.commit()
def _mark_install(self, patterns): q = CompsQuery(self.base.comps, self.base.history, CompsQuery.GROUPS | CompsQuery.ENVIRONMENTS, CompsQuery.AVAILABLE | CompsQuery.INSTALLED) solver = self.base._build_comps_solver() res = q.get(*patterns) if self.opts.with_optional: types = tuple(self.base.conf.group_package_types + ['optional']) else: types = tuple(self.base.conf.group_package_types) pkg_types = self.base._translate_comps_pkg_types(types) for env_id in res.environments: dnf.comps.install_or_skip(solver._environment_install, env_id, pkg_types) for group_id in res.groups: dnf.comps.install_or_skip(solver._group_install, group_id, pkg_types)
def _mark_install(self, patterns): q = CompsQuery(self.base.comps, self.base.history, CompsQuery.GROUPS | CompsQuery.ENVIRONMENTS, CompsQuery.AVAILABLE | CompsQuery.INSTALLED) solver = self.base._build_comps_solver() res = q.get(*patterns) if self.opts.with_optional: types = tuple(self.base.conf.group_package_types + ['optional']) else: types = tuple(self.base.conf.group_package_types) pkg_types = libdnf.transaction.listToCompsPackageType(types) for env_id in res.environments: solver._environment_install(env_id, pkg_types) for group_id in res.groups: solver._group_install(group_id, pkg_types)
def _mark_remove(self, patterns): persistor = self.base.group_persistor q = CompsQuery(self.base.comps, persistor, CompsQuery.GROUPS | CompsQuery.ENVIRONMENTS, CompsQuery.INSTALLED) solver = self.base.build_comps_solver() res = q.get(*patterns) for env in res.environments: solver.environment_remove(env) if res.environments: logger.info(_('Environments marked removed: %s'), ','.join([g.ui_name for g in res.environments])) for grp in res.groups: solver.group_remove(grp) if res.groups: logger.info(_('Groups marked removed: %s'), ','.join([g.ui_name for g in res.groups])) persistor.commit()
def _mark_install(self, patterns): persistor = self.base.group_persistor q = CompsQuery(self.base.comps, persistor, CompsQuery.GROUPS | CompsQuery.ENVIRONMENTS, CompsQuery.AVAILABLE | CompsQuery.INSTALLED) solver = self.base.build_comps_solver() res = q.get(*patterns) types = dnf.comps.DEFAULT | dnf.comps.MANDATORY | dnf.comps.OPTIONAL dnf.comps.install_or_skip(solver.environment_install, res.environments, types) if res.environments: logger.info(_('Environments marked installed: %s'), ','.join([g.ui_name for g in res.environments])) dnf.comps.install_or_skip(solver.group_install, res.groups, types) if res.groups: logger.info(_('Groups marked installed: %s'), ','.join([g.ui_name for g in res.groups])) persistor.commit()
def _mark_remove(self, patterns): prst = self.base._group_persistor q = CompsQuery(self.base.comps, prst, CompsQuery.GROUPS | CompsQuery.ENVIRONMENTS, CompsQuery.INSTALLED) solver = self.base._build_comps_solver() res = q.get(*patterns) for env_id in res.environments: solver._environment_remove(env_id) for grp_id in res.groups: solver._group_remove(grp_id) if res.environments: logger.info(_('Environments marked removed: %s'), ','.join([prst.environment(e_id).ui_name for e_id in res.environments])) if res.groups: logger.info(_('Groups marked removed: %s'), ','.join([prst.group(g_id).ui_name for g_id in res.groups])) prst.commit()
def _mark_install(self, patterns): q = CompsQuery(self.base.comps, self.base.history, CompsQuery.GROUPS | CompsQuery.ENVIRONMENTS, CompsQuery.AVAILABLE | CompsQuery.INSTALLED) solver = self.base._build_comps_solver() res = q.get(*patterns) types = dnf.comps.DEFAULT | dnf.comps.MANDATORY | dnf.comps.OPTIONAL for env_id in res.environments: if not dnf.comps.install_or_skip(solver._environment_install, env_id, types): res.environments.remove(env_id) for group_id in res.groups: if not dnf.comps.install_or_skip(solver._group_install, group_id, types): res.groups.remove(group_id) if res.groups or res.environments: self._history_commit() if res.environments: logger.info( _('Environments marked installed: %s'), ','.join([ ucd(self.base.history.env.get(g).getTranslatedName()) for g in res.environments ])) if res.groups: print(res.groups) for g in res.groups: x = self.base.history.group.get(g) print(x, type(x), dir(x)) logger.info( _('Groups marked installed: %s'), ','.join([ ucd(self.base.history.group.get(g).getTranslatedName()) for g in res.groups ]))
def _mark_install(self, patterns): persistor = self.base.group_persistor q = CompsQuery( self.base.comps, persistor, CompsQuery.GROUPS | CompsQuery.ENVIRONMENTS, CompsQuery.AVAILABLE | CompsQuery.INSTALLED, ) solver = self.base.build_comps_solver() res = q.get(*patterns) types = dnf.comps.DEFAULT | dnf.comps.MANDATORY | dnf.comps.OPTIONAL for env in res.environments: if not dnf.comps.install_or_skip(solver.environment_install, env, types): res.environments.remove(env) for group in res.groups: if not dnf.comps.install_or_skip(solver.group_install, group, types): res.groups.remove(group) if res.environments: logger.info(_("Environments marked installed: %s"), ",".join([g.ui_name for g in res.environments])) if res.groups: logger.info(_("Groups marked installed: %s"), ",".join([g.ui_name for g in res.groups])) persistor.commit()
def test_installed(self): q = CompsQuery(self.comps, self.prst, CompsQuery.GROUPS, CompsQuery.INSTALLED) res = q.get('somerset') self.assertEmpty(res.environments) self.assertCountEqual(res.groups, ('somerset',))
def test_installed(self): q = CompsQuery(self.comps, self.prst, CompsQuery.GROUPS, CompsQuery.INSTALLED) res = q.get('somerset') self.assertEmpty(res.environments) self.assertCountEqual(res.groups, ('somerset', ))
def test_err(self): q = CompsQuery(self.comps, self.prst, CompsQuery.ENVIRONMENTS, CompsQuery.AVAILABLE) with self.assertRaises(dnf.exceptions.CompsError): q.get('*er*')
def test_err(self): q = CompsQuery(self.comps, self.persistor, CompsQuery.ENVIRONMENTS, CompsQuery.AVAILABLE) with self.assertRaises(dnf.exceptions.CompsError): q.get('*er*')