[yum-cvs] yum cli.py, 1.173, 1.174 output.py, 1.52, 1.53 shell.py, 1.7, 1.8 yummain.py, 1.94, 1.95

Seth Vidal skvidal at login.linux.duke.edu
Sun Mar 27 08:46:30 UTC 2005


Update of /home/groups/yum/cvs/yum
In directory login:/tmp/cvs-serv14281

Modified Files:
	cli.py output.py shell.py yummain.py 
Log Message:

add 'enablerepo' and 'disablerepo' commands to yum shell. 
 - modified doRepoSetup() to take a thisrepo setup argument so we can setup
   one repo at a time
 - modified the RepoStorage.populateSack() so that the repos list is checked
   if it is repoids or repo objects and used correctly
 - We might want to think about a YumBase.reset() function that resets the
   internal state of the object.

- cleaned up some garbage comments and white space in yummain.py and cli.py


Index: cli.py
===================================================================
RCS file: /home/groups/yum/cvs/yum/cli.py,v
retrieving revision 1.173
retrieving revision 1.174
diff -u -r1.173 -r1.174
--- cli.py	27 Mar 2005 07:58:53 -0000	1.173
+++ cli.py	27 Mar 2005 08:46:28 -0000	1.174
@@ -27,7 +27,6 @@
 import re
 
 import output
-from urlgrabber.progress import TextMeter
 import shell
 import yum
 import yum.Errors
@@ -57,12 +56,11 @@
         self.localPackages = [] # for local package handling - possibly needs
                                 # to move to the lower level class
 
-    def doRepoSetup(self, nosack=None):
-        """grabs the repomd.xml for each enabled repository and sets up the
-        basics of the repository
-        """
+    def doRepoSetup(self, dosack=1, thisrepo=None):
+        """grabs the repomd.xml for each enabled repository 
+           and sets up the basics of the repository"""
         
-        if hasattr(self, 'pkgSack'):
+        if hasattr(self, 'pkgSack') and thisrepo is None:
             self.log(7, 'skipping reposetup, pkgsack exists')
             return
             
@@ -71,19 +69,13 @@
         # Call parent class to do the bulk of work 
         # (this also ensures that reposetup plugin hook is called)
         try:
-            yum.YumBase.doRepoSetup(self)
+            yum.YumBase.doRepoSetup(self, thisrepo=thisrepo)
         except yum.Errors.RepoError, e:
             sys.exit(1)
 
-        # Error out if there's no actual repos
-        if len(self.repos.listEnabled()) < 1:
-            self.errorlog(0, 'No repositories available to set up')
-            sys.exit(1)
-
-        # So we can make the dirs and grab the repomd.xml but not import the md
-        if not nosack: 
+        if dosack: # so we can make the dirs and grab the repomd.xml but not import the md
             self.log(2, 'Reading repository metadata in from local files')
-            self.doSackSetup()
+            self.doSackSetup(thisrepo=thisrepo)
     
         
     def getOptionsConfig(self, args):
@@ -239,24 +231,8 @@
             self.usage()
             sys.exit(1)
             
-        # if we're below 2 on the debug level we don't need to be outputting
-        # progress bars - this is hacky - I'm open to other options
-        # One of these is a download
-        if self.conf.getConfigOption('debuglevel') < 2 or not sys.stdout.isatty():
-            self.repos.setProgressBar(None)
-            self.repos.callback = None
-        else:
-            self.repos.setProgressBar(TextMeter(fo=sys.stdout))
-            self.repos.callback = output.CacheProgressCallback(self.log,
-                    self.errorlog, self.filelog)
-
-        # setup our failure report for failover
-        freport = (self.failureReport,(),{})
-        self.repos.setFailureCallback(freport)
-        
-        # setup our depsolve progress callback
-        dscb = output.DepSolveProgressCallBack(self.log, self.errorlog)
-        self.dsCallback = dscb
+        # setup the progress bars/callbacks
+        self.setupProgessCallbacks()
         
         # save our original args out
         self.args = args
@@ -266,8 +242,8 @@
             self.cmdstring += '%s ' % arg
 
         try:
-            self.parseCommands() # before we exit check over the base command + args
-                             # make sure they match/make sense
+            self.parseCommands() # before we return check over the base command + args
+                                 # make sure they match/make sense
         except CliError:
             sys.exit(1)
     
@@ -512,7 +488,7 @@
 
             self.log(2, "Setting up Group Process")
 
-            self.doRepoSetup(nosack=1)
+            self.doRepoSetup(dosack=0)
             try:
                 self.doGroupSetup()
             except yum.Errors.GroupsError:
@@ -572,7 +548,7 @@
             self.log(2, "This may take a while depending on the speed of this computer")
             self.log(3, '%s' % self.pickleRecipe())
             try:
-                self.doRepoSetup(nosack=1)
+                self.doRepoSetup(dosack=0)
                 self.repos.populateSack(with='metadata', pickleonly=1)
                 self.repos.populateSack(with='filelists', pickleonly=1)
                 self.repos.populateSack(with='otherdata', pickleonly=1)
