Setup Drush configration file.
173529
protected function doSetupDrush() {
    $content = file_get_contents(__DIR__ . '/../dist/drushrc.php');
    $content = str_replace('BUILD_ROOT', $this->getBuildRoot(), $content);
    $filename = $this->getDefaultDirectory() . '/drushrc.php';
    $this->write('Setup default Drush configuration file at <comment>%s</comment>', $this->shortenDirectory($filename));
    file_put_contents($filename, $content);
  }
1120027
private void setupFile() {
        if (!new File(directory).exists() && !new File(directory).mkdirs()) {
            try {
                throw new IOException("Unable to create output directory");
            } catch (IOException e) {
                log.info(e);
            }
        }
        if (!file.exists()) {
            try {
                if (!file.createNewFile()) {
                    throw new IOException("Unable to create output file");
                }
            } catch (IOException e) {
                log.error(e);
            }
        }
    }
715880
public function populateHelperConfig() {
    $this->set('drush.alias', $this->get('drush.default_alias'));

    if (!$this->get('multisites')) {
      $this->set('multisites', $this->getSiteDirs());
    }

    $multisites = $this->get('multisites');
    $first_multisite = reset($multisites);
    $site = $this->get('site', $first_multisite);
    $this->setSite($site);
  }
1327380
public function import() {
    $task = $this->taskDrush()
      ->drush('sql-drop')
      ->drush('sql-cli < ' . $this->getConfigValue('setup.dump-file'));
    $result = $task->run();
    $exit_code = $result->getExitCode();

    if ($exit_code) {
      throw new BltException("Unable to import setup.dump-file.");
    }
  }
1330394
def setup(self):
        """"""
        if not isinstance(self.filePath, str):
            raise TypeError("File path is not a string!")
        if self.controller is None:
            raise ValueError("Command controller hasn't been specified!")
1073847
def _setup_output_file(self, output_filename, args, write_header=True):
        """"""
        # write command line into outputFile
        # (without environment variables, they are documented by benchexec)
        try:
            output_file = open(output_filename, 'w') # override existing file
        except IOError as e:
            sys.exit(e)

        if write_header:
            output_file.write(' '.join(map(util.escape_string_shell, self._build_cmdline(args)))
                              + '\n\n\n' + '-' * 80 + '\n\n\n')
            output_file.flush()

        return output_file
702508
public function setupDrupalFilesystem()
    {
        $this->taskFilesystemStack()
            ->chmod($this->sitesPath, 0775, 0000, true)
            ->mkdir("{$this->sitesPath}/default/files", 0775, true)
            ->run();

        if ($this->getProjectVersion() >= 8) {
            $install_path = $this->getInstallPath();

            $this->taskFilesystemStack()
                ->mkdir("{$install_path}/profiles/custom", 0775, true)
                ->mkdir("{$install_path}/modules/custom", 0775, true)
                ->mkdir("{$install_path}/modules/contrib", 0775, true)
                ->run();
        }

        return $this;
    }
909356
def init(ctx, client, directory, name, force, use_external_storage):
    """"""
    if not client.use_external_storage:
        use_external_storage = False

    ctx.obj = client = attr.evolve(
        client,
        path=directory,
        use_external_storage=use_external_storage,
    )

    msg = 'Initialized empty project in {path}'
    branch_name = None

    stack = contextlib.ExitStack()

    if force and client.repo:
        msg = 'Initialized project in {path} (branch {branch_name})'
        merge_args = ['--no-ff', '-s', 'recursive', '-X', 'ours']

        try:
            commit = client.find_previous_commit(
                str(client.renku_metadata_path),
            )
            branch_name = 'renku/init/' + str(commit)
        except KeyError:
            from git import NULL_TREE
            commit = NULL_TREE
            branch_name = 'renku/init/root'
            merge_args.append('--allow-unrelated-histories')

        ctx.obj = client = stack.enter_context(
            client.worktree(
                branch_name=branch_name,
                commit=commit,
                merge_args=merge_args,
            )
        )

    try:
        with client.lock:
            path = client.init_repository(name=name, force=force)
    except FileExistsError:
        raise click.UsageError(
            'Renku repository is not empty. '
            'Please use --force flag to use the directory as Renku '
            'repository.'
        )

    stack.enter_context(client.commit())

    with stack:
        # Install Git hooks.
        from .githooks import install
        ctx.invoke(install, force=force)

        # Create all necessary template files.
        from .runner import template
        ctx.invoke(template, force=force)

    click.echo(msg.format(path=path, branch_name=branch_name))
463831
def setup():
    

    init_tasks()

    run_hook("before_setup")

    # Create shared folder
    env.run("mkdir -p %s" % (paths.get_shared_path()))
    env.run("chmod 755 %s" % (paths.get_shared_path()))

    # Create backup folder
    env.run("mkdir -p %s" % (paths.get_backup_path()))
    env.run("chmod 750 %s" % (paths.get_backup_path()))

    # Create uploads folder
    env.run("mkdir -p %s" % (paths.get_upload_path()))
    env.run("chmod 775 %s" % (paths.get_upload_path()))

    run_hook("setup")
    run_hook("after_setup")
