summaryrefslogtreecommitdiffstats
path: root/client
diff options
context:
space:
mode:
authorJohannes Löthberg <johannes@kyriasis.com>2014-10-03 00:14:59 +0200
committerJohannes Löthberg <johannes@kyriasis.com>2014-10-03 00:14:59 +0200
commitbc3550b0ff9959cd44702e6e98a5df43a3f52254 (patch)
treeee5f1ecc9164d8ef14d1352b1378f2cf230df03d /client
parentfb217ca2658c25f4df0a9b9b471ad85c608377a9 (diff)
downloadtbt-bc3550b0ff9959cd44702e6e98a5df43a3f52254.tar.xz
another big dump. github oauth authentiation is "working"
But it's done really hackily and probably should never be done like this.
Diffstat (limited to 'client')
-rwxr-xr-xclient/bug.py1
-rwxr-xr-xclient/bug_list.py39
-rwxr-xr-xclient/bug_open.py6
-rwxr-xr-xclient/bug_show.py8
4 files changed, 11 insertions, 43 deletions
diff --git a/client/bug.py b/client/bug.py
index 24a523c..ff7958f 100755
--- a/client/bug.py
+++ b/client/bug.py
@@ -13,7 +13,6 @@ commands:
show Show a specific ticket by ID
[Not implemented yet:]
- resolution Set the resolution status of a ticket
edit Edit a ticket
reopen Reopen a previously closed ticket
close Close a ticket
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))
diff --git a/client/bug_open.py b/client/bug_open.py
index 17a3e4f..e9ecb19 100755
--- a/client/bug_open.py
+++ b/client/bug_open.py
@@ -38,16 +38,16 @@ def call(args):
ticket = {
'summary': summary,
'body': body,
- 'user_nickname': 'demi'
+ 'token': 'TOKENHERE'
}
headers = {
'Content-Type': 'application/json',
- 'Accept': 'text/plain'
+ 'Accept': 'text/plain',
}
payload = json.dumps(ticket)
- r = requests.post(api_endpoint, data=payload, headers=headers)
+ r = requests.post(api_endpoint, data=payload, headers=headers, verify=False)
t = json.loads(r.text).get('ticket')
diff --git a/client/bug_show.py b/client/bug_show.py
index 0c3c9b8..18175ef 100755
--- a/client/bug_show.py
+++ b/client/bug_show.py
@@ -34,19 +34,11 @@ def show_ticket(ticket):
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" ))