From bc3550b0ff9959cd44702e6e98a5df43a3f52254 Mon Sep 17 00:00:00 2001 From: Johannes Löthberg Date: Fri, 3 Oct 2014 00:14:59 +0200 Subject: another big dump. github oauth authentiation is "working" But it's done really hackily and probably should never be done like this. --- client/bug_list.py | 39 ++++++++------------------------------- 1 file changed, 8 insertions(+), 31 deletions(-) (limited to 'client/bug_list.py') diff --git a/client/bug_list.py b/client/bug_list.py index 6084414..701b327 100755 --- a/client/bug_list.py +++ b/client/bug_list.py @@ -11,6 +11,7 @@ required. from docopt import docopt from textwrap import indent from datetime import datetime +from bug_show import show_ticket import json, requests if __name__ == '__main__': @@ -20,37 +21,13 @@ def call(args): print(args) api_endpoint = args['--uri'] + '/api/1.0/tickets' - r = requests.get(api_endpoint) + r = requests.get(api_endpoint, verify=False) - tickets = json.loads(r.text).get('tickets') + tickets = json.loads(r.text) + if not tickets: + exit("No tickets found.") - for ticket in tickets: - output = '[TBT#{}] '.format(ticket['id']) - - if 'deleted' in ticket and ticket['deleted'] == True: - output += '[DELETED] ' - - output += '[{}] '.format(ticket['status']) - - output += '{}\n'.format(ticket['summary']) - - if ticket['status'] != 'open': - output += 'Resolution: {}\n'.format(ticket['resolution']) - - if ticket['reason']: - output += 'Reason: {}\n'.format(ticket['reason']) + tickets = tickets.get('tickets') - output += 'Opened by: {} <{}>\n'.format(ticket['opened_by']['nickname'], ticket['opened_by']['email']) - output += 'Opened at: {} UTC\n'.format(datetime.strptime( ticket['opened_at'], "%Y-%m-%dT%H:%M:%S" )) - - if ticket['assigned_to']: - output += 'Assigned to: {} <{}>\n'.format(ticket['assigned_to']['nickname'], ticket['assigned_to']['email']) - else: - output += 'Assigned to: Unassigned\n' - - if ticket['updated_at']: - output += 'Updated at: {} UTC\n'.format(datetime.strptime(ticket['opened_at'], "%Y-%m-%dT%H:%M:%S" )) - - output += '\n' + indent('{}'.format(ticket['body']), ' ') + '\n' - - print(output) + for ticket in tickets: + print(show_ticket(ticket)) -- cgit v1.2.3-54-g00ecf