cudadog / pydot

Automatically exported from code.google.com/p/pydot
MIT License
0 stars 0 forks source link

find_graphviz() fails on Windows when no registry entry present #29

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Install Graphviz on Windows.
2. If it was created then remove the SOFTWARE\ATT\Graphviz key from the 
registry.
3. import pydot; pydot.find_graphviz()

What is the expected output? What do you see instead?
I would expect the registry check to fail and for the code to fall back to 
checking paths.  Instead, an (C++?) 
exception is raised when calling win32api.RegOpenKeyEx(...).

What version of the product are you using? On what operating system?
pydot 1.0.2, Graphviz 2.22.2 (?) on Windows XP

Please provide any additional information below.

The following alternate "Method 1" for find_graphviz() that uses winreg/_winreg 
appears to work:

    # Method 1 (Windows only)
    #
    if os.sys.platform == 'win32':

        # Get the GraphViz install path from the registry
        #
        try:
            import winreg  # Python 3.0+
        except:
            try:
                import _winreg as winreg  # Python 2.0+
            except:
                winreg = None

        if winreg is not None:
            hkey = winreg.ConnectRegistry(None, winreg.HKEY_LOCAL_MACHINE)

            try:
                gvkey = winreg.OpenKey(hkey, "SOFTWARE\\ATT\\Graphviz", 0, winreg.KEY_READ)

                if gvkey is not None:
                    path = winreg.QueryValueEx(gvkey, "InstallPath")[0]

                    if path is not None:
                        progs = __find_executables(path + os.sep + "bin")
                        if progs is not None :
                            #print "Used Windows registry"
                            return progs
            except:
                pass
            finally:
                winreg.CloseKey(hkey)

Original issue reported on code.google.com by kn...@mac.com on 22 Apr 2009 at 8:07

GoogleCodeExporter commented 9 years ago
FYI: The registry key used by a recent install is:
"SOFTWARE\AT&T Research Labs\Graphviz"

note that 'ATT' has changed to 'AT&T Research Labs'

Original comment by phrrn...@gmail.com on 30 Apr 2009 at 8:58

GoogleCodeExporter commented 9 years ago
Attached is a patch to 1.0.2 that fixes these problems.

Original comment by jubaj...@gmail.com on 15 Jul 2009 at 1:51

Attachments:

GoogleCodeExporter commented 9 years ago
thanks for the patch

Original comment by hans.don...@pobox.com on 19 Jul 2009 at 8:38

GoogleCodeExporter commented 9 years ago
Extra information: Installing Graphviz 2.26.3 on Windows 7 didn't create either 
registry-key. Applying the patch also prevents error for that case.
This issue 29 and issue 35 are releated and could be closed.

Original comment by ndegroot0 on 16 Aug 2010 at 9:54

GoogleCodeExporter commented 9 years ago
Issue 37 has been merged into this issue.

Original comment by ero.carr...@gmail.com on 30 Oct 2010 at 10:31

GoogleCodeExporter commented 9 years ago

Original comment by ero.carr...@gmail.com on 30 Oct 2010 at 10:32

GoogleCodeExporter commented 9 years ago

Original comment by ero.carr...@gmail.com on 31 Oct 2010 at 12:22