[Reproducible-commits] [misc] 05/05: clean-notes: use a sane output, and a sane set of options (--enable/--disable)
Mattia Rizzolo
mapreri-guest at moszumanska.debian.org
Wed Jan 7 00:11:56 UTC 2015
This is an automated email from the git hooks/post-receive script.
mapreri-guest pushed a commit to branch master
in repository misc.
commit fbc16bc028ee41197e8191f21bb4f322bdab802f
Author: Mattia Rizzolo <mattia at mapreri.org>
Date: Wed Jan 7 01:08:27 2015 +0100
clean-notes: use a sane output, and a sane set of options (--enable/--disable)
---
clean-notes | 97 +++++++++++++++++++++++++++++++++++++++++++------------------
1 file changed, 68 insertions(+), 29 deletions(-)
diff --git a/clean-notes b/clean-notes
index 4f39ccf..b70ebc9 100755
--- a/clean-notes
+++ b/clean-notes
@@ -23,16 +23,43 @@ notes_yaml = 'packages.yml'
# {package_name: {version: 0.0.0, comments: "blablabla", bugs: [111, 222],
# issues: [issue1, issue2]}, {...}}
-parser = argparse.ArgumentParser(description = "housekeep the packages.yml file")
-group = parser.add_mutually_exclusive_group()
-group.add_argument("-v", "--verbose", action="store_true")
-group.add_argument("-q", "--quiet", action="store_true")
+description = """Houskeep the packages.yml file from the notes.git repository.
+
+This script is also able to show you other informations:
+* missing-version: list notes without version
+* fixed-magically: list notes which version is marked as reproducible by jenkins
+* new-tested-version: there is a new version tested in jenkins, but the package
+ is not reproducible anyway...
+* missing-usertagged: list usertagged bugs but not listed in the notes
+* not-usertagged: list bugs listed in notes but without usertags
+"""
+parser = argparse.ArgumentParser(description=description,
+ formatter_class=argparse.RawTextHelpFormatter)
+parser.add_argument('-e', '--enable', action='append', default=[],
+ help="enable a particular view (choose from above)")
+parser.add_argument('-d', '--disable', action='append', default=[],
+ help="enable a particular view (choose from above)")
+parser.add_argument("-v", "--verbose", action="store_true")
parser.add_argument("-n", "--dry-run", action="store_true")
-parser.add_argument("-d", "--db", action="store_true", help="do the UDD query and fill the notes")
args = parser.parse_args()
-def warning(*objs):
- print("WARNING: ", *objs, file=sys.stderr)
+disabled_features = [
+ 'fixed-magically',
+# 'missing-version',
+# 'missing-usertagged',
+ 'new-tested-version',
+# 'not-usertagged',
+ ]
+args.disable.extend(disabled_features)
+for feature in args.enable:
+ if feature in args.disable:
+ args.disable.remove(feature)
+
+if args.verbose:
+ print(args)
+
+def error(*objs):
+ print("ERROR: ", *objs, file=sys.stderr)
def start_udd_connection():
username = "public-udd-mirror"
@@ -41,12 +68,14 @@ def start_udd_connection():
port = 5432
db = "udd"
try:
+ if args.verbose:
+ print("Starting connection to the UDD database")
conn = psycopg2.connect("dbname=" + db +
" user=" + username +
" host=" + host +
" password=" + password)
except:
- warning("erorr connecting to the UDD database replica")
+ error("Erorr connecting to the UDD database replica")
raise
conn.set_client_encoding('utf8')
return conn
@@ -70,12 +99,18 @@ def load_notes():
notes = yaml.load(fd)
return notes
-def check_bugs(bugs):
+def check_bugs(notes):
"""
This function check whether all the bugs listed in notes.git are usertagged
-
- This `bugs` is a list of tuples: (package, bug_id)
"""
+ bugs = []
+ for pkg in sorted(notes, key=lambda x: str(x)):
+ if 'bugs' in notes[pkg]:
+ for bug in notes[pkg]['bugs']:
+ bugs.append((str(pkg), int(bug)))
+ if args.verbose:
+ print("looking throught bugs listed in the notes and check whether " +
+ "they are usertagged")
bugs_list = sorted([x[1] for x in bugs])
bugs_package = {x[1]: x[0] for x in bugs}
ids = 'id='
@@ -85,24 +120,26 @@ def check_bugs(bugs):
rows = query_udd("""SELECT id FROM bugs_usertags WHERE
email='reproducible-builds at lists.alioth.debian.org' AND (
%s )""" % ids)
- print(rows)
for bug in bugs_list:
if bug not in rows:
- warning("bug #" + str(bug) + " in package " + bugs_package[bug] +
+ print("bug #" + str(bug) + " in package " + bugs_package[bug] +
" is not usertagged")
def find_old_notes(testedpkgs, notes):
+ if args.verbose:
+ print("parsing the reproducible.json and the notes to find weirdness")
toremove = []
- listed_bugs = []
for pkg in sorted(notes, key=lambda x: str(x)):
- if 'version' not in notes[pkg]:
- warning("There is no version set for the package " + pkg)
+ if 'version' not in notes[pkg] and \
+ 'missing-version' not in args.disable:
+ print("There is no version set for the package " + pkg)
continue
for item in testedpkgs:
if item['package'] == pkg and \
item['version'] == notes[pkg]['version'] and \
- item['status'] == 'reproducible':
- warning("The package " + pkg + " has a note for the version "
+ item['status'] == 'reproducible'and \
+ 'fixed-magically' not in args.disable:
+ print("The package " + pkg + " has a note for the version "
+ item['version'] + " but that version is reproducible")
if item['package'] == pkg and \
item['status'] == 'reproducible' and \
@@ -113,13 +150,8 @@ def find_old_notes(testedpkgs, notes):
if item['package'] == pkg and \
apt_pkg.version_compare(str(item['version']),
str(notes[pkg]['version'])) > 0:
- if not args.quiet:
+ if 'new-tested-version' not in args.disable:
print("The package " + pkg + " has a new tested version")
- if 'bugs' in notes[pkg]:
- for bug in notes[pkg]['bugs']:
- listed_bugs.append((str(pkg), int(bug)))
- if args.db:
- check_bugs(listed_bugs)
return toremove
def is_virtual_package(package):
@@ -150,6 +182,8 @@ def parse_bugs(bugs):
The `bugs` argument is {bug_number: ["usertag1", "usertag2"]}
"""
+ if args.verbose:
+ print("find out if filed bugs are also noted in the notes")
packages = {}
ids = ''
bugs_list = sorted(bugs.keys())
@@ -179,18 +213,19 @@ def parse_bugs(bugs):
return packages
def join_notes_bugs(notes, bugs):
+ notify = ()
for package in bugs:
for bug in bugs[package]['bugs']:
try:
if 'bugs' in notes[package]:
if bug not in notes[package]['bugs']:
- warning("bug #" + str(bug) + " in package " +
+ print("bug #" + str(bug) + " in package " +
str(package) + " is not listed in notes.git.")
notes[package]['bugs'].append(bug)
else:
notes[package]['bugs'] = [bug]
except KeyError:
- warning("bug #" + str(bug) + " in package " + str(package) +
+ print("bug #" + str(bug) + " in package " + str(package) +
" is not listed in notes.git.")
notes[package] = {}
notes[package]['bugs'] = [bug]
@@ -211,7 +246,8 @@ def write_out(notes):
try:
out += (" version: " + str(values['version']) + "\n")
except KeyError:
- warning("There is no version set for the package " + pkg + ".")
+ if 'missing-version' not in args.disable:
+ print("There is no version set for the package " + pkg + ".")
if 'comments' in values:
out += (" comments: |\n")
for line in values['comments'].strip().split('\n'):
@@ -228,13 +264,16 @@ def write_out(notes):
fd.write(out.encode('utf-8'))
if __name__ == '__main__':
- if args.db:
+ if 'not-usertagged' not in args.disable or \
+ 'missing-usertagged' not in args.disable:
conn = start_udd_connection()
testedpkgs = load_reproducible_status()
notes = load_notes()
toremove = find_old_notes(testedpkgs, notes)
notes = cleanup_notes(notes, toremove)
- if args.db:
+ if 'not-usertagged' not in args.disable:
+ check_bugs(notes)
+ if 'missing-usertagged' not in args.disable:
bugs = get_bugs()
bugs = parse_bugs(bugs)
notes = join_notes_bugs(notes, bugs)
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/reproducible/misc.git
More information about the Reproducible-commits
mailing list