Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/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."
- sys.exit(2)
- from trac.env import open_environment
- from trac.ticket import Ticket
- t = Ticket(open_environment(TRAC_ENV))
- desc = ' '.join(sys.argv[1:])
- info = dict(
- status='open',
- owner=os.environ['USER'], reporter=os.environ['USER'],
- description = desc, summary=desc
- )
- t.populate(info)
- num = t.insert()
- if not num:
- print >>sys.stderr, "Ticket not created"
- print >>sys.stder, vals
- sys.exit(1)
- print "Ticket #%d: %s" % (num,desc)
- sys.exit(0) # all is well
Add Comment
Please, Sign In to add comment