def test_make_initialize_plan_bash_zsh(self):
     with tempdir() as conda_temp_prefix:
         plan = make_initialize_plan(conda_temp_prefix, ('bash', 'zsh'), for_user=True,
                                     for_system=True, anaconda_prompt=False)
         steps = tuple(step for step in plan if step['function'] == 'init_sh_user')
         assert len(steps) == 2
         steps = tuple(step for step in plan if step['function'] == 'init_sh_system')
         assert len(steps) == 1
Exemplo n.º 2
0
 def test_make_initialize_plan_bash_zsh(self):
     with tempdir() as conda_temp_prefix:
         plan = make_initialize_plan(conda_temp_prefix, ('bash', 'zsh'), for_user=True,
                                     for_system=True, anaconda_prompt=False)
         steps = tuple(step for step in plan if step['function'] == 'init_sh_user')
         assert len(steps) == 2
         steps = tuple(step for step in plan if step['function'] == 'init_sh_system')
         assert len(steps) == 1
Exemplo n.º 3
0
 def test_make_initialize_plan_cmd_exe(self):
     with tempdir() as conda_temp_prefix:
         plan = make_initialize_plan(conda_temp_prefix, ('cmd.exe',), for_user=True,
                                     for_system=True, anaconda_prompt=True)
         steps = tuple(step for step in plan if step['function'] == 'init_cmd_exe_registry')
         assert len(steps) == 2
         steps = tuple(step for step in plan if step['function'] == 'install_anaconda_prompt')
         assert len(steps) == 2
Exemplo n.º 4
0
 def test_make_initialize_plan_cmd_exe(self):
     with tempdir() as conda_temp_prefix:
         plan = make_initialize_plan(conda_temp_prefix, ('cmd.exe',), for_user=True,
                                     for_system=True, anaconda_prompt=True)
         steps = tuple(step for step in plan if step['function'] == 'init_cmd_exe_registry')
         assert len(steps) == 2
         steps = tuple(step for step in plan if step['function'] == 'install_anaconda_prompt')
         assert len(steps) == 2
Exemplo n.º 5
0
def shell_init(args):
    if args.all:
        selected_shells = COMPATIBLE_SHELLS
    else:
        selected_shells = tuple(args.shells)

    if not selected_shells:
        if on_win:
            selected_shells = ("cmd.exe", "powershell")
        if on_mac:
            selected_shells = ("bash", "zsh")
        else:
            selected_shells = ("bash", )

    if args.dev:
        assert (len(selected_shells) == 1
                ), "--dev can only handle one shell at a time right now"
        shell = selected_shells[0]
        return initialize_dev(shell)

    else:
        for_user = args.user
        if not (args.install and args.user and args.system):
            for_user = True
        if args.no_user:
            for_user = False

        anaconda_prompt = on_win and args.anaconda_prompt
        exit_code = initialize(
            context.conda_prefix,
            selected_shells,
            for_user,
            args.system,
            anaconda_prompt,
            args.reverse,
        )

    changed = False
    if not exit_code and not args.reverse:
        plan = make_initialize_plan(
            context.conda_prefix,
            selected_shells,
            for_user,
            args.system,
            anaconda_prompt,
            args.reverse,
        )
        for el in plan:
            if el.get("function") == "init_sh_user":
                args = el.get("kwargs")
                target_path = args["target_path"]
                conda_prefix = args["conda_prefix"]
                add_mamba_to_rcfile(target_path, conda_prefix)
                changed = True
            if el.get("function") == "init_sh_system":
                args = el.get("kwargs")
                target_path = args["target_path"]
                conda_prefix = args["conda_prefix"]
                add_mamba_to_rcfile(target_path, conda_prefix)
                changed = True
    if changed:
        print("\n==> For changes to take effect, close"
              "and re-open your current shell. <==\n")
    return exit_code