def main(args=None): args = command_handle_args(args, definition) config = get_config() try: ic = InstallerContext(config=config) default_installer_name = ic.get_default_installer_name() results, errors = resolve(args.xylem_key, all_keys=args.all, config=config, installer_context=ic) if errors: error("\n".join(indent(exc_to_str(e), 2, exclude_first=True) for _, e in errors)) for key, (installer_name, resolutions) in results: if installer_name != default_installer_name or \ args.show_default_installer: installer_string = "{0}: ".format(installer_name) else: installer_string = "" resolution_string = ', '.join(map(to_str, resolutions)) info("{0} --> {1}{2}". format(ansi("cyanf") + key + ansi("reset"), ansi("bluef") + installer_string, ansi("yellowf") + resolution_string)) if errors: sys.exit(1) except (KeyboardInterrupt, EOFError): info('') sys.exit(1)
def main(args=None): args = command_handle_args(args, definition) config = get_config() try: resolve_errors, install_errors = install( args.xylem_key, all_keys=args.all, config=config, reinstall=args.reinstall, simulate=args.dry_run, continue_on_error=args.continue_on_error, fix_prerequisites=args.fix_prerequisites) if resolve_errors: # error("The following errors occurred during resolution:") error("\n".join( indent(exc_to_str(e), 2, exclude_first=True) for _, e in resolve_errors)) if install_errors: # error("The following errors occurred during installation:") error("\n".join( indent(exc_to_str(e), 2, exclude_first=True) for e in install_errors)) if resolve_errors or install_errors: sys.exit(1) except (KeyboardInterrupt, EOFError): info('') sys.exit(1)
def update(dry_run=False, config=None, sources_context=None): """Update the xylem cache. If the prefix is set then the source lists are searched for in the prefix. If the prefix is not set (None) or the source lists are not found in the prefix, then the default, builtin source list is used. :param bool dry_run: if `True`, then no actual action is taken, only pretend to :param config: config dict to create source context with; if `None` is passed, use global configuration :type config: `dict` or `None` :param sources_context: the sources context to be used to instantiate the rules database; if `None` is passed, a sources context from ``config`` is created :type sources_context: `SourcesContext` or `None` """ if config is None: config = get_config() sources_context = sources_context or SourcesContext(config) sources_context.ensure_cache_dir() database = RulesDatabase(sources_context) database.print_info = True # support partial update of local sources even without connectivity: database.raise_on_error = False database.update()
def main(args=None): args = command_handle_args(args, definition) config = get_config() try: resolve_errors, install_errors = install( args.xylem_key, all_keys=args.all, config=config, reinstall=args.reinstall, simulate=args.dry_run, continue_on_error=args.continue_on_error, fix_prerequisites=args.fix_prerequisites) if resolve_errors: # error("The following errors occurred during resolution:") error("\n".join(indent(exc_to_str(e), 2, exclude_first=True) for _, e in resolve_errors)) if install_errors: # error("The following errors occurred during installation:") error("\n".join(indent(exc_to_str(e), 2, exclude_first=True) for e in install_errors)) if resolve_errors or install_errors: sys.exit(1) except (KeyboardInterrupt, EOFError): info('') sys.exit(1)
def __init__(self, config=None, os_support=None, setup_installers=True): if config is None: config = get_config() self.config = config if os_support is None: self.setup_os() else: self.os_support = os_support self.installer_plugins = load_installer_plugins( self.config.disabled_plugins.installer) if setup_installers: self.setup_installers() else: self.core_installers = [] self.additional_installers = []
def main(args=None): args = command_handle_args(args, definition) config = get_config() try: # TODO: handle multiple keys in one go ic = InstallerContext(config=config) for key in args.xylem_key: result = lookup(key, compact=True, config=config, installer_context=ic) info("Rules for '{}' on '{}':\n{}". format(ansi('cyanf') + key + ansi('reset'), ansi('cyanf') + ic.get_os_string() + ansi('reset'), ansi('yellowf') + dump_yaml(result)[:-1])) except (KeyboardInterrupt, EOFError): # Note: @William why EOFError here? info('') sys.exit(1)
def main(args=None): args = command_handle_args(args, definition) config = get_config() try: # TODO: handle multiple keys in one go ic = InstallerContext(config=config) for key in args.xylem_key: result = lookup(key, compact=True, config=config, installer_context=ic) info("Rules for '{}' on '{}':\n{}".format( ansi('cyanf') + key + ansi('reset'), ansi('cyanf') + ic.get_os_string() + ansi('reset'), ansi('yellowf') + dump_yaml(result)[:-1])) except (KeyboardInterrupt, EOFError): # Note: @William why EOFError here? info('') sys.exit(1)
def lookup(xylem_key, compact=False, config=None, sources_context=None, installer_context=None): if config is None: config = get_config() sources_context = sources_context or SourcesContext(config) ic = installer_context or InstallerContext(config) database = RulesDatabase(sources_context) database.load_from_cache() installer_dict = database.lookup(xylem_key, ic) if compact: default_installer_name = ic.get_default_installer_name() compacted = compact_installer_dict(installer_dict, default_installer_name) return compacted
def __init__(self, config=None, spec_plugins=None): if config is None: config = get_config() self.setup_paths(config) self.spec_plugins = spec_plugins or load_spec_plugins( config.disabled_plugins.spec)