Deploy/Update a function from a project directory
434840
def deploy(
    config,
    name,
    bucket,
    timeout,
    memory,
    description,
    subnet_ids,
    security_group_ids
):
    
    # options should override config if it is there
    myname = name or config.name
    mybucket = bucket or config.bucket
    mytimeout = timeout or config.timeout
    mymemory = memory or config.memory
    mydescription = description or config.description
    mysubnet_ids = subnet_ids or config.subnet_ids
    mysecurity_group_ids = security_group_ids or config.security_group_ids

    vpc_config = {}
    if mysubnet_ids and mysecurity_group_ids:
        vpc_config = {
            'SubnetIds': mysubnet_ids.split(','),
            'SecurityGroupIds': mysecurity_group_ids.split(',')
        }

    click.echo('Deploying {} to {}'.format(myname, mybucket))
    lambder.deploy_function(
        myname,
        mybucket,
        mytimeout,
        mymemory,
        mydescription,
        vpc_config
    )
1093815
def perform_release(context):
    """"""
    try:
        run_tests()

        if not context.skip_changelog:
            generate_changelog(context)

        increment_version(context)

        build_distributions(context)

        install_package(context)

        upload_package(context)

        install_from_pypi(context)

        publish(context)
    except Exception:
        log.exception('Error releasing')
647541
def copy_helper(app_or_project, name, directory, dist, template_dir, noadmin):
    

    import shutil
    if not re.search(r'^[_a-zA-Z]\w*$', name): # If it's not a valid directory name.
        # Provide a smart error message, depending on the error.
        if not re.search(r'^[_a-zA-Z]', name):
            message = 'make sure the name begins with a letter or underscore'
        else:
            message = 'use only numbers, letters and underscores'
        raise CommandError("%r is not a valid project name. Please %s." % (name, message))
    top_dir = os.path.join(directory, dist)
    try:
        os.mkdir(top_dir)
    except OSError, e:
        raise CommandError(e)
        
    for d, subdirs, files in os.walk(template_dir):
        relative_dir = d[len(template_dir)+1:].replace('project_name', name)
        if relative_dir:
            os.mkdir(os.path.join(top_dir, relative_dir))
        for subdir in subdirs[:]:
            if subdir.startswith('.'):
                subdirs.remove(subdir)
        for f in files:
            if not f.endswith('.py'):
                # Ignore .pyc, .pyo, .py.class etc, as they cause various
                # breakages.
                continue
            path_old = os.path.join(d, f)
            path_new = os.path.join(top_dir, relative_dir, f.replace('project_name', name))
            fp_old = open(path_old, 'r')
            fp_new = open(path_new, 'w')
            if noadmin:
                fp_new.write(fp_old.read().replace('{{ project_name }}', name))
            else:
                fp_new.write(fp_old.read().replace('{{ project_name }}', name).replace('## ',''))
            fp_old.close()
            fp_new.close()
            try:
                shutil.copymode(path_old, path_new)
                _make_writeable(path_new)
            except OSError:
                sys.stderr.write(style.NOTICE("Notice: Couldn't set permission bits on %s. You're probably using an uncommon filesystem setup. No problem.\n" % path_new))
994651
function buildApp(src, dest, options, callback) {
  const appArgs = selectAppArgs(options);
  copy(src, dest, (error) => {
    if (error) {
      callback(`Error Copying temporary directory: ${error}`);
      return;
    }

    fs.writeFileSync(
      path.join(dest, '/nativefier.json'),
      JSON.stringify(appArgs),
    );

    maybeCopyScripts(options.inject, dest)
      .catch((err) => {
        log.warn(err);
      })
      .then(() => {
        changeAppPackageJsonName(dest, appArgs.name, appArgs.targetUrl);
        callback();
      });
  });
}
8827
def deploy(version):
    
    NAME = "pathquery"
    git = Command("git").in_dir(DIR.project)
    version_file = DIR.project.joinpath("VERSION")
    old_version = version_file.bytes().decode('utf8')
    if version_file.bytes().decode("utf8") != version:
        DIR.project.joinpath("VERSION").write_text(version)
        git("add", "VERSION").run()
        git("commit", "-m", "RELEASE: Version {0} -> {1}".format(
            old_version,
            version
        )).run()
        git("push").run()
        git("tag", "-a", version, "-m", "Version {0}".format(version)).run()
        git("push", "origin", version).run()
    else:
        git("push").run()

    # Set __version__ variable in __init__.py, build sdist and put it back
    initpy = DIR.project.joinpath(NAME, "__init__.py")
    original_initpy_contents = initpy.bytes().decode('utf8')
    initpy.write_text(
        original_initpy_contents.replace("DEVELOPMENT_VERSION", version)
    )
    python("setup.py", "sdist").in_dir(DIR.project).run()
    initpy.write_text(original_initpy_contents)

    # Upload to pypi
    python(
        "-m", "twine", "upload", "dist/{0}-{1}.tar.gz".format(NAME, version)
    ).in_dir(DIR.project).run()
