2 # vi: encoding=utf-8 ts=8 sts=4 sw=4 et
6 sys.path.insert(0, os.environ['HOME']+'/pld-ftp-admin/modules')
8 from common import checkdir
12 print >>sys.stderr, "ERR: not enough parameters given"
13 print >>sys.stderr, "rpmlint.py tree package1 [package2...]"
18 ftpio.connect('rpmlint')
20 if not ftpio.lock(sys.argv[1], True):
21 print >>sys.stderr, "ERR: %s tree already locked" % sys.argv[1]
26 tree = ftptree.FtpTree(sys.argv[1])
27 tree.mark4moving(sys.argv[2:])
28 files = tree.rpmfiles(debugfiles = False, sourcefiles = False)
30 except ftptree.SomeError:
31 # In case of problems we need to unlock the tree before exiting
32 ftpio.unlock(sys.argv[1])
35 ftpio.unlock(sys.argv[1])
37 # http://mail.python.org/pipermail/python-list/2009-February/700658.html
38 def chunk(seq, size, pad=None):
40 Slice a list into consecutive disjoint 'chunks' of
41 length equal to size. The last chunk is padded if necessary.
43 >>> list(chunk(range(1,10),3))
44 [[1, 2, 3], [4, 5, 6], [7, 8, 9]]
45 >>> list(chunk(range(1,9),3))
46 [[1, 2, 3], [4, 5, 6], [7, 8, None]]
47 >>> list(chunk(range(1,8),3))
48 [[1, 2, 3], [4, 5, 6], [7, None, None]]
49 >>> list(chunk(range(1,10),1))
50 [[1], [2], [3], [4], [5], [6], [7], [8], [9]]
51 >>> list(chunk(range(1,10),9))
52 [[1, 2, 3, 4, 5, 6, 7, 8, 9]]
53 >>> for X in chunk([],3): print X
58 for i in xrange(0, n - mod, size):
59 yield seq[i : i + size]
65 cmd = ['/usr/bin/rpmlint'] + files
66 rc = subprocess.call(cmd, stdin = subprocess.PIPE, stdout = sys.stdout, stderr = sys.stderr, close_fds = True)
69 print "rpmlint of %d files from %d packages" % (len(files), len(tree.loadedpkgs))
70 for x in chunk(files, 512):
71 print "rpmlint %d files" % len(x)