]> git.pld-linux.org Git - projects/pld-ftp-admin.git/commitdiff
- chunk the signing to 512 packages a time
authorElan Ruusamäe <glen@pld-linux.org>
Sun, 28 Jun 2009 17:43:00 +0000 (17:43 +0000)
committerElan Ruusamäe <glen@pld-linux.org>
Sun, 28 Jun 2009 17:43:00 +0000 (17:43 +0000)
- print progress of sign files check

Changed files:
    bin/pfa-signpkg -> 1.7

bin/pfa-signpkg

index f4438cb39c09a0caeb064936648c5adeb2277188..310a5087e90b0a2e4a7fc92daf08a2a188f8d368 100644 (file)
@@ -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)
This page took 0.060926 seconds and 4 git commands to generate.