591
593
return bug_products
595
def getCommentIds(self, bug_watch):
596
"""See `ISupportsCommentImport`."""
597
actual_bug_id = self._getActualBugId(bug_watch.remotebug)
599
# Check that the bug exists, first.
600
if actual_bug_id not in self._bugs:
601
raise BugNotFound(bug_watch.remotebug)
603
# Get only the remote comment IDs and store them in the
604
# 'comments' field of the bug.
605
bug_comments_dict = self.xmlrpc_proxy.Bug.comments({
606
'ids': [actual_bug_id],
607
'include_fields': ['id'],
610
# We need to convert bug and comment ids to strings (see bugs
611
# 248662 amd 248938).
612
bug_comments = bug_comments_dict['bugs'][str(actual_bug_id)]
613
return [str(comment['id']) for comment in bug_comments]
615
def fetchComments(self, bug_watch, comment_ids):
616
"""See `ISupportsCommentImport`."""
617
actual_bug_id = self._getActualBugId(bug_watch.remotebug)
619
# We need to cast comment_ids to integers, since
620
# BugWatchUpdater.importBugComments() will pass us a list of
621
# strings (see bug 248938).
622
comment_ids = [int(comment_id) for comment_id in comment_ids]
624
# Fetch the comments we want.
625
return_dict = self.xmlrpc_proxy.Bug.comments({
626
'comment_ids': comment_ids,
628
comments = return_dict['comments']
630
# As a sanity check, drop any comments that don't belong to the
632
for comment_id, comment in comments.items():
633
if int(comment['bug_id']) != actual_bug_id:
634
del comments[comment_id]
636
self._bugs[actual_bug_id]['comments'] = return_dict['comments']
638
def getPosterForComment(self, bug_watch, comment_id):
639
"""See `ISupportsCommentImport`."""
640
actual_bug_id = self._getActualBugId(bug_watch.remotebug)
642
# We need to cast comment_id to integers, since
643
# BugWatchUpdater.importBugComments() will pass us a string (see
645
comment_id = int(comment_id)
647
comment = self._bugs[actual_bug_id]['comments'][comment_id]
648
display_name, email = parseaddr(comment['author'])
650
# If the name is empty then we return None so that
651
# IPersonSet.ensurePerson() can actually do something with it.
655
return (display_name, email)
657
def getMessageForComment(self, bug_watch, comment_id, poster):
658
"""See `ISupportsCommentImport`."""
659
actual_bug_id = self._getActualBugId(bug_watch.remotebug)
661
# We need to cast comment_id to integers, since
662
# BugWatchUpdater.importBugComments() will pass us a string (see
664
comment_id = int(comment_id)
665
comment = self._bugs[actual_bug_id]['comments'][comment_id]
667
# Turn the time in the comment, which is an XML-RPC datetime
668
# into something more useful to us.
669
# XXX 2008-08-05 gmb (bug 254999):
670
# We can remove these lines once we upgrade to python 2.5.
671
comment_timestamp = time.mktime(
672
time.strptime(str(comment['time']), '%Y%m%dT%H:%M:%S'))
673
comment_datetime = datetime.fromtimestamp(comment_timestamp)
674
comment_datetime = comment_datetime.replace(
675
tzinfo=pytz.timezone('UTC'))
677
message = getUtility(IMessageSet).fromText(
678
owner=poster, subject='', content=comment['text'],
679
datecreated=comment_datetime)
594
684
class BugzillaLPPlugin(BugzillaAPI):
595
685
"""An `ExternalBugTracker` to handle Bugzillas using the LP Plugin."""
745
835
self._bugs[actual_bug_id]['comments'] = bug_comments
747
def getPosterForComment(self, bug_watch, comment_id):
748
"""See `ISupportsCommentImport`."""
749
actual_bug_id = self._getActualBugId(bug_watch.remotebug)
751
# We need to cast comment_id to integers, since
752
# BugWatchUpdater.importBugComments() will pass us a string (see
754
comment_id = int(comment_id)
756
comment = self._bugs[actual_bug_id]['comments'][comment_id]
757
display_name, email = parseaddr(comment['author'])
759
# If the name is empty then we return None so that
760
# IPersonSet.ensurePerson() can actually do something with it.
764
return (display_name, email)
766
def getMessageForComment(self, bug_watch, comment_id, poster):
767
"""See `ISupportsCommentImport`."""
768
actual_bug_id = self._getActualBugId(bug_watch.remotebug)
770
# We need to cast comment_id to integers, since
771
# BugWatchUpdater.importBugComments() will pass us a string (see
773
comment_id = int(comment_id)
774
comment = self._bugs[actual_bug_id]['comments'][comment_id]
776
# Turn the time in the comment, which is an XML-RPC datetime
777
# into something more useful to us.
778
# XXX 2008-08-05 gmb (bug 254999):
779
# We can remove these lines once we upgrade to python 2.5.
780
comment_timestamp = time.mktime(
781
time.strptime(str(comment['time']), '%Y%m%dT%H:%M:%S'))
782
comment_datetime = datetime.fromtimestamp(comment_timestamp)
783
comment_datetime = comment_datetime.replace(
784
tzinfo=pytz.timezone('UTC'))
786
message = getUtility(IMessageSet).fromText(
787
owner=poster, subject='', content=comment['text'],
788
datecreated=comment_datetime)
792
837
@needs_authentication
793
838
def addRemoteComment(self, remote_bug, comment_body, rfc822msgid):
794
839
"""Add a comment to the remote bugtracker.