Example #1
0
def install(name, progress_callback=None):
    with closing(open_addons(flag="r")) as addons:
        addon = addons[name.lower()]

    source_urls = [
        url for url in addon.release_urls if url.packagetype == "sdist"
    ]
    release_url = source_urls[0]

    try:
        tmpdir = tempfile.mkdtemp()

        stream = urllib2.urlopen(release_url.url, timeout=120)

        package_path = os.path.join(tmpdir, release_url.filename)

        progress_cb = (lambda value: progress_callback(value, 0)) \
                      if progress_callback else None
        with open(package_path, "wb") as package_file:
            Orange.utils.copyfileobj(stream,
                                     package_file,
                                     progress=progress_cb)

        extract_archive(package_path, tmpdir)

        setup_py = os.path.join(tmpdir, name + '-' + addon.available_version,
                                'setup.py')

        if not os.path.isfile(setup_py):
            raise Exception("Unable to install add-on - it is not properly "
                            "packed.")

        switches = []
        if not hasattr(sys, "real_prefix"):
            # we're not in a virtualenv
            switches.append('--user')
        run_setup(setup_py, ['install'] + switches)
    finally:
        shutil.rmtree(tmpdir, ignore_errors=True)

    for p in list(sys.path):
        site.addsitedir(p)
    reload(pkg_resources)
    for p in list(sys.path):
        pkg_resources.find_distributions(p)
    from orngRegistry import load_new_addons
    load_new_addons()
    load_installed_addons()
    for func in addon_refresh_callback:
        func()
Example #2
0
def install(name, progress_callback=None):
    with closing(open_addons(flag="r")) as addons:
        addon = addons[name.lower()]

    source_urls = [url for url in addon.release_urls
                   if url.packagetype == "sdist"]
    release_url = source_urls[0]

    try:
        tmpdir = tempfile.mkdtemp()

        stream = urllib2.urlopen(release_url.url, timeout=120)

        package_path = os.path.join(tmpdir, release_url.filename)

        progress_cb = (lambda value: progress_callback(value, 0)) \
                      if progress_callback else None
        with open(package_path, "wb") as package_file:
            Orange.utils.copyfileobj(
                stream, package_file, progress=progress_cb)

        extract_archive(package_path, tmpdir)

        setup_py = os.path.join(tmpdir, name + '-' + addon.available_version,
                                'setup.py')

        if not os.path.isfile(setup_py):
            raise Exception("Unable to install add-on - it is not properly "
                            "packed.")

        switches = []
        if not hasattr(sys, "real_prefix"):
            # we're not in a virtualenv
            switches.append('--user')
        run_setup(setup_py, ['install'] + switches)
    finally:
        shutil.rmtree(tmpdir, ignore_errors=True)

    for p in list(sys.path):
        site.addsitedir(p)
    reload(pkg_resources)
    for p in list(sys.path):
        pkg_resources.find_distributions(p)
    from orngRegistry import load_new_addons
    load_new_addons()
    load_installed_addons()
    for func in addon_refresh_callback:
        func()
Example #3
0
                "Unable to install add-on - it is not properly packed.")

        switches = []
        if site.USER_SITE in sys.path:  # we're not in a virtualenv
            switches.append('--user')
        run_setup(setup_py, ['install'] + switches)
    finally:
        shutil.rmtree(tmpdir, ignore_errors=True)

    for p in list(sys.path):
        site.addsitedir(p)
    reload(pkg_resources)
    for p in list(sys.path):
        pkg_resources.find_distributions(p)
    from orngRegistry import load_new_addons
    load_new_addons()
    load_installed_addons()
    for func in addon_refresh_callback:
        func()


def uninstall(name, progress_callback=None):
    try:
        import pip.req
        ao = pip.req.InstallRequirement(name, None)
        ao.uninstall(True)
    except ImportError:
        raise Exception(
            "Pip is required for add-on uninstallation. Install pip and try again."
        )
            raise Exception("Unable to install add-on - it is not properly packed.")

        switches = []
        if site.USER_SITE in sys.path:   # we're not in a virtualenv
            switches.append('--user')
        run_setup(setup_py, ['install'] + switches)
    finally:
        shutil.rmtree(tmpdir, ignore_errors=True)

    for p in list(sys.path):
        site.addsitedir(p)
    reload(pkg_resources)
    for p in list(sys.path):
        pkg_resources.find_distributions(p)
    from orngRegistry import load_new_addons
    load_new_addons()
    load_installed_addons()
    for func in addon_refresh_callback:
        func()

def uninstall(name, progress_callback=None):
    try:
        import pip.req
        ao = pip.req.InstallRequirement(name, None)
        ao.uninstall(True)
    except ImportError:
        raise Exception("Pip is required for add-on uninstallation. Install pip and try again.")

def upgrade(name, progress_callback=None):
    install(name, progress_callback)