http://www.mediawiki.org/wiki/Special:Code/MediaWiki/98015
Revision: 98015
Author: laner
Date: 2011-09-24 19:16:20 +0000 (Sat, 24 Sep 2011)
Log Message:
-----------
Adding python-rtkit deb
Added Paths:
-----------
trunk/debs/python-rtkit/
trunk/debs/python-rtkit/README
trunk/debs/python-rtkit/debian/
trunk/debs/python-rtkit/debian/changelog
trunk/debs/python-rtkit/debian/compat
trunk/debs/python-rtkit/debian/control
trunk/debs/python-rtkit/debian/copyright
trunk/debs/python-rtkit/debian/rules
trunk/debs/python-rtkit/setup.py
Added: trunk/debs/python-rtkit/README
===================================================================
--- trunk/debs/python-rtkit/README (rev 0)
+++ trunk/debs/python-rtkit/README 2011-09-24 19:16:20 UTC (rev 98015)
@@ -0,0 +1,226 @@
+====================
+python-rtkit
+====================
+`Best Practical RT`_ (Request Tracker) data access python module for REST
interface.
+
+
+Installation
+================
+
+Rest Api Summary
+================
+More detailed version: `Request Tracker Wiki`_
+
+::
+
+ [01][-W] Create ticket | ticket/new
+ [02][RW] Read/Update ticket | ticket/<ticket-id>
+ [03][-W] Create ticket comment | ticket/<ticket-id>/comment
+ [04][RW] Read/Update ticket links | ticket/<ticket-id>/links
+ [05][R-] Read ticket attachments | ticket/<ticket-id>/attachments
+ [06][R-] Read ticket attachment |
ticket/<ticket-id>/attachments/<attachment-id>
+ [07][R-] Read ticket attachment content |
ticket/<ticket-id>/attachments/<attachment-id>/content
+ [08][R-] Read ticket history | ticket/<ticket-id>/history
+ [09][R-] Read detailed ticket history |
ticket/<ticket-id>/history?format=l
+ [10][R-] Read ticket history item |
ticket/<ticket-id>/history/id/<history-id>
+ [11][R-] Read user by id | user/<user-id>
+ [12][R-] Read user by name | user/<user-Name>
+ [13][R-] Read queue by id | queue/<queue-id>
+ [14][R-] Read queue by name | queue/<queue-Name>
+ [15][R-] Search tickets |
search/ticket?query=<query>&orderby=<sort-order>&format=<format>
+
+Low Level Layer: Examples and Tips
+================
+For Now Only Basic Authentication is supported
+----------------
+
+::
+
+ from rtkit import RTResource, set_logging, RTResourceError
+ import logging
+
+ set_logging('debug')
+ logger = logging.getLogger('rtkit')
+
+ resource = RTResource('http://<HOST>/REST/1.0/', (<USER>, <PWD>))
+
+Create ticket
+----------------
+
+::
+
+ message = 'My useless\ntext on\nthree lines.'
+ content = {
+ 'Queue': 1,#'', 2
+ 'Subject' : 'New Ticket',
+ 'Text' : message.replace('\n', '\n '),
+ }
+ try:
+ response = resource.post(path='ticket/new', payload=content,)
+ logger.info(response.parsed)
+ except RTResourceError as e:
+ logger.error(e.response.status_int)
+ logger.error(e.response.status)
+ logger.error(e.response.parsed)
+
+::
+
+ #OK
+ [DEBUG] POST ticket/new
+ [DEBUG] {'Content-Type': 'application/x-www-form-urlencoded', 'Accept':
'text/plain', 'User-Agent': 'pyRTkit/0.0.1'}
+ [DEBUG] u'content=Queue: 1\nText: My useless\n text on\n three
lines.\nSubject: New Ticket\n'
+ [INFO] HTTP_STATUS: 200 OK
+ [DEBUG] 'RT/3.8.10 200 Ok\n\n# Ticket 17 created.\n\n'
+ [INFO] RESOURCE_STATUS: 200 Ok
+ [INFO] [[('id', 'ticket/17')]]
+
+::
+
+ #MISSING OR MISSPELLED QUEUE
+ [DEBUG] POST ticket/new
+ [DEBUG] {'Content-Type': 'application/x-www-form-urlencoded', 'Accept':
'text/plain', 'User-Agent': 'pyRTkit/0.0.1'}
+ [DEBUG] u'content=Queue: \nText: My useless\n text on\n three
lines.\nSubject: New Ticket\n'
+ [INFO] HTTP_STATUS: 200 OK
+ [DEBUG] 'RT/3.8.10 200 Ok\n\n# Could not create ticket.\n# Could not create
ticket. Queue not set\n\n'
+ [INFO] RESOURCE_STATUS: 400 Could not create ticket. Queue not set
+ [ERROR] 400
+ [ERROR] 400 Could not create ticket. Queue not set
+ [ERROR] []
+
+::
+
+ #NO PERMISSION ON QUEUE
+ [DEBUG] POST ticket/new
+ [DEBUG] {'Content-Type': 'application/x-www-form-urlencoded', 'Accept':
'text/plain', 'User-Agent': 'pyRTkit/0.0.1'}
+ [DEBUG] u'content=Queue: 2\nText: My useless\n text on\n three
lines.\nSubject: New Ticket\n'
+ [INFO] HTTP_STATUS: 200 OK
+ [DEBUG] "RT/3.8.10 200 Ok\n\n# Could not create ticket.\n# No permission to
create tickets in the queue '___Approvals'\n\n"
+ [INFO] RESOURCE_STATUS: 400 No permission to create tickets in the queue
'___Approvals'
+ [ERROR] 400
+ [ERROR] 400 No permission to create tickets in the queue '___Approvals'
+ [ERROR] []
+
+Read a ticket
+----------------
+
+::
+
+ try:
+ response = resource.get(path='ticket/1')
+ for r in response.parsed:
+ for t in r:
+ logger.info(t) except RTResourceError as e:
+ logger.error(e.response.status_int)
+ logger.error(e.response.status)
+ logger.error(e.response.parsed)
+
+::
+
+ #TICKET FOUND
+ [DEBUG] GET ticket/1
+ [DEBUG] {'Accept': 'text/plain', 'User-Agent': 'pyRTkit/0.0.1'}
+ [DEBUG] None
+ [INFO] HTTP_STATUS: 200 OK
+ [DEBUG] 'RT/3.8.10 200 Ok\n\nid: ticket/1\nQueue: General\nOwner:
Nobody\nCreator: pyrtkit\nSubject: pyrt-create4\nStatus: open\nPriority:
5\nInitialPriority: 0\nFinalPriority: 0\nRequestors:\nCc:\nAdminCc:\nCreated:
Sun Jul 03 10:48:57 2011\nStarts: Not set\nStarted: Not set\nDue: Not
set\nResolved: Not set\nTold: Wed Jul 06 12:58:00 2011\nLastUpdated: Thu Jul 07
14:42:32 2011\nTimeEstimated: 0\nTimeWorked: 25 minutes\nTimeLeft: 0\n\n'
+ [INFO] RESOURCE_STATUS: 200 Ok
+ [INFO] ('id', 'ticket/1')
+ [INFO] ('Queue', 'General')
+ [INFO] ('Owner', 'Nobody')
+ [INFO] ('Creator', 'pyrtkit')
+ [INFO] ('Subject', 'pyrt-create4')
+ [INFO] ('Status', 'open')
+ [INFO] ('Priority', '5')
+ [INFO] ('InitialPriority', '0')
+ [INFO] ('FinalPriority', '0')
+ [INFO] ('Requestors', '')
+ [INFO] ('Cc', '')
+ [INFO] ('AdminCc', '')
+ [INFO] ('Created', 'Sun Jul 03 10:48:57 2011')
+ [INFO] ('Starts', 'Not set')
+ [INFO] ('Started', 'Not set')
+ [INFO] ('Due', 'Not set')
+ [INFO] ('Resolved', 'Not set')
+ [INFO] ('Told', 'Wed Jul 06 12:58:00 2011')
+ [INFO] ('LastUpdated', 'Thu Jul 07 14:42:32 2011')
+ [INFO] ('TimeEstimated', '0')
+ [INFO] ('TimeWorked', '25 minutes')
+ [INFO] ('TimeLeft', '0')
+
+::
+
+ #TICKET NOT FOUND
+ [DEBUG] GET ticket/100
+ [DEBUG] {'Accept': 'text/plain', 'User-Agent': 'pyRTkit/0.0.1'}
+ [DEBUG] None
+ [INFO] HTTP_STATUS: 200 OK
+ [DEBUG] 'RT/3.8.10 200 Ok\n\n# Ticket 100 does not exist.\n\n\n'
+ [INFO] RESOURCE_STATUS: 404 Ticket 100 does not exist
+ [ERROR] 404
+ [ERROR] 404 Ticket 100 does not exist
+ [ERROR] []
+
+Edit a ticket or ticket's links
+----------------
+Ticket (or ticket's links) editing hasn't all-or-nothing behaviour; so it's
very difficult to capture errors.
+For example trying to change Queue to a not admitted one (or to edit an
unknown field) RT will return:
+
+::
+
+ RT/3.8.10 409 Syntax Error
+
+ # queue: You may not create requests in that queue.
+ # spam: Unknown field.
+
+ id:
+ Subject: Try Edit Ticket
+ TimeWorked: 1
+ Queue: 2
+ Spam: 10
+
+For now rtkit will raise SyntaxError with the errors list in e.response.parsed
+
+::
+
+ [DEBUG] POST ticket/1
+ [DEBUG] {'Content-Type': 'application/x-www-form-urlencoded', 'Accept':
'text/plain', 'User-Agent': 'pyRTkit/0.0.1'}
+ [DEBUG] u'content=Queue: 2\nSpam: 10\nTimeWorked: 1\nSubject: Try Edit
Ticket\n'
+ [INFO] HTTP_STATUS: 200 OK
+ [DEBUG] 'RT/3.8.10 409 Syntax Error\n\n# queue: You may not create requests
in that queue.\n# spam: Unknown field.\n\nid: \nSubject: Try Edit
Ticket\nTimeWorked: 1\nQueue: 2\nSpam: 10\n\n'
+ [INFO] RESOURCE_STATUS: 409 Syntax Error
+ [ERROR] 409
+ [ERROR] 409 Syntax Error
+ [ERROR] [[('queue', 'You may not create requests in that queue.'), ('spam',
'Unknown field.')]]
+
+Comment on a Ticket with Attachments
+------------
+
+Usually your requests will be something like this.
+
+::
+
+ try:
+ params = {
+ 'content' :{
+ 'Action' : 'comment',
+ 'Text' : 'Comment with attach',
+ 'Attachment' : 'x.txt, 140x105.jpg',
+ },
+ 'attachment_1' : file('x.txt'),
+ 'attachment_2' : file('140x105.jpg'),
+ }
+ response = resource.post(path='ticket/16/comment', payload=params,)
+ for r in response.parsed:
+ for t in r:
+ logger.info(t)
+ except RTResourceError as e:
+ logger.error(e.response.status_int)
+ logger.error(e.response.status)
+ logger.error(e.response.parsed)
+
+References
+================
+* `Best Practical RT`_
+* `Request Tracker Wiki`_
+
+.. _Best Practical RT: http://bestpractical.com/rt/
+.. _Request Tracker Wiki: http://requesttracker.wikia.com/wiki/REST
\ No newline at end of file
Added: trunk/debs/python-rtkit/debian/changelog
===================================================================
--- trunk/debs/python-rtkit/debian/changelog (rev 0)
+++ trunk/debs/python-rtkit/debian/changelog 2011-09-24 19:16:20 UTC (rev
98015)
@@ -0,0 +1,5 @@
+python-rtkit (0.0.1-1wm1~lucid1) lucid-wikimedia; urgency=low
+
+ * Initial creation of package
+
+ -- Ryan Lane <[email protected]> Wed, 24 Sep 2010 18:58:34 +0000
Added: trunk/debs/python-rtkit/debian/compat
===================================================================
--- trunk/debs/python-rtkit/debian/compat (rev 0)
+++ trunk/debs/python-rtkit/debian/compat 2011-09-24 19:16:20 UTC (rev
98015)
@@ -0,0 +1 @@
+6
Added: trunk/debs/python-rtkit/debian/control
===================================================================
--- trunk/debs/python-rtkit/debian/control (rev 0)
+++ trunk/debs/python-rtkit/debian/control 2011-09-24 19:16:20 UTC (rev
98015)
@@ -0,0 +1,16 @@
+Source: python-rtkit
+Section: python
+Priority: optional
+XS-Python-Version: all
+Maintainer: Andrea De Marco <[email protected]>
+Uploaders: Ryan Lane <[email protected]>
+Build-Depends: debhelper (>= 6)
+Build-Depends-Indep: python, python-support, python-setuptools
+Standards-Version: 3.8.3
+Homepage: https://github.com/z4r/python-rtkit
+
+Package: python-rtkit
+Architecture: all
+Depends: ${misc:Depends}, ${python:Depends}
+Description: Python Api for Request Tracker's REST interface
+ Best Practical RT (Request Tracker) data access python module for REST
interface.
Added: trunk/debs/python-rtkit/debian/copyright
===================================================================
--- trunk/debs/python-rtkit/debian/copyright (rev 0)
+++ trunk/debs/python-rtkit/debian/copyright 2011-09-24 19:16:20 UTC (rev
98015)
@@ -0,0 +1,14 @@
+Copyright (C) Andrea De Marco <[email protected]>
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
Added: trunk/debs/python-rtkit/debian/rules
===================================================================
--- trunk/debs/python-rtkit/debian/rules (rev 0)
+++ trunk/debs/python-rtkit/debian/rules 2011-09-24 19:16:20 UTC (rev
98015)
@@ -0,0 +1,39 @@
+#!/usr/bin/make -f
+# -*- makefile -*-
+
+# Uncomment this to turn on verbose mode.
+#export DH_VERBOSE=1
+
+PREFIX := debian/python-rtkit
+PACKAGE_DIR := /usr/share/python-support/python-rtkit
+
+build:
+
+clean:
+ dh_testdir
+ dh_testroot
+
+ dh_clean *.pyc
+
+install: build
+ dh_testdir
+ dh_testroot
+
+ python ./setup.py install --no-compile --root=$(PREFIX)
+
+# Build architecture-independent files here.
+binary-indep: build install
+ dh_testdir
+ dh_testroot
+ dh_installdocs
+ dh_compress
+ dh_fixperms
+ dh_pysupport
+ dh_installdeb
+ dh_gencontrol
+ dh_md5sums
+ dh_builddeb
+
+binary: binary-indep
+binary-arch:
+.PHONY: build clean binary-indep binary install
Property changes on: trunk/debs/python-rtkit/debian/rules
___________________________________________________________________
Added: svn:executable
+ *
Added: trunk/debs/python-rtkit/setup.py
===================================================================
--- trunk/debs/python-rtkit/setup.py (rev 0)
+++ trunk/debs/python-rtkit/setup.py 2011-09-24 19:16:20 UTC (rev 98015)
@@ -0,0 +1,18 @@
+#!/usr/bin/env python
+
+from setuptools import setup
+import rtkit
+
+setup(name="python-rtkit",
+ version=rtkit.__version__,
+ description="Python Api for Request Tracker's REST interface",
+ long_description=open("README").read(),
+ author=rtkit.__author__,
+ author_email="[email protected]",
+ maintainer="Andrea de Marco",
+ maintainer_email="[email protected]",
+ url="https://github.com/z4r/python-rtkit",
+ download_url="https://github.com/z4r/python-rtkit/tarball/master",
+ packages=["rtkit"],
+ classifiers=rtkit.__classifiers__
+ )
_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs