コード例 #1
0
ファイル: env.py プロジェクト: pghysels/spack
def env_remove(args):
    """Remove a *named* environment.

    This removes an environment managed by Spack. Directory environments
    and `spack.yaml` files embedded in repositories should be removed
    manually.
    """
    read_envs = []
    for env_name in args.rm_env:
        env = ev.read(env_name)
        read_envs.append(env)

    if not args.yes_to_all:
        answer = tty.get_yes_or_no(
            'Really remove %s %s?' % (
                string.plural(len(args.rm_env), 'environment', show_n=False),
                string.comma_and(args.rm_env)),
            default=False)
        if not answer:
            tty.die("Will not remove any environments")

    for env in read_envs:
        if env.active:
            tty.die("Environment %s can't be removed while activated."
                    % env.name)

        env.destroy()
        tty.msg("Successfully removed environment '%s'" % env.name)
コード例 #2
0
ファイル: env.py プロジェクト: LLNL/spack
def env_remove(args):
    """Remove a *named* environment.

    This removes an environment managed by Spack. Directory environments
    and `spack.yaml` files embedded in repositories should be removed
    manually.
    """
    read_envs = []
    for env_name in args.rm_env:
        env = ev.read(env_name)
        read_envs.append(env)

    if not args.yes_to_all:
        answer = tty.get_yes_or_no(
            'Really remove %s %s?' % (
                string.plural(len(args.rm_env), 'environment', show_n=False),
                string.comma_and(args.rm_env)),
            default=False)
        if not answer:
            tty.die("Will not remove any environments")

    for env in read_envs:
        if env.active:
            tty.die("Environment %s can't be removed while activated.")

        env.destroy()
        tty.msg("Successfully removed environment '%s'" % env.name)
コード例 #3
0
ファイル: build_environment.py プロジェクト: zeta1999/spack
    def long_message(self):
        out = StringIO()
        out.write(self._long_message if self._long_message else '')

        if (self.module, self.name) in ChildError.build_errors:
            # The error happened in some external executed process. Show
            # the build log with errors or warnings highlighted.
            if self.build_log and os.path.exists(self.build_log):
                errors, warnings = parse_log_events(self.build_log)
                nerr = len(errors)
                nwar = len(warnings)
                if nerr > 0:
                    # If errors are found, only display errors
                    out.write("\n%s found in build log:\n" %
                              plural(nerr, 'error'))
                    out.write(make_log_context(errors))
                elif nwar > 0:
                    # If no errors are found but warnings are, display warnings
                    out.write("\n%s found in build log:\n" %
                              plural(nwar, 'warning'))
                    out.write(make_log_context(warnings))

        else:
            # The error happened in in the Python code, so try to show
            # some context from the Package itself.
            if self.context:
                out.write('\n')
                out.write('\n'.join(self.context))
                out.write('\n')

        if out.getvalue():
            out.write('\n')

        if self.build_log and os.path.exists(self.build_log):
            out.write('See build log for details:\n')
            out.write('  %s\n' % self.build_log)

        return out.getvalue()
コード例 #4
0
ファイル: build_environment.py プロジェクト: matzke1/spack
    def long_message(self):
        out = StringIO()
        out.write(self._long_message if self._long_message else '')

        if (self.module, self.name) in ChildError.build_errors:
            # The error happened in some external executed process. Show
            # the build log with errors or warnings highlighted.
            if self.build_log and os.path.exists(self.build_log):
                errors, warnings = parse_log_events(self.build_log)
                nerr = len(errors)
                nwar = len(warnings)
                if nerr > 0:
                    # If errors are found, only display errors
                    out.write(
                        "\n%s found in build log:\n" % plural(nerr, 'error'))
                    out.write(make_log_context(errors))
                elif nwar > 0:
                    # If no errors are found but warnings are, display warnings
                    out.write(
                        "\n%s found in build log:\n" % plural(nwar, 'warning'))
                    out.write(make_log_context(warnings))

        else:
            # The error happened in in the Python code, so try to show
            # some context from the Package itself.
            if self.context:
                out.write('\n')
                out.write('\n'.join(self.context))
                out.write('\n')

        if out.getvalue():
            out.write('\n')

        if self.build_log and os.path.exists(self.build_log):
            out.write('See build log for details:\n')
            out.write('  %s' % self.build_log)

        return out.getvalue()
