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 test_PackageNotFoundError(self): package = "Potato" with env_var("CONDA_JSON", "yes", stack_callback=conda_tests_ctxt_mgmt_def_pol): with captured() as c: exc = PackagesNotFoundError((package, )) conda_exception_handler(_raise_helper, exc) json_obj = json.loads(c.stdout) assert not c.stderr assert json_obj[ 'exception_type'] == "<class 'conda.exceptions.PackagesNotFoundError'>" assert json_obj['message'] == text_type(exc) assert json_obj['error'] == repr(exc) with env_var("CONDA_JSON", "no", stack_callback=conda_tests_ctxt_mgmt_def_pol): with captured() as c: conda_exception_handler(_raise_helper, exc) assert not c.stdout assert c.stderr.strip() == dals(""" PackagesNotFoundError: The following packages are missing from the target environment: - Potato """).strip()
def get_dists_for_spec(spec, emptyok=False): # Here, spec should be a MatchSpec res = groups[spec.name] if not res and not emptyok: raise PackagesNotFoundError((spec,)) return res