How to quickly add tickets in Trac?


It's very painful to add multiple tickets to Trac or to have it as your own todo list. That causes people to use their own task management tools so tasks are then spread all around.

Is there any plugin or macro that would quicken the process of adding a ticket?

Best Solution

The following allows you to type a quick note. The note becomes a Trac ticket, assigned to yourself. I use this for very quick bugs and/or features I don't want to forget. Or, if I make up a feature I open then close a ticket for it, so I get full credit :) - j

#!/usr/bin/env python

trac-bug: add bug/feature to current Trac project, from the command line.
Specify Trac project directory in TRAC_ENV environment variable.

import os, sys

TRAC_ENV = os.environ.get('TRAC_ENV') or os.path.expanduser('~/trac/projectenv')
if not os.path.isdir(TRAC_ENV):
    print >>sys.stderr, "Set TRAC_ENV to the Trac project directory."

from trac.env import open_environment
from trac.ticket import Ticket
t = Ticket(open_environment(TRAC_ENV))

desc = ' '.join(sys.argv[1:])
info = dict(
    owner=os.environ['USER'], reporter=os.environ['USER'],
    description = desc, summary=desc

num = t.insert()
if not num:
    print >>sys.stderr, "Ticket not created"
    print >>sys.stder, vals

print "Ticket #%d: %s" % (num,desc)
sys.exit(0)                 # all is well

Usage is brief:

$ trac-bug out of beer

Ticket #9: out of beer

Related Question