@@ -1401,11 +1377,6 @@
         # otherwise, don't prompt        
         return False
 
-
-
-            
-        
-        
     def usage(self):
         print _("""
     Usage:  yum [options] < update | install | info | remove | list |

Index: output.py
===================================================================
RCS file: /home/groups/yum/cvs/yum/output.py,v
retrieving revision 1.52
retrieving revision 1.53
diff -u -r1.52 -r1.53
--- output.py	15 Mar 2005 07:43:03 -0000	1.52
+++ output.py	27 Mar 2005 08:46:28 -0000	1.53
@@ -23,6 +23,8 @@
 import time
 from i18n import _
 
+from urlgrabber.progress import TextMeter
+
 try:
     import readline
 except:
@@ -285,7 +287,28 @@
         
         return out
 
-
+    def setupProgessCallbacks(self):
+        """sets up the progress callbacks and various 
+           output bars based on debug level"""
+
+        # if we're below 2 on the debug level we don't need to be outputting
+        # progress bars - this is hacky - I'm open to other options
+        # One of these is a download
+        if self.conf.debuglevel < 2 or not sys.stdout.isatty():
+            self.repos.setProgressBar(None)
+            self.repos.callback = None
+        else:
+            self.repos.setProgressBar(TextMeter(fo=sys.stdout))
+            self.repos.callback = CacheProgressCallback(self.log, self.errorlog,
+                                                        self.filelog)
+        # setup our failure report for failover
+        freport = (self.failureReport,(),{})
+        self.repos.setFailureCallback(freport)
+        
+        # setup our depsolve progress callback
+        dscb = DepSolveProgressCallBack(self.log, self.errorlog)
+        self.dsCallback = dscb
+            
     
     def pickleRecipe(self):
         """ don't ask """

Index: shell.py
===================================================================
RCS file: /home/groups/yum/cvs/yum/shell.py,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- shell.py	7 Mar 2005 07:08:08 -0000	1.7
+++ shell.py	27 Mar 2005 08:46:28 -0000	1.8
@@ -58,7 +58,21 @@
         pass
     
     def do_help(self, arg):
-        self.base.usage()
+        msg = """
+    commands:  update, install, info, remove, list, clean, provides, search,
+    check-update, groupinstall, groupupdate, grouplist, groupinfo, groupremove,
+    makecache, localinstall, transaction, run, quit, exit
+    """
+        if arg in ['transaction', 'ts']:
+            msg = """
+    transaction arg
+      list: lists the contents of the transaction
+      reset: reset (zero-out) the transaction
+      solve: run the dependency solver on the transaction
+      run: run the transaction
+                  """
+
+        self.base.log(1, msg)
         
     def do_EOF(self, line):
         self.resultmsgs = ['Leaving Shell']
@@ -100,6 +114,42 @@
         else:
             self.do_help('transaction')
     
+    def do_enablerepo(self, line):
+        line = line.replace('\n', '')
+        repos = line.split()
+        for repo in repos:
+            try:
+                changed = self.base.repos.enableRepo(repo)
+            except yum.Errors.ConfigError, e:
+                self.base.errorlog(0, e)
+            else:
+                for repoid in changed:
+                    self.base.doRepoSetup(thisrepo=repoid)
+                
+                if hasattr(self.base, 'up'): # reset the updates
+                    del self.base.up
+
+
+    def do_disablerepo(self, line):
+        line = line.replace('\n', '')
+        repos = line.split()
+        for repo in repos:
+            try:
+                self.base.repos.disableRepo(repo)
+            except yum.Errors.ConfigError, e:
+                self.base.errorlog(0, e)
+
+            else:
+                if hasattr(self.base, 'pkgSack'): # kill the pkgSack
+                    del self.base.pkgSack
+                    self.base.repos._selectSackType()
+                if hasattr(self.base, 'up'): # reset the updates
+                    del self.base.up
+                # reset the transaction set and refresh everything
+                self.base.closeRpmDB() 
+                self.base.doTsSetup()
+                self.base.doRpmDBSetup()
+                
     def do_test(self, line):
         (cmd, args, line) = self.parseline(line)
         print cmd

Index: yummain.py
===================================================================
RCS file: /home/groups/yum/cvs/yum/yummain.py,v
retrieving revision 1.94
retrieving revision 1.95
diff -u -r1.94 -r1.95
--- yummain.py	4 Mar 2005 18:29:35 -0000	1.94
+++ yummain.py	27 Mar 2005 08:46:28 -0000	1.95
@@ -143,8 +143,7 @@
 
     base.log(2, '\nDependencies Resolved')
     base.log(3, time.time())
-    #run post-depresolve script here
-    #run  pre-trans script here
+
     # run the transaction
     try:
         base.doTransaction()
@@ -162,10 +161,6 @@
         unlock()
         sys.exit(1)
 
-    # run post-trans script here
-    # things ran correctly
-    # run a report function base.whatwedid() :)
-    
     base.log(2, 'Complete!')
     unlock()
     sys.exit(0)




More information about the Yum-cvs-commits mailing list