Beispiel #1
0
def _setup_for_xpcom():
    # Use a temporary user data dir
    userDataRoot = tempfile.mkdtemp(prefix="ko-test-userdata-")
    atexit.register(shutil.rmtree, userDataRoot)
    os.environ["KOMODO_USERDATADIR"] = userDataRoot

    # The tests are run outside of Komodo. If run with PyXPCOM up
    # parts codeintel will try to use the nsIDirectoryService and
    # will query dirs only provided by nsXREDirProvider -- which
    # isn't registered outside of Komodo (XRE_main() isn't called).
    # The KoTestService provides a backup.
    from xpcom import _xpcom
    from xpcom import components
    from xpcom.server import UnwrapObject
    koTestSvc = components.classes["@activestate.com/koTestService;1"] \
        .getService(components.interfaces.koITestService)
    koTestSvc.init()

    # Reset the startup-env.tmp file (normally done by komodo.exe), otherwise
    # we'll be reading stale environment settings from whenever Komodo was last
    # run on this machine.
    koEnvironSvc = components.classes["@activestate.com/koUserEnviron;1"] \
        .getService(components.interfaces.koIUserEnviron)
    pyEnvironSvc = UnwrapObject(koEnvironSvc)
    try:
        os.remove(pyEnvironSvc.startupEnvFileName)
    except OSError:
        # Doesn't exist, or we don't have the correct permissions... ignore.
        pass
    pyEnvironSvc._UpdateFromStartupEnv()
Beispiel #2
0
def _setup_for_xpcom():
    # Use a temporary user data dir
    userDataRoot = tempfile.mkdtemp(prefix="ko-test-userdata-")
    atexit.register(shutil.rmtree, userDataRoot)
    os.environ["KOMODO_USERDATADIR"] = userDataRoot

    # The tests are run outside of Komodo. If run with PyXPCOM up
    # parts codeintel will try to use the nsIDirectoryService and
    # will query dirs only provided by nsXREDirProvider -- which
    # isn't registered outside of Komodo (XRE_main() isn't called).
    # The KoTestService provides a backup.
    from xpcom import _xpcom
    from xpcom import components
    from xpcom.server import UnwrapObject
    koTestSvc = components.classes["@activestate.com/koTestService;1"] \
        .getService(components.interfaces.koITestService)
    koTestSvc.init()

    # Reset the startup-env.tmp file (normally done by komodo.exe), otherwise
    # we'll be reading stale environment settings from whenever Komodo was last
    # run on this machine.
    koEnvironSvc = components.classes["@activestate.com/koUserEnviron;1"] \
        .getService(components.interfaces.koIUserEnviron)
    pyEnvironSvc = UnwrapObject(koEnvironSvc)
    try:
        os.remove(pyEnvironSvc.startupEnvFileName)
    except OSError:
        # Doesn't exist, or we don't have the correct permissions... ignore.
        pass
    pyEnvironSvc._UpdateFromStartupEnv()