copy project to local temp directory
4983
private boolean copyProjectFolder(String projectFolder, File buildGradleTempDirectory) {
        try {
            FileUtils.copyDirectory(new File(projectFolder), buildGradleTempDirectory);
        } catch (IOException e) {
            logger.error("Could not copy the folder {} to {} , the cause {}", projectFolder, buildGradleTempDirectory.getPath(), e.getMessage());
            return false;
        }
        logger.debug("copied folder {} to temp folder successfully", projectFolder);
        return true;
    }
1178041
private void copyToLocal(AlluxioURI srcPath, AlluxioURI dstPath) throws AlluxioException,
      IOException {
    URIStatus srcStatus = mFileSystem.getStatus(srcPath);
    File dstFile = new File(dstPath.getPath());
    if (srcStatus.isFolder()) {
      // make a local directory
      if (!dstFile.exists()) {
        if (!dstFile.mkdirs()) {
          throw new IOException("mkdir failure for directory: " + dstPath);
        } else {
          System.out.println("Create directory: " + dstPath);
        }
      }

      List<URIStatus> statuses;
      try {
        statuses = mFileSystem.listStatus(srcPath);
      } catch (AlluxioException e) {
        throw new IOException(e.getMessage());
      }

      List<String> errorMessages = new ArrayList<>();
      for (URIStatus status : statuses) {
        try {
          File subDstFile = new File(dstFile.getAbsolutePath(), status.getName());
          copyToLocal(
              new AlluxioURI(srcPath.getScheme(), srcPath.getAuthority(), status.getPath()),
              new AlluxioURI(dstPath.getScheme(), dstPath.getAuthority(), subDstFile.getPath()));
        } catch (IOException e) {
          errorMessages.add(e.getMessage());
        }
      }

      if (errorMessages.size() != 0) {
        throw new IOException(Joiner.on('\n').join(errorMessages));
      }
    } else {
      copyFileToLocal(srcPath, dstPath);
    }
  }
318699
def copy_config(project_path, output_dir):
    
    project_config = os.path.join(project_path, 'config.json')
    saved_config = os.path.join(output_dir, 'config.json')
    shutil.copy(project_config, saved_config)
23018
def make_temp(suffix="", prefix="tmp", dir=None):
    
    temporary = tempfile.mkstemp(suffix=suffix, prefix=prefix, dir=dir)
    os.close(temporary[0])
    try:
        yield temporary[1]
    finally:
        os.remove(temporary[1])
1349107
def _newproject(command, path, name, settings):
    
    key = None
    title = _get_project_title()
    template = _get_template(settings)

    # Init repo
    git = sh.git.bake(_cwd=path)
    puts(git.init())

    if template.get("url"):
        # Create submodule
        puts(git.submodule.add(template['url'], '_blueprint'))
        puts(git.submodule.update(*['--init']))

        # Create spreadsheet
        key = _create_spreadsheet(name, title, path, settings)

        # Copy html files
        puts(colored.green("\nCopying html files..."))
        files = glob.iglob(os.path.join(path, "_blueprint", "*.html"))
        for file in files:
            if os.path.isfile(file):
                dir, filename = os.path.split(file)
                if not filename.startswith("_") and not filename.startswith("."):
                    puts("Copying {0} to {1}".format(filename, path))
                    shutil.copy2(file, path)
        ignore = os.path.join(path, "_blueprint", ".gitignore")
        if os.path.isfile(ignore):
            shutil.copy2(ignore, path)
    else:
        empty_index_path = os.path.join(path, "index.html")
        open(empty_index_path, "w")

    # Create config file
    _copy_config_template(name, title, template, path, key, settings)

    # Commit
    puts(colored.green("\nInitial commit"))
    puts(git.add('.'))
    puts(git.commit(m='Created {0} from {1}'.format(name, template['name'])))

    _install_requirements(path)

    # Get site, run hook
    with ensure_project(command, args, path) as site:
        site.call_hook("newproject", site, git)

    # Messages
    puts("\nAll done! To preview your new project, type:\n")
    puts("{0} {1}".format(colored.green("tarbell switch"), colored.green(name)))
    puts("\nor\n")
    puts("{0}".format(colored.green("cd %s" % path)))
    puts("{0}".format(colored.green("tarbell serve\n")))

    puts("\nYou got this!\n")
