Download files from the repository
169588
def downloadFiles(self, prompt=True, extract=False):
		""""""
		#First, get the download urls
		data = self.data
		downloadUrls = self.getDownloadUrls()
		
		#Then, confirm the user wants to do this
		if prompt:
			confirm = raw_input("Download files [Y/N]? ")
			if confirm.lower() != 'y':
				self.printd("Operation aborted by user input")
				return
				
		#Now, if they still do, do all this stuff:
		counter = -1
		for datum in data:
			counter += 1
			try:
				download = downloadUrls[counter]
			except:
				pass
				
			# Download the file; fix our user agent
			self.printd("Downloading " + datum[0] + " from " + download)
			headers = { 'User-Agent' : 'calcpkg/2.0' }
			request = urllib2.Request(download, None, headers)
			fileData = urllib2.urlopen(request).read()
			
			# Now, process the downloaded file
			dowName = datum[0]
			# Use a helper function to remove /pub, /files
			dowName = util.removeRootFromName(dowName)
			dowName = dowName[1:]
			dowName = dowName.replace('/', '-')
			dowName = self.downloadDir + dowName
			try:
				downloaded = open(dowName, 'wb')
			except:
				os.remove(dowName)
			downloaded.write(fileData)
			downloaded.close()
			self.printd("Download complete! Wrote file " + dowName + "\n")

			#Extract them if told to do so
			if extract:
				extractType = ""
				if '.zip' in dowName:
					extractType = "zip"
				elif '.tar' in dowName:
					extractType = "tar"
					specType = ""
					if '.bz2' in dowName:
						specType = ":bz2"
					elif ".gz" in dowName:
						specType = ":gz"
				elif ".tgz" in dowName:
					extractType = "tar"
					specType = ":gz"

				if extractType != "":
					self.printd("Extracting file " + dowName + ", creating directory for extracted files")
					dirName, a, ending = dowName.partition('.')
					dirName = dirName + '-' + ending
					try:
						os.mkdir(dirName)
					except:
						pass
					if extractType == "zip":
						archive = zipfile.ZipFile(dowName, 'r')
					elif extractType == "tar":
						archive = tarfile.open(dowName, "r" + specType)
					else:
						self.printd("An unknown error has occured!")
						return
					archive.extractall(dirName)
					self.printd("All files in archive extracted to " + dirName)
					os.remove(dowName)
					self.printd("The archive file " + dowName + " has been deleted!\n")
277536
def download(self, path, file):
        """"""

        resp = self._sendRequest("GET", path)
        if resp.status_code == 200:
            with open(file, "wb") as f:
                f.write(resp.content)
        else:
            raise YaDiskException(resp.status_code, resp.content)
1206903
def download(self, filename, representation, overwrite=False):
        
        download(self.input, filename, representation, overwrite, self.resolvers, self.get3d, **self.kwargs)
405157
def release_downloads(request, package_name, version):
    
    session = DBSession()
    release_files = ReleaseFile.by_release(session, package_name, version)
    if release_files:
        release_files = [(f.release.package.name,
                            f.filename) for f in release_files]
    return release_files
947500
function(dataUri, fileName) {

            var blob = joint.util.dataUriToBlob(dataUri);
            joint.util.downloadBlob(blob, fileName);
        }
1174891
def pub_download(args, location=None, prefix=""):
    
    download(location, remotes=args, prefix=prefix)
266980
def repository(namespace, name, branch='master'):
    ''''''
    with TemporaryDirectory() as download_path:
        old_directory = str(pwd()).strip()
        try:
            git.clone('https://github.com/{0}/{1}.git'.format(namespace, name), download_path)
            cd(download_path)
            git.fetch('origin', branch)
            git.checkout(branch)
            yield (download_path, git('rev-parse', 'HEAD'), redis.Dict(key="{0}.{1}".format(namespace, name)))
        except ErrorReturnCode_128:
            mkdir(download_path)
            yield (None, None, None)
        cd(old_directory)
940838
def download_files(files):
    ''''''
    for (url, file) in files:
        print("Downloading %s as %s" % (url, file))
        data = download_url(url)
        if data is None:
            continue
        try:
            open(file, mode='wb').write(data)
        except Exception as e:
            print("Failed to save to %s : %s" % (file, e))
435275
def _download_repodata(self, checked_repos):
        """"""
        self._files_downloaded = []
        self._repodata_files = []
        self.__counter = -1

        if checked_repos:
            for repo in checked_repos:
                path = self._repo_url_to_path(repo)
                self._files_downloaded.append(path)
                self._repodata_files.append(path)
                worker = self.download_async(repo, path)
                worker.url = repo
                worker.path = path
                worker.sig_finished.connect(self._repodata_downloaded)
        else:
            # Empty, maybe there is no internet connection
            # Load information from conda-meta and save that file
            path = self._get_repodata_from_meta()
            self._repodata_files = [path]
            self._repodata_downloaded()
1100736
def download_file(self, remote, local):
        
        file = open(local, 'wb')
        try:
            self.download(remote, file)
        finally:
            file.close()
