Python-Redmine¶
Python-Redmine is a library for communicating with a Redmine project management application. Redmine exposes some data via REST API for which Python-Redmine provides a simple but powerful Pythonic API inspired by a well-known Django ORM:
>>> from redminelib import Redmine >>> redmine = Redmine(‘http://demo.redmine.org’, username=‘foo’, password=‘bar’) >>> project = redmine.project.get(‘vacation’) >>> project.id 30404 >>> project.identifier ‘vacation’ >>> project.created_on datetime.datetime(2013, 12, 31, 13, 27, 47) >>> project.issues >>> project.issues[0] >>> dir(project.issues[0]) [‘assigned_to’, ‘author’, ‘created_on’, ‘description’, ‘done_ratio’, ‘due_date’, ‘estimated_hours’, ‘id’, ‘priority’, ‘project’, ‘relations’, ‘start_date’, ‘status’, ‘subject’, ‘time_entries’, ‘tracker’, ‘updated_on’] >>> project.issues[0].subject ‘Vacation’ >>> project.issues[0].time_entries
Features¶
- Supports 100% of Redmine API
- Supports external Redmine plugins API
- Supports Python 3.7 — 3.11 and PyPy3
- Supports different request engines
- Extendable via custom resources and custom request engines
- Extensively documented
- Provides ORM-style Pythonic API
- And many more…
Contacts and Support¶
Support for Standard Edition is provided via GitHub only, while support for Pro Edition is provided both via GitHub and support @ python-redmine . com. Be sure to write from email that was specified during the purchase procedure.
Copyright and License¶
Python-Redmine Standard Edition is licensed under Apache 2.0 license. Python-Redmine Pro Edition is licensed under the Python-Redmine Pro Edition 1.0 license. Check the License for details.
Table of contents¶
- Editions
- Standard Edition
- Pro Edition
- Dependencies
- Standard Edition
- PyPI
- GitHub
- Redmine
- Parameters
- Location
- Version
- Authentication
- Impersonation
- DateTime Formats
- Timezone
- Exception Control
- Connection Options
- Request Engines
- Custom Resources
- Operations
- create
- read
- update
- delete
- Introspection
- Export
- Refresh
- Url
- Limit/Offset
- Export
- Methods
- Attributes
- Redmine
- Issue
- Project
- Project Membership
- User
- Time Entry
- News
- Issue Relation
- Version
- Wiki Page
- Query
- File
- Attachment
- Issue Status
- Tracker
- Enumeration
- Issue Category
- Role
- Group
- Custom Field
- Contact
- Contact Tag
- Note
- Deal
- Deal Status
- Deal Category
- CRM Query
- Ticket
- Checklist
- Invoice
- Invoice Payment
- Expense
- Product
- Product Category
- Order
- Order Status
- Request Engines
- Engines
- Session
- Custom Engine
- Existing Resources
- Creation
- Name
- Methods and Attributes
- Upload
- Download
- Create/Update/Delete resource operations don’t work
- Can I use Python-Redmine with ChiliProject fork
- BaseRedmineWarning
- PerformanceWarning
- BaseRedmineError
- ResourceError
- NoFileError
- FileObjectError
- ResourceNotFoundError
- ConflictError
- AuthError
- ImpersonateError
- ServerError
- RequestEntityTooLargeError
- UnknownError
- ValidationError
- ResourceSetIndexError
- ResourceSetFilterLookupError
- ResourceBadMethodError
- ResourceFilterError
- ResourceNoFiltersProvidedError
- ResourceNoFieldsProvidedError
- ResourceAttrError
- ReadonlyAttrError
- VersionFormatError
- VersionMismatchError
- ResourceVersionMismatchError
- ResultSetTotalCountError
- CustomFieldValueError
- ResourceRequirementsError
- FileUrlError
- ForbiddenError
- JSONDecodeError
- ExportNotSupported
- ExportFormatNotSupportedError
- HTTPProtocolError
- TimezoneError
- EngineClassError
- Standard Edition
- Pro Edition
- 2.5.0 (XXXX-XX-XX)
- 2.4.0 (2023-01-18)
- 2.3.0 (2020-05-21)
- 2.2.1 (2019-02-28)
- 2.2.0 (2019-01-13)
- 2.1.1 (2018-05-02)
- 2.1.0 (2018-05-02)
- 2.0.2 (2017-04-19)
- 2.0.1 (2017-04-10)
- 2.0.0 (2017-04-10)
- 1.5.1 (2016-03-27)
- 1.5.0 (2015-11-26)
- 1.4.0 (2015-10-18)
- 1.3.0 (2015-10-18)
- 1.2.0 (2015-07-09)
- 1.1.2 (2015-05-20)
- 1.1.1 (2015-03-26)
- 1.1.0 (2015-02-20)
- 1.0.3 (2015-02-03)
- 1.0.2 (2014-11-13)
- 1.0.1 (2014-09-23)
- 1.0.0 (2014-09-22)
- 0.9.0 (2014-09-11)
- 0.8.4 (2014-08-08)
- 0.8.3 (2014-08-01)
- 0.8.2 (2014-05-27)
- 0.8.1 (2014-04-02)
- 0.8.0 (2014-03-27)
- 0.7.2 (2014-03-17)
- 0.7.1 (2014-03-14)
- 0.7.0 (2014-03-12)
- 0.6.2 (2014-03-09)
- 0.6.1 (2014-02-27)
- 0.6.0 (2014-02-19)
- 0.5.0 (2014-02-09)
- 0.4.0 (2014-02-08)
- 0.3.1 (2014-01-23)
- 0.3.0 (2014-01-18)
- 0.2.0 (2014-01-16)
- 0.1.1 (2014-01-10)
- 0.1.0 (2014-01-09)
Using the REST API with Python¶
Python-Redmine is a library which supports 100% features of Redmine’s REST API. It provides a simple but powerful Pythonic API inspired by a well-known Django ORM and is thoroughly tested. Example:
>>> from redminelib import Redmine >>> redmine = Redmine('http://demo.redmine.org', username='foo', password='bar') >>> project = redmine.project.get('vacation') >>> project.id 30404 >>> project.identifier 'vacation' >>> project.created_on datetime.datetime(2013, 12, 31, 13, 27, 47) >>> project.issues redminelib.resultsets.ResourceSet object with Issue resources> >>> project.issues[0] redminelib.resources.Issue #34441 "Vacation"> >>> dir(project.issues[0]) ['assigned_to', 'author', 'created_on', 'description', 'done_ratio', 'due_date', 'estimated_hours', 'id', 'priority', 'project', 'relations', 'start_date', 'status', 'subject', 'time_entries', 'tracker', 'updated_on'] >>> project.issues[0].subject 'Vacation' >>> project.issues[0].time_entries redminelib.resultsets.ResourceSet object with TimeEntry resources>
PyRedmineWS example:¶
Suppose Eric fell ill and was out for several days. You need to crawl through the project called Parrot and move any due date for issues assigned to Eric out by two more weeks.
The dateutil library contains a handy method called relativedelta for calculating relative dates.
# Import the Redmine class from redmine import Redmine from dateutil.relativedelta import relativedelta server = Redmine('http://my-server.com', username='Me', password='seakrit') project = server.projects['parrot'] # Find Eric in the user data for u in server.users: if u.firstname == 'Eric' and u.lastname == 'Idle': user = u break else: raise Exception("Didn't find Eric Idle in the user dateabase") # Extend issues in project assigned to user by two weeks for issue in project.issues(assigned_to_id=user.id): if issue.due_date is not None: issue.due_date += relativedelta(weeks=+2) issue.save('Giving Eric more time to complete - he was out ill')
PyActiveResource example:¶
# Importing pyactiveresource from pyactiveresource.activeresource import ActiveResource class Issue(ActiveResource): _site = 'http://redmine.foo.org' _user = 'username' _password = 'password' # Get issues issues = Issue.find() # Get a specific issue, from its id issue = Issue.find(1345) # Issue attributes # Updating an attribute