本文整理汇总了Python中dnf.comps.CompsQuery类的典型用法代码示例。如果您正苦于以下问题:Python CompsQuery类的具体用法?Python CompsQuery怎么用?Python CompsQuery使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CompsQuery类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _mark_install
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()
示例2: _mark_install
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()
示例3: test_all
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'))
示例4: _upgrade
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)
示例5: test_all
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'))
示例6: test_installed
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',))
示例7: test_installed
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',))
示例8: _mark_remove
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()
示例9: _mark_install
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()
示例10: _mark_remove
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()
示例11: _mark_install
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()
示例12: test_err
def test_err(self):
q = CompsQuery(self.comps, self.persistor, CompsQuery.ENVIRONMENTS,
CompsQuery.AVAILABLE)
with self.assertRaises(dnf.exceptions.CompsError):
q.get('*er*')
示例13: test_installed
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',))