[yum-cvs] cli.py yumcommands.py
Seth Vidal
skvidal at linux.duke.edu
Tue Sep 4 19:49:53 UTC 2007
cli.py | 17 +++++++++++------
yumcommands.py | 47 +++++++++++++++++++++++++++++++++++++++++++++--
2 files changed, 56 insertions(+), 8 deletions(-)
New commits:
commit 623233e928ae79040a4c75f6eb7548ce7cd56cbb
Author: Seth Vidal <skvidal at fedoraproject.org>
Date: Tue Sep 4 15:48:27 2007 -0400
add needTs() method to yumcommands.YumCommand
defaults to returning True
return False for conditions where it is not necessary to setup the Ts to run the command
closes rh bug #276151
diff --git a/cli.py b/cli.py
index ff75d51..120435f 100644
--- a/cli.py
+++ b/cli.py
@@ -263,11 +263,17 @@ class YumBaseCli(yum.YumBase, output.YumOutput):
# at this point we know the args are valid - we don't know their meaning
# but we know we're not being sent garbage
- # setup our transaction sets (needed globally, here's a good a place as any)
- try:
- self._getTs()
- except yum.Errors.YumBaseError, e:
- return 1, [str(e)]
+ # setup our transaction set if the command we're using needs it
+ # compat with odd modules not subclassing YumCommand
+ needTs = True
+ if hasattr(self.yum_cli_commands[self.basecmd], 'needTs'):
+ needTs = self.yum_cli_commands[self.basecmd].needTs(self, self.basecmd, self.extcmds)
+
+ if needTs:
+ try:
+ self._getTs()
+ except yum.Errors.YumBaseError, e:
+ return 1, [str(e)]
return self.yum_cli_commands[self.basecmd].doCommand(self, self.basecmd, self.extcmds)
@@ -878,7 +884,6 @@ class YumBaseCli(yum.YumBase, output.YumOutput):
def cleanCli(self, userlist):
hdrcode = pkgcode = xmlcode = dbcode = 0
pkgresults = hdrresults = xmlresults = dbresults = []
-
if 'all' in userlist:
self.verbose_logger.log(yum.logginglevels.INFO_2,
'Cleaning up Everything')
diff --git a/yumcommands.py b/yumcommands.py
index cc47562..0f5ec94 100644
--- a/yumcommands.py
+++ b/yumcommands.py
@@ -100,6 +100,7 @@ def checkShellArg(base, basecmd, extcmds):
raise cli.CliError
class YumCommand:
+
def getNames(self):
return []
@@ -117,7 +118,10 @@ class YumCommand:
2 = we've got work yet to do, onto the next stage
"""
return 0, ['Nothing to do']
-
+
+ def needTs(self, base, basecmd, extcmds):
+ return True
+
class InstallCommand(YumCommand):
def getNames(self):
return ['install']
@@ -182,7 +186,14 @@ class InfoCommand(YumCommand):
return 1, ['No matching Packages to list']
return 0, []
+ def needTs(self, base, basecmd, extcmds):
+ if len(extcmds) and extcmds == ['installed']:
+ return False
+
+ return True
+
class EraseCommand(YumCommand):
+
def getNames(self):
return ['erase', 'remove']
@@ -198,6 +209,9 @@ class EraseCommand(YumCommand):
except yum.Errors.YumBaseError, e:
return 1, [str(e)]
+ def needTs(self, base, basecmd, extcmds):
+ return False
+
class GroupCommand(YumCommand):
def doCommand(self, base, basecmd, extcmds):
base.verbose_logger.log(logginglevels.INFO_2,
@@ -220,6 +234,9 @@ class GroupListCommand(GroupCommand):
GroupCommand.doCommand(self, base, basecmd, extcmds)
return base.returnGroupLists(extcmds)
+ def needTs(self, base, basecmd, extcmds):
+ return False
+
class GroupInstallCommand(GroupCommand):
def getNames(self):
return ['groupinstall', 'groupupdate']
@@ -251,6 +268,9 @@ class GroupRemoveCommand(GroupCommand):
except yum.Errors.YumBaseError, e:
return 1, [str(e)]
+ def needTs(self, base, basecmd, extcmds):
+ return False
+
class GroupInfoCommand(GroupCommand):
def getNames(self):
return ['groupinfo']
@@ -265,7 +285,11 @@ class GroupInfoCommand(GroupCommand):
except yum.Errors.YumBaseError, e:
return 1, [str(e)]
+ def needTs(self, base, basecmd, extcmds):
+ return False
+
class MakeCacheCommand(YumCommand):
+
def getNames(self):
return ['makecache']
@@ -287,7 +311,11 @@ class MakeCacheCommand(YumCommand):
return 1, [str(e)]
return 0, ['Metadata Cache Created']
+ def needTs(self, base, basecmd, extcmds):
+ return False
+
class CleanCommand(YumCommand):
+
def getNames(self):
return ['clean']
@@ -299,6 +327,9 @@ class CleanCommand(YumCommand):
base.conf.cache = 1
return base.cleanCli(extcmds)
+ def needTs(self, base, basecmd, extcmds):
+ return False
+
class ProvidesCommand(YumCommand):
def getNames(self):
return ['provides', 'whatprovides']
@@ -344,6 +375,9 @@ class SearchCommand(YumCommand):
except yum.Errors.YumBaseError, e:
return 1, [str(e)]
+ def needTs(self, base, basecmd, extcmds):
+ return False
+
class UpgradeCommand(YumCommand):
def getNames(self):
return ['upgrade']
@@ -380,6 +414,9 @@ class LocalInstallCommand(YumCommand):
except yum.Errors.YumBaseError, e:
return 1, [str(e)]
+ def needTs(self, base, basecmd, extcmds):
+ return False
+
class ResolveDepCommand(YumCommand):
def getNames(self):
return ['resolvedep']
@@ -405,6 +442,9 @@ class ShellCommand(YumCommand):
except yum.Errors.YumBaseError, e:
return 1, [str(e)]
+ def needTs(self, base, basecmd, extcmds):
+ return False
+
class DepListCommand(YumCommand):
def getNames(self):
@@ -423,7 +463,6 @@ class DepListCommand(YumCommand):
class RepoListCommand:
usage = 'repolist [all|enabled|disabled]'
-
def getNames(self):
return ('repolist',)
@@ -458,3 +497,7 @@ class RepoListCommand:
repo, repo.name, 'disabled')
return 0, []
+
+ def needTs(self, base, basecmd, extcmds):
+ return False
+
More information about the Yum-cvs-commits
mailing list