Repository: conan-io/conan

Issue:
Uncontrolled error in connection error
Conan shows traces if a connection error happen during the version check:

`conan install
curl/7.47.1@lasote/stable: Not found, looking in remotes...
libcurl/7.47.1@lasote/stable: Trying with 'conan.io'...
Downloading conanmanifest.txt
[==================================================]                  
Downloading conanfile.py
Traceback (most recent call last):
  File "/usr/local/Cellar/conan/0.8.0/libexec/bin/conan", line 9, in <module>
    load_entry_point('conan==0.8.0', 'console_scripts', 'conan')()
  File "/usr/local/Cellar/conan/0.8.0/libexec/lib/python2.7/site-packages/conans/conan.py", line 6, in run
    main(sys.argv[1:])
  File "/usr/local/Cellar/conan/0.8.0/libexec/lib/python2.7/site-packages/conans/client/command.py", line 615, in main
    error = command.run(args)
  File "/usr/local/Cellar/conan/0.8.0/libexec/lib/python2.7/site-packages/conans/client/command.py", line 529, in run
    method(args[0][1:])
  File "/usr/local/Cellar/conan/0.8.0/libexec/lib/python2.7/site-packages/conans/client/command.py", line 218, in install
    update=args.update)
  File "/usr/local/Cellar/conan/0.8.0/libexec/lib/python2.7/site-packages/conans/client/manager.py", line 178, in install
    deps_graph = builder.load(reference, conanfile)
  File "/usr/local/Cellar/conan/0.8.0/libexec/lib/python2.7/site-packages/conans/client/deps_builder.py", line 243, in load
    self._load_deps(root_node, Requirements(), dep_graph, public_deps, conan_ref, None)
  File "/usr/local/Cellar/conan/0.8.0/libexec/lib/python2.7/site-packages/conans/client/deps_builder.py", line 270, in _load_deps
    new_node = self._create_new_node(node, dep_graph, require, public_deps, name)
  File "/usr/local/Cellar/conan/0.8.0/libexec/lib/python2.7/site-packages/conans/client/deps_builder.py", line 314, in _create_new_node
    conanfile_path = self._retriever.get_conanfile(requirement.conan_reference)
  File "/usr/local/Cellar/conan/0.8.0/libexec/lib/python2.7/site-packages/conans/client/proxy.py", line 122, in get_conanfile
    self._retrieve_conanfile(conan_reference, output)
  File "/usr/local/Cellar/conan/0.8.0/libexec/lib/python2.7/site-packages/conans/client/proxy.py", line 161, in _retrieve_conanfile
    return _retrieve_from_remote(remote)
  File "/usr/local/Cellar/conan/0.8.0/libexec/lib/python2.7/site-packages/conans/client/proxy.py", line 146, in _retrieve_from_remote
    result = self._remote_manager.get_conanfile(conan_reference, remote)
  File "/usr/local/Cellar/conan/0.8.0/libexec/lib/python2.7/site-packages/conans/client/remote_manager.py", line 65, in get_conanfile
    uncompress_files(export_files, export_folder, EXPORT_TGZ_NAME)
  File "/usr/local/Cellar/conan/0.8.0/libexec/lib/python2.7/site-packages/conans/client/remote_manager.py", line 151, in uncompress_files
    for file_name, content in files:
  File "/usr/local/Cellar/conan/0.8.0/libexec/lib/python2.7/site-packages/conans/client/rest/rest_client.py", line 333, in download_files
    contents = downloader.download(resource_url)
  File "/usr/local/Cellar/conan/0.8.0/libexec/lib/python2.7/site-packages/conans/client/rest/uploader_downloader.py", line 28, in download
    response = self.requester.get(url, stream=True, verify=self.verify)
  File "/usr/local/Cellar/conan/0.8.0/libexec/lib/python2.7/site-packages/conans/client/rest/version_checker.py", line 20, in get
    ret = self.requester.get(url, auth=auth, headers=headers, verify=verify, stream=stream)
  File "/usr/local/Cellar/conan/0.8.0/libexec/vendor/lib/python2.7/site-packages/requests/sessions.py", line 477, in get
    return self.request('GET', url, **kwargs)
  File "/usr/local/Cellar/conan/0.8.0/libexec/vendor/lib/python2.7/site-packages/requests/sessions.py", line 465, in request
    resp = self.send(prep, **send_kwargs)
  File "/usr/local/Cellar/conan/0.8.0/libexec/vendor/lib/python2.7/site-packages/requests/sessions.py", line 573, in send
    r = adapter.send(request, **kwargs)
  File "/usr/local/Cellar/conan/0.8.0/libexec/vendor/lib/python2.7/site-packages/requests/adapters.py", line 415, in send
    raise ConnectionError(err, request=request)
requests.exceptions.ConnectionError: ('Connection aborted.', error(54, 'Connection reset by peer'))`



