Esempio n. 1
0
def FindRegisterPackage(packageName,
                        knownFile,
                        searchPaths,
                        registryAppName=None):
    """Find and Register a package.

       Assumes the core registry setup correctly.

       In addition, if the location located by the package is already
       in the **core** path, then an entry is registered, but no path.
       (no other paths are checked, as the application whose path was used
       may later be uninstalled.  This should not happen with the core)
    """
    import regutil, string
    if not packageName: raise error, "A package name must be supplied"
    corePaths = string.split(regutil.GetRegisteredNamedPath(None), ";")
    if not searchPaths: searchPaths = corePaths
    registryAppName = registryAppName or packageName
    try:
        pathLook, pathAdd = FindPackagePath(packageName, knownFile,
                                            searchPaths)
        if pathAdd is not None:
            if pathAdd in corePaths:
                pathAdd = ""
            regutil.RegisterNamedPath(registryAppName, pathAdd)
        return pathLook
    except error, details:
        print "*** The %s package could not be registered - %s" % (packageName,
                                                                   details)
        print "*** Please ensure you have passed the correct paths on the command line."
        print "*** - For packages, you should pass a path to the packages parent directory,"
        print "*** - and not the package directory itself..."
Esempio n. 2
0
def SetupCore(searchPaths):
    """Setup the core Python information in the registry.

    This function makes no assumptions about the current state of sys.path.

    After this function has completed, you should have access to the standard
    Python library, and the standard Win32 extensions
    """

    import sys

    for path in searchPaths:
        sys.path.append(path)

    import os
    import regutil, win32api, win32con

    installPath, corePaths = LocatePythonCore(searchPaths)
    # Register the core Pythonpath.
    print(corePaths)
    regutil.RegisterNamedPath(None, ";".join(corePaths))

    # Register the install path.
    hKey = win32api.RegCreateKey(regutil.GetRootKey(),
                                 regutil.BuildDefaultPythonKey())
    try:
        # Core Paths.
        win32api.RegSetValue(hKey, "InstallPath", win32con.REG_SZ, installPath)
    finally:
        win32api.RegCloseKey(hKey)

    # Register the win32 core paths.
    win32paths = (
        os.path.abspath(os.path.split(win32api.__file__)[0]) + ";" +
        os.path.abspath(
            os.path.split(LocateFileName("win32con.py;win32con.pyc",
                                         sys.path))[0]))

    # Python has builtin support for finding a "DLLs" directory, but
    # not a PCBuild.  Having it in the core paths means it is ignored when
    # an EXE not in the Python dir is hosting us - so we add it as a named
    # value
    check = os.path.join(sys.prefix, "PCBuild")
    if "64 bit" in sys.version:
        check = os.path.join(check, "amd64")
    if os.path.isdir(check):
        regutil.RegisterNamedPath("PCBuild", check)
Esempio n. 3
0
def SetupCore(searchPaths):
    """Setup the core Python information in the registry.

	   This function makes no assumptions about the current state of sys.path.

	   After this function has completed, you should have access to the standard
	   Python library, and the standard Win32 extensions
	"""

    import sys
    for path in searchPaths:
        sys.path.append(path)

    import string, os
    import regutil, _winreg, win32api

    installPath, corePaths = LocatePythonCore(searchPaths)
    # Register the core Pythonpath.
    print corePaths
    regutil.RegisterNamedPath(None, string.join(corePaths, ";"))

    # Register the install path.
    hKey = _winreg.CreateKey(regutil.GetRootKey(),
                             regutil.BuildDefaultPythonKey())
    try:
        # Core Paths.
        _winreg.SetValue(hKey, "InstallPath", _winreg.REG_SZ, installPath)
    finally:
        _winreg.CloseKey(hKey)
    # The core DLL.


#	regutil.RegisterCoreDLL()

# Register the win32 extensions, as some of them are pretty much core!
# Why doesnt win32con.__file__ give me a path? (ahh - because only the .pyc exists?)

# Register the win32 core paths.
    win32paths = os.path.abspath( os.path.split(win32api.__file__)[0]) + ";" + \
                 os.path.abspath( os.path.split(LocateFileName("win32con.py;win32con.pyc", sys.path ) )[0] )

    suffix = IsDebug()
    ver_str = hex(sys.hexversion)[2] + hex(sys.hexversion)[4]
    FindRegisterModule("pywintypes", "pywintypes%s%s.dll" % (ver_str, suffix),
                       [".", win32api.GetSystemDirectory()])
    regutil.RegisterNamedPath("win32", win32paths)
Esempio n. 4
0
def FindRegisterApp(appName, knownFiles, searchPaths):
    """Find and Register a package.

       Assumes the core registry setup correctly.

    """
    import regutil, string
    if type(knownFiles) == type(''):
        knownFiles = [knownFiles]
    paths = []
    try:
        for knownFile in knownFiles:
            pathLook = FindAppPath(appName, knownFile, searchPaths)
            if pathLook:
                paths.append(pathLook)
    except error as details:
        print("*** ", details)
        return

    regutil.RegisterNamedPath(appName, ";".join(paths))
Esempio n. 5
0
    """
    import regutil, string
    if type(knownFiles) == type(''):
        knownFiles = [knownFiles]
    paths = []
    try:
        for knownFile in knownFiles:
            pathLook = FindAppPath(appName, knownFile, searchPaths)
            if pathLook:
                paths.append(pathLook)
    except error, details:
        print "*** ", details
        return

    regutil.RegisterNamedPath(appName, string.join(paths, ";"))


def FindRegisterPythonExe(exeAlias, searchPaths, actualFileNames=None):
    """Find and Register a Python exe (not necessarily *the* python.exe)

       Assumes the core registry setup correctly.
    """
    import regutil, string
    fname, ok = FindPythonExe(exeAlias, actualFileNames, searchPaths)
    if not ok:
        regutil.RegisterPythonExe(fname, exeAlias)
    return fname


def FindRegisterHelpFile(helpFile, searchPaths, helpDesc=None):
Esempio n. 6
0
     print(examples)
 if o == '--shell':
     print("Registering the Python core.")
     RegisterShellInfo(searchPaths)
 if o == '-p':
     print("Registering package", a)
     FindRegisterPackage(a, None, searchPaths)
 if o in ['--upackage', '--uapp']:
     import regutil
     print("Unregistering application/package", a)
     regutil.UnregisterNamedPath(a)
 if o == '-a':
     import regutil
     path = ";".join(searchPaths)
     print("Registering application", a, "to path", path)
     regutil.RegisterNamedPath(a, path)
 if o == '-c':
     if not len(searchPaths):
         raise error(
             "-c option must provide at least one additional path")
     import win32api, regutil
     currentPaths = regutil.GetRegisteredNamedPath(None).split(";")
     oldLen = len(currentPaths)
     for newPath in searchPaths:
         if newPath not in currentPaths:
             currentPaths.append(newPath)
     if len(currentPaths) != oldLen:
         print("Registering %d new core paths" %
               (len(currentPaths) - oldLen))
         regutil.RegisterNamedPath(None, ";".join(currentPaths))
     else: