| Line | Revision | Contents |
| 1 | 18.1.45 | #!/usr/bin/python |
| 2 | 22.1.5 | # -*- coding: utf-8 -*- |
| 3 | 18.1.45 | # |
| 4 | 135 | # Copyright (C) 2007 Canonical Ltd., Daniel Holbach |
| 5 | # Copyright (C) 2008 Jonathan Patrick Davies <jpds@ubuntu.com> |
|
| 6 | # |
|
| 7 | # ################################################################## |
|
| 8 | # |
|
| 9 | # This program is free software; you can redistribute it and/or |
|
| 10 | # modify it under the terms of the GNU General Public License |
|
| 11 | # as published by the Free Software Foundation; version 3. |
|
| 12 | # |
|
| 13 | # This program is distributed in the hope that it will be useful, |
|
| 14 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
| 15 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
| 16 | # GNU General Public License for more details. |
|
| 17 | # |
|
| 18 | # See file /usr/share/common-licenses/GPL-3 for more details. |
|
| 19 | # |
|
| 20 | # ################################################################## |
|
| 21 | # |
|
| 22 | 125 | # |
| 23 | # hugdaylist - produces MoinMoin wiki formatted tables based on a Launchpad bug |
|
| 24 | # list. |
|
| 25 | 18.1.45 | # |
| 26 | # hugdaylist <url> |
|
| 27 | # - produces lists like https://wiki.ubuntu.com/UbuntuBugDay/20070912?action=raw |
|
| 28 | # |
|
| 29 | # hugdaylist -n <howmany> <url> |
|
| 30 | 125 | # - will only list <howmany> URLs. |
| 31 | 18.1.45 | |
| 32 | 125 | import os |
| 33 | 18.1.45 | import re |
| 34 | 125 | import string |
| 35 | 18.1.45 | import sys |
| 36 | 125 | from optparse import OptionParser |
| 37 | 18.1.45 | |
| 38 | 302 | from ubuntutools.lp.libsupport import get_launchpad, translate_web_api, translate_api_web |
| 39 | 18.1.45 | |
| 40 | def check_args(): |
|
| 41 | howmany = -1 |
|
| 42 | url = "" |
|
| 43 | 125 | |
| 44 | # Our usage options. |
|
| 45 | usage = "usage: %prog [-n <number>] launchpad-buglist-url" |
|
| 46 | optParser = OptionParser(usage) |
|
| 47 | 132 | argsParsed = 0 |
| 48 | 125 | |
| 49 | # Options - namely just the number of bugs to output. |
|
| 50 | 161 | optParser.add_option("-n", "--number", type = "int", |
| 51 | 125 | dest = "number", help = "Number of entries to output.") |
| 52 | ||
| 53 | # Parse arguments. |
|
| 54 | (options, args) = optParser.parse_args() |
|
| 55 | |
|
| 56 | # Check if we want a number other than the default. |
|
| 57 | 161 | howmany = options.number |
| 58 | 125 | |
| 59 | # Check that we have an URL. |
|
| 60 | if not args: |
|
| 61 | print >> sys.stderr, "An URL pointing to a Launchpad bug list is " \ |
|
| 62 | "required." |
|
| 63 | optParser.print_help() |
|
| 64 | sys.exit(1) |
|
| 65 | 18.1.45 | else: |
| 66 | 132 | url = args[argsParsed] |
| 67 | 125 | |
| 68 | 18.1.45 | return (howmany, url) |
| 69 | ||
| 70 | 248.1.7 | def filter_unsolved(task): |
| 71 | # TODO: don't use this filter here, only check status and assignee of |
|
| 72 | # the given task |
|
| 73 | 125 | # Filter out special types of bugs: |
| 74 | # - https://wiki.ubuntu.com/Bugs/HowToTriage#Special%20types%20of%20bugs |
|
| 75 | 248.1.7 | subscriptions = set(s.person.name for s in task.bug.subscriptions) #this is expensive, parse name out of self_link instead? |
| 76 | if (task.status != "Fix Committed" and |
|
| 77 | (not task.assignee or task.assignee.name in ['motu','desktop-bugs']) and |
|
| 78 | 'ubuntu-main-sponsors' not in subscriptions and |
|
| 79 | 'ubuntu-universe-sponsors' not in subscriptions and |
|
| 80 | 'ubuntu-archive' not in subscriptions): |
|
| 81 | return True |
|
| 82 | return False |
|
| 83 | 18.1.52 | |
| 84 | 18.1.45 | def main(): |
| 85 | (howmany, url) = check_args() |
|
| 86 | 248.1.4 | if len(url.split("?", 1)) == 2: |
| 87 | # search options not supported, because there is no mapping web ui options <-> API options |
|
| 88 | print >> sys.stderr, "Options in url are not supported, url: %s" %url |
|
| 89 | sys.exit(1) |
|
| 90 | |
|
| 91 | 523 | launchpad = None |
| 92 | try: |
|
| 93 | launchpad = get_launchpad("ubuntu-dev-tools") |
|
| 94 | except IOError, e: |
|
| 95 | print e |
|
| 96 | sys.exit(1) |
|
| 97 | |
|
| 98 | 248.1.4 | api_url = translate_web_api(url, launchpad) |
| 99 | 132 | try: |
| 100 | 248.1.4 | product = launchpad.load(api_url) |
| 101 | except Exception, e: |
|
| 102 | x = getattr(e, "response", {}) |
|
| 103 | if response.get("status", None) == "404": |
|
| 104 | print >> sys.stderr, "The URL at '%s' does not appear to be a valid url to a product" %url |
|
| 105 | sys.exit(1) |
|
| 106 | else: |
|
| 107 | raise |
|
| 108 | |
|
| 109 | bl = product.searchTasks() |
|
| 110 | 132 | |
| 111 | 44 | l = filter(filter_unsolved, bl) |
| 112 | 18.1.45 | |
| 113 | 44 | if not l: |
| 114 | 248 | print "Bug list of %s is empty." % url |
| 115 | 18.1.45 | sys.exit(0) |
| 116 | if howmany == -1: |
|
| 117 | 44 | howmany = len(l) |
| 118 | ||
| 119 | print """ |
|
| 120 | ## ||<rowbgcolor="#CCFFCC"> This task is done || somebody || || |
|
| 121 | ## ||<rowbgcolor="#FFFFCC"> This task is assigned || somebody || <status> || |
|
| 122 | ## ||<rowbgcolor="#FFEBBB"> This task isn't || ... || || |
|
| 123 | ## ||<rowbgcolor="#FFCCCC"> This task is blocked on something || somebody || <explanation> || |
|
| 124 | 18.1.45 | |
| 125 | 44 | || Bug || Subject || Triager ||""" |
| 126 | 18.1.45 | |
| 127 | 44 | for i in list(l)[:howmany]: |
| 128 | 248.1.7 | bug = i.bug |
| 129 | 44 | print '||<rowbgcolor="#FFEBBB"> [%s %s] || %s || ||' % \ |
| 130 | 248.1.7 | (translate_api_web(bug.self_link), bug.id, bug.title) |
| 131 | 18.1.45 | |
| 132 | ||
| 133 | if __name__ == '__main__': |
|
| 134 | 124 | try: |
| 135 | 248.1.7 | main() |
| 136 | 124 | except KeyboardInterrupt: |
| 137 | 125 | print >> sys.stderr, "Aborted." |
| 138 | 124 | sys.exit(1) |
Loggerhead 1.10 is a web-based interface for Bazaar branches