From: Elan Ruusamäe Date: Sat, 12 Feb 2011 18:30:32 +0000 (+0000) Subject: - add show option X-Git-Url: https://git.pld-linux.org/?a=commitdiff_plain;h=413b382d22084d5ee36bf56544e743f24e4293d6;p=projects%2Fpld-ftp-admin.git - add show option Changed files: bin/pfa-lintpkg -> 1.8 --- diff --git a/bin/pfa-lintpkg b/bin/pfa-lintpkg index f0c0cdf..78bc704 100644 --- a/bin/pfa-lintpkg +++ b/bin/pfa-lintpkg @@ -10,16 +10,19 @@ from common import checkdir 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 @@ try: # 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 @@ class LintPkg: (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 @@ class LintPkg: 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 @@ for file in files: lint.rpmlint(file) if not quiet: lint.print_stats(file) + if show: + lint.show_results(file) if not quiet: lint.print_stats()