コード例 #5
0
def write_log_summary(out, log_type, log, last=None):
    errors, warnings = parse_log_events(log)
    nerr = len(errors)
    nwar = len(warnings)

    if nerr > 0:
        if last and nerr > last:
            errors = errors[-last:]
            nerr = last

        # If errors are found, only display errors
        out.write("\n%s found in %s log:\n" %
                  (plural(nerr, 'error'), log_type))
        out.write(make_log_context(errors))
    elif nwar > 0:
        if last and nwar > last:
            warnings = warnings[-last:]
            nwar = last

        # If no errors are found but warnings are, display warnings
        out.write("\n%s found in %s log:\n" %
                  (plural(nwar, 'warning'), log_type))
        out.write(make_log_context(warnings))
コード例 #6
0
ファイル: find.py プロジェクト: cgmb/rocm-spack
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)
コード例 #7
0
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', required=False)
    if env:
        decorator, added, roots, removed = setup_env(env)

    # Exit early 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

    # 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 env:
        tty.msg('In environment %s' % env.name)

        if not env.user_specs:
            tty.msg('No root specs')
        else:
            tty.msg('Root specs')
            display_specs(env.user_specs,
                          args,
                          decorator=lambda s, f: color.colorize('@*{%s}' % f))
        print()

        if args.show_concretized:
            tty.msg('Concretized roots')
            display_specs(env.specs_by_hash.values(),
                          args,
                          decorator=decorator)
            print()

    tty.msg("%s" % plural(len(results), 'installed package'))

    display_specs(results, args, decorator=decorator, all_headers=True)
コード例 #8
0
def listspecs(args):
    """list binary packages available from mirrors"""
    specs = bindist.update_cache_and_get_specs()
    if not args.allarch:
        arch = spack.architecture.default_arch().to_spec()
        specs = [s for s in specs if s.satisfies(arch)]

    if args.specs:
        constraints = set(args.specs)
        specs = [s for s in specs if any(s.satisfies(c) for c in constraints)]
    if sys.stdout.isatty():
        builds = len(specs)
        tty.msg("%s." % plural(builds, 'cached build'))
        if not builds and not args.allarch:
            tty.msg("You can query all available architectures with:",
                    "spack buildcache list --allarch")
    display_specs(specs, args, all_headers=True)
コード例 #9
0
ファイル: find.py プロジェクト: LLNL/spack
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', required=False)
    if env:
        decorator, added, roots, removed = setup_env(env)

    # Exit early 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

    # 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 env:
        tty.msg('In environment %s' % env.name)

        if not env.user_specs:
            tty.msg('No root specs')
        else:
            tty.msg('Root specs')
            display_specs(
                env.user_specs, args,
                decorator=lambda s, f: color.colorize('@*{%s}' % f))
        print()

        if args.show_concretized:
            tty.msg('Concretized roots')
            display_specs(
                env.specs_by_hash.values(), args, decorator=decorator)
            print()

    tty.msg("%s" % plural(len(results), 'installed package'))

    display_specs(results, args, decorator=decorator, all_headers=True)
コード例 #10
0
ファイル: find.py プロジェクト: timkphd/spack
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)
コード例 #11
0
def test_plural():
    assert plural(0, 'thing') == '0 things'
    assert plural(1, 'thing') == '1 thing'
    assert plural(2, 'thing') == '2 things'
    assert plural(1, 'thing', 'wombats') == '1 thing'
    assert plural(2, 'thing', 'wombats') == '2 wombats'