Example #1
0
def install_modules(args):
    matching_names = au.search_remote(*args.modules)
    if len(matching_names) > 1 and args.version is not None:
        sys.exit('Version filter cannot be applied to multiple modules')
    selected_install = {}
    for module_name in matching_names:
        remote_info = au.get_remote_module_info(module_name)
        if args.version is None:
            local_info = au.get_local_module_info(module_name)
            if local_info is not None:
                local_ver = local_info.version
                remote_ver = remote_info.latest_version
                if not args.force and LooseVersion(local_ver) >= LooseVersion(remote_ver):
                    print(f'{module_name}: latest is already installed. ({local_ver})')
                    continue
            selected_install[module_name] = remote_info.latest_version
        elif remote_info.has_version(args.version):
            selected_install[module_name] = args.version
        else:
            continue
    if args.private:
        if args.version is None:
            sys.exit('--include-private cannot be used without specifying a version using -v/--version')
        for module_name in args.modules:
            if au.module_exists_remote(module_name, version=args.version, private=True):
                selected_install[module_name] = args.version
    # Add dependencies of selected modules
    dep_install = {}
    if not args.skip_dependencies:
        for module_name, version in selected_install.items():
            deps = au.get_install_deps(module_name, version=version)
            dep_install.update(deps)
    # If overlap between selected modules and dependency modules, use the dependency version
    to_install = selected_install
    to_install.update(dep_install)
    if len(to_install) == 0:
        print('No modules to install found')
    else:
        print('Installing: {:}'\
                .format(', '.join([name+':'+version for name, version in sorted(to_install.items())]))
                )
        if not(args.yes):
            while True:
                resp = input('Proceed? (y/n) > ')
                if resp == 'y':
                    break
                if resp == 'n':
                    exit()
                else:
                    print('Your response (\'{:}\') was not one of the expected responses: y, n'.format(resp))
                    continue
        for module_name, module_version in sorted(to_install.items()):
            stage_handler = InstallProgressStdout(module_name, module_version)
            au.install_module(module_name,
                                version=module_version,
                                force_data=args.force_data,
                                stage_handler=stage_handler,
                                force=args.force,
                                skip_data=args.skip_data,
                                )
Example #2
0
async def queue_install (request):
    global install_queue
    queries = request.rel_url.query
    if 'version' in queries:
        module_version = queries['version']
    else:
        module_version = None
    module_name = queries['module']
    data = {'module': module_name, 'version': module_version}
    install_queue.put(data)
    deps = au.get_install_deps(module_name, module_version)
    for dep_name, dep_version in deps.items():
        install_queue.put({'module':dep_name,'version':dep_version})
    return web.Response(text = 'queued ' + queries['module'])
Example #3
0
async def queue_install(request):
    global install_queue
    global servermode
    if servermode and server_ready:
        r = await cravat_multiuser.is_admin_loggedin(request)
        if r == False:
            response = 'notadmin'
            return web.json_response(response)
    queries = request.rel_url.query
    if 'version' in queries:
        module_version = queries['version']
    else:
        module_version = None
    module_name = queries['module']
    data = {'module': module_name, 'version': module_version}
    install_queue.put(data)
    deps = au.get_install_deps(module_name, module_version)
    for dep_name, dep_version in deps.items():
        install_queue.put({'module': dep_name, 'version': dep_version})
    return web.Response(text='queued ' + queries['module'])