Merge lp:~jpds/ubuntu-bots/bugs-via-launchpad-api into lp:~tsimpson/ubuntu-bots/tweak

Proposed by Jonathan Davies
Status: Rejected
Rejected by: Terence Simpson
Proposed branch: lp:~jpds/ubuntu-bots/bugs-via-launchpad-api
Merge into: lp:~tsimpson/ubuntu-bots/tweak
Diff against target: 164 lines (+63/-62)
1 file modified
Bugtracker/plugin.py (+63/-62)
To merge this branch: bzr merge lp:~jpds/ubuntu-bots/bugs-via-launchpad-api
Reviewer Review Type Date Requested Status
Terence Simpson belated Disapprove
Review via email: mp+17957@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Jonathan Davies (jpds) wrote :

Added Launchpad API support to Bugtracker.

155. By Jonathan Davies

Removed old Launchpad bug snarfing code.

156. By Jonathan Davies

Removed debug code.

157. By Jonathan Davies

Allow reading data from bug 1 on Launchpad (this is cached).

158. By Jonathan Davies

Read task data of a bug from the last task.

159. By Jonathan Davies

Really catch private bugs.

160. By Jonathan Davies

Catch bugs with more than one task and report the number of tasks.

161. By Jonathan Davies

Improved wording of more projects reply.

162. By Jonathan Davies

Display how many users a bug affects.

163. By Jonathan Davies

Report how many duplicates a bug report has.

164. By Jonathan Davies

Added a : here.

165. By Jonathan Davies

Bugtracker/plugin.py: Don't import commands - not used.

166. By Jonathan Davies

Fall back to auth'ed API login if login_anonymously is not available.

167. By Jonathan Davies

Catch AttributeError instead.

168. By Jonathan Davies

Display bug heat stuff.

Revision history for this message
Terence Simpson (tsimpson) wrote :

I'm marking as rejected only because the original feature is now already implemented and so there's no need to attempt a merge.

review: Disapprove (belated)

Unmerged revisions

168. By Jonathan Davies

Display bug heat stuff.

167. By Jonathan Davies

Catch AttributeError instead.

166. By Jonathan Davies

Fall back to auth'ed API login if login_anonymously is not available.

165. By Jonathan Davies

Bugtracker/plugin.py: Don't import commands - not used.

164. By Jonathan Davies

Added a : here.

163. By Jonathan Davies

Report how many duplicates a bug report has.

162. By Jonathan Davies

Display how many users a bug affects.

161. By Jonathan Davies

Improved wording of more projects reply.

160. By Jonathan Davies

Catch bugs with more than one task and report the number of tasks.

159. By Jonathan Davies

Really catch private bugs.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'Bugtracker/plugin.py'
--- Bugtracker/plugin.py 2009-11-30 19:04:54 +0000
+++ Bugtracker/plugin.py 2010-03-30 21:47:24 +0000
@@ -1,5 +1,6 @@
1###1###
2# Copyright (c) 2005-2007 Dennis Kaarsemaker2# Copyright (c) 2005-2007 Dennis Kaarsemaker
3# Copyright (C) 2010 Jonathan Davies
3#4#
4# This program is free software; you can redistribute it and/or modify5# This program is free software; you can redistribute it and/or modify
5# it under the terms of version 2 of the GNU General Public License as6# it under the terms of version 2 of the GNU General Public License as
@@ -21,12 +22,23 @@
21import supybot.registry as registry22import supybot.registry as registry
22import supybot.schedule as schedule23import supybot.schedule as schedule
2324
24import re, os, time, imaplib, commands25import re, os, time, imaplib
25import xml.dom.minidom as minidom26import xml.dom.minidom as minidom
26from htmlentitydefs import entitydefs as entities27from htmlentitydefs import entitydefs as entities
27import email.FeedParser28import email.FeedParser
28import SOAPpy29import SOAPpy
2930
31# Launchpad bindings.
32from launchpadlib.launchpad import Launchpad
33cachedir = os.path.expanduser("~/.launchpadlib/cache/")
34
35try:
36 launchpad = Launchpad.login_anonymously('Supybot: Bugtracker plugin', 'edge',
37 cachedir)
38except AttributeError:
39 launchpad = Launchpad.login_with('Supybot: Bugtracker plugin', 'edge',
40 cachedir)
41
30bad_words = ["fuck","fuk","fucking","fuking","fukin","fuckin","fucked","fuked","fucker","shit","cunt","bastard","nazi","nigger","nigga","cock","bitches","bitch"]42bad_words = ["fuck","fuk","fucking","fuking","fukin","fuckin","fucked","fuked","fucker","shit","cunt","bastard","nazi","nigger","nigga","cock","bitches","bitch"]
3143
32def makeClean(s):44def makeClean(s):
@@ -372,9 +384,6 @@
372 else:384 else:
373 for bugid in bugids:385 for bugid in bugids:
374 bugid = int(bugid)386 bugid = int(bugid)
375 if bugid == 1 and tracker == self.db["lp"]:
376 irc.reply("https://bugs.launchpad.net/ubuntu/+bug/1 (Not reporting large bug)")
377 continue
378 try:387 try:
379 report = self.get_bug(msg.args[0],tracker,bugid,self.registryValue('showassignee', msg.args[0]))388 report = self.get_bug(msg.args[0],tracker,bugid,self.registryValue('showassignee', msg.args[0]))
380 except BugNotFoundError:389 except BugNotFoundError:
@@ -582,68 +591,60 @@
582 return [(id, component, title, severity, status, assignee, "%s/show_bug.cgi?id=%d" % (self.url, id))]591 return [(id, component, title, severity, status, assignee, "%s/show_bug.cgi?id=%d" % (self.url, id))]
583592
584class Launchpad(IBugtracker):593class Launchpad(IBugtracker):
585 def _parse(self, task):
586 parser = email.FeedParser.FeedParser()
587 parser.feed(task)
588 return parser.close()
589 def _sort(self, task1, task2):
590 # Status sort:
591 try:
592 statuses = ['Rejected', 'Fix Released', 'Fix Committed', 'Unconfirmed','Needs Info','Confirmed','In Progress']
593 severities = ['Undecided', 'Wishlist', 'Minor', 'Low', 'Normal', 'Medium', 'Major', 'High', 'Critical']
594 if task1['status'] not in statuses and task2['status'] in statuses: return -1
595 if task1['status'] in statuses and task2['status'] not in statuses: return 1
596 if task1['importance'] not in severities and task2['importance'] in severities: return -1
597 if task1['importance'] in severities and task2['importance'] not in severities: return 1
598 if not (task1['status'] == task2['status']):
599 if statuses.index(task1['status']) < statuses.index(task2['status']):
600 return -1
601 return 1
602 if not (task1['importance'] == task2['importance']):
603 if severities.index(task1['importance']) < severities.index(task2['importance']):
604 return -1
605 return 1
606 except: # Launchpad changed again?
607 return 0
608 return 0
609 def get_bug(self, id):594 def get_bug(self, id):
610 try:595 try:
611# print("%s/bugs/%d/+text" % (self.url,id))596 #print "Looking up bug #%s..." % id
612 bugdata = utils.web.getUrl("%s/bugs/%d/+text" % (self.url,id))597 bug_data = launchpad.bugs[int(id)]
613 except Exception, e:598 except KeyError:
614 if '404' in str(e):599 raise BugtrackerError, "Bug #%s not found." % id
615 raise BugNotFoundError600 except:
616 s = 'Could not parse data returned by %s: %s (%s/bugs/%d)' % (self.description, e, self.url, id)601 print Exception.message
617 raise BugtrackerError, s602
618 summary = {}
619 # Trap private bugs
620 if "<!-- 4a. didn't try to log in last time: -->" in bugdata:
621 raise BugtrackerError, "This bug is private"
622 try:603 try:
623 # Split bug data into separate pieces (bug data, task data)604 bug_data.private
624 data = bugdata.split('\n\n')605 except:
625 bugdata = data[0]606 raise BugtrackerError, "Bug #%s is private." % id
626 taskdata = data[1:]607
627 parser = email.FeedParser.FeedParser()608 bug_title = bug_data.title
628 parser.feed(bugdata)609 people_affected = bug_data.users_affected_count_with_dupes
629 bugdata = parser.close()610 bug_tasks_number = len(bug_data.bug_tasks) - 1
630 taskdata = map(self._parse, taskdata)611 # Read task data from last task.
631 taskdata.sort(self._sort)612 bug_task = list(bug_data.bug_tasks)[bug_tasks_number]
632 taskdata = taskdata[-1]613 bug_project = bug_task.bug_target_name
633 614 bug_importance = bug_task.importance
634 except Exception, e:615 bug_status = bug_task.status
635 s = 'Could not parse data returned by %s: %s (%s/bugs/%d)' % (self.description, e, self.url, id)616 bug_assignee = ""
636 raise BugtrackerError, s617 bug_duplicates = len(bug_data.duplicates)
618 bug_heat = bug_data.heat
619
620 if bug_task.assignee:
621 bug_assignee = bug_task.assignee.name
622
623 if bug_tasks_number > 0:
624 if bug_tasks_number == 1:
625 bug_project += " (and %d other project)" % bug_tasks_number
626 else:
627 bug_project += " (and %d other projects)" % bug_tasks_number
628
637 # Try and find duplicates629 # Try and find duplicates
638 t = taskdata['task']630 if bug_data.duplicate_of is not None:
639 if '(' in t:631 dup_bug = launchpad.bugs[id].duplicate_of
640 t = t[:t.rfind('(') -1]632 return [(id, bug_project,
641 if bugdata['duplicate-of']:633 bug_title + (' (dup-of: %d)' % dup_bug.id), bug_importance,
642 dupbug = self.get_bug(int(bugdata['duplicate-of']))634 bug_status, bug_assignee,
643 return [(id, t, bugdata['title'] + (' (dup-of: %d)' % dupbug[0][0]), taskdata['importance'], 635 "%s/bugs/%s" % (self.url, id))] + self.get_bug(dup_bug.id)
644 taskdata['status'], taskdata['assignee'], "%s/bugs/%s" % (self.url, id))] + dupbug636
645 return [(id, t, bugdata['title'], taskdata['importance'], 637 if people_affected > 0:
646 taskdata['status'], taskdata['assignee'], "%s/bugs/%s" % (self.url, id))]638 bug_title += " (affects: %d)" % people_affected
639
640 if bug_duplicates > 0:
641 bug_title += " (dups: %d)" % bug_duplicates
642
643 if bug_heat != 0:
644 bug_title += " (heat: %d)" % bug_heat
645
646 return [(id, bug_project, bug_title, bug_importance, bug_status,
647 bug_assignee, "%s/bugs/%s" % (self.url, id))]
647 648
648# <rant>649# <rant>
649# Debbugs sucks donkeyballs650# Debbugs sucks donkeyballs

Subscribers

People subscribed via source and target branches