I modified MyTicketChangeScriptCaller.py and here it is now:
> from subprocess import Popen
> from trac.core import *
> from trac.config import Option
> from trac.ticket import ITicketChangeListener
> class TicketChangeScript(Component):
> """ Calling a script file on ticket changes."""
> implements(ITicketChangeListener)
> script = Option('ticket_change_script', 'call', '',
> doc="/usr/local/bin/test.sh")
> # ITicketChangeListener Interface
> def ticket_created(self, ticket):
> self._call(ticket, 'created')
> def ticket_changed(self, ticket, comment, author, old_values):
> self._call(ticket, 'modified')
> # def ticket_deleted(self, ticket):
> # # Beware: We may not have all ticket properties here,
> # # just ticket number.
> # self._call(ticket, 'deleted')
> def _call(self, tkt, tkt_change):
> Popen([' '.join([self.script, tkt.id, tkt['summary'],
> tkt_change])], shell=True)
Now I got this error in Trac, after modifying a ticket:
> TypeError: sequence item 1: expected string or Unicode, int found
Any idea how t fix it?
On Tue, Oct 9, 2012 at 8:38 PM, Steffen Hoffmann <[email protected]> wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> On 09.10.2012 09:17, Adelphe Rafanambinana wrote:
> > I check log file and I saw IndentationError. I was able to fix it, and
> > got the plugin loaded.
> > When I changed/created ticket, I got this error in TRAC:
> > NameError: global name 'script' is not defined
> >
> > Then I added
> > global script
> >
> > before this line in MyTicketChangeScriptCaller.py file:
> > script = Option('ticket_change_script', 'call', '',
> > doc="/usr/local/bin/test.sh")
> >
> > Then I got this error:
> > TypeError: sequence item 0: expected string, Option found
> > Any idea how to fix it?
>
> Seems like good progress so far.
>
> Sure, this is just about python classes. And no need for 'global' here.
>
> The Option declaration in the beginning of the class declaration makes
> all defined variables available in the classes context, so you need to call
> script
>
> as
> self.script
>
> in any class method.
>
> Steffen Hoffmann
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.10 (GNU/Linux)
> Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
>
> iEYEARECAAYFAlB0YPUACgkQ31DJeiZFuHdZzQCguItfkYtnakTzDEaBTbc3I1JM
> /ycAn1IqA0EN1RNjgkUE/hNPlc5bY3s2
> =ozfm
> -----END PGP SIGNATURE-----
>
> --
> 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.
>
>
--
Adelphe Rafanambinana
--
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.