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"
# 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)
(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):
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)
lint.rpmlint(file)
if not quiet:
lint.print_stats(file)
+ if show:
+ lint.show_results(file)
if not quiet:
lint.print_stats()