]> sipb.mit.edu Git - snippets/.git/commitdiff
In TracZephyrPlugin: use subprocess instead of os.popen.
authorEvan Broder <broder@mit.edu>
Tue, 31 Mar 2009 19:09:50 +0000 (15:09 -0400)
committerEvan Broder <broder@mit.edu>
Tue, 31 Mar 2009 19:31:40 +0000 (15:31 -0400)
TracZephyrPlugin/ZephyrPlugin.py

index 688749ada13abb9e351c21909aff6e1806c24e2f..317cb0d50aa42b652bef9d75fad823c87d30c460 100644 (file)
@@ -1,6 +1,6 @@
 from trac.core import *
 from trac.ticket import ITicketChangeListener
 from trac.core import *
 from trac.ticket import ITicketChangeListener
-import os
+import subprocess
 import textwrap
 
 class ZephyrPlugin(Component):
 import textwrap
 
 class ZephyrPlugin(Component):
@@ -10,9 +10,13 @@ class ZephyrPlugin(Component):
                zclass = self.config.get('ZephyrPlugin', 'class')
                if zclass == '':
                        return
                zclass = self.config.get('ZephyrPlugin', 'class')
                if zclass == '':
                        return
-               pipe = os.popen('zwrite -q -l -d -c %s -i trac-#%s' % (zclass, id), 'w')
-               pipe.write("\n".join(textwrap.wrap(message)).encode('utf-8', 'replace'))
-               pipe.close()
+                p = subprocess.Popen(['zwrite', '-q', '-l', '-d',
+                                      '-c', zclass,
+                                      '-i', 'trac-#%s' % id],
+                                     stdin=subprocess.PIPE)
+                p.stdin.write("\n".join(textwrap.wrap(message)).encode('utf-8', 'replace'))
+               p.stdin.close()
+                p.wait()
        
        def ticket_created(self, ticket):
                message = "%s filed a new ticket:\n%s\n\n%s" % (ticket['reporter'], ticket['summary'], ticket['description'][:255])
        
        def ticket_created(self, ticket):
                message = "%s filed a new ticket:\n%s\n\n%s" % (ticket['reporter'], ticket['summary'], ticket['description'][:255])