Dimitri Maziuk wrote:
> Errm... why bother, can't you just post newticket with e.g. curl?
>
Posting via URLs is a bit of a problem as the site has HTTPS encrypted
username/passwords. But is an option I guess. I just have to hard code
a password into the commit script.
> Alan, if you use Postgres for backend, you can inject your tickets directly
> into DB using anything from Java to psql shell. With the default sqlite
> engine, you're limited (AFAIK) to C API or sqlite3 shell.
>
> It looks like to create new ticket you only really need to insert a row into
> ticket table, so something like
> sqlite3 'mytrac.db' 'insert into ticket ...'
> should do the trick. (Disclaimer: ICBW, I haven't tried this myself.)
>
Thanks. This is sounding an interesting approach - I don't have to do
web authentication this way (from the shell script). Thanks for the
lead. I am using sqlite3 and I can see the table structures - there
are actually 'ticket', 'ticket_change', and 'ticket_custom'. However if
I do this (and its safe), then the rest of Trac is not going to mail out
notifications of new tickets etc is it?
However someone else suggested the XmlRpcPlugin. Again, HTTPS posts are
a pain due to authentication, but looking at the XmlRpcPlugin source
code I found a 'create()' method which seems to be along the lines of
what I need - so I am going to try a bit of copy/paste and see if I can
create my first Python program.....
Well, here it is in case anyone is interested for future reference. It
just creates a new ticket (for my specific purpose - its not general
purpose - lots of hard coded strings). So it all seems to be going
OK... so far!
Thanks everyone for their help.
Alan
#!/usr/bin/env python
import trac.ticket.model as model
from trac.ticket.notification import TicketNotifyEmail
from sys import stdin
from sys import argv
from trac.env import open_environment
if len(argv) == 5:
project = argv[1]
summary = argv[2]
description = stdin.read()
committer = argv[3]
reviewer = argv[4]
env = open_environment(project)
t = model.Ticket(env)
t['status'] = 'new'
t['summary'] = summary
t['description'] = description
t['reporter'] = committer
t['owner'] = reviewer
t['type'] = 'commit-review'
t['priority'] = '5 - important'
t['component'] = 'general'
t.insert()
try:
tn = TicketNotifyEmail(env)
tn.notify(t, newticket=True)
except Exception, e:
print "Failure sending notification on creation of ticket #%s:
%s" % (t.
id, e))
else:
print "Usage: %s project summary submitter reviewer" % (argv[0])
print "Full description is read from stdin"
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Trac
Users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/trac-users?hl=en
-~----------~----~----~----~------~----~------~--~---