|Version 8 (modified by tst, 9 years ago) (diff)|
Trac and SlimTimer integration
Table of Contents
Provides some rudimentary support for:
- creating SlimTimer tasks from trac tickets;
- setting hours in trac tickets (such as the 'totalhours' field of the TimingAndEstimationPlugin) based on SlimTimer data; and
- backing up SlimTimer data to an external database.
The plugin allows a group of users to be defined by trac username and SlimTimer login providing some basic group sharing of SlimTimer tasks.
There are two parts to its operation: synchronisation and reporting.
When a trac ticket enters the assigned state (i.e. it is accepted by someone), TracSlimTimer creates a corresponding task in SlimTimer. The ID of the SlimTimer task is then recorded with the trac ticket (as a custom field).
The operation is shown below.
More generally, synchronisation occurs when:
- a ticket is assigned. Note that it is not just sufficient to put a name in the "assigned to" field. The assigned person also needs to accept the ticket before it enters the assigned state. Until then the ticket is in the "new" state.
- a ticket is closed.
- a ticket is reopened.
- a ticket is deleted.
- any of the following fields is changed while the ticket is in the assigned or reopened state:
The following synchronisation is performed:
- When tickets are assigned or reopened a corresponding task in SlimTimer is created if it does not already exist.
- When a SlimTimer task is created the SlimTimer ID is stored in a custom field of the trac ticket.
- When a ticket is closed in trac the corresponding task is marked as complete in SlimTimer.
- When a ticket is reopened in trac the corresponding task is marked as incomplete in SlimTimer.
- When a ticket is deleted in trac the corresponding task is marked as complete in SlimTimer.
- The name of the SlimTimer task is composed of the trac ticket ID followed by the trac summary, e.g. " #40: Plan & co-ordinate 0.4 release"
- The tags of the SlimTimer task will include the trac milestone and keywords.
- The coworkers of the SlimTimer task will include all the users configured in the TracSlimTimer module who have the "default CC/coworker" property selected and any users listed in trac's CC field.
- The total hours recorded in SlimTimer are stored in the trac ticket using the custom field 'totalhours' (for compatibility with the TimingAndEstimationPlugin)
The second function of TracSlimTimer is to collect all the SlimTimer data for the configured users and record it in a separate data store. This provides a backup of the SlimTimer data and allows reporting for a whole group of users.
The operation is shown below.
Currently only MySQL is supported as a database. From MySQL the user can perform their own reporting (e.g. using Excel via MyODBC or some web-reporting tool.)
Not all users will require this function and it is possible to operate TracSlimTimer without a database.
If you're looking for screenshots, see Examples below.
This plugin will currently only work with trac 0.10. This is because:
- ITicketChangeListener is used so it will not work with 0.9
- Only ClearSilver templates are provided so it will not work with Genshi.
Some of the code has been written so that it might just work with 0.11 and Genshi if the templates were provided. For example, there is code in admin_ui.py to use the alternate IAdminPageProvider vs IAdminPageProvider templates but it is entirely untested. (This code is courtesy of http://svn.edgewall.com/repos/trac/sandbox/spam-filter/tracspamfilter/admin.py)
- Install the plugin. If you want to run it from source you might use something like,
/opt/trac/0.10.3/install/bin/python setup.py develop -md /var/trac/0.10.3/var/trac/plugins
Otherwise you can can make the egg and use easy_install. e.g.
/opt/trac/0.10.3/install/bin/python setup.py bdist_egg
Then run /opt/trac/0.10.3/install/bin/easy_install <egg> where <egg> is whatever got dumped in your dist directory.
You might have some trouble with dependencies. If you do check below under Dependencies below.
- Enable the plugin in trac.ini. For example, in /var/trac/0.10.3/var/trac/conf/trac.ini. you should add tracslimtimer.* = enabled under [components], e.g.
... [components] ... tracslimtimer.* = enabled
- Upgrade (setup) the environment for the plugin by running trac-admin, e.g.
/opt/trac/0.10.3/install/bin/trac-admin /var/trac/0.10.3/var/trac upgrade
This adds the slimtimer_id custom ticket field. If you skip this step you'll probably get an error in the error.log (see below for more information on troubleshooting).
[Tue Apr 24 12:50:34 2007] [error] [client 10.0.10.177] PythonHandler trac.web.modpython_frontend: TracError: The Trac Environment needs to be upgraded. Run trac-admin /var/trac/0.10.3/var/trac upgrade", referer: ...
- Restart the trac server, e.g.
If you have trouble with installation it may well be because of the dependencies. There are two dependencies: ElementTree and !MySQL-python aka MySQLdb.
The main dependency of is ElementTree. It is listed as a dependency in setup.py file so if you're lucky simply installing the egg might result in the ElementTree module being downloaded. Chances are though you will have trouble here. The best option is just to easy_install it.
You can learn all about easy_install at: http://peak.telecommunity.com/DevCenter/EasyInstall
Make sure you use trac's version of easy_install, e.g.
Running this version of easy_install will mean the packages are installed in the appropriate site-packages folder so trac's version of Python can find them.
So just try something like:
After installing, you'll need to restart the trac server. This can be done like so:
The other dependency is !MySQL-python. This module can also be installed using easy_install and implements the Python DB-API for MySQL.
NOTE: The latest version of MySQL-python that is compatible with Python 2.3 does not support the authentication protocol used by some MySQL servers. You must use at least Python 2.4 so that you can use the most recent version of MySQL-python.
1. Just disable the plugin
If you run in to trouble the easiest thing to do so you can keep working is just to disable the TracSlimTimer plugin. Go to the admin page in trac, Plugins, TracSlimTimer 0.1.0. Then untick the "Enable" box next to each component (although it is probably only the TracSlimTimerTicketChangeListener component that will get in your way). Select "Apply Changes" and restart trac.
2. Inspect the logs
If you actually want to fix the problem you should start with the logs:
- /var/trac/0.10.3/log/httpd/trac.log — This is usually the most helpful log. You can set the logging level to 'debug' under the Administration page (see 'General', 'Logging'). The TracSlimTimer plugin writes quite a few things to this log so it's worth a look.
- /var/trac/0.10.3/log/httpd/error.log — Sometimes errors show up here. I think these are mostly errors encountered while loading plugins like syntax errors.
3. But I've got nothing
I came across one occasion where the whole web server would just crash with no log, nothing, just a seg fault. The problem seemed to be that Apache's version of expat (1.95.7) was conflicting with Python's (1.95.8). It would happen whenever a module was loaded that used expat (e.g. elementtree and I think genshi too). The solution was simply to upgrade the system (and also Apache's) expat to 1.95.8. See this article for details.
So you've changed the code and yet you're still getting the problem? I don't know how Python/trac's caching works but often it doesn't reload the file properly. One way to ensure the file is reloaded is to restart trac:
Summary of important paths
On my setup here are the places to look:
/opt/trac/0.10.3/install/bin — trac's version of Python, easy_install etc.
/var/trac/0.10.3/var/trac/plugins — trac plugins (eggs)
/var/trac/0.10.3/var/trac/conf — trac configuration (including trac.ini and TracSlimTimer's users.xml)
/var/trac/0.10.3/log/httpd — trac logs (and logs from the module)
/var/trac/0.10.3/log/time_report.log — reporting module log
/opt/trac/0.10.3/install/etc/init.d/httpd restart — The command to restart trac (including Apache)
A brief overview of the code is available in the developers guide.
If you have any issues, create a new ticket.
Download the zipped source from [download:tracslimtimerplugin here].
- 12095 by rjollos on 2012-10-02 19:56:38
Refs #10248: Branching for Trac 0.11 and later. Copied 0.10 directory to branches/0.10. Moved 0.10 directory to trunk.
- 11915 by rjollos on 2012-08-09 21:01:33
Fixes #1904: Fixed incorrect package_data specification. Thanks to Paolo Caravello for the patch.
- 2206 by tst on 2007-04-27 09:20:33
Added time tracking schema.