[yum-git] 2 commits - Makefile test/yum-utils-pylintrc yum-complete-transaction.py yum-debug-dump.py

Tim Lauridsen timlau at linux.duke.edu
Wed Sep 24 10:14:10 UTC 2008


 Makefile                    |    2 
 test/yum-utils-pylintrc     |   21 ++++----
 yum-complete-transaction.py |  109 +++++++++++++++++++++-----------------------
 yum-debug-dump.py           |   37 ++++++++------
 4 files changed, 87 insertions(+), 82 deletions(-)

New commits:
commit 20bd67b504c893c6a953a229f2f040683add806c
Author: Tim Lauridsen <timlau at fedoraproject.org>
Date:   Wed Sep 24 12:13:50 2008 +0200

    add yum-debug-dump to pylint check and cleaned up the problems

diff --git a/Makefile b/Makefile
index 8d3ad5c..c66c36b 100644
--- a/Makefile
+++ b/Makefile
@@ -82,7 +82,7 @@ ChangeLog: FORCE
 	@git log --pretty --numstat --summary | ./tools/git2cl > ChangeLog
 
 pylint:
-	@pylint --rcfile=test/yum-utils-pylintrc yumdownloader.py yum-complete-transaction.py
+	@pylint --rcfile=test/yum-utils-pylintrc yumdownloader.py yum-complete-transaction.py yum-debug-dump.py
 	
 	
 FORCE:	
diff --git a/test/yum-utils-pylintrc b/test/yum-utils-pylintrc
index 3b947d2..5b78a76 100644
--- a/test/yum-utils-pylintrc
+++ b/test/yum-utils-pylintrc
@@ -53,16 +53,17 @@ load-plugins=
 #enable-msg=
 
 # Disable the message(s) with the given id(s).
-# W0401: *Wildcard import %s*
-# C0324: *Comma not followed by a space*
+# W0401: *Wildcard import %s* 
+# C0324: *Comma not followed by a space* 
 # C0301: *Line too long (%s/%s)*
-# C0111: *Missing docstring*
+# C0111: *Missing docstring* (to bad, but off for now)
 # E1101: *%s %r has no %r member* (The init-hook for do sys.path manipulation don't, so we cant find the utils module)
 # F0401: *Unable to import %r (%s)* (See above)
-# R0201: *Method could be a function*
-# W0704: *Except doesn't do anything*
-# W0612: *Unused variable %r*
-disable-msg=W0401,C0324,C0301,C0111,E1101,F0401,R0201,W0704,W0612
+# R0201: *Method could be a function* (dont care is self is used inside a function)
+# W0704: *Except doesn't do anything* ( Except xxxxxx,e : pass is ok)
+# W0612: *Unused variable %r* ( dont care if x,y,z = f() and y,z is not used) 
+# W0212: *Access to a protected member %s of a client class*  (if sucks, but we do that a lot)
+disable-msg=W0401,C0324,C0301,C0111,E1101,F0401,R0201,W0704,W0612,W0212
 
 
 [REPORTS]
@@ -138,7 +139,7 @@ method-rgx=[a-z_][a-z0-9_A-Z]{2,30}$
 attr-rgx=[a-z_][a-z0-9_A-Z]{2,30}$
 
 # Regular expression which should only match correct argument names
-argument-rgx=[a-z_][a-z0-9_A-Z]{2,30}$
+argument-rgx=[a-z_][a-z0-9_A-Z]{1,30}$
 
 # Regular expression which should only match correct variable names
 variable-rgx=[a-z_][a-z0-9_A-Z]{1,30}$
@@ -270,7 +271,7 @@ max-attributes=7
 min-public-methods=2
 
 # Maximum number of public methods for a class (see R0904).
-max-public-methods=20
+max-public-methods=100
 
 
 # checks for :
diff --git a/yum-debug-dump.py b/yum-debug-dump.py
index d63257c..c278e93 100644
--- a/yum-debug-dump.py
+++ b/yum-debug-dump.py
@@ -32,6 +32,8 @@ class YumDebugDump(yum.YumBase):
     def __init__(self):
         self.file_version = '1'
         yum.YumBase.__init__(self)
