def find(parser, args): q_args = query_arguments(args) # Query the current store or the internal bootstrap store if required if args.bootstrap: bootstrap_store_path = spack.bootstrap.store_path() msg = 'Showing internal bootstrap store at "{0}"' tty.msg(msg.format(bootstrap_store_path)) with spack.store.use_store(bootstrap_store_path): results = args.specs(**q_args) else: results = args.specs(**q_args) decorator = lambda s, f: f added = set() removed = set() env = ev.get_env(args, 'find') if env: decorator, added, roots, removed = setup_env(env) # use groups by default except with format. if args.groups is None: args.groups = not args.format # Exit early with an error code if no package matches the constraint if not results and args.constraint: msg = "No package matches the query: {0}" msg = msg.format(' '.join(args.constraint)) tty.msg(msg) return 1 # If tags have been specified on the command line, filter by tags if args.tags: packages_with_tags = spack.repo.path.packages_with_tags(*args.tags) results = [x for x in results if x.name in packages_with_tags] if args.loaded: hashes = os.environ.get(uenv.spack_loaded_hashes_var, '').split(':') results = [x for x in results if x.dag_hash() in hashes] # Display the result if args.json: cmd.display_specs_as_json(results, deps=args.deps) else: if not args.format: if env: display_env(env, args, decorator) if sys.stdout.isatty() and args.groups: tty.msg("%s" % plural(len(results), 'installed package')) cmd.display_specs(results, args, decorator=decorator, all_headers=True)
def test_display_json_deps(database, capsys): specs = [Spec(s).concretized() for s in [ "mpileaks ^zmpi", "mpileaks ^mpich", "mpileaks ^mpich2", ]] cmd.display_specs_as_json(specs, deps=True) spec_list = json.loads(capsys.readouterr()[0]) _check_json_output_deps(spec_list) cmd.display_specs_as_json(specs + specs + specs, deps=True) spec_list = json.loads(capsys.readouterr()[0]) _check_json_output_deps(spec_list)
def _find(parser, args): q_args = query_arguments(args) results = args.specs(**q_args) env = ev.active_environment() decorator = lambda s, f: f if env: decorator, _, roots, _ = setup_env(env) # use groups by default except with format. if args.groups is None: args.groups = not args.format # Exit early with an error code if no package matches the constraint if not results and args.constraint: msg = "No package matches the query: {0}" msg = msg.format(' '.join(args.constraint)) tty.msg(msg) raise SystemExit(1) # If tags have been specified on the command line, filter by tags if args.tags: packages_with_tags = spack.repo.path.packages_with_tags(*args.tags) results = [x for x in results if x.name in packages_with_tags] if args.loaded: results = spack.cmd.filter_loaded_specs(results) # Display the result if args.json: cmd.display_specs_as_json(results, deps=args.deps) else: if not args.format: if env: display_env(env, args, decorator) if sys.stdout.isatty() and args.groups: pkg_type = "loaded" if args.loaded else "installed" spack.cmd.print_how_many_pkgs(results, pkg_type) cmd.display_specs(results, args, decorator=decorator, all_headers=True)
def find(parser, args): q_args = query_arguments(args) results = args.specs(**q_args) decorator = lambda s, f: f added = set() removed = set() env = ev.get_env(args, 'find') if env: decorator, added, roots, removed = setup_env(env) # use groups by default except with format. if args.groups is None: args.groups = not args.format # Exit early with an error code if no package matches the constraint if not results and args.constraint: msg = "No package matches the query: {0}" msg = msg.format(' '.join(args.constraint)) tty.msg(msg) return 1 # If tags have been specified on the command line, filter by tags if args.tags: packages_with_tags = spack.repo.path.packages_with_tags(*args.tags) results = [x for x in results if x.name in packages_with_tags] # Display the result if args.json: cmd.display_specs_as_json(results, deps=args.deps) else: if env: display_env(env, args, decorator) if args.groups: tty.msg("%s" % plural(len(results), 'installed package')) cmd.display_specs(results, args, decorator=decorator, all_headers=True)