summaryrefslogtreecommitdiffstats
path: root/bin/src2bin_text.py
diff options
context:
space:
mode:
authorLuciano Bello <luciano@debian.org>2017-08-12 21:48:59 +0000
committerLuciano Bello <luciano@debian.org>2017-08-12 21:48:59 +0000
commit36a168ce33c24b48c5dc88ed90030954b7ca6753 (patch)
tree45d81c9d0a1f1a94d97d2c3b600567238f358147 /bin/src2bin_text.py
parent20fdd37246043a2c00b4c615675d77125641b68f (diff)
script to include the list of binary packages in the DSA
git-svn-id: svn+ssh://svn.debian.org/svn/secure-testing@54706 e39458fd-73e7-0310-bf30-c45bca0a0e42
Diffstat (limited to 'bin/src2bin_text.py')
-rwxr-xr-xbin/src2bin_text.py69
1 files changed, 69 insertions, 0 deletions
diff --git a/bin/src2bin_text.py b/bin/src2bin_text.py
new file mode 100755
index 0000000000..139666b6ad
--- /dev/null
+++ b/bin/src2bin_text.py
@@ -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,

© 2014-2024 Faster IT GmbH | imprint | privacy policy