Skip to content

Commit

Permalink
Handling error when reference not found using conan download (#5399)
Browse files Browse the repository at this point in the history
* Added required = True to subparsers in order to print error message in Py2 and Py3.

* sync

* basic concurrent upload at reference level with futures

* revert changes

* add line

* output error message when conan download tries to download
a reference that is not in the remote

* catch NotFoundException in correct place

* re-raise NotFoundException

* raise RecipeNotFound exception

* test error is raised when the reference is not found in server
  • Loading branch information
czoido authored and memsharded committed Jun 25, 2019
1 parent dfe12eb commit b6840cc
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
8 changes: 6 additions & 2 deletions conans/client/cmd/download.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from conans.client.output import ScopedOutput
from conans.client.source import complete_recipe_sources
from conans.model.ref import ConanFileReference, PackageReference

from conans.errors import NotFoundException, RecipeNotFoundException

def download(ref, package_ids, remote, recipe, remote_manager,
cache, out, recorder, loader, hook_manager, remotes):
Expand All @@ -11,7 +11,11 @@ def download(ref, package_ids, remote, recipe, remote_manager,

hook_manager.execute("pre_download", reference=ref, remote=remote)

ref = remote_manager.get_recipe(ref, remote)
try:
ref = remote_manager.get_recipe(ref, remote)
except NotFoundException:
raise RecipeNotFoundException(ref)

with cache.package_layout(ref).update_metadata() as metadata:
metadata.recipe.remote = remote.name

Expand Down
9 changes: 8 additions & 1 deletion conans/test/functional/command/download_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,4 +195,11 @@ def download_package_argument_test(self):
# Check at conanfile.py is downloaded
self.assertTrue(os.path.exists(package_layout.conanfile()))
# Check package folder created
self.assertTrue(os.path.exists(package_folder))
self.assertTrue(os.path.exists(package_folder))

def download_not_found_reference_test(self):
server = TestServer()
servers = {"default": server}
client = TurboTestClient(servers=servers, users={"default": [("lasote", "mypass")]})
client.run("download pkg/0.1@lasote/stable", assert_error=True)
self.assertIn("ERROR: Recipe not found: 'pkg/0.1@lasote/stable'", client.out)

0 comments on commit b6840cc

Please sign in to comment.