1158754
function (project_id, copy_options, cb) {

            _util.buildQuery('projects/' + project_id + '/copy', copy_options, function (error, data) {

                return cb(error, data);

            });

        }
1194645
def update_project_files(cfg, proj_version):
    
    counters = {'files': 0, 'changes': 0}

    for project_file in cfg.files:
        if not project_file.file.exists():
            print("File \"%s\" not found" % project_file.filename, file=sys.stderr)
            continue

        # prepare data
        date_format = project_file.date_format or cfg.date_format

        rxp = re.compile(project_file.search, project_file.search_flags)
        replace = project_file.replace % {
            "date": time.strftime(date_format),
            "major": proj_version.major,
            "minor": proj_version.minor,
            "patch": proj_version.patch,
            "prerelease": proj_version.prerelease,
            "version": str(proj_version),
            "build": proj_version.build,
        }

        # update project files
        with \
                project_file.file.open(mode="r", encoding=project_file.encoding) as fh_in, \
                tempfile.NamedTemporaryFile(mode="w", encoding=project_file.encoding, delete=False) as fh_out:
            if project_file.match == 'line':
                changes = 0
                for line in fh_in:
                    (line, cnt) = rxp.subn(replace, line)
                    if cnt:
                        changes += cnt
                    fh_out.write(line)

                if changes:
                    counters['files'] += 1
                    counters['changes'] += changes

            elif project_file.match == 'file':
                data = fh_in.read()
                (data, cnt) = rxp.subn(replace, data)
                if cnt:
                    counters['files'] += 1
                    counters['changes'] += cnt
                fh_out.write(data)

            else:
                raise ConfigError("Unknown match type: \"%s\"" % project_file.match)

            fh_out.close()

            shutil.copystat(project_file.filename, fh_out.name)
            pathlib.Path(fh_out.name).rename(project_file.filename)

    return counters
