I suggest you take a look at :
http://trac-hacks.org/wiki/PeerReviewPlugin
In particular, check out http://www.blisted.org/wiki/projects/JianCha
Thanks,
Tim
Thanks - I had looked at the code already. My problem is I don't want
an email submission process, I want to create a new ticket from a
command line. I tried to look into the code, but I am not a Python
programmer (yes, I can learn it) and am not familiar with the internal
Trac APIs (which I assume are documented somewhere). I was hoping to
avoid the days of learning a new programming language and new APIs if at
all possible. I was hoping it would only be a few minutes for someone
to do (but days for me) - or if someone knew of such an existing script
in one of the other Trac hacks.
I have browsed through the list several times, but the length of the
list of hacks available does making finding something specific
non-trivial - hence this plea for help!
Thanks for your help,
Alan
Thanks. I had seen the peer review plugin. The comments I had read on
it however did not make it look appealing. (As others have said), I
want something that hooks into the SVN commit process, so the changes
are automatically identified.
I had a look an JianCha (I had not seen that before). It was not clear
to me from the above whether there was an actual implementation yet, or
just specs on how it is going to be done. Looking around I did not get
the impression that it is backed by an active and live community. I
would like something either trivial so we can support it in house, or if
more complex backed by a live community.
I have most of the infrastructure in place already for a simple solution
(borrowed from a mature C++ project in SVN that does not use Trac) - I
am trying to port the same practice to a Trac based Java process. All I
need is to create a ticket from a shell script and its ready for
internal trial. Not knowing Python or the Trac API means writing this is
not a trivial undertaking.
Thanks for the links though - it is appreciated.
Alan
If you know a language that can execute XMLRPC remote command (Perl,
for example), you could use the XmlRpcPlugin to create a ticket with a
very simple API.
Cheers,
Manu
Errm... why bother, can't you just post newticket with e.g. curl?
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.)
Dima
--
Dimitri Maziuk
Programmer/sysadmin
BioMagResBank, UW-Madison -- http://www.bmrb.wisc.edu
This is very bad advice. Never go behind the back of software unless you
have no option. We provide a very rich Python API for local use, and an
XML-RPC system for non-Python or non-local scripting. All the common
languages will have at least one library for XML-RPC (Perl looks to have a
few dozen), so you have no excuse to not use it.
--Noah
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"
Like Noah before me, I also would seriously advise about going this route. It
will effectively mean you are on your own and there are no guarantees your
data will remain intact, that your cat will keep all its hair, that your
girlfriend will not walk out on you and your house burn down. So you've been
warned. :)
You're better off looking at `pydoc trac.ticket.api` and using that API.
--
Jeroen Ruigrok van der Werven <asmodai(-at-)in-nomine.org> / asmodai
イェルーン ラウフロック ヴァン デル ウェルヴェン
http://www.in-nomine.org/ | http://www.rangaku.org/
Agnosco veteris vestigia flammae...
Right so, good advice. While we're on the subject:
I'm using 0.10.4 and I get:
% pydoc trac.ticket.api
Traceback (most recent call last):
File "/usr/bin/pydoc", line 5, in ?
pydoc.cli()
File "/usr/lib/python2.4/pydoc.py", line 2235, in cli
help.help(arg)
File "/usr/lib/python2.4/pydoc.py", line 1689, in help
elif request: doc(request, 'Help on %s:')
File "/usr/lib/python2.4/pydoc.py", line 1475, in doc
pager(title % desc + '\n\n' + text.document(object, name))
File "/usr/lib/python2.4/pydoc.py", line 295, in document
if inspect.ismodule(object): return self.docmodule(*args)
File "/usr/lib/python2.4/pydoc.py", line 1066, in docmodule
contents = [self.formattree(
File "/usr/lib/python2.4/inspect.py", line 590, in getclasstree
for parent in c.__bases__:
TypeError: iteration over non-sequence
Anyone know why?
/L
pydoc unittest.TestSuite
works as expected? (Just want to make sure whether it is pydoc or trac
failing.)
--
Jeroen Ruigrok van der Werven <asmodai(-at-)in-nomine.org> / asmodai
イェルーン ラウフロック ヴァン デル ウェルヴェン
http://www.in-nomine.org/ | http://www.rangaku.org/
Courage is not the absence of fear, but rather the judgment that
something else is more important than fear.
Maintenance, robustness, and many other reasons that make APIs exist ;-)
Cheers,
Manu
Yes indeed, it does, and so does...
% pydoc trac
...but not...
% pydoc trac.ticket
% pydoc trac.ticket.api
I'm not python savvy so I have no clue,
any help appreciated.
/L
That's odd. I just tested it on my FreeBSD box with both 2.4 and 2.5 and I can
pydoc those two module specifications without any hickups.
--
Jeroen Ruigrok van der Werven <asmodai(-at-)in-nomine.org> / asmodai
イェルーン ラウフロック ヴァン デル ウェルヴェン
http://www.in-nomine.org/ | http://www.rangaku.org/
Blessed are the meek, for they shall inherit the earth...
OP specifically stated he didn't want to use existing python API. My
comment was about wrapping RPC call in XML and sending it over HTTP --
it's almost always a waste of cycles and bandwidth.
Personally, I'd learn Python -- we use enough Python software nowadays
I'll pretty much have to, sooner or later -- and it looks like OP is
going that way too.
Dima
> OP specifically stated he didn't want to use existing python API.
My answer was about using another language, ie. similar API, not
related to Python - I was quoting PERL, for example.
No need to learn Python here.
> it's almost always a waste of cycles and bandwidth.
Is this optmization really important on nowadays machines ?
Cheers,
Manu
Yeah, I kinda figured. I did put a disclaimer on that, plus OP sounded smart
enough to understand about reaching into storage tier directly and
bypassing "business logic" layer.
> Is this optmization really important on nowadays machines ?
Yes. Nobody's figured out how to beat the kiss principle yet, and whether
today's focus is on energy consumption, maintenance costs, or whatever, it
always tends to boil down to that in the end. Optimization aside, if all you
want is to send or receive a chunk of data over http, xml is nothing but
overhead. If you want rpc, you probably need things xml-http-rpc doesn't do.
If you look around, most people who use that stuff are the ones who paid
megabucks to oracle/ibm. The rest of us do json mashups over restful API --
so much so that even w3c got off its xml horse, finally.
I don't share the same opinion, but as this thread as really evolved
OOT, let's close it ;-)
Cheers,
Manu