pld-ftp-admin: scripts/sign.py - chunk the signing to 512 packages a time -...
glen
glen at pld-linux.org
Sun Jun 28 19:43:05 CEST 2009
Author: glen Date: Sun Jun 28 17:43:05 2009 GMT
Module: pld-ftp-admin Tag: HEAD
---- Log message:
- chunk the signing to 512 packages a time
- print progress of sign files check
---- Files affected:
pld-ftp-admin/scripts:
sign.py (1.6 -> 1.7)
---- Diffs:
================================================================
Index: pld-ftp-admin/scripts/sign.py
diff -u pld-ftp-admin/scripts/sign.py:1.6 pld-ftp-admin/scripts/sign.py:1.7
--- pld-ftp-admin/scripts/sign.py:1.6 Wed May 27 21:53:29 2009
+++ pld-ftp-admin/scripts/sign.py Sun Jun 28 19:43:00 2009
@@ -41,17 +41,51 @@
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)
================================================================
---- CVS-web:
http://cvs.pld-linux.org/cgi-bin/cvsweb.cgi/pld-ftp-admin/scripts/sign.py?r1=1.6&r2=1.7&f=u
More information about the pld-cvs-commit
mailing list