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, )
def list_available_modules(pattern=r'.*', types=[]): header = [ 'Name', 'Type', 'Latest version', 'Installed', 'Installed version', 'Up-to-date', 'Size' ] all_toks = [header] for module_name in au.search_remote(pattern): remote_info = au.get_remote_module_info(module_name) if len(types) > 0 and remote_info.type not in types: continue local_info = au.get_local_module_info(module_name) if local_info is not None: installed = True local_version = local_info.version up_to_date = local_version == remote_info.latest_version else: installed = False local_version = '' up_to_date = '' toks = [ module_name, remote_info.type, remote_info.latest_version, installed, local_version, up_to_date, humanize_bytes(remote_info.size) ] all_toks.append(toks) print_tabular_lines(all_toks)
def list_available_modules(pattern=r'.*', types=[], include_hidden=False, tags=[], quiet=False, raw_bytes=False): if quiet: all_toks = [] else: header = [ 'Name', 'Title', 'Type', 'Installed', 'Store ver', 'Store data ver', 'Local ver', 'Local data ver', 'Size' ] all_toks = [header] for module_name in au.search_remote(pattern): remote_info = au.get_remote_module_info(module_name) if len(types) > 0 and remote_info.type not in types: continue if len(tags) > 0: if remote_info.tags is None: continue if len(set(tags).intersection(remote_info.tags)) == 0: continue if remote_info.hidden and not include_hidden: continue local_info = au.get_local_module_info(module_name) if local_info is not None: installed = 'yes' local_version = local_info.version local_datasource = local_info.datasource else: installed = '' local_version = '' local_datasource = '' if quiet: toks = [module_name] else: toks = [ module_name, remote_info.title, remote_info.type, installed, remote_info.latest_version, remote_info.datasource, local_version, local_datasource, ] if raw_bytes: toks.append(remote_info.size) else: toks.append(util.humanize_bytes(remote_info.size)) all_toks.append(toks) print_tabular_lines(all_toks)
def install_modules(args): matching_names = au.search_remote(*args.modules) if len(matching_names) > 1 and args.version is not None: print('WARNING: Version filter applied to all matching modules') to_install = {} for module_name in matching_names: remote_info = au.get_remote_module_info(module_name) if args.version is None: to_install[module_name] = remote_info.latest_version elif remote_info.has_version(args.version): to_install[module_name] = args.version else: continue if len(to_install) > 0: 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) else: print('No modules found')
def list_available_modules(pattern=r'.*', types=[], include_hidden=False): header = [ 'Name', 'Type', 'Installed', 'Up to date', 'Store latest ver', 'Store data source ver', 'Local ver', 'Local data source ver', 'Size' ] all_toks = [header] for module_name in au.search_remote(pattern): remote_info = au.get_remote_module_info(module_name) if len(types) > 0 and remote_info.type not in types: continue if remote_info.hidden and not include_hidden: continue local_info = au.get_local_module_info(module_name) if local_info is not None: installed = 'yes' local_version = local_info.version up_to_date = local_version == remote_info.latest_version if up_to_date: up_to_date = 'yes' else: up_to_date = '' local_datasource = local_info.datasource else: installed = '' local_version = '' up_to_date = '' local_datasource = '' toks = [ module_name, remote_info.type, installed, up_to_date, remote_info.latest_version, remote_info.datasource, local_version, local_datasource, humanize_bytes(remote_info.size) ] all_toks.append(toks) print_tabular_lines(all_toks)