[Secure-testing-commits] r54706 - bin

Luciano Bello luciano at moszumanska.debian.org
Sat Aug 12 21:48:59 UTC 2017


Author: luciano
Date: 2017-08-12 21:48:59 +0000 (Sat, 12 Aug 2017)
New Revision: 54706

Added:
   bin/src2bin_text.py
Log:
script to include the list of binary packages in the DSA

Added: bin/src2bin_text.py
===================================================================
--- bin/src2bin_text.py	                        (rev 0)
+++ bin/src2bin_text.py	2017-08-12 21:48:59 UTC (rev 54706)
@@ -0,0 +1,69 @@
+#!/usr/bin/env python2
+
+import sys
+import os
+import fileinput
+
+ca_path = '/etc/ssl/ca-debian'
+if os.path.isdir(ca_path):
+    os.environ['SSL_CERT_DIR'] = ca_path
+
+default_url = 'https://packages.qa.debian.org/cgi-bin/soap-alpha.cgi'
+
+def soappy_query(url, method, **kwargs):
+    import SOAPpy
+
+    ws = SOAPpy.SOAPProxy(url)
+    return getattr(ws, method)(**kwargs)
+
+def joinEN(words):
+    if len(words) == 1: return words[0]
+    if len(words) == 2: return ' and '.join(words)
+    if len(words) >= 3: return ', '.join(words[:-1]+ ['and %s' % words[-1]])
+
+def filterPkg(bins,rms):
+    for rm in rms:
+        bins = filter(lambda x: not x.endswith('-%s' % rm), bins)
+    return bins
+    
+def getBin(srcPkg):
+    return [ i for i in soappy_query(default_url,'binary_names',source=srcPkg)]
+
+def word_wrap(string, width=80, ind1=0, ind2=0, prefix=''):
+    """ word wrapping function.
+        string: the string to wrap
+        width: the column number to wrap at
+        prefix: prefix each line with this string (goes before any indentation)
+        ind1: number of characters to indent the first line
+        ind2: number of characters to indent the rest of the lines
+    """
+    string = prefix + ind1 * " " + string
+    newstring = ""
+    while len(string) > width:
+        # find position of nearest whitespace char to the left of "width"
+        marker = width - 1
+        while not string[marker].isspace():
+            marker = marker - 1
+
+        # remove line from original string and add it to the new string
+        newline = string[0:marker] + "\n"
+        newstring = newstring + newline
+        string = prefix + ind2 * " " + string[marker + 1:]
+
+    return newstring + string
+
+def change(line, toRemove):
+    srcPkg = line[35:-11]
+    bins = filterPkg(getBin(srcPkg),toRemove)
+    return joinEN(bins)
+
+if __name__ == '__main__':
+    exclude = []
+    if '-x' in sys.argv:
+       i = sys.argv.index('-x')
+       exclude = sys.argv[i+1:]
+       sys.argv = sys.argv[:i]
+    for line in fileinput.input():
+       if 'We recommend that you upgrade your' in line:
+	 line = word_wrap("%s: %s.\n" % (line[:-2],change(line,exclude)),width=73)
+       print line,


Property changes on: bin/src2bin_text.py
___________________________________________________________________
Added: svn:executable
   + *




More information about the Secure-testing-commits mailing list