268873
function customStrategy(projectDir, builder, cb)
{
  const dest = builder.getTargetDestination(projectDir);
  shelljs.rm('-rf', dest);

  const copyOptions = { overwrite: true, expand: true, dot: true };

  const onCustomInstallerFilesReady = function (err) {
    builder.buildFromSource(dest, projectDir);
    cb();
  };

  const onInstallerFilesReady = function (err) {
    if (err) {
      cb(err);
      return;
    }

    let customInstallerSrc = path.resolve(projectDir, "src", "installer");
    customInstallerSrc = fs.realpathSync(customInstallerSrc);

    const customInstallerTarget = path.resolve(dest, "src", "settings");
    copy(customInstallerSrc, customInstallerTarget, copyOptions, onCustomInstallerFilesReady);
  };

  let installerDir = path.resolve(projectDir, "node_modules", "@deskpro", INSTALLER_PACKAGE_NAME);
  installerDir = fs.realpathSync(installerDir);
  copy(installerDir, dest, copyOptions, onInstallerFilesReady);
}
767822
def _publish():

    import copy
    
    unity = _get_unity()
    fnlist = unity.list_toolkit_functions()
    # Loop through all the functions and inject it into
    # turicreate.extensions.[blah]
    # Note that [blah] may be somemodule.somefunction
    # and so the injection has to be
    # turicreate.extensions.somemodule.somefunction
    for fn in fnlist:
        props = unity.describe_toolkit_function(fn)
        # quit if there is nothing we can process
        if 'arguments' not in props:
            continue
        arguments = props['arguments']

        newfunc = _make_injected_function(fn, arguments)

        newfunc.__doc__ = "Name: " + fn + "\nParameters: " + str(arguments) + "\n"
        if 'documentation' in props:
            newfunc.__doc__ += props['documentation'] + "\n"

        newfunc.__dict__['__glmeta__'] = {'extension_name':fn}
        modpath = fn.split('.')
        # walk the module tree
        mod = _thismodule
        for path in modpath[:-1]:
            try:
                getattr(mod, path)
            except:
                _setattr_wrapper(mod, path, _types.ModuleType(name=path))
            mod = getattr(mod, path)
        _setattr_wrapper(mod, modpath[-1], newfunc)

    # Repeat for classes
    tkclasslist = unity.list_toolkit_classes()
    for tkclass in tkclasslist:
        m = unity.describe_toolkit_class(tkclass)
        # of v2 type
        if not ('functions' in m and 'get_properties' in m and 'set_properties' in m and 'uid' in m):
            continue

        # create a new class
        if _version_info.major == 3:
            new_class = _ToolkitClass.__dict__.copy()
            del new_class['__dict__']
            del new_class['__weakref__']
        else:
            new_class = copy.deepcopy(_ToolkitClass.__dict__)

        new_class['__init__'] = _types.FunctionType(new_class['__init__'].__code__,
                                                    new_class['__init__'].__globals__,
                                                    name='__init__',
                                                    argdefs=(),
                                                    closure=())

        # rewrite the init method to add the toolkit class name so it will
        # default construct correctly
        new_class['__init__'].tkclass_name = tkclass

        newclass = _class_type(tkclass, (), new_class)
        setattr(newclass, '__glmeta__', {'extension_name':tkclass})
        class_uid_to_class[m['uid']] = newclass
        modpath = tkclass.split('.')
        # walk the module tree
        mod = _thismodule
        for path in modpath[:-1]:
            try:
                getattr(mod, path)
            except:
                _setattr_wrapper(mod, path, _types.ModuleType(name=path))
            mod = getattr(mod, path)
        _setattr_wrapper(mod, modpath[-1], newclass)
442359
function rebuild (dir, _callback) {
  var cwd     = process.cwd()
    , gypInst = gyp()

  var callback = function (err) {
    _callback(err)
  }

  gypInst.parseArgv([ null, null, 'rebuild', '--loglevel', 'silent' ])
  process.chdir(dir)
  gypInst.commands.clean([], function (err) {
    if (err)
      return callback(new Error('node-gyp clean: ' + err.message))
    gypInst.commands.configure([], function (err) {
      if (err)
        return callback(new Error('node-gyp configure: ' + err.message))
      gypInst.commands.build([], function (err) {
        if (err)
          return callback(new Error('node-gyp build: ' + err.message))

        process.chdir(cwd)
        return callback()
      })
    })
  })
}
200143
function updateSite () {
    start('Adding new version of the docs site...');
    const options = { cwd: './code.material.angularjs.org' };
    writeDocsJson();

    // build files for bower
    exec([
        'rm -rf dist',
        'gulp docs'
    ]);
    replaceFilePaths();

    // copy files over to site repo
    exec([
        `cp -Rf ../dist/docs ${newVersion}`,
        'rm -rf latest && cp -Rf ../dist/docs latest',
        'git add -A',
        `git commit -m "release: version ${newVersion}"`,
        'rm -rf ../dist'
    ], options);
    replaceBaseHref(newVersion);
    replaceBaseHref('latest');

    // update firebase.json file
    updateFirebaseJson();
    exec(['git commit --amend --no-edit -a'], options);
    done();

    // add steps to push script
    pushCmds.push(
        comment('push the site'),
        'cd ' + options.cwd,
        'git pull --rebase --strategy=ours',
        'git push',
        'cd ..'
    );

    function updateFirebaseJson () {
      fs.writeFileSync(options.cwd + '/firebase.json', getFirebaseJson());
      function getFirebaseJson () {
        const json = require(options.cwd + '/firebase.json');
        json.hosting.rewrites = json.hosting.rewrites || [];
        const rewrites = json.hosting.rewrites;

        switch (rewrites.length) {
          case 0:
            rewrites.push(getRewrite('HEAD'));
          case 1:
            rewrites.push(getRewrite('latest'));
          default:
            rewrites.push(getRewrite(newVersion));
        }
        return JSON.stringify(json, null, 2);
        function getRewrite (str) {
          return {
            source:      '/' + str + '/**/!(*.@(js|html|css|json|svg|png|jpg|jpeg))',
            destination: '/' + str + '/index.html'
          };
        }
      }
    }

    function writeDocsJson () {
      const config = require(options.cwd + '/docs.json');
      config.versions.unshift(newVersion);

      // only set to default if not a release candidate
      config.latest = newVersion;
      fs.writeFileSync(options.cwd + '/docs.json', JSON.stringify(config, null, 2));
    }
  }
