1 from trac.core import *
2 from trac.ticket import ITicketChangeListener
6 class ZephyrPlugin(Component):
7 implements(ITicketChangeListener)
9 def zwrite(self, id, message):
10 zclass = self.config.get('ZephyrPlugin', 'class')
13 command = self.config.get('ZephyrPlugin', 'command').split(' ')
15 command = ['zwrite', '-q', '-l', '-d']
16 p = subprocess.Popen(command +
18 '-i', 'trac-#%s' % id],
19 stdin=subprocess.PIPE)
20 p.stdin.write(message.encode('utf-8', 'replace'))
24 def ticket_created(self, ticket):
25 message = "%s filed a new ticket:\n%s\n\n%s" % (ticket['reporter'],
27 textwrap.fill(ticket['description'][:255]))
28 self.zwrite(ticket.id, message)
30 def ticket_changed(self, ticket, comment, author, old_values):
31 if old_values.has_key('status'):
32 if ticket['status'] == 'closed':
33 message = "%s closed ticket as %s\n(%s)" % (author, ticket['resolution'], ticket['summary'])
35 message = "%s set status to %s\n(%s)" % (author, ticket['status'], ticket['summary'])
37 message = "%s updated this ticket\n(%s)" % (author, ticket['summary'])
38 self.zwrite(ticket.id, message)
40 def ticket_deleted(self, ticket):