Modify

Opened 9 years ago

Closed 7 years ago

#102 closed defect (fixed)

popen2.Popen3() does not exist on Windows

Reported by: gotoh@… Owned by: pkropf
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

     
    344344
    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 = 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;
    356354        return ret, out, err
    357355
    358356

Attachments (0)

Change History (5)

comment:1 Changed 9 years ago by anonymous

  • Resolution set to fixed
  • Status changed from new to closed

Fixed in v0.5 release.

comment:2 Changed 9 years ago by kilian

  • Cc kilian.cavalotti@… added; anonymous removed
  • Resolution fixed deleted
  • Status changed from closed to 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 9 years ago 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...

comment:4 Changed 9 years ago by athomas

Would win32pipe be usable for this?

comment:5 Changed 7 years ago by pkropf

  • Resolution set to fixed
  • Status changed from reopened to closed
  • Trac Release set to 0.8

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

Add Comment

Modify Ticket

Action
as closed The owner will remain pkropf.
The resolution will be deleted. Next status will be 'reopened'.
Author


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

 
Note: See TracTickets for help on using tickets.