Opened 12 years ago

Closed 10 years ago

#102 closed defect (fixed)

popen2.Popen3() does not exist on Windows

Reported by: gotoh@… Owned by: Peter Kropf
Priority: normal Component: GraphvizPlugin
Severity: major Keywords: windows
Cc: kilian.cavalotti@… Trac Release: 0.8


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/

    345345    def launch(self, cmd, input):
    346346        """Launch a process (cmd), and returns exitcode, stdout + stderr"""
    347         p = popen2.Popen3(cmd, capturestderr=1)
     347        p = popen2.popen3(cmd)
    348348        if input:
    349             p.tochild.writelines(input)
    350         p.tochild.close()
    351         out =
    352         err =
    353         ret = p.wait()
    354         if == "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;
    356354        return ret, out, err

Attachments (0)

Change History (5)

comment:1 Changed 12 years ago by anonymous

Resolution: fixed
Status: newclosed

Fixed in v0.5 release.

comment:2 Changed 12 years ago by kilian

Cc: kilian.cavalotti@… added; anonymous removed
Resolution: fixed
Status: closedreopened

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 12 years ago by Peter Kropf

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 But I don't have much experience with it.

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

comment:4 Changed 12 years ago by Alec Thomas

Would win32pipe be usable for this?

comment:5 Changed 10 years ago by Peter Kropf

Resolution: fixed
Status: reopenedclosed
Trac Release: 0.8

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

Modify Ticket

Change Properties
Set your email in Preferences
as closed The owner will remain Peter Kropf.
The resolution will be deleted.

Add Comment

E-mail address and name can be saved in the Preferences.

Note: See TracTickets for help on using tickets.