22 | | == Bugs/Feature Requests == |
23 | | |
24 | | Existing bugs and feature requests for TracCronPlugin are |
25 | | [report:9?COMPONENT=TracCronPlugin here]. |
26 | | |
27 | | If you have any issues, create a |
28 | | [http://trac-hacks.org/newticket?component=TracCronPlugin&owner=t2y new ticket]. |
29 | | |
30 | | == Download == |
31 | | |
32 | | === Lastest release === |
33 | | |
34 | | Current stable release is '''0.3.1''' |
35 | | You can use easy_install or pip to download the latest package into your python environment |
| 23 | == Bugs/Feature Requests |
| 24 | |
| 25 | Existing bugs and feature requests for TracCronPlugin are [report:9?COMPONENT=TracCronPlugin here]. |
| 26 | |
| 27 | If you have any issues, create a [http://trac-hacks.org/newticket?component=TracCronPlugin&owner=t2y new ticket]. |
| 28 | |
| 29 | == Download |
| 30 | |
| 31 | === Lastest release |
| 32 | |
| 33 | Current stable release is '''0.3.1'''. |
| 34 | You can use easy_install or pip to download the latest package into your Python environment: |
49 | | Originally, TracCronPlugin source is hosted in [http://trac-hacks.org/svn/traccronplugin trac-hacks.org svn]. I won't maintain any longer. |
50 | | |
51 | | == Example == |
52 | | |
53 | | My company needed to synchronize trac users with an external account source. The job was done by an ETL but fine tuning of trac user was still done by a our modified version of Trac by clicking on a button on the admin panel that call a well designed API. So instead of manually clicking on the button I searched for a way to automate it. Unfortunately, I did not find any plugin for this and even if I could use a unix cron task or an windows AT command to plane the task, I thought it would be better done inside Trac process. |
54 | | |
55 | | So if you have any function for entry point of a process (I mean trac related process) and you want to plane it as a job, Trac Cron Plugin is for you. |
56 | | |
57 | | Simply create in a module (.py) a class that implements the ICronTask and put it inside the plugins directory. Then you can either trick the trac.ini either comfortably use the dedicated admin panel. |
58 | | |
59 | | === How to write a task === |
60 | | |
61 | | You have to write python class that inherits of ICronTask which code is below: |
| 51 | Originally, TracCronPlugin source is hosted in [http://trac-hacks.org/svn/traccronplugin trac-hacks.org svn], but is no longer maintained there. |
| 52 | |
| 53 | == Example |
| 54 | |
| 55 | Simply create in a module (.py) a class that implements the ICronTask and put it inside the plugins directory. Then you can either modify the trac.ini or use the Trac cron admin panel. |
| 56 | |
| 57 | === Writing a task |
| 58 | |
| 59 | You have to write a Python class that inherits ICronTask: |
114 | | You need to implement the interface and to put the definition of the task inside the '''wake_up''' method |
115 | | |
116 | | === How to install the task === |
117 | | |
118 | | Since tasks are components you just have to put the class definition of your task in a python module in the plugins directory. |
119 | | You can either create a .py file and put it in plugins directory or package the .py file into an eggs you'll leave in plugins directory. |
120 | | |
121 | | TracCronPlugin will show up the task in it administration panel. Enjoy ! |
122 | | |
123 | | == Configuration == |
| 112 | You need to implement the interface and to put the definition of the task inside the '''wake_up''' method. |
| 113 | |
| 114 | === Installing a task |
| 115 | |
| 116 | Since tasks are components you just have to put the class definition of your task in a Python module in the plugins directory. |
| 117 | You can either create a .py file and put it in the plugins directory. Alternatively you can package the .py file into an egg and leave it in plugins directory. |
| 118 | |
| 119 | TracCronPlugin will show up the task in the administration panel. |
| 120 | |
| 121 | == Configuration |
160 | | This key control the interval between each wake up of the ticker. The ticker thread periodically wake up to see if there is task to execute. Then the ticker thread go sleep for the amount of minutes specified by this key. You should not have modify this value except if you have system load issue. Default value is '''1'''. |
161 | | |
162 | | |
163 | | === Task setting === |
164 | | |
165 | | For each task loaded by Trac Component manager, Trac Cron Plugin have those parameters. Let's look at hear beat task: |
166 | | |
167 | | ==== Enable/Disable a task ==== |
168 | | |
| 158 | This key control the interval between each wake up of the ticker. The ticker thread periodically wakes up to see if there is task to execute. Then the ticker thread go sleep for the amount of minutes specified by this key. You should not have modify this value, except if you have system load issue. Default value is '''1'''. |
| 159 | |
| 160 | === Task settings |
| 161 | |
| 162 | For each task loaded by the Trac Component manager, Trac Cron Plugin have those parameters. Let's look at a heart beat task. |
| 163 | |
| 164 | ==== Enabling and disabling a task |
175 | | This is the second way to enable or disable a task. Since ''ticker_enabled'' is global and so all task will be affected, this key only affect one task. If False, whatever schedule the task have, no one will be triggered, so this is a way to disable a task while keep all the schedule in place for the time you will enable the task. Default is '''True'''. |
176 | | |
177 | | |
178 | | ==== Task scheduling ==== |
| 171 | This is the second way to enable or disable a task. Since ''ticker_enabled'' is global and so all tasks will be affected, this key only affects one task. If False, whatever schedule the task has, not one will be triggered, so this is a way to disable a task while keeping the schedule in place for the time you will enable the task. Default is '''True'''. |
| 172 | |
| 173 | ==== Task scheduling |
222 | | ==== Pass argument to a task ==== |
223 | | |
224 | | You can pass arguments to the task on a per schedule basis. Here an example for daily schedule: |
225 | | |
226 | | {{{ |
227 | | #!ini |
228 | | hear_beat_daily.arg = Good Morging |
229 | | }}} |
230 | | |
231 | | When the daily schedule triggers the task, the value of the key is passed to the '''wake_up''' call. Parameters can be coma separated multiple value. Default is '''empty''' |
232 | | |
233 | | == Bundled Task == |
234 | | |
235 | | Besides the HearBeat task provided for testing purpose, TracCronPlugin comes with the following useful task. |
236 | | |
237 | | === sleeping_ticket === |
238 | | |
239 | | This task reminds reporter about orphaned ticket and assigned user about sleeping ticket. An orphaned ticket is a ticket in new status since more than a given amount of day. An email notification is sent to the reporter in such a case. A sleeping ticket is a ticket assigned to an user, but the user either did not accept it or did not touch the ticket(make comment for example) since more than a given amount of day. The assigned user is notified in such a case. The delay is an optional parameter associated with each schedule. Default value is '''3 day'''. |
240 | | |
241 | | === unreachable milestone === |
| 214 | ==== Pass argument to a task |
| 215 | |
| 216 | You can pass arguments to the task on a per schedule basis. Here an example for a daily schedule: |
| 217 | |
| 218 | {{{ |
| 219 | #!ini |
| 220 | hear_beat_daily.arg = Good Morning |
| 221 | }}} |
| 222 | |
| 223 | When the daily schedule triggers the task, the value of the key is passed to the '''wake_up''' call. Parameters can be comma separated values. Default is '''empty'''. |
| 224 | |
| 225 | == Bundled Task |
| 226 | |
| 227 | Besides the HeartBeat task provided for testing purposes, TracCronPlugin comes with the following useful tasks. |
| 228 | |
| 229 | === sleeping_ticket |
| 230 | |
| 231 | This task reminds the reporter about orphaned tickets and the assigned user about sleeping ticket. An orphaned ticket is a ticket in new status since more than a given amount of day. An email notification is sent to the reporter in such a case. A sleeping ticket is a ticket assigned to an user, but the user either did not accept it or did not touch the ticket(make comment for example) since more than a given amount of day. The assigned user is notified in such a case. The delay is an optional parameter associated with each schedule. Default value is '''3 day'''. |
| 232 | |
| 233 | === unreachable milestone |
| 234 | |
272 | | === Auto postpone task === |
273 | | |
274 | | '''note''': since 0.2dev_r9390 |
275 | | |
276 | | Trac allow the administrator to postpone still opened ticket in a given milestone when he close a this milestone. But this is not mandatory. The auto postpone task will help to not forget opened tickets in closed milestone. The task look for such tickets and postpone them in the more recent still opened milestone (milestone must have a due date) |
277 | | |
278 | | === Ticket deadline task === |
279 | | |
280 | | '''note''': since 0.3 |
281 | | |
282 | | This task notify to ticket's reporter and owner when its ticket is near the deadline as a custom field. You can add date field for ticket using [http://trac-hacks.org/wiki/DateFieldPlugin DateFieldPlugin]. Besides scheduler settings, there are 3 options to configure when DateFieldPlugin is used. |
| 265 | === Auto postpone task |
| 266 | |
| 267 | '''Note''': since 0.2dev_r9390 |
| 268 | |
| 269 | Trac allow the administrator to postpone still opened ticket in a given milestone when he closes this milestone. But this is not mandatory. The auto postpone task will help to not forget opened tickets in closed milestone. The task look for such tickets and postpone them in the more recent still opened milestone. Milestone must have a due date. |
| 270 | |
| 271 | === Ticket deadline task |
| 272 | |
| 273 | '''Note''': since 0.3 |
| 274 | |
| 275 | This task notify to ticket's reporter and owner when its ticket is near the deadline as a custom field. You can add a date field for ticket using [http://trac-hacks.org/wiki/DateFieldPlugin DateFieldPlugin]. Besides scheduler settings, there are the following options to configure when DateFieldPlugin is used: |
367 | | == Bundled Listener == |
368 | | |
369 | | === Email notification of task event === |
370 | | |
371 | | This listener notify by email about task execution. You can choose the number of event sent by email by setting the value of ''email_task_event.limit''. When the listener has received at least the number of task execution,it will send the mail. Default is '''1'''. The value of ''email_task_event.recipient'' '''must''' be filled otherwise no mail will be sent. |
372 | | |
373 | | Here the configuration for this listener |
| 360 | == Bundled Listener |
| 361 | |
| 362 | === Email notification of task event |
| 363 | |
| 364 | This listener notify by email about task execution. You can choose the number of event sent by email by setting the value of ''email_task_event.limit''. When the listener has received at least the number of task execution, it will send the mail. Default is '''1'''. The value of ''email_task_event.recipient'' '''must''' be filled, otherwise no mail will be sent. |
| 365 | |
| 366 | Here is the configuration for this listener: |
| 367 | |