pld-ftp-admin: bin/pfa-lintpkg - add -o outfile support
glen
glen at pld-linux.org
Thu Feb 17 09:31:47 CET 2011
Author: glen Date: Thu Feb 17 08:31:47 2011 GMT
Module: pld-ftp-admin Tag: HEAD
---- Log message:
- add -o outfile support
---- Files affected:
pld-ftp-admin/bin:
pfa-lintpkg (1.11 -> 1.12)
---- Diffs:
================================================================
Index: pld-ftp-admin/bin/pfa-lintpkg
diff -u pld-ftp-admin/bin/pfa-lintpkg:1.11 pld-ftp-admin/bin/pfa-lintpkg:1.12
--- pld-ftp-admin/bin/pfa-lintpkg:1.11 Sun Feb 13 13:03:52 2011
+++ pld-ftp-admin/bin/pfa-lintpkg Thu Feb 17 09:31:42 2011
@@ -10,7 +10,7 @@
import ftpio
try:
- opts, args = getopt.getopt(sys.argv[1:], 'qs', [ "quiet" ])
+ opts, args = getopt.getopt(sys.argv[1:], 'qso:', [ "quiet" ])
except getopt.GetoptError:
print >>sys.stderr, "ERR: options error"
print >>sys.stderr, "rpmlint.py tree package1 [package2...]"
@@ -18,11 +18,14 @@
quiet = False
show = False
+outstream = sys.stdout
for o, a in opts:
if o == "-q" or o == "--quiet":
quiet = True
if o == "-s":
show = True
+ if o == "-o":
+ outstream = open(a, 'w')
if len(args) < 1:
print >>sys.stderr, "ERR: missing tree name"
@@ -66,6 +69,8 @@
class LintPkg:
def __init__(self, cachedir):
+ self.outstream = sys.stdout
+
# for rpmlint stats
self.packages = self.specfiles = self.errors = self.warnings = 0
# 1 packages and 0 specfiles checked; 0 errors, 0 warnings.
@@ -115,13 +120,13 @@
def print_stats(self, file = None):
if file:
(dirname, filename) = os.path.split(file)
- print "\r\033[0K%d packages and %d specfiles checked; %d errors, %d warnings. [%s]" % (self.packages, self.specfiles, self.errors, self.warnings, filename),
+ print >>self.outstream, "\r\033[0K%d packages and %d specfiles checked; %d errors, %d warnings. [%s]" % (self.packages, self.specfiles, self.errors, self.warnings, filename),
else:
- print "\r\033[0K%d packages and %d specfiles checked; %d errors, %d warnings." % (self.packages, self.specfiles, self.errors, self.warnings)
+ print >>self.outstream, "\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 cat(self, file):
- print "".join(open(file, 'r').readlines())
+ print >>self.outstream, "".join(open(file, 'r').readlines())
def show_results(self, file):
m = self.get_stats(file)
@@ -130,9 +135,11 @@
cachefile = self.cachefile(file)
if not os.path.exists(cachefile):
- print "MISSING: report: %s" % file
+ print >>self.outsteram, "MISSING: report: %s" % file
if m['errors'] > 0 or m['warnings'] > 0:
+ (dirname, filename) = os.path.split(file)
+ print >>self.outstream, "rpmlint: %s" % filename
self.cat(cachefile)
def rpmlint(self, file):
@@ -162,8 +169,9 @@
sys.exit(1)
if not quiet:
- print "rpmlint of %d files from %d packages" % (len(files), len(tree.loadedpkgs))
+ print >>outstream, "rpmlint of %d files from %d packages" % (len(files), len(tree.loadedpkgs))
lint = LintPkg("~/tmp/rpmlint")
+ lint.outstream = outstream
for file in files:
lint.rpmlint(file)
if not quiet:
@@ -175,6 +183,6 @@
lint.print_stats()
ftpio.unlock(lock)
-except Exception:
+except (Exception, KeyboardInterrupt):
ftpio.unlock(lock)
raise
================================================================
---- CVS-web:
http://cvs.pld-linux.org/cgi-bin/cvsweb.cgi/pld-ftp-admin/bin/pfa-lintpkg?r1=1.11&r2=1.12&f=u
More information about the pld-cvs-commit
mailing list