From 80b9ee1b7c4e4580628b753bd4c079290f43ad07 Mon Sep 17 00:00:00 2001
From: Stanislav Ochotnicky <sochotnicky@redhat.com>
Date: Mon, 11 Feb 2013 10:09:36 +0100
Subject: [PATCH 1/3] Rename find-failures so it can be later used as a module

---
 scripts/find-failures.py | 105 -----------------------------------------------
 scripts/find_failures.py | 105 +++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 105 insertions(+), 105 deletions(-)
 delete mode 100755 scripts/find-failures.py
 create mode 100755 scripts/find_failures.py

diff --git a/scripts/find-failures.py b/scripts/find-failures.py
deleted file mode 100755
index 8eaf8dc..0000000
--- a/scripts/find-failures.py
+++ /dev/null
@@ -1,105 +0,0 @@
-#!/usr/bin/python
-#
-# find-failures.py - A utility to discover failed builds in a given tag
-#                    Output is currently rough html
-#
-# Copyright (c) 2009 Red Hat
-#
-# Authors:
-#     Jesse Keating <jkeating@redhat.com>
-#
-
-import koji
-import os
-import operator
-import datetime
-
-# Set some variables
-# Some of these could arguably be passed in as args.
-buildtag = 'f18-rebuild' # tag to check
-desttag = 'f18' # Tag where fixed builds go
-targets = [desttag, buildtag, 'rawhide', 'f18-candidate']
-epoch = '2012-07-17 14:18:03.000000' # Date to check for failures from
-failures = {} # dict of owners to lists of packages that failed.
-failed = [] # raw list of failed packages
-failbuilds = [] # list of all the failed build tasks.
-
-# Create a koji session
-kojisession = koji.ClientSession('https://koji.fedoraproject.org/kojihub')
-
-# Get a list of failed build tasks since our epoch
-failtasks = sorted(kojisession.listBuilds(createdAfter=epoch, state=3),
-                   key=operator.itemgetter('task_id'))
-
-# Get a list of successful builds tagged
-goodbuilds = kojisession.listTagged(buildtag, latest=True)
-
-# Get a list of successful builds after the epoch in our dest tag
-destbuilds = kojisession.listTagged(desttag, latest=True, inherit=True)
-for build in destbuilds:
-    if build['creation_time'] > epoch:
-        goodbuilds.append(build)
-
-pkgs = kojisession.listPackages(desttag, inherited=True)
-
-# get the list of packages that are blocked
-pkgs = sorted([pkg for pkg in pkgs if pkg['blocked']],
-              key=operator.itemgetter('package_id'))
-
-# Check if newer build exists for package
-for build in failtasks:
-    if ((not build['package_id'] in [goodbuild['package_id'] for goodbuild in goodbuilds]) and (not build['package_id'] in [pkg['package_id'] for pkg in pkgs])):
-        failbuilds.append(build)
-        
-# Generate taskinfo for each failed build
-kojisession.multicall = True
-for build in failbuilds:
-    kojisession.getTaskInfo(build['task_id'], request=True)
-
-taskinfos = kojisession.multiCall()
-
-for build, [taskinfo] in zip(failbuilds, taskinfos):
-    build['taskinfo'] = taskinfo
-
-# Get owners of the packages with failures
-kojisession.multicall = True
-for build in failbuilds:
-    kojisession.listPackages(tagID=buildtag,
-                             pkgID=build['package_id'],
-                             inherited=True)
-
-pkginfo = kojisession.multiCall()
-for build, [pkg] in zip(failbuilds, pkginfo):
-    build['package_owner'] = pkg[0]['owner_name']
-
-# Generate the dict with the failures and urls
-for build in failbuilds:
-    if not build['taskinfo']['request'][1] == buildtag:
-        continue
-    taskurl = 'http://koji.fedoraproject.org/koji/taskinfo?taskID=%s' % build['task_id']
-    owner = build['package_owner']
-    pkg = build['package_name']
-    if not pkg in failed:
-        failed.append(pkg)
-    failures.setdefault(owner, {})[pkg] = taskurl
-
-now = datetime.datetime.now()
-now_str = "%s UTC" % str(now.utcnow())
-print '<html><head>'
-print '<title>Packages that failed to build as of %s</title>' % now_str
-print '<style type="text/css"> dt { margin-top: 1em } </style>'
-print '</head><body>'
-print "<p>Last run: %s</p>" % now_str
-        
-print '%s failed builds:<p>' % len(failed)
-
-# Print the results
-print '<dl>'
-print '<style type="text/css"> dt { margin-top: 1em } </style>'
-for owner in sorted(failures.keys()):
-    print '<dt>%s (%s):</dt>' % (owner, len(failures[owner]))
-    for pkg in sorted(failures[owner].keys()):
-        print '<dd><a href="%s">%s</a></dd>' % (failures[owner][pkg], pkg)
-print '</dl>'
-print '</body>'
-print '</html>'
diff --git a/scripts/find_failures.py b/scripts/find_failures.py
new file mode 100755
index 0000000..8eaf8dc
--- /dev/null
+++ b/scripts/find_failures.py
@@ -0,0 +1,105 @@
+#!/usr/bin/python
+#
+# find-failures.py - A utility to discover failed builds in a given tag
+#                    Output is currently rough html
+#
+# Copyright (c) 2009 Red Hat
+#
+# Authors:
+#     Jesse Keating <jkeating@redhat.com>
+#
+
+import koji
+import os
+import operator
+import datetime
+
+# Set some variables
+# Some of these could arguably be passed in as args.
+buildtag = 'f18-rebuild' # tag to check
+desttag = 'f18' # Tag where fixed builds go
+targets = [desttag, buildtag, 'rawhide', 'f18-candidate']
+epoch = '2012-07-17 14:18:03.000000' # Date to check for failures from
+failures = {} # dict of owners to lists of packages that failed.
+failed = [] # raw list of failed packages
+failbuilds = [] # list of all the failed build tasks.
+
+# Create a koji session
+kojisession = koji.ClientSession('https://koji.fedoraproject.org/kojihub')
+
+# Get a list of failed build tasks since our epoch
+failtasks = sorted(kojisession.listBuilds(createdAfter=epoch, state=3),
+                   key=operator.itemgetter('task_id'))
+
+# Get a list of successful builds tagged
+goodbuilds = kojisession.listTagged(buildtag, latest=True)
+
+# Get a list of successful builds after the epoch in our dest tag
+destbuilds = kojisession.listTagged(desttag, latest=True, inherit=True)
+for build in destbuilds:
+    if build['creation_time'] > epoch:
+        goodbuilds.append(build)
+
+pkgs = kojisession.listPackages(desttag, inherited=True)
+
+# get the list of packages that are blocked
+pkgs = sorted([pkg for pkg in pkgs if pkg['blocked']],
+              key=operator.itemgetter('package_id'))
+
+# Check if newer build exists for package
+for build in failtasks:
+    if ((not build['package_id'] in [goodbuild['package_id'] for goodbuild in goodbuilds]) and (not build['package_id'] in [pkg['package_id'] for pkg in pkgs])):
+        failbuilds.append(build)
+        
+# Generate taskinfo for each failed build
+kojisession.multicall = True
+for build in failbuilds:
+    kojisession.getTaskInfo(build['task_id'], request=True)
+
+taskinfos = kojisession.multiCall()
+
+for build, [taskinfo] in zip(failbuilds, taskinfos):
+    build['taskinfo'] = taskinfo
+
+# Get owners of the packages with failures
+kojisession.multicall = True
+for build in failbuilds:
+    kojisession.listPackages(tagID=buildtag,
+                             pkgID=build['package_id'],
+                             inherited=True)
+
+pkginfo = kojisession.multiCall()
+for build, [pkg] in zip(failbuilds, pkginfo):
+    build['package_owner'] = pkg[0]['owner_name']
+
+# Generate the dict with the failures and urls
+for build in failbuilds:
+    if not build['taskinfo']['request'][1] == buildtag:
+        continue
+    taskurl = 'http://koji.fedoraproject.org/koji/taskinfo?taskID=%s' % build['task_id']
+    owner = build['package_owner']
+    pkg = build['package_name']
+    if not pkg in failed:
+        failed.append(pkg)
+    failures.setdefault(owner, {})[pkg] = taskurl
+
+now = datetime.datetime.now()
+now_str = "%s UTC" % str(now.utcnow())
+print '<html><head>'
+print '<title>Packages that failed to build as of %s</title>' % now_str
+print '<style type="text/css"> dt { margin-top: 1em } </style>'
+print '</head><body>'
+print "<p>Last run: %s</p>" % now_str
+        
+print '%s failed builds:<p>' % len(failed)
+
+# Print the results
+print '<dl>'
+print '<style type="text/css"> dt { margin-top: 1em } </style>'
+for owner in sorted(failures.keys()):
+    print '<dt>%s (%s):</dt>' % (owner, len(failures[owner]))
+    for pkg in sorted(failures[owner].keys()):
+        print '<dd><a href="%s">%s</a></dd>' % (failures[owner][pkg], pkg)
+print '</dl>'
+print '</body>'
+print '</html>'
-- 
1.8.1

