]> snippets.scripts.mit.edu Git - Scripts/git/.git/blame - TracZephyrPlugin/ZephyrPlugin.py
Add apt-zephyr hook.
[Scripts/git/.git] / TracZephyrPlugin / ZephyrPlugin.py
CommitLineData
76e24b1f
EB
1from trac.core import *
2from trac.ticket import ITicketChangeListener
6ae9f02e 3import subprocess
76e24b1f
EB
4import textwrap
5
6class ZephyrPlugin(Component):
cace67b2
EB
7 implements(ITicketChangeListener)
8
9 def zwrite(self, id, message):
10 zclass = self.config.get('ZephyrPlugin', 'class')
11 if zclass == '':
12 return
13 p = subprocess.Popen(['zwrite', '-q', '-l', '-d',
14 '-c', zclass,
15 '-i', 'trac-#%s' % id],
16 stdin=subprocess.PIPE)
606dbf12 17 p.stdin.write(message.encode('utf-8', 'replace'))
cace67b2
EB
18 p.stdin.close()
19 p.wait()
20
21 def ticket_created(self, ticket):
606dbf12
EB
22 message = "%s filed a new ticket:\n%s\n\n%s" % (ticket['reporter'],
23 ticket['summary'],
24 textwrap.fill(ticket['description'][:255]))
cace67b2
EB
25 self.zwrite(ticket.id, message)
26
27 def ticket_changed(self, ticket, comment, author, old_values):
28 if old_values.has_key('status'):
29 if ticket['status'] == 'closed':
30 message = "%s closed ticket as %s\n(%s)" % (author, ticket['resolution'], ticket['summary'])
31 else:
32 message = "%s set status to %s\n(%s)" % (author, ticket['status'], ticket['summary'])
33 else:
34 message = "%s updated this ticket\n(%s)" % (author, ticket['summary'])
35 self.zwrite(ticket.id, message)
36
37 def ticket_deleted(self, ticket):
38 pass