113016
private function download()
    {
        $file = (string) gps('file');

        try {
            $backups = $this->getBackups();
        } catch (Exception $e) {
        }

        if (empty($backups) || !isset($backups[$file])) {
            $this->browser(array(gTxt('rah_backup_can_not_download'), E_ERROR));
            return;
        }

        extract($backups[$file]);

        @ini_set('zlib.output_compression', 'Off');
        @set_time_limit(0);
        @ignore_user_abort(true);

        ob_clean();
        header('Content-Description: File Download');
        header('Content-Type: application/octet-stream');
        header('Content-Disposition: attachment; filename="'.$name.'"; size="'.$size.'"');
        header('Content-Transfer-Encoding: binary');
        header('Expires: 0');
        header('Cache-Control: private');
        header('Content-Length: '.$size);
        ob_flush();
        flush();

        if ($f = fopen($path, 'rb')) {
            while(!feof($f) && connection_status() == 0) {
                echo fread($f, 1024*64);
                ob_flush();
                flush();
            }

            fclose($f);
        }

        exit;
    }
434395
def download_artifact(path, opts = {})
      download_file = "#{name}.#{Time.new.to_i}"
      begin
        URI.download path, download_file, opts
        if File.exist?(download_file)
          FileUtils.mkdir_p(File.dirname(name))
          FileUtils.mv(download_file, name)
        end
      ensure
        File.delete(download_file) if File.exist?(download_file)
      end
    end
972217
def download_file(self, *args, **kwargs):
        """"""
        return download_file(*args, **self._merge_overrides(**kwargs)).run()
418861
def download(self, project, filename, targetfilename, loadmetadata=None):
        """"""
        if loadmetadata is None: loadmetadata = self.loadmetadata
        f = clam.common.data.CLAMOutputFile(self.url + project,  filename, loadmetadata, self)
        f.copy(targetfilename)
1325443
File downloadFromRemoteRepository(ArtifactCoordinates artifactCoordinates, String packaging, Path artifactDirectory) {
        String artifactRelativeHttpPath = toGradleArtifactPath(artifactCoordinates);
        String artifactRelativeMetadataHttpPath = artifactCoordinates.relativeMetadataPath('/');
        for (String remoteRepos : remoteRepositories) {
            String artifactAbsoluteHttpPath = remoteRepos + artifactRelativeHttpPath + ".";
            File targetArtifactPomDirectory = artifactDirectory.resolve(computeGradleUUID(artifactCoordinates + ":pom")).toFile();
            File targetArtifactDirectory = artifactDirectory.resolve(computeGradleUUID(artifactCoordinates + ":" + packaging)).toFile();

            File artifactFile = doDownload(remoteRepos, artifactAbsoluteHttpPath, artifactRelativeHttpPath, artifactCoordinates, packaging, targetArtifactPomDirectory, targetArtifactDirectory);
            if (artifactFile != null) {
                return artifactFile; // Success
            }

            //Try to doDownload the snapshot version
            if (artifactCoordinates.isSnapshot()) {
                String remoteMetadataPath = remoteRepos + artifactRelativeMetadataHttpPath;
                try {
                    String timestamp = MavenArtifactUtil.downloadTimestampVersion(artifactCoordinates + ":" + packaging, remoteMetadataPath);

                    String timestampedArtifactRelativePath = artifactCoordinates.relativeArtifactPath('/', timestamp);
                    String artifactTimestampedAbsoluteHttpPath = remoteRepos + timestampedArtifactRelativePath + ".";
                    File targetTimestampedArtifactPomDirectory = artifactDirectory.resolve(computeGradleUUID(artifactCoordinates + ":" + timestamp + ":pom")).toFile();
                    File targetTimestampedArtifactDirectory = artifactDirectory.resolve(computeGradleUUID(artifactCoordinates + ":" + packaging)).toFile();

                    File snapshotArtifactFile = doDownload(remoteRepos, artifactTimestampedAbsoluteHttpPath, timestampedArtifactRelativePath, artifactCoordinates, packaging, targetTimestampedArtifactPomDirectory, targetTimestampedArtifactDirectory);
                    if (snapshotArtifactFile != null) {
                        return snapshotArtifactFile; //Success
                    }
                } catch (XPathExpressionException | IOException ex) {
                    Module.getModuleLogger().trace(ex, "Could not doDownload '%s' from '%s' repository", artifactRelativeHttpPath, remoteRepos);
                    // try next one
                }
            }
        }
        return null;
    }
708474
function download(target, dest, opts, fn) {
	if (typeof opts === 'function') {
		fn = opts;
		opts = null;
	}
	opts = opts || {};
	let clone = opts.clone || false;

	const repo = normalize(target);
	let url = getUrl(repo, clone);
	if (url && typeof url === 'object' && url.url) {
		if (typeof url.clone === 'boolean') {
			clone = url.clone;
		}
		url = url.url;
	}

	return PromiseA.try(() => {
		if (clone) {
			const checkout = repo.checkout && repo.checkout !== 'master' ? repo.checkout : null;
			debug('Cloning from:', url, checkout ? '#' + checkout : '');
			return PromiseA.fromCallback(cb => gitclone(url, dest, {checkout}, cb)).then(() => rm(dest + '/.git'));
		} else {
			debug('Downloading from:', url);
			return PromiseA.resolve(downloadUrl(url, dest, {extract: true, strip: 1, mode: '666', headers: {accept: 'application/zip'}}));
		}
	}).asCallback(fn);
}
196775
def download(client, target_dir):
    """"""
    print('')
    print("download inappproducts")
    print('---------------------')
    products = client.list_inappproducts()

    for product in products:
        path = os.path.join(target_dir, 'products')
        del product['packageName']
        mkdir_p(path)
        with open(os.path.join(path, product['sku'] + '.json'), 'w') as outfile:
            print("save product for {0}".format(product['sku']))
            json.dump(
                product, outfile, sort_keys=True,
                indent=4, separators=(',', ': '))