Redirecting Print Streams

Mike Driscoll kyosohma at
Tue Jun 13 22:21:55 CEST 2006


I am working on a Tkinter GUI that will display software package's install
status. I work for a company that wants to control how software is installed
and where. Anyway, the package installer I am working with currently prints
to a console window for each software package installed. So, if we have 4
packages, it would open 4 windows in sequence. I want it to just print what
it is doing in a Tkinter GUI instead of opening windows, but I cannot figure
out how to redirect the print streams in the custom package installer.

Here is the main module I am trying to redirect data from:

def InstallPack(PackageName):
    """ Installs a software package """
    iniFile = '\\\\%s\\client$\\Packages\\%s\\package.ini' % (serverName,
    print iniFile
    config = section2Dict(iniFile)
    reg = ConnectRegistry(None, HKEY_LOCAL_MACHINE)
    regpath = r"SOFTWARE\MCIS"
    key = OpenKey(reg, regpath, 0, KEY_ALL_ACCESS)
    iniSerial = config['SerialNumber']
        q = QueryValueEx(key, PackageName)
        RegSerial = q[0]
        #print "Package: %s found in Registry!" % PackageName
        if RegSerial == iniSerial:
            print "Package already installed. Installation aborted!"
    except WindowsError:
        # Package not installed

    print 'Installing package: %s' % PackageName
    print 'Description: %s' % config['Description']
    zipPart(PackageName, config['ZipFile'])
    regPart(PackageName, config['RegFile'], config['RegType'])
    SetValueEx(key, PackageName, 0, REG_EXPAND_SZ, iniSerial)

Thanks a lot!

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the Python-list mailing list