535510
def copy_to_temp_file(file, temp_base_name)
      Tempfile.new(temp_base_name, AttachmentMagic.tempfile_path).tap do |tmp|
        tmp.close
        FileUtils.cp file, tmp.path
      end
    end
802892
def copy_dir(src, dst):
   
   try:
      debug.log("copy dir from "+ src, "to "+ dst)
      shutil.copytree(src, dst)
   except Exception as e:
      debug.log("Error: happened while copying!\n%s\n"%e)
49773
def setup(api=None):
    
    global tmp_dir_object

    tmp_dir_object = tempfile.TemporaryDirectory()

    dir_name = tmp_dir_object.name

    dir_a = os.path.join(dir_name, "a")
    os.mkdir(dir_a)
    dir_b = os.path.join(dir_name, "b")
    os.mkdir(dir_b)

    # populate directory a with text files
    file_list = [
            ["hi.txt", """Hi World!"""],
            ["hi.html", """<strong>Hi World!</strong>"""],
            ["hello.html", """
                <img src='/static/b/smile.png'</img>
                pop-up
                <script src='/static/a/hi.js'></script>"""],
            ["hi.js", """alert('Hi World')""" ]
    ]

    for f in file_list:
        with open(os.path.join(dir_a, f[0]), mode="wt") as fo:
            fo.write(f[1])

    # populate directory b with binary file
    image = b'\x89PNG\r\n\x1a\n\x00\x00\x00\rIHDR\x00\x00\x00\n\x00\x00\x00\n\x08\x02\x00\x00\x00\x02PX\xea\x00\x00\x006IDAT\x18\xd3c\xfc\xff\xff?\x03n\xc0\xc4\x80\x170100022222\xc2\x85\x90\xb9\x04t3\x92`7\xb2\x15D\xeb\xc6\xe34\xa8n4c\xe1F\x120\x1c\x00\xc6z\x12\x1c\x8cT\xf2\x1e\x00\x00\x00\x00IEND\xaeB`\x82'

    with open(os.path.join(dir_b, "smile.png"), mode="wb") as fo:
            fo.write(image)
1188571
def _copy_sources(self, target, results_dir):
    
    buildroot = get_buildroot()
    source_relative_to = target.address.spec_path
    for source in target.sources_relative_to_buildroot():
      dest = os.path.join(results_dir, os.path.relpath(source, source_relative_to))
      safe_mkdir(os.path.dirname(dest))
      shutil.copyfile(os.path.join(buildroot, source), dest)
432548
def copy(self, project, name=None):
        
        project = Transform.to_project(project)
        data = {
            'project': project
        }
        if name:
            data['name'] = name
        extra = {'resource': self.__class__.__name__, 'query': {
            'id': self.id,
            'data': data
        }}
        logger.info('Copying file', extra=extra)
        new_file = self._api.post(url=self._URL['copy'].format(id=self.id),
                                  data=data).json()
        return File(api=self._api, **new_file)
1089540
function copyFilesToPack(grunt, buildPath, filesToPack) {
	return function(callback) {
		grunt.util.async.forEach(filesToPack, function(fileConfig, callback) {
			try {
				var filepathDest;
				if (detectDestType(grunt, fileConfig.dest) === 'directory') {
					var dest = (fileConfig.orig.expand) ? fileConfig.dest : path.join(fileConfig.dest, fileConfig.src);
					filepathDest = path.join(buildPath, dest);
				} else {
					filepathDest = path.join(buildPath, fileConfig.dest);
				}

				if (grunt.file.isDir(fileConfig.src)) {
					if (fileConfig.directory) {
						// Copy a whole folder to the destination directory.
						grunt.verbose.writeln('Copying folder "' + fileConfig.src + '" to "' + filepathDest + '"');
						fs.copyRecursive(fileConfig.src, filepathDest, callback);
					} else {
						// Create a folder inside the destination directory.
						grunt.verbose.writeln('Creating folder "' + filepathDest + '"');
						fs.mkdirs(filepathDest, callback);
					}
				} else {
					// Copy a file to the destination directory inside the tmp folder.
					if (fileConfig.link) {
						grunt.verbose.writeln('Copying symlink "' + fileConfig.src + '->' + fileConfig.link + '" to "' + filepathDest + '"');
						//ensure the parent directory exists when making symlinks
						fs.mkdirs(getDirName(filepathDest), function(err) {
							if (err) throw err;
							_fs.symlink(fileConfig.link, filepathDest, 'file', callback);
						});
						
					}
					else {
						grunt.verbose.writeln('Copying file "' + fileConfig.src + '" to "' + filepathDest + '"');
						grunt.file.copy(fileConfig.src, filepathDest);
						fs.lstat(fileConfig.src, function(err, stat) {
							if (err) throw err;
							_fs.chmod(filepathDest, stat.mode, callback);
						});
					}
				}
				
			} catch(e) {
				callback(e);
			}
		}, callback);
	};
}
1054114
def _copy(src, dst):
    """"""
    try:
        shutil.copy(src, dst)
    except IsADirectoryError:
        if os.path.isdir(dst):
            dst = os.path.join(dst, os.path.basename(src))
        shutil.copytree(src, dst)
