blob: 60844145abc9d5e6545e38c97f58ebd9b1b51bd9 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
|
#!../flask/bin/python
"""
usage: bug list [options]
If no arguments are given it will open your $EDITOR where the first line is
the summary following a newline and then the body of the report. Both are
required.
-h, --help Print this help text
"""
from docopt import docopt
from textwrap import indent
from datetime import datetime
import json, requests
if __name__ == '__main__':
print(docopt(__doc__))
def call(args):
print(args)
api_endpoint = args['--uri'] + '/api/1.0/tickets'
r = requests.get(api_endpoint)
tickets = json.loads(r.text).get('tickets')
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'])
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)
|