def download(url, filename, verify=True, out=None, retry=None, retry_wait=None, overwrite=False, auth=None, headers=None, requester=None): if retry is None: retry = 2 if retry_wait is None: retry_wait = 5 out = default_output(out, 'conans.client.tools.net.download') requester = default_requester(requester, 'conans.client.tools.net.download') downloader = Downloader(requester=requester, output=out, verify=verify) downloader.download(url, filename, retry=retry, retry_wait=retry_wait, overwrite=overwrite, auth=auth, headers=headers) out.writeln("")
def _get_path(self, url, path): urls = self._get_file_to_url_dict(url) def is_dir(the_path): if the_path == ".": return True for _the_file in urls: if the_path == _the_file: return False elif _the_file.startswith(the_path): return True raise NotFoundException("The specified path doesn't exist") if is_dir(path): ret = [] for the_file in urls: if path == "." or the_file.startswith(path): tmp = the_file[len(path) - 1:].split("/", 1)[0] if tmp not in ret: ret.append(tmp) return sorted(ret) else: downloader = Downloader(self.requester, None, self.verify_ssl) auth, _ = self._file_server_capabilities(urls[path]) content = downloader.download(urls[path], auth=auth) return decode_text(content)
def download(url, filename, verify=True): out = ConanOutput(sys.stdout, True) if verify: # We check the certificate using a list of known verifiers import conans.client.rest.cacert as cacert verify = cacert.file_path downloader = Downloader(requests, out, verify=verify) downloader.download(url, filename) out.writeln("")
def download(url, filename, verify=True, out=None, retry=2, retry_wait=5): out = out or ConanOutput(sys.stdout, True) if verify: # We check the certificate using a list of known verifiers import conans.client.rest.cacert as cacert verify = cacert.file_path downloader = Downloader(_global_requester, out, verify=verify) downloader.download(url, filename, retry=retry, retry_wait=retry_wait) out.writeln("")
def download(url, filename, verify=True, out=None, retry=2, retry_wait=5): out = out or ConanOutput(sys.stdout, True) if verify: # We check the certificate using a list of known verifiers import conans.client.rest.cacert as cacert verify = cacert.file_path downloader = Downloader(requests, out, verify=verify) downloader.download(url, filename, retry=retry, retry_wait=retry_wait) out.writeln("")
def _download_and_save_files(self, base_url, dest_folder, files): downloader = Downloader(self.requester, self._output, self.verify_ssl) # Take advantage of filenames ordering, so that conan_package.tgz and conan_export.tgz # can be < conanfile, conaninfo, and sent always the last, so smaller files go first for filename in sorted(files, reverse=True): if self._output: self._output.writeln("Downloading %s" % filename) resource_url = "%s/%s" % (base_url, filename) abs_path = os.path.join(dest_folder, filename) downloader.download(resource_url, abs_path, auth=self.auth)
def download(url, filename, verify=True): out = ConanOutput(sys.stdout, True) if verify: # We check the certificate using a list of known verifiers import conans.client.rest.cacert as cacert verify = cacert.file_path downloader = Downloader(requests, out, verify=verify) content = downloader.download(url) out.writeln("") save(filename, content)
def download_files(self, file_urls, output): """ :param: file_urls is a dict with {filename: url} Its a generator, so it yields elements for memory performance """ downloader = Downloader(self.requester, output, self.VERIFY_SSL) for filename, resource_url in file_urls.iteritems(): output.writeln("Downloading %s" % filename) contents = downloader.download(resource_url) output.writeln("") yield os.path.normpath(filename), contents
def _download_files(self, file_urls): """ :param: file_urls is a dict with {filename: url} Its a generator, so it yields elements for memory performance """ downloader = Downloader(self.requester, self._output, self.verify_ssl) # Take advantage of filenames ordering, so that conan_package.tgz and conan_export.tgz # can be < conanfile, conaninfo, and sent always the last, so smaller files go first for filename, resource_url in sorted(file_urls.items(), reverse=True): self._output.writeln("Downloading %s" % filename) auth, _ = self._file_server_capabilities(resource_url) contents = downloader.download(resource_url, auth=auth) self._output.writeln("") yield os.path.normpath(filename), contents
def download_files(self, file_urls, output=None): """ :param: file_urls is a dict with {filename: url} Its a generator, so it yields elements for memory performance """ downloader = Downloader(self.requester, output, self.verify_ssl) # Take advantage of filenames ordering, so that conan_package.tgz and conan_export.tgz # can be < conanfile, conaninfo, and sent always the last, so smaller files go first for filename, resource_url in sorted(file_urls.items(), reverse=True): if output: output.writeln("Downloading %s" % filename) auth, _ = self._file_server_capabilities(resource_url) contents = downloader.download(resource_url, auth=auth) if output: output.writeln("") yield os.path.normpath(filename), contents
def get_path(self, conan_reference, package_id, path): """Gets a file content or a directory list""" tmp = "%s/download_urls" if not package_id: url = tmp % self._recipe_url(conan_reference) else: url = tmp % self._package_url( PackageReference(conan_reference, package_id)) try: urls = self._get_file_to_url_dict(url) except NotFoundException: if package_id: raise NotFoundException("Package %s:%s not found" % (conan_reference, package_id)) else: raise NotFoundException("Recipe %s not found" % str(conan_reference)) def is_dir(the_path): if the_path == ".": return True for the_file in urls: if the_path == the_file: return False elif the_file.startswith(the_path): return True raise NotFoundException("The specified path doesn't exist") if is_dir(path): ret = [] for the_file in urls: if path == "." or the_file.startswith(path): tmp = the_file[len(path) - 1:].split("/", 1)[0] if tmp not in ret: ret.append(tmp) return sorted(ret) else: downloader = Downloader(self.requester, None, self.verify_ssl) auth, _ = self._file_server_capabilities(urls[path]) content = downloader.download(urls[path], auth=auth) return decode_text(content)
def download(url, filename, verify=True, out=None, retry=2, retry_wait=5, overwrite=False, auth=None, headers=None): out = out or ConanOutput(sys.stdout, True) downloader = Downloader(_global_requester, out, verify=verify) downloader.download(url, filename, retry=retry, retry_wait=retry_wait, overwrite=overwrite, auth=auth, headers=headers) out.writeln("")
def _download_files_to_folder(self, file_urls, to_folder): """ :param: file_urls is a dict with {filename: abs_path} It writes downloaded files to disk (appending to file, only keeps chunks in memory) """ downloader = Downloader(self.requester, self._output, self.verify_ssl) ret = {} # Take advantage of filenames ordering, so that conan_package.tgz and conan_export.tgz # can be < conanfile, conaninfo, and sent always the last, so smaller files go first for filename, resource_url in sorted(file_urls.items(), reverse=True): if self._output: self._output.writeln("Downloading %s" % filename) auth, _ = self._file_server_capabilities(resource_url) abs_path = os.path.join(to_folder, filename) downloader.download(resource_url, abs_path, auth=auth) if self._output: self._output.writeln("") ret[filename] = abs_path return ret
def download_files_to_folder(self, file_urls, to_folder, output=None): """ :param: file_urls is a dict with {filename: abs_path} It writes downloaded files to disk (appending to file, only keeps chunks in memory) """ downloader = Downloader(self.requester, output, self.verify_ssl) ret = {} # Take advantage of filenames ordering, so that conan_package.tgz and conan_export.tgz # can be < conanfile, conaninfo, and sent always the last, so smaller files go first for filename, resource_url in sorted(file_urls.items(), reverse=True): if output: output.writeln("Downloading %s" % filename) auth, _ = self._file_server_capabilities(resource_url) abs_path = os.path.join(to_folder, filename) downloader.download(resource_url, abs_path, auth=auth) if output: output.writeln("") ret[filename] = abs_path return ret
def get_path(self, conan_reference, package_id, path): """Gets a file content or a directory list""" if not package_id: url = "%s/conans/%s/download_urls" % (self._remote_api_url, "/".join(conan_reference)) else: url = "%s/conans/%s/packages/%s/download_urls" % (self._remote_api_url, "/".join(conan_reference), package_id) try: urls = self._get_file_to_url_dict(url) except NotFoundException: if package_id: raise NotFoundException("Package %s:%s not found" % (conan_reference, package_id)) else: raise NotFoundException("Recipe %s not found" % str(conan_reference)) def is_dir(the_path): if the_path == ".": return True for the_file in urls.keys(): if the_path == the_file: return False elif the_file.startswith(the_path): return True raise NotFoundException("The specified path doesn't exist") if is_dir(path): ret = [] for the_file in urls.keys(): if path == "." or the_file.startswith(path): tmp = the_file[len(path)-1:].split("/", 1)[0] if tmp not in ret: ret.append(tmp) return sorted(ret) else: downloader = Downloader(self.requester, None, self.verify_ssl) auth, _ = self._file_server_capabilities(urls[path]) content = downloader.download(urls[path], auth=auth) return decode_text(content)
def download(url, filename, verify=True, out=None, retry=2, retry_wait=5, overwrite=False, auth=None, headers=None): out = out or ConanOutput(sys.stdout, True) if verify: # We check the certificate using a list of known verifiers import conans.client.rest.cacert as cacert verify = cacert.file_path downloader = Downloader(_global_requester, out, verify=verify) downloader.download(url, filename, retry=retry, retry_wait=retry_wait, overwrite=overwrite, auth=auth, headers=headers) out.writeln("")
def _get_remote_file_contents(self, url): # We don't want traces in output of these downloads, they are ugly in output downloader = Downloader(self.requester, None, self.verify_ssl) contents = downloader.download(url, auth=self.auth) return contents
def _get_remote_file_contents(self, url): downloader = Downloader(self.requester, self._output, self.verify_ssl) contents = downloader.download(url, auth=self.auth) return contents