[yum-git] utils.py

Seth Vidal skvidal at linux.duke.edu
Thu Feb 21 03:53:22 UTC 2008


 utils.py |   15 +++++++++++++++
 1 file changed, 15 insertions(+)

New commits:
commit 097a3231f4c9831242310d046ba91fc9ab556949
Author: Seth Vidal <skvidal at fedoraproject.org>
Date:   Wed Feb 20 22:49:10 2008 -0500

    add a waitForLock to utils.py YumUtilsBase - let's a yum-util easily use the yum
    timing thing.

diff --git a/utils.py b/utils.py
index d132ba8..9f5f4a1 100644
--- a/utils.py
+++ b/utils.py
@@ -14,6 +14,7 @@
 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 
 import sys
+import time
 
 import yum
 from cli import *
@@ -32,6 +33,20 @@ class YumUtilBase(YumBaseCli):
         
     def getOptionParser(self):
         return self._parser        
+    
+    def waitForLock(self):
+        lockerr = ""
+        while True:
+            try:
+                self.doLock()
+            except yum.Errors.LockError, e:
+                if "%s" %(e.msg,) != lockerr:
+                    lockerr = "%s" %(e.msg,)
+                    self.logger.critical(lockerr)
+                self.logger.critical("Another app is currently holding the yum lock; waiting for it to exit...")  
+                time.sleep(2)
+            else:
+                break
         
     def _printUtilVersion(self):
         print "%s - %s (yum - %s)" % (self._utilName,self._utilVer,yum.__version__)



More information about the Yum-cvs-commits mailing list