---
cli.py | 50 +++++++++++++++++++++++---
yumcommands.py | 110 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 155 insertions(+), 5 deletions(-)
diff --git a/cli.py b/cli.py
index 7ef147d..5c3b9c3 100644
--- a/cli.py
+++ b/cli.py
@@ -84,11 +84,7 @@ class YumBaseCli(yum.YumBase, output.YumOutput):
self.registerCommand(yumcommands.InfoCommand())
self.registerCommand(yumcommands.ListCommand())
self.registerCommand(yumcommands.EraseCommand())
- self.registerCommand(yumcommands.GroupCommand())
- self.registerCommand(yumcommands.GroupListCommand())
- self.registerCommand(yumcommands.GroupInstallCommand())
- self.registerCommand(yumcommands.GroupRemoveCommand())
- self.registerCommand(yumcommands.GroupInfoCommand())
+ self.registerCommand(yumcommands.GroupsCommand())
self.registerCommand(yumcommands.MakeCacheCommand())
self.registerCommand(yumcommands.CleanCommand())
self.registerCommand(yumcommands.ProvidesCommand())
@@ -1283,6 +1279,50 @@ class YumBaseCli(yum.YumBase, output.YumOutput):
done = True
return 0, [_('Done')]
+
+ def returnGroupSummary(self, userlist):
+
+ uservisible=1
+
+ if len(userlist) > 0:
+ if userlist[0] == 'hidden':
+ uservisible=0
+ userlist.pop(0)
+ if not userlist:
+ userlist = None # Match everything...
+
+ installed, available = self.doGroupLists(uservisible=uservisible,
+ patterns=userlist)
+
+ def _out_grp(sect, num):
+ if not num:
+ return
+ self.verbose_logger.log(yum.logginglevels.INFO_2, '%s %u',
sect,num)
+ done = 0
+ for group in installed:
+ if group.langonly: continue
+ done += 1
+ _out_grp(_('Installed Groups:'), done)
+
+ done = 0
+ for group in installed:
+ if not group.langonly: continue
+ done += 1
+ _out_grp(_('Installed Language Groups:'), done)
+
+ done = False
+ for group in available:
+ if group.langonly: continue
+ done += 1
+ _out_grp(_('Available Groups:'), done)
+
+ done = False
+ for group in available:
+ if not group.langonly: continue
+ done += 1
+ _out_grp(_('Available Language Groups:'), done)
+
+ return 0, [_('Done')]
def returnGroupInfo(self, userlist):
"""returns complete information on a list of groups"""
diff --git a/yumcommands.py b/yumcommands.py
index baf5e93..4c9e0a5 100644
--- a/yumcommands.py
+++ b/yumcommands.py
@@ -441,7 +441,117 @@ class GroupCommand(YumCommand):
return 1, [_('No Groups on which to run command')]
except yum.Errors.YumBaseError, e:
return 1, [str(e)]
+
+class GroupsCommand(YumCommand):
+ """ Single sub-command interface for most groups interaction. """
+ direct_commands = {'grouplist' : 'list',
+ 'groupinstall' : 'install',
+ 'groupupdate' : 'install',
+ 'groupremove' : 'remove',
+ 'grouperase' : 'remove',
+ 'groupinfo' : 'info'}
+
+ def getNames(self):
+ return ['groups', 'group'] + self.direct_commands.keys()
+
+ def getUsage(self):
+ return "[list|info|summary|install|upgrade|remove|mark] [GROUP]"
+
+ def getSummary(self):
+ return _("Display, or use, the groups information")
+
+ def _grp_setup_doCommand(self, base):
+ self.doneCommand(base, _("Setting up Group Process"))
+
+ base.doRepoSetup(dosack=0)
+ try:
+ base.doGroupSetup()
+ except yum.Errors.GroupsError:
+ return 1, [_('No Groups on which to run command')]
+ except yum.Errors.YumBaseError, e:
+ return 1, [str(e)]
+
+ def _grp_cmd(self, basecmd, extcmds):
+ if basecmd in self.direct_commands:
+ cmd = self.direct_commands[basecmd]
+ elif extcmds:
+ cmd = extcmds[0]
+ extcmds = extcmds[1:]
+ else:
+ cmd = 'summary'
+
+ remap = {'update' : 'upgrade',
+ 'erase' : 'remove',
+ 'mark-erase' : 'mark-remove',
+ }
+ cmd = remap.get(cmd, cmd)
+
+ return cmd, extcmds
+
+ def doCheck(self, base, basecmd, extcmds):
+ cmd, extcmds = self._grp_cmd(basecmd, extcmds)
+
+ checkEnabledRepo(base)
+
+ if cmd in ('install', 'remove',
+ 'mark-install', 'mark-remove',
+ 'mark-members', 'info', 'mark-members-sync'):
+ checkGroupArg(base, cmd, extcmds)
+
+ if cmd in ('install', 'remove', 'upgrade',
+ 'mark-install', 'mark-remove',
+ 'mark-members', 'mark-members-sync'):
+ checkRootUID(base)
+
+ if cmd in ('install', 'upgrade'):
+ checkGPGKey(base)
+
+ cmds = ('list', 'info', 'remove', 'install', 'upgrade', 'summary',
+ 'mark-install', 'mark-remove',
+ 'mark-members', 'mark-members-sync')
+ if cmd not in cmds:
+ base.logger.critical(_('Invalid groups sub-command, use: %s.'),
+ ", ".join(cmds))
+ raise cli.CliError
+
+ def doCommand(self, base, basecmd, extcmds):
+ cmd, extcmds = self._grp_cmd(basecmd, extcmds)
+
+ self._grp_setup_doCommand(base)
+ if cmd == 'summary':
+ return base.returnGroupSummary(extcmds)
+
+ if cmd == 'list':
+ return base.returnGroupLists(extcmds)
+
+ try:
+ if cmd == 'info':
+ return base.returnGroupInfo(extcmds)
+ if cmd == 'install':
+ return base.installGroups(extcmds)
+ if cmd == 'upgrade':
+ return base.installGroups(extcmds, upgrade=True)
+ if cmd == 'remove':
+ return base.removeGroups(extcmds)
+
+ except yum.Errors.YumBaseError, e:
+ return 1, [str(e)]
+
+
+ def needTs(self, base, basecmd, extcmds):
+ cmd, extcmds = self._grp_cmd(basecmd, extcmds)
+
+ if cmd in ('list', 'info', 'remove', 'summary'):
+ return False
+ return True
+
+ def needTsRemove(self, base, basecmd, extcmds):
+ cmd, extcmds = self._grp_cmd(basecmd, extcmds)
+
+ if cmd in ('remove',):
+ return True
+ return False
class GroupListCommand(GroupCommand):
def getNames(self):
--
1.7.5.2
_______________________________________________
Yum-devel mailing list
[email protected]
http://lists.baseurl.org/mailman/listinfo/yum-devel