def handle_txn(unlink_link_transaction, prefix, args, newenv, remove_op=False): if unlink_link_transaction.nothing_to_do: if remove_op: # No packages found to remove from environment raise PackagesNotFoundError(args.package_names) elif not newenv: if context.json: cli_common.stdout_json_success( message="All requested packages already installed." ) return if context.dry_run: actions = unlink_link_transaction._make_legacy_action_groups()[0] if context.json: cli_common.stdout_json_success(prefix=prefix, actions=actions, dry_run=True) raise DryRunExit() try: unlink_link_transaction.download_and_extract() if context.download_only: raise CondaExitZero( "Package caches prepared. UnlinkLinkTransaction cancelled with " "--download-only option." ) unlink_link_transaction.execute() except SystemExit as e: raise CondaSystemExit("Exiting", e) if context.json: actions = unlink_link_transaction._make_legacy_action_groups()[0] cli_common.stdout_json_success(prefix=prefix, actions=actions)
def install(prefix, specs, args, env, prune=False): # TODO: support all various ways this happens # Including 'nodefaults' in the channels list disables the defaults new_specs = [] channel_urls = set() for elem in specs: if "::" in elem: channel_urls.add(elem.split("::")[0]) new_specs.append(elem.split("::")[-1]) else: new_specs.append(elem) specs = new_specs channel_urls = list(channel_urls) # TODO: support all various ways this happens # Including 'nodefaults' in the channels list disables the defaults index = get_index(channel_urls=channel_urls + [chan for chan in env.channels if chan != 'nodefaults'], prepend='nodefaults' not in env.channels, prefix=prefix) actions = plan.install_actions(prefix, index, specs, prune=prune) with common.json_progress_bars(json=args.json and not args.quiet): try: plan.execute_actions(actions, index, verbose=not args.quiet) except RuntimeError as e: if len(e.args) > 0 and "LOCKERROR" in e.args[0]: raise LockError('Already locked: %s' % text_type(e)) else: raise CondaRuntimeError('RuntimeError: %s' % e) except SystemExit as e: raise CondaSystemExit('Exiting', e)