:call-seq:
   download_artifact

 Downloads artifact from given repository,
 supports downloading snapshot artifact with relocation on succeed to local repository
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
103192
def collect_local(self, path):
        
        for f in os.listdir(path):
            lpath = os.path.join(path, f)
            if not os.path.isfile(lpath):
                continue
            Artifact(self, lpath)
125740
def _do_download(version, download_base, to_dir, download_delay):
    """"""
    py_desig = 'py{sys.version_info[0]}.{sys.version_info[1]}'.format(sys=sys)
    tp = 'setuptools-{version}-{py_desig}.egg'
    egg = os.path.join(to_dir, tp.format(**locals()))
    if not os.path.exists(egg):
        archive = download_setuptools(version, download_base,
            to_dir, download_delay)
        _build_egg(egg, archive, to_dir)
    sys.path.insert(0, egg)

    # Remove previously-imported pkg_resources if present (see
    # https://bitbucket.org/pypa/setuptools/pull-request/7/ for details).
    if 'pkg_resources' in sys.modules:
        _unload_pkg_resources()

    import setuptools
    setuptools.bootstrap_install_from = egg
580143
function fetchArchive(targetPath, template) {
  var q = Q.defer();
  var replace = require("replace");

  var archiveUrl = template.repo
  // The folder name the project will be downloaded and extracted to
  var message = ['Downloading:'.bold, archiveUrl].join(' ');
  console.log(message);

  var tmpFolder = os.tmpdir();
  var tempZipFilePath = path.join(tmpFolder, 'mobilecaddy-' + new Date().getTime());

  new Download({mode: '755', extract: true})
    .get(archiveUrl)
    .dest(tempZipFilePath)
    .run(function (err, files) {
        if (!err) {
          fs.rename(files[0].path, targetPath,
            function(res){
              if (!res) {
                replace({
                    regex: template.name,
                    replacement: targetPath,
                    paths: [targetPath],
                    recursive: true,
                    silent: true,
                });
                q.resolve();
              } else {
                console.error('Renaming template repo failed '.error);
                console.error(res);
                q.reject(res);
              }
            })
        } else {
          console.error(err);
          q.reject(err);
        }
    });

  return q.promise;
}
1188379
def download(self, local, remote):
        
        self.sync(RemoteFile(remote, self.api), LocalFile(local))
1138028
def _save_artifact(build, data, content_type):
    """"""
    sha1sum = hashlib.sha1(data).hexdigest()
    artifact = models.Artifact.query.filter_by(id=sha1sum).first()

    if artifact:
      logging.debug('Upload already exists: artifact_id=%r', sha1sum)
    else:
      logging.info('Upload received: artifact_id=%r, content_type=%r',
                   sha1sum, content_type)
      artifact = models.Artifact(
          id=sha1sum,
          content_type=content_type,
          data=data)
      _artifact_created(artifact)

    artifact.owners.append(build)
    return artifact
759636
def upload_from_archive(local_path, remote_path, properties = {})
      artifact = Resource::Artifact.new(local_path: local_path)
      artifact.upload_from_archive(key, remote_path, properties)
    end
698639
def fork_repository(self, project, repository, new_repository):
        
        url = 'rest/api/1.0/projects/{project}/repos/{repository}'.format(project=project,
                                                                          repository=repository)
        body = {}
        if new_repository is not None:
            body['name'] = new_repository
        if new_repository is not None:
            body['project'] = {'key': project}
        return self.post(url, data=body)
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)
1357185
def download_repo(repo_url, destination, commit=None):
    '''
    '''
    command = "git clone %s %s" % (repo_url, destination)
    os.system(command)
    return destination
509825
def download_file_part_run(download_context):
    
    destination_dir, file_url_data_dict, seek_amt, bytes_to_read = download_context.params
    project_file = ProjectFile(file_url_data_dict)
    local_path = project_file.get_local_path(destination_dir)
    retry_chunk_downloader = RetryChunkDownloader(project_file, local_path,
                                                  seek_amt, bytes_to_read,
                                                  download_context)
    retry_chunk_downloader.run()
    return 'ok'
5172
def download_to(self, folder):
        '''
        
        '''
        urlretrieve(self.maven_url, os.path.join(folder, self.filename))
