r98015 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r98014‎ | r98015 | r98016 >
Date:19:16, 24 September 2011
Author:laner
Status:deferred
Tags:
Comment:
Adding python-rtkit deb
Modified paths:
  • /trunk/debs/python-rtkit (added) (history)
  • /trunk/debs/python-rtkit/README (added) (history)
  • /trunk/debs/python-rtkit/debian (added) (history)
  • /trunk/debs/python-rtkit/debian/changelog (added) (history)
  • /trunk/debs/python-rtkit/debian/compat (added) (history)
  • /trunk/debs/python-rtkit/debian/control (added) (history)
  • /trunk/debs/python-rtkit/debian/copyright (added) (history)
  • /trunk/debs/python-rtkit/debian/rules (added) (history)
  • /trunk/debs/python-rtkit/setup.py (added) (history)

Diff [purge]

Index: trunk/debs/python-rtkit/debian/control
@@ -0,0 +1,16 @@
 2+Source: python-rtkit
 3+Section: python
 4+Priority: optional
 5+XS-Python-Version: all
 6+Maintainer: Andrea De Marco <24erre@gmail.com>
 7+Uploaders: Ryan Lane <rlane@wikimedia.org>
 8+Build-Depends: debhelper (>= 6)
 9+Build-Depends-Indep: python, python-support, python-setuptools
 10+Standards-Version: 3.8.3
 11+Homepage: https://github.com/z4r/python-rtkit
 12+
 13+Package: python-rtkit
 14+Architecture: all
 15+Depends: ${misc:Depends}, ${python:Depends}
 16+Description: Python Api for Request Tracker's REST interface
 17+ Best Practical RT (Request Tracker) data access python module for REST interface.
Index: trunk/debs/python-rtkit/debian/compat
@@ -0,0 +1 @@
 2+6
Index: trunk/debs/python-rtkit/debian/changelog
@@ -0,0 +1,5 @@
 2+python-rtkit (0.0.1-1wm1~lucid1) lucid-wikimedia; urgency=low
 3+
 4+ * Initial creation of package
 5+
 6+ -- Ryan Lane <rlane@wikimedia.org> Wed, 24 Sep 2010 18:58:34 +0000
Index: trunk/debs/python-rtkit/debian/copyright
@@ -0,0 +1,14 @@
 2+Copyright (C) Andrea De Marco <24erre@gmail.com>
 3+
 4+ This program is free software: you can redistribute it and/or modify
 5+ it under the terms of the GNU General Public License as published by
 6+ the Free Software Foundation, either version 3 of the License, or
 7+ (at your option) any later version.
 8+
 9+ This program is distributed in the hope that it will be useful,
 10+ but WITHOUT ANY WARRANTY; without even the implied warranty of
 11+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 12+ GNU General Public License for more details.
 13+
 14+ You should have received a copy of the GNU General Public License
 15+ along with this program. If not, see <http://www.gnu.org/licenses/>.
Index: trunk/debs/python-rtkit/debian/rules
@@ -0,0 +1,39 @@
 2+#!/usr/bin/make -f
 3+# -*- makefile -*-
 4+
 5+# Uncomment this to turn on verbose mode.
 6+#export DH_VERBOSE=1
 7+
 8+PREFIX := debian/python-rtkit
 9+PACKAGE_DIR := /usr/share/python-support/python-rtkit
 10+
 11+build:
 12+
 13+clean:
 14+ dh_testdir
 15+ dh_testroot
 16+
 17+ dh_clean *.pyc
 18+
 19+install: build
 20+ dh_testdir
 21+ dh_testroot
 22+
 23+ python ./setup.py install --no-compile --root=$(PREFIX)
 24+
 25+# Build architecture-independent files here.
 26+binary-indep: build install
 27+ dh_testdir
 28+ dh_testroot
 29+ dh_installdocs
 30+ dh_compress
 31+ dh_fixperms
 32+ dh_pysupport
 33+ dh_installdeb
 34+ dh_gencontrol
 35+ dh_md5sums
 36+ dh_builddeb
 37+
 38+binary: binary-indep
 39+binary-arch:
 40+.PHONY: build clean binary-indep binary install