768119
function (callback) {
		fs.mkdir("./dist", function (err) {
			if (err && err.code !== "EEXIST") {
				callback(err);
				return;
			}

			callback(null);
		});
	}
192077
function downloadProjectCompilations(project, outputDir) {
	const promises = [];
	for (const platform in project.compilations) {
		if (!project.compilations.hasOwnProperty(platform)) {
			continue;
		}
		promises.push(downloadProjectCompilation(project, platform, outputDir).catch(() => {
			return undefined;
		}));
	}
	return Promise.all(promises);
}
265398
def deploy_local(self, dotfiles, target_root=None):
        """"""
        if target_root is None:
            target_root = self.args.path

        for source_path, target_path in dotfiles.items():
            source_path = path.join(self.source, source_path)
            target_path = path.join(target_root, target_path)

            if path.isfile(target_path) or path.islink(target_path):
                self.log.debug('Removing existing file at %s', target_path)
                os.unlink(target_path)

            elif path.isdir(target_path):
                self.log.debug('Removing existing dir at %s', target_path)
                shutil.rmtree(target_path)

            parent_dir = path.dirname(target_path)
            if not path.isdir(parent_dir):
                self.log.debug('Creating parent dir %s', parent_dir)
                os.makedirs(parent_dir)

            if self.args.copy:
                if path.isdir(source_path):
                    self.log.debug('Copying file %s to %s',
                                   source_path, target_path)
                    shutil.copytree(source_path, target_path)
                else:
                    self.log.debug('Copying dir %s to %s',
                                   source_path, target_path)
                    shutil.copy(source_path, target_path)

            else:
                self.log.debug('Symlinking %s -> %s', target_path, source_path)
                os.symlink(source_path, target_path)
1187783
function(dir, prefix) {
    if (fs.existsSync(dir)) {
      let dirname = path.relative(this.project.root, dir);
      let globs = this.parentRegistry.extensionsForType('js').map((extension) => `**/*.${extension}`);

      return walkSync(dir, { directories: false, globs }).map(file => {
        let module = prefix + '/' + file.replace(EXT_RE, '.js');
        this.fileLookup[module] = path.join(dirname, file);
        return module;
      });
    } else {
      return [];
    }
  }
854610
private function updateEverything()
    {
        // update env
        $env = basename($this->cwd);
        echo "\n> $env\n----------------------------\n";
        $this->exec('update', 'update-root-project');

        // update all projects
        $path = $this->cwd.'/'.$this->projectsDir;
        foreach (scandir($path) as $projectName) {
            if ($projectName[0] != '.' && is_dir($path.'/'.$projectName)) {
                echo "\n> $projectName\n----------------------------\n";
                $this->exec('update', 'update-project', [$projectName]);
            }
        }
    }
583455
def deploy(overwrite=False):
    
    check_settings()
    if overwrite:
        rmvirtualenv()
    deploy_funcs = [deploy_project,deploy_templates, deploy_static, deploy_media,  deploy_webconf, deploy_wsgi]
    if not patch_project() or overwrite:
        deploy_funcs = [deploy_db,mkvirtualenv,pip_install_requirements] + deploy_funcs
    for func in deploy_funcs: func()