14476
public static function download( $id, $repository_name ) {
		if ( Utils\is_snapshot_cached( $id ) ) {
			Log::instance()->write( 'Snapshot found in cache.' );

			return self::get( $id );
		}

		$create_dir = Utils\create_snapshot_directory( $id );

		if ( ! $create_dir ) {
			Log::instance()->write( 'Cannot create necessary snapshot directories.', 0, 'error' );

			return false;
		}

		$repository = RepositoryManager::instance()->setup( $repository_name );

		if ( ! $repository ) {
			Log::instance()->write( 'Could not setup repository.', 0, 'error' );

			return false;
		}

		Log::instance()->write( 'Getting snapshot information...' );

		$snapshot = $repository->getDB()->getSnapshot( $id );

		if ( ! $snapshot ) {
			Log::instance()->write( 'Could not get snapshot from database.', 0, 'error' );

			return false;
		}

		if ( empty( $snapshot ) || empty( $snapshot['project'] ) ) {
			Log::instance()->write( 'Missing critical snapshot data.', 0, 'error' );
			return false;
		}

		/**
		 * Backwards compant. Add repository to meta before we started saving it.
		 */
		if ( empty( $snapshot['repository'] ) ) {
			$snapshot['repository'] = $repository_name;
		}

		Log::instance()->write( 'Downloading snapshot files and database (' . Utils\format_bytes( $snapshot['size'] ) . ')...' );

		$snapshot_path = Utils\get_snapshot_directory() . $id . '/';

		$download = $repository->getS3()->downloadSnapshot( $id, $snapshot['project'], $snapshot_path . 'data.sql.gz', $snapshot_path . 'files.tar.gz' );

		if ( ! $download ) {
			Log::instance()->write( 'Failed to download snapshot.', 0, 'error' );

			return false;
		}

		/**
		 * Finally save snapshot meta to meta.json
		 */
		$meta_handle = @fopen( $snapshot_path . 'meta.json', 'x' ); // Create file and fail if it exists.

		if ( ! $meta_handle ) {
			Log::instance()->write( 'Could not create meta.json.', 0, 'error' );

			return false;
		}

		fwrite( $meta_handle, json_encode( $snapshot, JSON_PRETTY_PRINT ) );

		return new self( $id, $repository_name, $snapshot, true );
	}
1107333
function downloadUpdateRepo(config, callback) {

  console.log('Downloading repo...'.magenta);

  // Keep track if the request fails to prevent the continuation of the install
  var requestFailed = false;

  // TODO: have this hit different templating repos
  var repoRequest = request(config.baseGit + '/generate-repo.zip');

  repoRequest
    .on('response', function (response) {
      // If we fail, set it as failing and remove zip file
      if (response.statusCode !== 200) {
        requestFailed = true;
        fs.unlinkSync('.generate-repo.zip');
        callback(true);
      }
    })
    .pipe(fs.createWriteStream('.generate-repo.zip'))
    .on('close', function () {
      if (requestFailed) return;

      callback(null, '.generate-repo.zip');
    });
}
246396
public void resolveDependencies(boolean downloadArtifacts, Map<String,String> properties) throws URLException, DependencyException {
        log.debug( "Resolving Dependencies" );
        
        log.debug("Local Repo Path: {}", localRepoPath);

        if ( log.isDebugEnabled() ) {
            log.debug("Remote Repositories:");
            for (RemoteRepository repo : getRemoteRepositories()) {
                log.debug("  {}", repo.toString());
            }
        }

        RepositoryClient repoClient = new RepositoryClient(this.getLocalRepoPath());
        if ( properties != null ) {
            repoClient.setProperties( properties );
        }
        
        // If there are local build artifacts, create a BuildWorkspaceReader to
        // override remote artifacts with the local build artifacts.
        if ( buildArtifacts.size() > 0 ) {
            repoClient.setBuildWorkspaceReader( buildArtifacts );
        }
        
        CollectRequest collectRequest = new CollectRequest();
        collectRequest.setDependencies( new ArrayList<Dependency>(getDependencies()));
        
        try {
            collectRequest.addRepository(RepoBuilder.remoteRepositoryFromUrl("file:" + this.getLocalRepoPath()));
        } catch (MalformedURLException e) {
            throw new URLException("Failed to add local repo to request", e);
        }

        for (RemoteRepository repo : getRemoteRepositories()) {
            collectRequest.addRepository(repo);
        }

        CollectResult collectResult;
        try {
            collectResult = repoClient.collectDependencies(collectRequest);
        } catch (DependencyCollectionException e) {
            throw new DependencyException(e);
        }

        preorderedNodeList = new PreorderNodeListGenerator();
        if (downloadArtifacts) {
            DependencyRequest dependencyRequest = new DependencyRequest(collectRequest, null);

            log.debug("Resolving dependencies to files");
            DependencyResult dependencyResult;
            try {
                dependencyResult = repoClient.resolveDependencies(dependencyRequest);
            } catch (DependencyResolutionException e) {
                throw new DependencyException(e);
            }
            dependencyResult.getRoot().accept(preorderedNodeList);

        } else {
            collectResult.getRoot().accept(preorderedNodeList);
        }

        //this.setDependencies( new HashSet<Dependency>(preorderedNodeList.getDependencies(true)));
        log.debug("Setting resolved dependencies: {}", this.getDependencies());
    }
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
233420
def _download_repo_metadata(self, args):
        '''
        
        '''
        cache = salt.cache.Cache(self.opts, self.opts['spm_cache_dir'])

        def _update_metadata(repo, repo_info):
            dl_path = '{0}/SPM-METADATA'.format(repo_info['url'])
            if dl_path.startswith('file://'):
                dl_path = dl_path.replace('file://', '')
                with salt.utils.files.fopen(dl_path, 'r') as rpm:
                    metadata = salt.utils.yaml.safe_load(rpm)
            else:
                metadata = self._query_http(dl_path, repo_info)

            cache.store('.', repo, metadata)

        repo_name = args[1] if len(args) > 1 else None
        self._traverse_repos(_update_metadata, repo_name)