def get(self, bugid, comments = True, attachments = True): """ Fetch bug details given the bug id """ self.log('Getting bug %s ..' % bugid) result = Bugz.get(self, bugid) if result is None: raise RuntimeError('Bug %s not found' % bugid) # Print out all the fields below by extract the text # directly from the tag, and just ignore if we don't # see the tag. FIELDS = ( ('short_desc', 'Title'), ('assigned_to', 'Assignee'), ('creation_ts', 'Reported'), ('delta_ts', 'Updated'), ('bug_status', 'Status'), ('resolution', 'Resolution'), ('bug_file_loc', 'URL'), ('bug_severity', 'Severity'), ('priority', 'Priority'), ('reporter', 'Reporter'), ) MORE_FIELDS = ( ('product', 'Product'), ('component', 'Component'), ('status_whiteboard', 'Whiteboard'), ('keywords', 'Keywords'), ) for field, name in FIELDS + MORE_FIELDS: try: value = result.find('.//%s' % field).text if value is None: continue except AttributeError: continue print '%-12s: %s' % (name, value.encode(self.enc)) # Print out the cc'ed people cced = result.findall('.//cc') for cc in cced: print '%-12s: %s' % ('CC', cc.text) # print out depends dependson = ', '.join([d.text for d in result.findall('.//dependson')]) blocked = ', '.join([d.text for d in result.findall('.//blocked')]) if dependson: print '%-12s: %s' % ('DependsOn', dependson) if blocked: print '%-12s: %s' % ('Blocked', blocked) bug_comments = result.findall('.//long_desc') bug_attachments = result.findall('.//attachment') print '%-12s: %d' % ('Comments', len(bug_comments)) print '%-12s: %d' % ('Attachments', len(bug_attachments)) print if attachments: for attachment in bug_attachments: aid = attachment.find('.//attachid').text desc = attachment.find('.//desc').text when = attachment.find('.//date').text print '[Attachment] [%s] [%s]' % (aid, desc.encode(self.enc)) if comments: i = 0 wrapper = textwrap.TextWrapper(width = self.columns) for comment in bug_comments: try: who = comment.find('.//who').text.encode(self.enc) except AttributeError: # Novell doesn't use 'who' on xml who = "" when = comment.find('.//bug_when').text.encode(self.enc) what = comment.find('.//thetext').text print '\n[Comment #%d] %s : %s' % (i, who, when) print '-' * (self.columns - 1) if what is None: what = '' # print wrapped version for line in what.split('\n'): if len(line) < self.columns: print line.encode(self.enc) else: for shortline in wrapper.wrap(line): print shortline.encode(self.enc) i += 1 print
def get(self, bugid, comments = True, attachments = True): """ Fetch bug details given the bug id """ self.log('Getting bug %s ..' % bugid) result = Bugz.get(self, bugid) if result == None: raise RuntimeError('Bug %s not found' % bugid) # Print out all the fields below by extract the text # directly from the tag, and just ignore if we don't # see the tag. FIELDS = ( ('short_desc', 'Title'), ('assigned_to', 'Assignee'), ('creation_ts', 'Reported'), ('delta_ts', 'Updated'), ('bug_status', 'Status'), ('resolution', 'Resolution'), ('bug_file_loc', 'URL'), ('bug_severity', 'Severity'), ('priority', 'Priority'), ('reporter', 'Reporter'), ) MORE_FIELDS = ( ('product', 'Product'), ('component', 'Component'), ('status_whiteboard', 'Whiteboard'), ('keywords', 'Keywords'), ) for field, name in FIELDS + MORE_FIELDS: try: value = result.find('//%s' % field).text except AttributeError: continue print '%-12s: %s' % (name, value.encode(self.enc)) # Print out the cc'ed people cced = result.findall('.//cc') for cc in cced: print '%-12s: %s' % ('CC', cc.text) # print out depends dependson = ', '.join([d.text for d in result.findall('.//dependson')]) blocked = ', '.join([d.text for d in result.findall('.//blocked')]) if dependson: print '%-12s: %s' % ('DependsOn', dependson) if blocked: print '%-12s: %s' % ('Blocked', blocked) bug_comments = result.findall('//long_desc') bug_attachments = result.findall('//attachment') print '%-12s: %d' % ('Comments', len(bug_comments)) print '%-12s: %d' % ('Attachments', len(bug_attachments)) print '%-12s: %s' % ('URL', '%s?id=%s' % (urljoin(self.base, config.urls['show']), bugid)) print if attachments: for attachment in bug_attachments: aid = attachment.find('.//attachid').text desc = attachment.find('.//desc').text when = attachment.find('.//date').text print '[Attachment] [%s] [%s]' % (aid, desc.encode(self.enc)) if comments: i = 0 wrapper = textwrap.TextWrapper(width = self.columns) for comment in bug_comments: try: who = comment.find('.//who').text.encode(self.enc) except AttributeError: # Novell doesn't use 'who' on xml who = "" when = comment.find('.//bug_when').text.encode(self.enc) what = comment.find('.//thetext').text print '\n[Comment #%d] %s : %s' % (i, who, when) print '-' * (self.columns - 1) if what is None: what = '' # print wrapped version for line in what.split('\n'): if len(line) < self.columns: print line.encode(self.enc) else: for shortline in wrapper.wrap(line): print shortline.encode(self.enc) i += 1 print