pld-ftp-admin: scripts/lintpkg.py - add show option
glen
glen at pld-linux.org
Sat Feb 12 19:30:37 CET 2011
Author: glen Date: Sat Feb 12 18:30:37 2011 GMT
Module: pld-ftp-admin Tag: HEAD
---- Log message:
- add show option
---- Files affected:
pld-ftp-admin/scripts:
lintpkg.py (1.7 -> 1.8)
---- Diffs:
================================================================
Index: pld-ftp-admin/scripts/lintpkg.py
diff -u pld-ftp-admin/scripts/lintpkg.py:1.7 pld-ftp-admin/scripts/lintpkg.py:1.8
--- pld-ftp-admin/scripts/lintpkg.py:1.7 Thu Feb 10 13:56:59 2011
+++ pld-ftp-admin/scripts/lintpkg.py Sat Feb 12 19:30:32 2011
@@ -10,16 +10,19 @@
import ftpio
try:
- opts, args = getopt.getopt(sys.argv[1:], 'q', [ "quiet" ])
+ opts, args = getopt.getopt(sys.argv[1:], 'qs', [ "quiet" ])
except getopt.GetoptError:
print >>sys.stderr, "ERR: options error"
print >>sys.stderr, "rpmlint.py tree package1 [package2...]"
sys.exit(1)
quiet = False
+show = False
for o, a in opts:
if o == "-q" or o == "--quiet":
quiet = True
+ if o == "-s":
+ show = True
if len(args) < 1:
print >>sys.stderr, "ERR: missing tree name"
@@ -46,6 +49,7 @@
# if no files specified, grab whole tree contents
tree = ftptree.FtpTree(treename, loadall = loadall)
+ tree.do_checkbuild = False
if loadall:
# this is hack, should be a param, not access private .loadedpkgs element
tree.mark4moving(tree.loadedpkgs)
@@ -77,22 +81,33 @@
(dirname, filename) = os.path.split(file)
return os.path.join(self.cachedir, filename+'.txt')
- """
- update stats from cachefile
- """
- def update_stats(self, file):
+ def get_stats(self, file):
cachefile = self.cachefile(file)
# show last line (that contains status)
l = (open(cachefile, 'r').readlines())[-1]
m = self.lintre.match(l)
if not m:
- return False
+ return None
- self.packages += int(m.group('packages'))
- self.specfiles += int(m.group('specfiles'))
- self.errors += int(m.group('errors'))
- self.warnings += int(m.group('warnings'))
+ return {
+ 'packages': int(m.group('packages')),
+ 'specfiles': int(m.group('specfiles')),
+ 'errors': int(m.group('errors')),
+ 'warnings': int(m.group('warnings')),
+ }
+
+ """
+ update stats from cachefile
+ """
+ def update_stats(self, file):
+ m = self.get_stats(file)
+ if not m:
+ return False
+ self.packages += m['packages']
+ self.specfiles += m['specfiles']
+ self.errors += m['errors']
+ self.warnings += m['warnings']
return True
def print_stats(self, file = None):
@@ -103,6 +118,15 @@
print "\r\033[0K%d packages and %d specfiles checked; %d errors, %d warnings." % (self.packages, self.specfiles, self.errors, self.warnings)
sys.stdout.flush()
+ def show_results(self, file):
+ m = self.get_stats(file)
+ if not m:
+ return False
+
+ cachefile = self.cachefile(file)
+ if m['errors'] > 0 or m['warnings'] > 0:
+ print "".join(open(cachefile, 'r').readlines())
+
def rpmlint(self, file):
cachefile = self.cachefile(file)
@@ -128,6 +152,8 @@
lint.rpmlint(file)
if not quiet:
lint.print_stats(file)
+ if show:
+ lint.show_results(file)
if not quiet:
lint.print_stats()
================================================================
---- CVS-web:
http://cvs.pld-linux.org/cgi-bin/cvsweb.cgi/pld-ftp-admin/scripts/lintpkg.py?r1=1.7&r2=1.8&f=u
More information about the pld-cvs-commit
mailing list