incubator-allura-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From john...@apache.org
Subject [3/5] git commit: [#6692] Added new_ticket.py script to demonstrate use of bearer tokens
Date Tue, 22 Oct 2013 20:32:39 GMT
[#6692] Added new_ticket.py script to demonstrate use of bearer tokens

Signed-off-by: Cory Johns <cjohns@slashdotmedia.com>


Project: http://git-wip-us.apache.org/repos/asf/incubator-allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-allura/commit/0355325b
Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/0355325b
Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/0355325b

Branch: refs/heads/cj/6692
Commit: 0355325b397be54b30b13ead51fba3a6935c739a
Parents: ab8d2c3
Author: Cory Johns <cjohns@slashdotmedia.com>
Authored: Tue Oct 22 18:29:46 2013 +0000
Committer: Cory Johns <cjohns@slashdotmedia.com>
Committed: Tue Oct 22 18:29:46 2013 +0000

----------------------------------------------------------------------
 scripts/new_ticket.py | 34 ++++++++++++++++++++++++++++++++++
 1 file changed, 34 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/0355325b/scripts/new_ticket.py
----------------------------------------------------------------------
diff --git a/scripts/new_ticket.py b/scripts/new_ticket.py
new file mode 100755
index 0000000..26efe17
--- /dev/null
+++ b/scripts/new_ticket.py
@@ -0,0 +1,34 @@
+#!/usr/bin/env python
+
+import sys
+import argparse
+import requests
+from pprint import pprint
+
+def get_opts():
+    parser = argparse.ArgumentParser(description='Post a new ticket using the API')
+    parser.add_argument('project', help='Project shortname')
+    parser.add_argument('mount_point', help='Tracker mount point')
+    parser.add_argument('-H', '--host', default='sourceforge.net')
+    opts = parser.parse_args()
+    opts.url = 'https://{}/rest/p/{}/{}/new'.format(opts.host, opts.project, opts.mount_point)
+    return opts
+
+opts = get_opts()
+access_token = raw_input('Access (bearer) token: ')
+summary = raw_input('Summary: ')
+print 'Description (C-d to end):'
+print '-----------------------------------------------'
+description = sys.stdin.read()
+print '-----------------------------------------------'
+
+r = requests.post(opts.url, verify=False, params={
+        'access_token': access_token,
+        'ticket_form.summary': summary,
+        'ticket_form.description': description,
+    })
+if r.status_code == 200:
+    print 'Ticket created at: %s' % r.url
+    pprint(r.json())
+else:
+    print 'Error [%s]:\n%s' % (r.status_code, r.text)


Mime
View raw message