+        self.opts = None
+        self.args = None
         self.parse_args()
 
     def parse_args(self):
@@ -83,7 +85,7 @@ class YumDebugDump(yum.YumBase):
         pkgs = {}
         for po in self.rpmdb.returnPackages():
             tup = po.pkgtup
-            header= po.hdr
+            header = po.hdr
             requires = zip(
                 header[rpm.RPMTAG_REQUIRENAME],
                 header[rpm.RPMTAG_REQUIREFLAGS],
@@ -101,7 +103,8 @@ class YumDebugDump(yum.YumBase):
                 if ver == '':
                     ver = None
                 rflags = flags & 15
-                if req.startswith('rpmlib'): continue # ignore rpmlib deps
+                if req.startswith('rpmlib'): 
+                    continue # ignore rpmlib deps
 
                 if not providers.has_key((req,rflags,ver)):
                     resolve_sack = self.rpmdb.whatProvides(req,rflags,ver)
commit 7f3d8b0e2bfb3fee9997b3a9b10547e2493c01a9
Author: Tim Lauridsen <timlau at fedoraproject.org>
Date:   Wed Sep 24 12:01:39 2008 +0200

    add yum-complete-transaction to pylint check and cleaned up the problems

diff --git a/Makefile b/Makefile
index 66a70da..8d3ad5c 100644
--- a/Makefile
+++ b/Makefile
@@ -82,7 +82,7 @@ ChangeLog: FORCE
 	@git log --pretty --numstat --summary | ./tools/git2cl > ChangeLog
 
 pylint:
-	@pylint --rcfile=test/yum-utils-pylintrc yumdownloader.py
+	@pylint --rcfile=test/yum-utils-pylintrc yumdownloader.py yum-complete-transaction.py
 	
 	
 FORCE:	
diff --git a/test/yum-utils-pylintrc b/test/yum-utils-pylintrc
index a108fa3..3b947d2 100644
--- a/test/yum-utils-pylintrc
+++ b/test/yum-utils-pylintrc
@@ -60,7 +60,9 @@ load-plugins=
 # E1101: *%s %r has no %r member* (The init-hook for do sys.path manipulation don't, so we cant find the utils module)
 # F0401: *Unable to import %r (%s)* (See above)
 # R0201: *Method could be a function*
-disable-msg=W0401,C0324,C0301,C0111,E1101,F0401,R0201
+# W0704: *Except doesn't do anything*
+# W0612: *Unused variable %r*
+disable-msg=W0401,C0324,C0301,C0111,E1101,F0401,R0201,W0704,W0612
 
 
 [REPORTS]
@@ -118,7 +120,7 @@ required-attributes=
 no-docstring-rgx=__.*__
 
 # Regular expression which should only match correct module names
-module-rgx=(([a-z_][a-z0-9_]*)|([A-Z][a-zA-Z0-9]+))$
+module-rgx=(([a-z_][a-z0-9_\-]*)|([A-Z][a-zA-Z0-9]+))$
 
 # Regular expression which should only match correct module level names
 const-rgx=(([A-Z_a-z][A-Z1-9_a-z]*)|(__.*__))$
@@ -146,7 +148,7 @@ variable-rgx=[a-z_][a-z0-9_A-Z]{1,30}$
 inlinevar-rgx=[A-Za-z_][A-Za-z0-9_]*$
 
 # Good variable names which should always be accepted, separated by a comma
-good-names=i,j,k,ex,Run,_,n,e,r,v,a,po
+good-names=i,j,k,ex,Run,_,n,e,r,v,a,po,f,m,u
 
 # Bad variable names which should always be refused, separated by a comma
 bad-names=foo,bar,baz,toto,tutu,tata
diff --git a/yum-complete-transaction.py b/yum-complete-transaction.py
index 13a5d6e..7bb7c5d 100755
--- a/yum-complete-transaction.py
+++ b/yum-complete-transaction.py
@@ -18,32 +18,31 @@ import sys
 sys.path.insert(0,'/usr/share/yum-cli')
 
 import yum
-from yum.misc import getCacheDir, setup_locale
+from yum.misc import setup_locale
 
 from cli import *
 from utils import YumUtilBase
 
-from urlparse import urljoin
-from urlgrabber.progress import TextMeter
+import logging
 
 
 try:
-   from yum.misc import find_unfinished_transactions, find_ts_remaining
+    from yum.misc import find_unfinished_transactions, find_ts_remaining
 except ImportError:
 
     import glob
     import os
     import os.path
-        
+
     def find_unfinished_transactions(yumlibpath='/var/lib/yum'):
-        """returns a list of the timestamps from the filenames of the unfinished 
+        """returns a list of the timestamps from the filenames of the unfinished
            transactions remaining in the yumlibpath specified.
         """
-        timestamps = []    
+        timestamps = []
         tsallg = '%s/%s' % (yumlibpath, 'transaction-all*')
-        tsdoneg = '%s/%s' % (yumlibpath, 'transaction-done*')
+        #tsdoneg = '%s/%s' % (yumlibpath, 'transaction-done*') # not used remove ?
         tsalls = glob.glob(tsallg)
-        tsdones = glob.glob(tsdoneg)
+        #tsdones = glob.glob(tsdoneg) # not used remove ?
 
         for fn in tsalls:
             trans = os.path.basename(fn)
@@ -52,86 +51,86 @@ except ImportError:
 
         timestamps.sort()
         return timestamps
-        
+
     def find_ts_remaining(timestamp, yumlibpath='/var/lib/yum'):
-        """this function takes the timestamp of the transaction to look at and 
+        """this function takes the timestamp of the transaction to look at and
            the path to the yum lib dir (defaults to /var/lib/yum)
            returns a list of tuples(action, pkgspec) for the unfinished transaction
            elements. Returns an empty list if none.
 
         """
-        
+
         to_complete_items = []
-        tsallpath = '%s/%s.%s' % (yumlibpath, 'transaction-all', timestamp)    
+        tsallpath = '%s/%s.%s' % (yumlibpath, 'transaction-all', timestamp)
         tsdonepath = '%s/%s.%s' % (yumlibpath,'transaction-done', timestamp)
         tsdone_items = []
 
         if not os.path.exists(tsallpath):
             # something is wrong, here, probably need to raise _something_
-            return to_complete_items    
+            return to_complete_items
+
 
-                
         if os.path.exists(tsdonepath):
             tsdone_fo = open(tsdonepath, 'r')
             tsdone_items = tsdone_fo.readlines()
-            tsdone_fo.close()     
-        
+            tsdone_fo.close()
+
         tsall_fo = open(tsallpath, 'r')
         tsall_items = tsall_fo.readlines()
         tsall_fo.close()
-        
+
         for item in tsdone_items:
             # this probably shouldn't happen but it's worth catching anyway
             if item not in tsall_items:
-                continue        
+                continue
             tsall_items.remove(item)
-            
+
         for item in tsall_items:
             item = item.replace('\n', '')
             if item == '':
                 continue
             (action, pkgspec) = item.split()
             to_complete_items.append((action, pkgspec))
-        
+
         return to_complete_items
 
 class YumCompleteTransaction(YumUtilBase):
     NAME = 'yum-complete-transactions'
     VERSION = '1.0'
     USAGE = """
-    yum-complete-transaction: completes unfinished yum transactions which occur due to error, failure 
+    yum-complete-transaction: completes unfinished yum transactions which occur due to error, failure
                               or act of $deity
-    
+
     usage: yum-complete-transaction
     """
-    
+
     def __init__(self):
         YumUtilBase.__init__(self,
                              YumCompleteTransaction.NAME,
                              YumCompleteTransaction.VERSION,
                              YumCompleteTransaction.USAGE)
-        self.logger = logging.getLogger("yum.verbose.cli.yumcompletets")                             
-        self.optparser = self.getOptionParser()         
+        self.logger = logging.getLogger("yum.verbose.cli.yumcompletets")
+        self.optparser = self.getOptionParser()
         self.addCmdOptions()
         self.main()
 
     def clean_up_ts_files(self, timestamp, path):
-    
-        # clean up the transactions 
+
+        # clean up the transactions
         tsdone = '%s/transaction-done.%s' % (path, timestamp)
-        tsall = '%s/transaction-all.%s' % (path, timestamp)        
+        tsall = '%s/transaction-all.%s' % (path, timestamp)
         for f in [tsall, tsdone]:
             if os.path.exists(f):
                 os.unlink(f)
 
     def addCmdOptions(self):
-        self.optparser.add_option("--cleanup-only", default=False, 
+        self.optparser.add_option("--cleanup-only", default=False,
             action="store_true", dest="cleanup",
             help='Do not complete the transaction just clean up transaction journals')
 
     def main(self):
         # Add util commandline options to the yum-cli ones
-        self.optparser = self.getOptionParser() 
+        self.optparser = self.getOptionParser()
         # Parse the commandline option and setup the basics.
         try:
             opts = self.doUtilConfigSetup()
@@ -144,7 +143,7 @@ class YumCompleteTransaction(YumUtilBase):
             self.logger.error("Error: You must be root to run yum-complete-transaction.")
             sys.exit(1)
 
-               
+
         # Setup yum (Ts, RPM db, Repo & Sack)
         self.doUtilYumSetup()
         # Do the real action
@@ -155,7 +154,7 @@ class YumCompleteTransaction(YumUtilBase):
         # run it
         times = find_unfinished_transactions(self.conf.persistdir)
         if not times:
-            print "No unfinished transactions left."      
+            print "No unfinished transactions left."
             sys.exit()
 
         if opts.cleanup:
@@ -165,49 +164,49 @@ class YumCompleteTransaction(YumUtilBase):
                 print "Cleaning up %s" % timestamp
                 self.clean_up_ts_files(timestamp, self.conf.persistdir)
             sys.exit()
-        
-        print "There are %d outstanding transactions to complete. Finishing the most recent one" % len(times)    
-        
+
+        print "There are %d outstanding transactions to complete. Finishing the most recent one" % len(times)
+
         timestamp = times[-1]
         remaining = find_ts_remaining(timestamp, yumlibpath=self.conf.persistdir)
         print "The remaining transaction had %d elements left to run" % len(remaining)
         for (action, pkgspec) in remaining:
             if action == 'install':
-               try:
-                   self.install(pattern=pkgspec)
-               except yum.Errors.InstallError, e:
-                   pass
+                try:
+                    self.install(pattern=pkgspec)
+                except yum.Errors.InstallError, e:
+                    pass
 
             if action == 'erase':
-               (e, m, u) = self.rpmdb.matchPackageNames([pkgspec])
-               for pkg in e:
-                   self.remove(po=pkg)
-                   
-                  
+                (e, m, u) = self.rpmdb.matchPackageNames([pkgspec])
+                for pkg in e:
+                    self.remove(po=pkg)
+
+
 
         self.buildTransaction()
         if len(self.tsInfo) < 1:
             print 'Nothing in the unfinished transaction to cleanup.'
-            print "Cleaning up completed transaction file"            
+            print "Cleaning up completed transaction file"
             self.clean_up_ts_files(timestamp, self.conf.persistdir)
             sys.exit()
-            
-        else:            
+
+        else:
             if self.doTransaction() == 0:
-                print "Cleaning up completed transaction file"            
+                print "Cleaning up completed transaction file"
                 self.clean_up_ts_files(timestamp, self.conf.persistdir)
                 sys.exit()
             else:
                 print "Not removing old transaction files"
                 sys.exit()
-                             
 
 
-        
-        
-    
+
+
+
+
 if __name__ == '__main__':
     setup_locale()
     util = YumCompleteTransaction()
-        
-       
+
+
diff --git a/yum-debug-dump.py b/yum-debug-dump.py
index ec7c3c9..d63257c 100644
--- a/yum-debug-dump.py
+++ b/yum-debug-dump.py
@@ -30,10 +30,10 @@ from optparse import OptionParser
 class YumDebugDump(yum.YumBase):
 
     def __init__(self):
-        self.file_version = '1'      
+        self.file_version = '1'
         yum.YumBase.__init__(self)
         self.parse_args()
-    
+
     def parse_args(self):
         parser = OptionParser()
         parser.set_usage("yum-debug-dump [options]")
@@ -45,7 +45,7 @@ class YumDebugDump(yum.YumBase):
         msg = "%%%%RPMDB\n"
         for po in self.rpmdb:
             msg += '  %s:%s-%s-%s.%s\n' % (po.epoch, po.name, po.ver,po.rel, po.arch)
-        
+
         return msg
 
     def dump_repos(self):
@@ -67,17 +67,17 @@ class YumDebugDump(yum.YumBase):
         msg += "  rpm ver: %s\n" % subprocess.Popen(["rpm", "--version"], stdout=subprocess.PIPE).communicate()[0].strip()
         msg += "  python ver: %s\n" % sys.version.replace('\n', '')
         return msg
-        
+
     def dump_yum_config_info(self):
         msg = "%%%%YUM INFO\n"
         msg += "  arch: %s\n" % self.conf.yumvar['arch']
-        msg += "  basearch: %s\n" % self.conf.yumvar['basearch']        
+        msg += "  basearch: %s\n" % self.conf.yumvar['basearch']
         msg += "  releasever: %s\n" % self.conf.yumvar['releasever']
         msg += "  yum ver: %s\n" % yum.__version__
         msg += "  enabled plugins: %s\n" % ",".join(self.plugins._plugins.keys())
         msg += "  global excludes: %s\n" % ",".join(self.conf.exclude)
         return msg
-    
+
     def dump_rpm_problems(self):
 
         pkgs = {}
@@ -93,7 +93,7 @@ class YumDebugDump(yum.YumBase):
 
 
         errors = []
-        providers = {} # To speed depsolving, don't recheck deps that have 
+        providers = {} # To speed depsolving, don't recheck deps that have
                        # already been checked
         provsomething = {}
         for (pkg,reqs) in pkgs.items():
@@ -102,12 +102,12 @@ class YumDebugDump(yum.YumBase):
                     ver = None
                 rflags = flags & 15
                 if req.startswith('rpmlib'): continue # ignore rpmlib deps
-                
+
                 if not providers.has_key((req,rflags,ver)):
                     resolve_sack = self.rpmdb.whatProvides(req,rflags,ver)
                 else:
                     resolve_sack = providers[(req,rflags,ver)]
-                    
+
                 if len(resolve_sack) < 1:
                     errors.append("Package %s requires %s" % (pkg[0],
                       miscutils.formatRequire(req,ver,rflags)))
@@ -130,18 +130,18 @@ class YumDebugDump(yum.YumBase):
         return msg
 
 
-    
+
     def create_debug_file(self, fn=None):
         """create debug txt file and compress it, place it at yum_debug_dump.txt.gz
            unless fn is specified"""
         if not fn:
             fn = 'yum_debug_dump.txt.gz'
-        
+
         if not fn.startswith('/'):
             fn = '%s/%s' % (os.getcwd(), fn)
-        
+
         fo = gzip.GzipFile(fn, 'w')
-        
+
         msg = "yum-debug-dump version %s\n" % self.file_version
         fo.write(msg)
         fo.write(self.dump_system_info())
@@ -152,12 +152,12 @@ class YumDebugDump(yum.YumBase):
             fo.write(self.dump_repos())
         fo.close()
         return fn
-        
+
 def main():
     my = YumDebugDump()
     fn = my.create_debug_file()
     print "Output written to: %s" % fn
-    
+
 if __name__ == "__main__":
     main()
 



More information about the Yum-cvs-commits mailing list