421669
protected function configure()
    {

        // initialize the command with the required/optional options
        $this->setName(CommandNames::IMPORT_CREATE_CONFIGURATION_FILE)
             ->setDescription('Create\'s a configuration file from the given entity\'s template')
             ->addOption(InputOptionKeys::DEST, null, InputOption::VALUE_REQUIRED, 'The relative/absolut pathname of the destination file');

        // invoke the parent method
        parent::configure();
    }
986756
def init(directory):
    """"""
    username = click.prompt("Input your username")
    password = click.prompt("Input your password", hide_input=True,
                            confirmation_prompt=True)
    log_directory = click.prompt("Input your log directory")

    if not path.exists(log_directory):
        sys.exit("Invalid log directory, please have a check.")

    config_file_path = path.join(directory, 'v2ex_config.json')
    config = {
        "username": username,
        "password": password,
        "log_directory": path.abspath(log_directory)
    }
    with open(config_file_path, 'w') as f:
        json.dump(config, f)
    click.echo("Init the config file at: {0}".format(config_file_path))
630605
def run(self):
        """"""
        self._make_lib_file_symbolic_links()
        self._copy_each_include_files_to_include_dir()
        self._make_dep_lib_file_sym_links_and_copy_include_files()
        self.setup_py.add_patchs_to_build_without_pkg_config(
            self.rpm.lib_dir, self.rpm.include_dir
        )
        self.setup_py.apply_and_save()
        self._build_and_install()
768541
def dump(self):
        """"""
        try:
            import yaml
            cfg_file = self._cfg_file()
            cfg_dir, __ = os.path.split(cfg_file)
            os.makedirs(cfg_dir, exist_ok=True)
            with open(cfg_file, 'w') as f:
                yaml.dump(self, f)
        except ImportError as err:
            raise RuntimeError(
                'Cannot dump the configuration settings to file. You need to '
                'install the necessary dependencies (pyyaml, appdirs).'
            ) from err
1192504
def __setup_fileserver(self):
        '''
        
        '''
        # Avoid circular import
        import salt.fileserver
        self.fs_ = salt.fileserver.Fileserver(self.opts)
        self._serve_file = self.fs_.serve_file
        self._file_find = self.fs_._find_file
        self._file_hash = self.fs_.file_hash
        self._file_hash_and_stat = self.fs_.file_hash_and_stat
        self._file_list = self.fs_.file_list
        self._file_list_emptydirs = self.fs_.file_list_emptydirs
        self._dir_list = self.fs_.dir_list
        self._symlink_list = self.fs_.symlink_list
        self._file_envs = self.fs_.file_envs
870628
def _setup_helper():
    """"""
    base = os.path.abspath(os.path.dirname(__file__))
    helper = os.path.join(base, "helper.sh")
    with open(helper) as fh:
        click.echo(fh.read())
542651
def merge(self):
        """"""
        temp_dir = self.temp_dir
        app_dir = self.application.directory
        for root, dirs, files in os.walk(temp_dir):
            for directory in dirs:
                directory = os.path.join(root, directory)
                directory = directory.replace(temp_dir, app_dir, 1)
                try:
                    os.mkdir(directory)
                except OSError:
                    pass
            for file in files:
                source = os.path.join(root, file)
                target = source.replace(temp_dir, app_dir, 1)
                relative_target = target.replace(app_dir, '.')
                action = 'r'
                if (
                    os.path.exists(target)
                    and not filecmp.cmp(source, target, shallow=False)
                    and os.stat(target).st_size > 0
                ):
                    # target exists, is not empty, and does not
                    # match source
                    if target.endswith('__init__.py'):
                        # default merge __init__.py files
                        # if non-empty, these should only
                        # contain imports from submoduiles
                        action = 'm'
                    elif target.endswith('base.py'):
                        # default skip base.py files
                        # these should be extended by the developer
                        action = 's'
                    else:
                        default = 'm'
                        action = click.prompt(
                            style.prompt(
                                '%s already exists, '
                                '[r]eplace, [s]kip, or [m]erge?' % (
                                    relative_target
                                ),
                            ),
                            default=style.default(default)
                        ) if self.interactive else default
                        action = click.unstyle(action).lower()
                        if action not in {'r', 'm', 's'}:
                            action = default

                if action == 's':
                    self.stdout.write(
                        '? %s' % style.white(relative_target),
                        fg='yellow'
                    )
                    continue
                if action == 'r':
                    with open(source, 'r') as source_file:
                        with open(target, 'w') as target_file:
                            target_file.write(source_file.read())
                    self.stdout.write(
                        style.green(
                            '+ %s' % style.white(relative_target)
                        )
                    )
                if action == 'm':
                    with open(target, 'r') as target_file:
                        with open(source, 'r') as source_file:
                            merged = merge(
                                target_file.read(),
                                source_file.read()
                            )
                    with open(target, 'w') as target_file:
                        target_file.write(merged)

                    self.stdout.write(
                        style.yellow('> %s' % style.white(relative_target))
                    )
895748
protected function configHandle()
    {
        $packageConfigPath = __DIR__.'/config/config.php';
        $appConfigPath     = config_path('comment.php');

        $this->mergeConfigFrom($packageConfigPath, 'comment');

        $this->publishes([
            $packageConfigPath => $appConfigPath,
        ], 'config');
    }