Property changes on: trunk/debs/python-rtkit/debian/rules
___________________________________________________________________
Added: svn:executable
141 + *
Index: trunk/debs/python-rtkit/setup.py
@@ -0,0 +1,18 @@
 2+#!/usr/bin/env python
 3+
 4+from setuptools import setup
 5+import rtkit
 6+
 7+setup(name="python-rtkit",
 8+ version=rtkit.__version__,
 9+ description="Python Api for Request Tracker's REST interface",
 10+ long_description=open("README").read(),
 11+ author=rtkit.__author__,
 12+ author_email="martine@danga.com",
 13+ maintainer="Andrea de Marco",
 14+ maintainer_email="24erre@gmail.com",
 15+ url="https://github.com/z4r/python-rtkit",
 16+ download_url="https://github.com/z4r/python-rtkit/tarball/master",
 17+ packages=["rtkit"],
 18+ classifiers=rtkit.__classifiers__
 19+ )
Index: trunk/debs/python-rtkit/README
@@ -0,0 +1,226 @@
 2+====================
 3+python-rtkit
 4+====================
 5+`Best Practical RT`_ (Request Tracker) data access python module for REST interface.
 6+
 7+
 8+Installation
 9+================
 10+
 11+Rest Api Summary
 12+================
 13+More detailed version: `Request Tracker Wiki`_
 14+
 15+::
 16+
 17+ [01][-W] Create ticket | ticket/new
 18+ [02][RW] Read/Update ticket | ticket/<ticket-id>
 19+ [03][-W] Create ticket comment | ticket/<ticket-id>/comment
 20+ [04][RW] Read/Update ticket links | ticket/<ticket-id>/links
 21+ [05][R-] Read ticket attachments | ticket/<ticket-id>/attachments
 22+ [06][R-] Read ticket attachment | ticket/<ticket-id>/attachments/<attachment-id>
 23+ [07][R-] Read ticket attachment content | ticket/<ticket-id>/attachments/<attachment-id>/content
 24+ [08][R-] Read ticket history | ticket/<ticket-id>/history
 25+ [09][R-] Read detailed ticket history | ticket/<ticket-id>/history?format=l
 26+ [10][R-] Read ticket history item | ticket/<ticket-id>/history/id/<history-id>
 27+ [11][R-] Read user by id | user/<user-id>
 28+ [12][R-] Read user by name | user/<user-Name>
 29+ [13][R-] Read queue by id | queue/<queue-id>
 30+ [14][R-] Read queue by name | queue/<queue-Name>
 31+ [15][R-] Search tickets | search/ticket?query=<query>&orderby=<sort-order>&format=<format>
 32+
 33+Low Level Layer: Examples and Tips
 34+================
 35+For Now Only Basic Authentication is supported
 36+----------------
 37+
 38+::
 39+
 40+ from rtkit import RTResource, set_logging, RTResourceError
 41+ import logging
 42+
 43+ set_logging('debug')
 44+ logger = logging.getLogger('rtkit')
 45+
 46+ resource = RTResource('http://<HOST>/REST/1.0/', (<USER>, <PWD>))
 47+
 48+Create ticket
 49+----------------
 50+
 51+::
 52+
 53+ message = 'My useless\ntext on\nthree lines.'
 54+ content = {
 55+ 'Queue': 1,#'', 2
 56+ 'Subject' : 'New Ticket',
 57+ 'Text' : message.replace('\n', '\n '),
 58+ }
 59+ try:
 60+ response = resource.post(path='ticket/new', payload=content,)
 61+ logger.info(response.parsed)
 62+ except RTResourceError as e:
 63+ logger.error(e.response.status_int)
 64+ logger.error(e.response.status)
 65+ logger.error(e.response.parsed)
 66+
 67+::
 68+
 69+ #OK
 70+ [DEBUG] POST ticket/new
 71+ [DEBUG] {'Content-Type': 'application/x-www-form-urlencoded', 'Accept': 'text/plain', 'User-Agent': 'pyRTkit/0.0.1'}
 72+ [DEBUG] u'content=Queue: 1\nText: My useless\n text on\n three lines.\nSubject: New Ticket\n'
 73+ [INFO] HTTP_STATUS: 200 OK
 74+ [DEBUG] 'RT/3.8.10 200 Ok\n\n# Ticket 17 created.\n\n'
 75+ [INFO] RESOURCE_STATUS: 200 Ok
 76+ [INFO] [[('id', 'ticket/17')]]
 77+
 78+::
 79+
 80+ #MISSING OR MISSPELLED QUEUE
 81+ [DEBUG] POST ticket/new
 82+ [DEBUG] {'Content-Type': 'application/x-www-form-urlencoded', 'Accept': 'text/plain', 'User-Agent': 'pyRTkit/0.0.1'}
 83+ [DEBUG] u'content=Queue: \nText: My useless\n text on\n three lines.\nSubject: New Ticket\n'
 84+ [INFO] HTTP_STATUS: 200 OK
 85+ [DEBUG] 'RT/3.8.10 200 Ok\n\n# Could not create ticket.\n# Could not create ticket. Queue not set\n\n'
 86+ [INFO] RESOURCE_STATUS: 400 Could not create ticket. Queue not set
 87+ [ERROR] 400
 88+ [ERROR] 400 Could not create ticket. Queue not set
 89+ [ERROR] []
 90+
 91+::
 92+
 93+ #NO PERMISSION ON QUEUE
 94+ [DEBUG] POST ticket/new
 95+ [DEBUG] {'Content-Type': 'application/x-www-form-urlencoded', 'Accept': 'text/plain', 'User-Agent': 'pyRTkit/0.0.1'}
 96+ [DEBUG] u'content=Queue: 2\nText: My useless\n text on\n three lines.\nSubject: New Ticket\n'
 97+ [INFO] HTTP_STATUS: 200 OK
 98+ [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"
 99+ [INFO] RESOURCE_STATUS: 400 No permission to create tickets in the queue '___Approvals'
 100+ [ERROR] 400
 101+ [ERROR] 400 No permission to create tickets in the queue '___Approvals'
 102+ [ERROR] []
 103+
 104+Read a ticket
 105+----------------
 106+
 107+::
 108+
 109+ try:
 110+ response = resource.get(path='ticket/1')
 111+ for r in response.parsed:
 112+ for t in r:
 113+ logger.info(t) except RTResourceError as e:
 114+ logger.error(e.response.status_int)
 115+ logger.error(e.response.status)
 116+ logger.error(e.response.parsed)
 117+
 118+::
 119+
 120+ #TICKET FOUND
 121+ [DEBUG] GET ticket/1
 122+ [DEBUG] {'Accept': 'text/plain', 'User-Agent': 'pyRTkit/0.0.1'}
 123+ [DEBUG] None
 124+ [INFO] HTTP_STATUS: 200 OK
 125+ [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'
 126+ [INFO] RESOURCE_STATUS: 200 Ok
 127+ [INFO] ('id', 'ticket/1')
 128+ [INFO] ('Queue', 'General')
 129+ [INFO] ('Owner', 'Nobody')
 130+ [INFO] ('Creator', 'pyrtkit')
 131+ [INFO] ('Subject', 'pyrt-create4')
 132+ [INFO] ('Status', 'open')
 133+ [INFO] ('Priority', '5')
 134+ [INFO] ('InitialPriority', '0')
 135+ [INFO] ('FinalPriority', '0')
 136+ [INFO] ('Requestors', '')
 137+ [INFO] ('Cc', '')
 138+ [INFO] ('AdminCc', '')
 139+ [INFO] ('Created', 'Sun Jul 03 10:48:57 2011')
 140+ [INFO] ('Starts', 'Not set')
 141+ [INFO] ('Started', 'Not set')
 142+ [INFO] ('Due', 'Not set')
 143+ [INFO] ('Resolved', 'Not set')
 144+ [INFO] ('Told', 'Wed Jul 06 12:58:00 2011')
 145+ [INFO] ('LastUpdated', 'Thu Jul 07 14:42:32 2011')
 146+ [INFO] ('TimeEstimated', '0')
 147+ [INFO] ('TimeWorked', '25 minutes')
 148+ [INFO] ('TimeLeft', '0')
 149+
 150+::
 151+
 152+ #TICKET NOT FOUND
 153+ [DEBUG] GET ticket/100
 154+ [DEBUG] {'Accept': 'text/plain', 'User-Agent': 'pyRTkit/0.0.1'}
 155+ [DEBUG] None
 156+ [INFO] HTTP_STATUS: 200 OK
 157+ [DEBUG] 'RT/3.8.10 200 Ok\n\n# Ticket 100 does not exist.\n\n\n'
 158+ [INFO] RESOURCE_STATUS: 404 Ticket 100 does not exist
 159+ [ERROR] 404
 160+ [ERROR] 404 Ticket 100 does not exist
 161+ [ERROR] []
 162+
 163+Edit a ticket or ticket's links
 164+----------------
 165+Ticket (or ticket's links) editing hasn't all-or-nothing behaviour; so it's very difficult to capture errors.
 166+For example trying to change Queue to a not admitted one (or to edit an unknown field) RT will return:
 167+
 168+::
 169+
 170+ RT/3.8.10 409 Syntax Error
 171+
 172+ # queue: You may not create requests in that queue.
 173+ # spam: Unknown field.
 174+
 175+ id:
 176+ Subject: Try Edit Ticket
 177+ TimeWorked: 1
 178+ Queue: 2
 179+ Spam: 10
 180+
 181+For now rtkit will raise SyntaxError with the errors list in e.response.parsed
 182+
 183+::
 184+
 185+ [DEBUG] POST ticket/1
 186+ [DEBUG] {'Content-Type': 'application/x-www-form-urlencoded', 'Accept': 'text/plain', 'User-Agent': 'pyRTkit/0.0.1'}
 187+ [DEBUG] u'content=Queue: 2\nSpam: 10\nTimeWorked: 1\nSubject: Try Edit Ticket\n'
 188+ [INFO] HTTP_STATUS: 200 OK
 189+ [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'
 190+ [INFO] RESOURCE_STATUS: 409 Syntax Error
 191+ [ERROR] 409
 192+ [ERROR] 409 Syntax Error
 193+ [ERROR] [[('queue', 'You may not create requests in that queue.'), ('spam', 'Unknown field.')]]
 194+
 195+Comment on a Ticket with Attachments
 196+------------
 197+
 198+Usually your requests will be something like this.
 199+
 200+::
 201+
 202+ try:
 203+ params = {
 204+ 'content' :{
 205+ 'Action' : 'comment',
 206+ 'Text' : 'Comment with attach',
 207+ 'Attachment' : 'x.txt, 140x105.jpg',
 208+ },
 209+ 'attachment_1' : file('x.txt'),
 210+ 'attachment_2' : file('140x105.jpg'),
 211+ }
 212+ response = resource.post(path='ticket/16/comment', payload=params,)
 213+ for r in response.parsed:
 214+ for t in r:
 215+ logger.info(t)
 216+ except RTResourceError as e:
 217+ logger.error(e.response.status_int)
 218+ logger.error(e.response.status)
 219+ logger.error(e.response.parsed)
 220+
 221+References
 222+================
 223+* `Best Practical RT`_
 224+* `Request Tracker Wiki`_
 225+
 226+.. _Best Practical RT: http://bestpractical.com/rt/
 227+.. _Request Tracker Wiki: http://requesttracker.wikia.com/wiki/REST
\ No newline at end of file

Status & tagging log