From 95843bd62ab0f3c2ca101429b2edd4cbe417558d Mon Sep 17 00:00:00 2001 From: =?utf8?q?Elan=20Ruusam=C3=A4e?= Date: Sun, 28 Jun 2009 17:43:00 +0000 Subject: [PATCH] - chunk the signing to 512 packages a time - print progress of sign files check Changed files: bin/pfa-signpkg -> 1.7 --- bin/pfa-signpkg | 38 ++++++++++++++++++++++++++++++++++++-- 1 file changed, 36 insertions(+), 2 deletions(-) diff --git a/bin/pfa-signpkg b/bin/pfa-signpkg index f4438cb..310a508 100644 --- a/bin/pfa-signpkg +++ b/bin/pfa-signpkg @@ -41,17 +41,51 @@ ftpio.unlock(sys.argv[1]) 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) -- 2.44.0