]> snippets.scripts.mit.edu Git - Scripts/git/.git/blobdiff - TracZephyrPlugin/ZephyrPlugin.py
TracZephyrPlugin: Escape @ as @@.
[Scripts/git/.git] / TracZephyrPlugin / ZephyrPlugin.py
index 791b6a35a2603bb7d87e366088d8a20154fe9a1c..0f40125be8d2cf7190d6df13cfa346948d547574 100644 (file)
@@ -2,6 +2,7 @@ from trac.core import *
 from trac.ticket import ITicketChangeListener
 import subprocess
 import textwrap
+import shlex
 
 class ZephyrPlugin(Component):
     implements(ITicketChangeListener)
@@ -10,11 +11,14 @@ class ZephyrPlugin(Component):
         zclass = self.config.get('ZephyrPlugin', 'class')
         if zclass == '':
             return
-        p = subprocess.Popen(['zwrite', '-q', '-l', '-d',
-                              '-c', zclass,
+        command = shlex.split(self.config.get('ZephyrPlugin', 'command'))
+        if not command:
+            command = ['zwrite', '-q', '-l', '-d']
+        p = subprocess.Popen(command +
+                             ['-c', zclass,
                               '-i', 'trac-#%s' % id],
                              stdin=subprocess.PIPE)
-        p.stdin.write(message.encode('utf-8', 'replace'))
+        p.stdin.write(message.replace('@', '@@').encode('utf-8', 'replace'))
         p.stdin.close()
         p.wait()