339551
def _make_temp_directory(prefix):
    '''
    
    '''
    temp_dir = _make_temp_filename(prefix=str(prefix))
    _os.makedirs(temp_dir)
    return temp_dir
1164175
def _tar_and_copy(src_dir, target_dir):
  """"""
  src_dir = src_dir.rstrip("/")
  target_dir = target_dir.rstrip("/")
  tmp_dir = tempfile.gettempdir().rstrip("/")
  src_base = os.path.basename(src_dir)
  shell_run(
      "tar --exclude=.git -zcf {tmp_dir}/{src_base}.tar.gz -C {src_dir} .",
      src_dir=src_dir,
      src_base=src_base,
      tmp_dir=tmp_dir)
  final_destination = "%s/%s.tar.gz" % (target_dir, src_base)
  shell_run(
      ("gsutil cp {tmp_dir}/{src_base}.tar.gz "
       "{final_destination}"),
      tmp_dir=tmp_dir,
      src_base=src_base,
      final_destination=final_destination)
  return final_destination
1079408
def copy_extras(config):
  """"""
  outdir = config['outdir']
  for dst, src in config['extras'].items():
    dst_path = os.path.join(outdir, dst)
    dst_dir = os.path.dirname(dst_path)
    if not os.path.isdir(dst_dir):
      os.makedirs(dst_dir)
    shutil.copy(src, dst_path)
1237490
def tempput(local_path=None, remote_path=None, use_sudo=False,
            mirror_local_mode=False, mode=None):
    """"""
    import warnings
    warnings.simplefilter('ignore', RuntimeWarning)
    if remote_path is None:
        remote_path = os.tempnam()
    put(local_path, remote_path, use_sudo, mirror_local_mode, mode)
    yield remote_path
    run("rm '{}'".format(remote_path))
552874
function copy() {

		// Copy dist files
		var distFolder = Release.dir.dist + "/dist",
			externalFolder = Release.dir.dist + "/external",
			readme = fs.readFileSync( Release.dir.dist + "/README.md", "utf8" ),
			rmIgnore = files
				.concat( [
					"README.md",
					"node_modules"
				] )
				.map( function( file ) {
					return Release.dir.dist + "/" + file;
				} );

		shell.config.globOptions = {
			ignore: rmIgnore
		};

		// Remove extraneous files before copy
		shell.rm( "-rf", Release.dir.dist + "/**/*" );

		shell.mkdir( "-p", distFolder );
		files.forEach( function( file ) {
			shell.cp( "-f", Release.dir.repo + "/" + file, distFolder );
		} );

		// Copy Sizzle
		shell.mkdir( "-p", externalFolder );
		shell.cp( "-rf", Release.dir.repo + "/external/sizzle", externalFolder );

		// Copy other files
		extras.forEach( function( file ) {
			shell.cp( "-rf", Release.dir.repo + "/" + file, Release.dir.dist );
		} );

		// Remove the wrapper from the dist repo
		shell.rm( "-f", Release.dir.dist + "/src/wrapper.js" );

		// Write generated bower file
		fs.writeFileSync( Release.dir.dist + "/bower.json", generateBower() );

		fs.writeFileSync( Release.dir.dist + "/README.md", editReadme( readme ) );

		console.log( "Files ready to add." );
		console.log( "Edit the dist README.md to include the latest blog post link." );
	}