Discussion:

Resolving patch:
diff --git a/conans/client/proxy.py b/conans/client/proxy.py
--- a/conans/client/proxy.py
+++ b/conans/client/proxy.py
@@ -269,6 +269,8 @@ def _retrieve_remote_package(self, package_reference, output, remote=None):
             self._remote_manager.get_package(package_reference, remote)
             output.success('Package installed %s' % package_id)
             return True
+        except ConanConnectionError:
+            raise  # This shouldn't be skipped
         except ConanException as e:
             output.warn('Binary for %s not in remote: %s' % (package_id, str(e)))
             return False
diff --git a/conans/client/rest/rest_client.py b/conans/client/rest/rest_client.py
--- a/conans/client/rest/rest_client.py
+++ b/conans/client/rest/rest_client.py
@@ -357,5 +357,3 @@ def upload_files(self, file_urls, files, output):
             raise ConanException("Upload failed!")
         else:
             logger.debug("\nAll uploaded! Total time: %s\n" % str(time.time() - t1))
-
-  
\ No newline at end of file
diff --git a/conans/client/rest/uploader_downloader.py b/conans/client/rest/uploader_downloader.py
--- a/conans/client/rest/uploader_downloader.py
+++ b/conans/client/rest/uploader_downloader.py
@@ -1,4 +1,4 @@
-from conans.errors import ConanException
+from conans.errors import ConanException, ConanConnectionError
 
 
 class Uploader(object):
@@ -29,24 +29,29 @@ def download(self, url):
         if not response.ok:
             raise ConanException("Error %d downloading file %s" % (response.status_code, url))
 
-        total_length = response.headers.get('content-length')
-
-        if total_length is None:  # no content length header
-            ret.append(response.content)
-        else:
-            dl = 0
-            total_length = int(total_length)
-            last_progress = None
-            for data in response.iter_content(chunk_size=1024):
-                dl += len(data)
-                ret.append(data)
-                units = progress_units(dl, total_length)
-                if last_progress != units:  # Avoid screen refresh if nothing has change
-                    if self.output:
-                        print_progress(self.output, units)
-                    last_progress = units
-
-        return "".join(ret)
+        try:
+            total_length = response.headers.get('content-length')
+
+            if total_length is None:  # no content length header
+                ret.append(response.content)
+            else:
+                dl = 0
+                total_length = int(total_length)
+                last_progress = None
+                for data in response.iter_content(chunk_size=1024):
+                    dl += len(data)
+                    ret.append(data)
+                    units = progress_units(dl, total_length)
+                    if last_progress != units:  # Avoid screen refresh if nothing has change
+                        if self.output:
+                            print_progress(self.output, units)
+                        last_progress = units
+
+            return "".join(ret)
+        except Exception as e:
+            # If this part failed, it means problems with the connection to server
+            raise ConanConnectionError("Download failed, check server, possibly try again\n%s"
+                                       % str(e))
 
 
 class upload_in_chunks(object):


Test patch: