Source

berlios / gmailtray / innoexe.py

#!/usr/bin/env python
'''Find InnoSetup executable'''

# Miki Tebeka <miki.tebeka@gmail.com>

from sys import platform

UNINST = r"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall"
ISCC = "ISCC.exe"
INNO = "Inno Setup"
NOT_FOUND = "error: can't find Inno Setup registery key"
LOCK_KEY = "InstallLocation"

if platform == "win32": 
    from _winreg import OpenKey, QueryValueEx, EnumKey, CloseKey, \
            HKEY_LOCAL_MACHINE 
    from itertools import count
    from os.path import join


    key = OpenKey(HKEY_LOCAL_MACHINE, UNINST)
    next = count(0).next

    # Find unistall key
    while 1:
        try:
            keyname = EnumKey(key, next())
            if INNO in keyname:
                break
        except WindowsError: # Passed last one
            raise SystemExit(NOT_FOUND)

    CloseKey(key)
    key = OpenKey(HKEY_LOCAL_MACHINE, UNINST + "\\" + keyname)
    # Get install directory
    value, type = QueryValueEx(key, LOCK_KEY)
    CloseKey(key)

    # Print full path to compiler
    print join(value, ISCC)

    raise SystemExit

# Cygwin starts here
from os import popen
UNINST = UNINST.replace("\\", "/")
for line in popen("/bin/regtool list /HKLM/%s" % UNINST):
    if INNO in line:
        break
else:
    raise SystemExit(NOT_FOUND)
keyname = line.strip()
path = popen("/bin/regtool get '/HKLM/%s/%s/%s'" % \
        (UNINST, keyname, LOCK_KEY)).read().strip()
path += ISCC
print popen("/bin/cygpath -au '%s'" % path).read().strip()
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.