Ticket #102 (closed defect: fixed)

Opened 3 years ago

Last modified 10 months ago

popen2.Popen3() does not exist on Windows

Reported by: gotoh@taiyo.co.jp Assigned to: pkropf
Priority: normal Component: GraphvizPlugin
Severity: major Keywords: windows
Cc: kilian.cavalotti@lip6.fr Trac Release: 0.8

Description

On windows python 2.3 does not have popen2.Popen3(), so plugin cannot invoke graphviz commands. For temporary workaround, I'm using following patch but is not correct fix because it cannot handle exit code.

Index: graphviz/graphviz.py
===================================================================
--- graphviz/graphviz.py	(revision 198)
+++ graphviz/graphviz.py	(working copy)
@@ -344,15 +344,13 @@
 
     def launch(self, cmd, input):
         """Launch a process (cmd), and returns exitcode, stdout + stderr"""
-        p = popen2.Popen3(cmd, capturestderr=1)
+        p = popen2.popen3(cmd)
         if input:
-            p.tochild.writelines(input)
-        p.tochild.close()
-        out = p.fromchild.read()
-        err = p.childerr.read()
-        ret = p.wait()
-        if os.name == "posix":
-            ret = ret >> 8
+            p[1].writelines(input)
+        p[1].close()
+        out = p[0].read()
+        err = p[2].read()
+	ret = 0;
         return ret, out, err
 
 

Attachments

Change History

12/16/05 16:30:01 changed by anonymous

  • status changed from new to closed.
  • resolution set to fixed.

Fixed in v0.5 release.

12/16/05 16:55:16 changed by kilian

  • cc set to kilian.cavalotti@lip6.fr.
  • status changed from closed to reopened.
  • resolution deleted.

Just a quick comment on Peter's fix in v0.5 : currently rsvg is kind enough to not display anything on stdout if no error occured, but that's not the case of otherpotential rasterizers, such as inkscape, which is verbose by default, even on success. So I guess checking len(stdout) could lead to false errors if rsvg output policy changes. Is there really no way to check exit codes under Windows?

12/16/05 17:31:41 changed by pkropf

Oh yeah, no doubt, this is not a great way of determining if a subprocess was successful. However, it works. At least for now ;-)

The most obvious way that I see to make things better is to create a platform specific launch methods. On Unix, it behaves as the previous version using popen2.Popen3. On windows it would use win32process. This means that there would be an additional requirement for GraphvizPlugin, the win32 extensions.

Another possibility is to use the process module from http://starship.python.net/crew/tmick/. But I don't have much experience with it.

Regardless, I'm open to suggestions for making the code more robust...

01/03/06 06:02:51 changed by athomas

Would win32pipe be usable for this?

03/18/08 12:29:58 changed by pkropf

  • release set to 0.8.
  • status changed from reopened to closed.
  • resolution set to fixed.

The Graphviz v0.7.x code now uses the subprocess module to run and communicate with the Graphviz programs.


Add/Change #102 (popen2.Popen3() does not exist on Windows)




Change Properties
Action