def info(self, args): """Display classic information about an issue""" issue = self.Jira.getIssue(self.mdl) title = u'%s: %s' % (issue['key'], issue['fields']['summary']) created = datetime.strftime(Jira.parseDate(issue['fields'].get('created')), '%Y-%m-%d %H:%M') resolution = u'' if issue['fields']['resolution'] == None else u'(%s)' % (issue['fields']['resolution']['name']) resolutiondate = u'' if issue['fields'].get('resolutiondate') != None: resolutiondate = datetime.strftime(Jira.parseDate(issue['fields'].get('resolutiondate')), '%Y-%m-%d %H:%M') print u'-' * 72 for l in textwrap.wrap(title, 68, initial_indent=' ', subsequent_indent=' '): print l print u' {0} - {1} - {2}'.format(issue['fields']['issuetype']['name'], issue['fields']['priority']['name'], u'https://tracker.moodle.org/browse/' + issue['key']) status = u'{0} {1} {2}'.format(issue['fields']['status']['name'], resolution, resolutiondate).strip() print u' {0}'.format(status) vw = u'[ V: %d - W: %d ]' % (issue['fields']['votes']['votes'], issue['fields']['watches']['watchCount']) print '{0:->70}--'.format(vw) print u'{0:<20}: {1} ({2}) on {3}'.format('Reporter', issue['fields']['reporter']['displayName'], issue['fields']['reporter']['name'], created) if issue['fields'].get('assignee') != None: print u'{0:<20}: {1} ({2})'.format('Assignee', issue['fields']['assignee']['displayName'], issue['fields']['assignee']['name']) if issue['named'].get('Peer reviewer'): print u'{0:<20}: {1} ({2})'.format('Peer reviewer', issue['named']['Peer reviewer']['displayName'], issue['named']['Peer reviewer']['name']) if issue['named'].get('Integrator'): print u'{0:<20}: {1} ({2})'.format('Integrator', issue['named']['Integrator']['displayName'], issue['named']['Integrator']['name']) if issue['named'].get('Tester'): print u'{0:<20}: {1} ({2})'.format('Tester', issue['named']['Tester']['displayName'], issue['named']['Tester']['name']) if args.testing and issue['named'].get('Testing Instructions'): print u'-' * 72 print u'Testing instructions:' for l in issue['named'].get('Testing Instructions').split('\r\n'): print ' ' + l print u'-' * 72
def run(self, args): issue = None if not args.issue: M = self.Wp.resolve() if M: parsedbranch = parseBranch(M.currentBranch(), self.C.get('wording.branchRegex')) if parsedbranch: issue = parsedbranch['issue'] else: issue = args.issue if not issue or not re.match('(MDL|mdl)?(-|_)?[1-9]+', issue): raise Exception('Invalid or unknown issue number') self.Jira = Jira() self.mdl = 'MDL-' + re.sub(r'(MDL|mdl)(-|_)?', '', issue) self.info(args)
class TrackerCommand(Command): _arguments = [ ( ['-t', '--testing'], { 'action': 'store_true', 'help': 'include testing instructions' } ), ( ['issue'], { 'help': 'MDL issue number. Guessed from the current branch if not specified.', 'nargs': '?' } ) ] _description = 'Retrieve information from the tracker' Jira = None mdl = None def run(self, args): issue = None if not args.issue: M = self.Wp.resolve() if M: parsedbranch = parseBranch(M.currentBranch(), self.C.get('wording.branchRegex')) if parsedbranch: issue = parsedbranch['issue'] else: issue = args.issue if not issue or not re.match('(MDL|mdl)?(-|_)?[1-9]+', issue): raise Exception('Invalid or unknown issue number') self.Jira = Jira() self.mdl = 'MDL-' + re.sub(r'(MDL|mdl)(-|_)?', '', issue) self.info(args) def info(self, args): """Display classic information about an issue""" issue = self.Jira.getIssue(self.mdl) title = u'%s: %s' % (issue['key'], issue['fields']['summary']) created = datetime.strftime(Jira.parseDate(issue['fields'].get('created')), '%Y-%m-%d %H:%M') resolution = u'' if issue['fields']['resolution'] == None else u'(%s)' % (issue['fields']['resolution']['name']) resolutiondate = u'' if issue['fields'].get('resolutiondate') != None: resolutiondate = datetime.strftime(Jira.parseDate(issue['fields'].get('resolutiondate')), '%Y-%m-%d %H:%M') print u'-' * 72 for l in textwrap.wrap(title, 68, initial_indent=' ', subsequent_indent=' '): print l print u' {0} - {1} - {2}'.format(issue['fields']['issuetype']['name'], issue['fields']['priority']['name'], u'https://tracker.moodle.org/browse/' + issue['key']) status = u'{0} {1} {2}'.format(issue['fields']['status']['name'], resolution, resolutiondate).strip() print u' {0}'.format(status) vw = u'[ V: %d - W: %d ]' % (issue['fields']['votes']['votes'], issue['fields']['watches']['watchCount']) print '{0:->70}--'.format(vw) print u'{0:<20}: {1} ({2}) on {3}'.format('Reporter', issue['fields']['reporter']['displayName'], issue['fields']['reporter']['name'], created) if issue['fields'].get('assignee') != None: print u'{0:<20}: {1} ({2})'.format('Assignee', issue['fields']['assignee']['displayName'], issue['fields']['assignee']['name']) if issue['named'].get('Peer reviewer'): print u'{0:<20}: {1} ({2})'.format('Peer reviewer', issue['named']['Peer reviewer']['displayName'], issue['named']['Peer reviewer']['name']) if issue['named'].get('Integrator'): print u'{0:<20}: {1} ({2})'.format('Integrator', issue['named']['Integrator']['displayName'], issue['named']['Integrator']['name']) if issue['named'].get('Tester'): print u'{0:<20}: {1} ({2})'.format('Tester', issue['named']['Tester']['displayName'], issue['named']['Tester']['name']) if args.testing and issue['named'].get('Testing Instructions'): print u'-' * 72 print u'Testing instructions:' for l in issue['named'].get('Testing Instructions').split('\r\n'): print ' ' + l print u'-' * 72