Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#5493 conan get reference is not found #5638

Merged
merged 2 commits into from Sep 13, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
30 changes: 17 additions & 13 deletions conans/client/conan_api.py
Expand Up @@ -1054,20 +1054,24 @@ def get_path(self, reference, package_id=None, path=None, remote_name=None):
if not path:
path = "conanfile.py" if not package_id else "conaninfo.txt"

if not remote_name:
package_layout = self.app.cache.package_layout(ref, short_paths=None)
return package_layout.get_path(path=path, package_id=package_id), path
else:
remote = self.get_remote_by_name(remote_name)
if self.app.cache.config.revisions_enabled and not ref.revision:
ref = self.app.remote_manager.get_latest_recipe_revision(ref, remote)
if package_id:
pref = PackageReference(ref, package_id)
if self.app.cache.config.revisions_enabled and not pref.revision:
pref = self.app.remote_manager.get_latest_package_revision(pref, remote)
return self.app.remote_manager.get_package_path(pref, path, remote), path
try:
if not remote_name:
package_layout = self.app.cache.package_layout(ref, short_paths=None)
return package_layout.get_path(path=path, package_id=package_id), path
else:
return self.app.remote_manager.get_recipe_path(ref, path, remote), path
remote = self.get_remote_by_name(remote_name)
if self.app.cache.config.revisions_enabled and not ref.revision:
ref = self.app.remote_manager.get_latest_recipe_revision(ref, remote)
if package_id:
pref = PackageReference(ref, package_id)
if self.app.cache.config.revisions_enabled and not pref.revision:
pref = self.app.remote_manager.get_latest_package_revision(pref, remote)
return self.app.remote_manager.get_package_path(pref, path, remote), path
else:
return self.app.remote_manager.get_recipe_path(ref, path, remote), path
except (RecipeNotFoundException, PackageNotFoundException) as e:
e.print_rev = True
raise e

@api_method
def export_alias(self, reference, target_reference):
Expand Down
2 changes: 1 addition & 1 deletion conans/errors.py
Expand Up @@ -196,7 +196,7 @@ def __init__(self, ref, remote=None, print_rev=False):

def __str__(self):
tmp = self.ref.full_str() if self.print_rev else str(self.ref)
return "Recipe not found: '{}'".format(tmp, self.remote_message())
return "Recipe not found: '{}'{}".format(tmp, self.remote_message())


class PackageNotFoundException(NotFoundException):
Expand Down
6 changes: 6 additions & 0 deletions conans/test/functional/command/conan_get_test.py
Expand Up @@ -166,3 +166,9 @@ def test_deprecated_argument(self):
pkg_id=NO_SETTINGS_PACKAGE_ID))
self.assertIn("WARN: Usage of `--package` argument is deprecated. Use a full reference "
"instead: `conan get [...] ", self.client.out)

def test_get_not_found_reference(self):
""" Conan get must return 'Recipe not found' when the server answer is 404
"""
self.client.run('get foobar/0.1.0@qux/channel -r default', assert_error=True)
self.assertIn("Recipe not found: 'foobar/0.1.0@qux/channel'. [Remote: default]", self.client.out)