print "Checking signatures of %d files from %d packages" % (len(files), len(tree.loadedpkgs))
sign = []
+n = c = 0
for file in files:
+ print "\r%d/%d %s\033[0K" % (n, c, file),
if not is_signed(file):
sign.append(file)
+ c += 1
+ n += 1
+
+print ""
if len(sign) == 0:
print "No files to sign"
sys.exit(0)
-print "Signing %d files" % len(sign)
+# http://mail.python.org/pipermail/python-list/2009-February/700658.html
+def chunk(seq, size, pad=None):
+ '''
+ Slice a list into consecutive disjoint 'chunks' of
+ length equal to size. The last chunk is padded if necessary.
+
+ >>> list(chunk(range(1,10),3))
+ [[1, 2, 3], [4, 5, 6], [7, 8, 9]]
+ >>> list(chunk(range(1,9),3))
+ [[1, 2, 3], [4, 5, 6], [7, 8, None]]
+ >>> list(chunk(range(1,8),3))
+ [[1, 2, 3], [4, 5, 6], [7, None, None]]
+ >>> list(chunk(range(1,10),1))
+ [[1], [2], [3], [4], [5], [6], [7], [8], [9]]
+ >>> list(chunk(range(1,10),9))
+ [[1, 2, 3, 4, 5, 6, 7, 8, 9]]
+ >>> for X in chunk([],3): print X
+ >>>
+ '''
+ n = len(seq)
+ mod = n % size
+ for i in xrange(0, n - mod, size):
+ yield seq[i : i + size]
+ if mod:
+ yield seq[-mod:]
+
+print "Total %d files to sign" % len(sign)
try:
- signpkgs(sign)
+ for x in chunk(sign, 512):
+ print "Signing %d files" % len(x)
+ signpkgs(x)
except OSError, e:
print >>sys.stderr, "ERR: %s" % e
exit(1)