Opened 19 years ago
Closed 17 years ago
#102 closed defect (fixed)
popen2.Popen3() does not exist on Windows
Reported by: | Owned by: | Peter Kropf | |
---|---|---|---|
Priority: | normal | Component: | GraphvizPlugin |
Severity: | major | Keywords: | windows |
Cc: | kilian.cavalotti@… | 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.
-
graphviz/graphviz.py
344 344 345 345 def launch(self, cmd, input): 346 346 """Launch a process (cmd), and returns exitcode, stdout + stderr""" 347 p = popen2. Popen3(cmd, capturestderr=1)347 p = popen2.popen3(cmd) 348 348 if input: 349 p.tochild.writelines(input) 350 p.tochild.close() 351 out = p.fromchild.read() 352 err = p.childerr.read() 353 ret = p.wait() 354 if os.name == "posix": 355 ret = ret >> 8 349 p[1].writelines(input) 350 p[1].close() 351 out = p[0].read() 352 err = p[2].read() 353 ret = 0; 356 354 return ret, out, err 357 355 358 356
Attachments (0)
Change History (5)
comment:1 Changed 19 years ago by
Resolution: | → fixed |
---|---|
Status: | new → closed |
comment:2 Changed 19 years ago by
Cc: | kilian.cavalotti@… added; anonymous removed |
---|---|
Resolution: | fixed |
Status: | closed → reopened |
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?
comment:3 Changed 19 years ago by
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...
comment:5 Changed 17 years ago by
Resolution: | → fixed |
---|---|
Status: | reopened → closed |
Trac Release: | → 0.8 |
The Graphviz v0.7.x code now uses the subprocess module to run and communicate with the Graphviz programs.
Fixed in v0.5 release.