Wizard for generating setup files.

Executes blt blt:init:settings command.
516149
public function wizardGenerateSettingsFiles() {
    $missing = FALSE;
    if (!$this->getInspector()->isDrupalLocalSettingsFilePresent()) {
      $this->logger->warning("<comment>{$this->getConfigValue('drupal.local_settings_file')}</comment> is missing.");
      $missing = TRUE;
    }
    elseif (!$this->getInspector()->isHashSaltPresent()) {
      $this->logger->warning("<comment>salt.txt</comment> is missing.");
      $missing = TRUE;
    }
    if ($missing) {
      $confirm = $this->confirm("Do you want to generate this required settings file(s)?");
      if ($confirm) {
        $bin = $this->getConfigValue('composer.bin');
        $this->executor
          ->execute("$bin/blt blt:init:settings")->printOutput(TRUE)->run();
      }
    }
  }
239749
def generate
      options = {}
      options[:title]  = title  if title
      options[:format] = format if format
      options[:output] = output if output
      options[:config] = config if config

      options[:files]  = collect_files

      locat = ::LOCat::Command.new(options)

      locat.run
    end
604437
def init(ctx, force):
    """"""
    if os.path.exists(PROJECT_CONFIG) and not force:
        click.secho(
            'An existing configuration file was found at "{}".\n'
            .format(PROJECT_CONFIG),
            fg='red', bold=True
        )
        click.secho(
            'Please remove it before in order to run the setup wizard or use\n'
            'the --force flag to overwrite it.'
        )
        ctx.exit(1)

    project_key = click.prompt('Project key on the issue tracker')
    base_branch = click.prompt('Integration branch', default='master')

    virtualenvs = ('.venv', '.env', 'venv', 'env')
    for p in virtualenvs:
        if os.path.exists(os.path.join(p, 'bin', 'activate')):
            venv = p
            break
    else:
        venv = ''
    venv_path = click.prompt('Path to virtual environment', default=venv)

    project_id = click.prompt('Project ID on Harvest', type=int)
    task_id = click.prompt('Task id on Harvest', type=int)

    config = configparser.ConfigParser()

    config.add_section('lancet')
    config.set('lancet', 'virtualenv', venv_path)

    config.add_section('tracker')
    config.set('tracker', 'default_project', project_key)

    config.add_section('harvest')
    config.set('harvest', 'project_id', str(project_id))
    config.set('harvest', 'task_id', str(task_id))

    config.add_section('repository')
    config.set('repository', 'base_branch', base_branch)

    with open(PROJECT_CONFIG, 'w') as fh:
        config.write(fh)

    click.secho('\nConfiguration correctly written to "{}".'
                .format(PROJECT_CONFIG), fg='green')
1308425
public function init() {
    $result = $this->taskFilesystemStack()
      ->copy(
        $this->getConfigValue('blt.root') . '/scripts/blt/examples/Commands/ExampleCommands.php',
        $this->getConfigValue('repo.root') . '/blt/src/Blt/Plugin/Commands/ExampleCommands.php', FALSE)
      ->copy(
        $this->getConfigValue('blt.root') . '/scripts/blt/examples/Test/ExampleTest.php',
        $this->getConfigValue('repo.root') . '/tests/phpunit/ExampleTest.php', FALSE)
      ->copy(
        $this->getConfigValue('blt.root') . '/scripts/blt/examples/Test/Examples.feature',
        $this->getConfigValue('repo.root') . '/tests/behat/features/Examples.feature', FALSE)
      ->copy(
        $this->getConfigValue('blt.root') . '/scripts/blt/examples/Filesets.php',
        $this->getConfigValue('repo.root') . '/blt/src/Filesets.php', FALSE)
      ->stopOnFail()
      ->setVerbosityThreshold(VerbosityThresholdInterface::VERBOSITY_VERBOSE)
      ->run();

    if (!$result->wasSuccessful()) {
      throw new BltException("Could not copy example files into the repository root.");
    }

    $this->say("<info>Example commands and hooks were copied to your repository root.</info>");
  }
1191350
def setup(self):
        
        r = self.call_ext_prog(self.get_option("script"))
        if r['status'] == 0:
            tarfile = ""
            for line in r['output']:
                line = line.strip()
                tarfile = self.do_regex_find_all(r"ftp (.*tar.gz)", line)
            if len(tarfile) == 1:
                self.add_copy_spec(tarfile[0])
672985
def generate(env):
    """"""
    SCons.Tool.createSharedLibBuilder(env)
    SCons.Tool.createProgBuilder(env)

    env['LINK']        = '$CC'
    env['LINKFLAGS']   = SCons.Util.CLVar('')
    env['LINKCOM']     = '$LINK -q $LINKFLAGS -e$TARGET $SOURCES $LIBS'
    env['LIBDIRPREFIX']=''
    env['LIBDIRSUFFIX']=''
    env['LIBLINKPREFIX']=''
    env['LIBLINKSUFFIX']='$LIBSUFFIX'
374740
private function setup()
    {
        $loader = new FilesystemLoader(GeneratorHelper::getTemplatePath());
        $this->tpl = new Environment($loader, array(
            'cache' => CACHE_DIR . DIRECTORY_SEPARATOR . 'twig',
            'debug' => (bool)$this->debug,
            'auto_reload' => Config::getParam('twig.autoreload', TRUE),
        ));
        $this->loadDomains();
    }
1217033
def setup(self, glbls):
        
        if not self.pluginPath() in sys.path:
            log.debug(self.pluginPath())
            sys.path.append(self.pluginPath())
        
        glbls['find'] = self.find
        glbls['listdir'] = self.listdir
        glbls['load'] = self.load
        glbls['read'] = self.read
        glbls['exists'] = self.exists
        glbls['setdefault'] = self.setDefault
        glbls['basePath'] = self.basePath
        glbls['setBasePath'] = self.setBasePath
        glbls['walk'] = self.walk
        glbls['isdir'] = self.isdir
        glbls['isfile'] = self.isfile
        glbls['init'] = self.init
        
        # setup the build system
        if 'python' in sys.executable and not self.useFilepath():
            self.build()
1011659
def _setup(self):
        """"""
        default_settings.reload()
        environment_variable = self._kwargs.get(
            "ENVVAR_FOR_DYNACONF", default_settings.ENVVAR_FOR_DYNACONF
        )
        settings_module = os.environ.get(environment_variable)
        self._wrapped = Settings(
            settings_module=settings_module, **self._kwargs
        )
        self.logger.debug("Lazy Settings _setup ...")
1146838
def init(self):
        
        self.logger.info('Start initialize dir [%s]', self.basePath)
        # Clean the directory
        for name in os.listdir(self.basePath):
            path = os.path.join(self.basePath, name)
            if os.path.isdir(path):
                shutil.rmtree(path)
            else:
                os.unlink(path)
        # Prepare dirs and files
        self.logger.info('Prepare dirs and files')
        for name in self.DIRS:
            os.mkdir(os.path.join(self.basePath, name))
        with open(os.path.join(self.basePath, self.FILE_INDEX), 'wb') as fd:
            pass
        with open(os.path.join(self.basePath, self.FILE_SERIAL), 'wb') as fd:
            print >>fd, 1000
        # Format the config file
        env = jinja2.Environment(
                loader = jinja2.FileSystemLoader(os.path.dirname(os.path.abspath(__file__))),
                trim_blocks = True,
                lstrip_blocks = True
                )
        template = env.get_template('openssl.config.template')
        content = template.render(basePath = self.basePath)
        with open(os.path.join(self.basePath, self.FILE_CONFIG), 'wb') as fd:
            print >>fd, content
354297
public function generateSiteConfigFiles() {
    if (!file_exists($this->getConfigValue('blt.config-files.local'))) {
      $result = $this->taskFilesystemStack()
        ->copy($this->getConfigValue('blt.config-files.example-local'), $this->getConfigValue('blt.config-files.local'))
        ->stopOnFail()
        ->setVerbosityThreshold(VerbosityThresholdInterface::VERBOSITY_VERBOSE)
        ->run();

      if (!$result->wasSuccessful()) {
        $filepath = $this->getInspector()->getFs()->makePathRelative($this->getConfigValue('blt.config-files.local'), $this->getConfigValue('repo.root'));
        throw new BltException("Unable to create $filepath.");
      }
    }

    // Generate hash file in salt.txt.
    $this->hashSalt();

    $default_multisite_dir = $this->getConfigValue('docroot') . "/sites/default";
    $default_project_default_settings_file = "$default_multisite_dir/default.settings.php";

    $multisites = $this->getConfigValue('multisites');
    $initial_site = $this->getConfigValue('site');
    $current_site = $initial_site;

    $this->logger->debug("Multisites found: " . implode(',', $multisites));
    $this->logger->debug("Initial site: $initial_site");

    foreach ($multisites as $multisite) {
      if ($current_site != $multisite) {
        $this->switchSiteContext($multisite);
        $current_site = $multisite;
      }

      // Generate settings.php.
      $multisite_dir = $this->getConfigValue('docroot') . "/sites/$multisite";
      $project_default_settings_file = "$multisite_dir/default.settings.php";
      $project_settings_file = "$multisite_dir/settings.php";

      // Generate local.settings.php.
      $blt_local_settings_file = $this->getConfigValue('blt.root') . '/settings/default.local.settings.php';
      $default_local_settings_file = "$multisite_dir/settings/default.local.settings.php";
      $project_local_settings_file = "$multisite_dir/settings/local.settings.php";

      // Generate default.includes.settings.php.
      $blt_includes_settings_file = $this->getConfigValue('blt.root') . '/settings/default.includes.settings.php';
      $default_includes_settings_file = "$multisite_dir/settings/default.includes.settings.php";

      // Generate sites/settings/default.global.settings.php.
      $blt_glob_settings_file = $this->getConfigValue('blt.root') . '/settings/default.global.settings.php';
      $default_glob_settings_file = $this->getConfigValue('docroot') . "/sites/settings/default.global.settings.php";

      // Generate local.drush.yml.
      $blt_local_drush_file = $this->getConfigValue('blt.root') . '/settings/default.local.drush.yml';
      $default_local_drush_file = "$multisite_dir/default.local.drush.yml";
      $project_local_drush_file = "$multisite_dir/local.drush.yml";

      $copy_map = [
        $blt_local_settings_file => $default_local_settings_file,
        $default_local_settings_file => $project_local_settings_file,
        $blt_includes_settings_file => $default_includes_settings_file,
        $blt_glob_settings_file => $default_glob_settings_file,
        $blt_local_drush_file => $default_local_drush_file,
        $default_local_drush_file => $project_local_drush_file,
      ];
      // Define an array of files that require property expansion.
      $expand_map = [
        $default_local_settings_file => $project_local_settings_file,
        $default_local_drush_file => $project_local_drush_file,
      ];

      // Only add the settings file if the default exists.
      if (file_exists($default_project_default_settings_file)) {
        $copy_map[$default_project_default_settings_file] = $project_default_settings_file;
        $copy_map[$project_default_settings_file] = $project_settings_file;
      }
      else {
        $this->logger->warning("No $default_project_default_settings_file file found.");
      }

      $task = $this->taskFilesystemStack()
        ->stopOnFail()
        ->setVerbosityThreshold(VerbosityThresholdInterface::VERBOSITY_VERBOSE)
        ->chmod($multisite_dir, 0777);

      if (file_exists($project_settings_file)) {
        $task->chmod($project_settings_file, 0777);
      }

      // Copy files without overwriting.
      foreach ($copy_map as $from => $to) {
        if (!file_exists($to)) {
          $task->copy($from, $to);
        }
      }

      $result = $task->run();

      foreach ($expand_map as $from => $to) {
        $this->getConfig()->expandFileProperties($to);
      }

      if (!$result->wasSuccessful()) {
        throw new BltException("Unable to copy files settings files from BLT into your repository.");
      }

      $result = $this->taskWriteToFile($project_settings_file)
        ->appendUnlessMatches('#vendor/acquia/blt/settings/blt.settings.php#', 'require DRUPAL_ROOT . "/../vendor/acquia/blt/settings/blt.settings.php";' . "\n")
        ->appendUnlessMatches('#Do not include additional settings here#', $this->settingsWarning . "\n")
        ->append(TRUE)
        ->setVerbosityThreshold(VerbosityThresholdInterface::VERBOSITY_VERBOSE)
        ->run();

      if (!$result->wasSuccessful()) {
        throw new BltException("Unable to modify $project_settings_file.");
      }

      $result = $this->taskFilesystemStack()
        ->chmod($project_settings_file, 0644)
        ->stopOnFail()
        ->setVerbosityThreshold(VerbosityThresholdInterface::VERBOSITY_VERBOSE)
        ->run();

      if (!$result->wasSuccessful()) {
        $filepath = $this->getInspector()->getFs()->makePathRelative($project_settings_file, $this->getConfigValue('repo.root'));
        throw new BltException("Unable to set permissions on $project_settings_file.");
      }
    }

    if ($current_site != $initial_site) {
      $this->switchSiteContext($initial_site);
    }
  }
1099662
def setup(self, options=None, extractor=None):
        
        # Get our programmatic options
        self._util.use_options(options, extractor)

        # Overwrite non defaults in self.values with values from config
        self._util.use_config_file()
505283
def setup():
    
    l_mitogen = logging.getLogger('mitogen')
    l_mitogen_io = logging.getLogger('mitogen.io')
    l_ansible_mitogen = logging.getLogger('ansible_mitogen')

    for logger in l_mitogen, l_mitogen_io, l_ansible_mitogen:
        logger.handlers = [Handler(display.vvv)]
        logger.propagate = False

    if display.verbosity > 2:
        l_ansible_mitogen.setLevel(logging.DEBUG)
        l_mitogen.setLevel(logging.DEBUG)
    else:
        # Mitogen copies the active log level into new children, allowing them
        # to filter tiny messages before they hit the network, and therefore
        # before they wake the IO loop. Explicitly setting INFO saves ~4%
        # running against just the local machine.
        l_mitogen.setLevel(logging.ERROR)
        l_ansible_mitogen.setLevel(logging.ERROR)

    if display.verbosity > 3:
        l_mitogen_io.setLevel(logging.DEBUG)
398304
def setup(self):
        
        decompress_dir('.')

        if self.backup:
            for f in FEFF_INPUT_FILES:
                shutil.copy(f, "{}.orig".format(f))

            for f in FEFF_BACKUP_FILES:
                if os.path.isfile(f):
                    shutil.copy(f, "{}.orig".format(f))
1062814
def setup(self, settings):
        '''
        
        '''
        # set up the default sc logger
        my_level = settings.get('SC_LOG_LEVEL', 'INFO')
        my_name = settings.get('SC_LOGGER_NAME', 'sc-logger')
        my_output = settings.get('SC_LOG_STDOUT', True)
        my_json = settings.get('SC_LOG_JSON', False)
        my_dir = settings.get('SC_LOG_DIR', 'logs')
        my_bytes = settings.get('SC_LOG_MAX_BYTES', '10MB')
        my_file = settings.get('SC_LOG_FILE', 'main.log')
        my_backups = settings.get('SC_LOG_BACKUPS', 5)

        self.logger = LogFactory.get_instance(json=my_json,
                                         name=my_name,
                                         stdout=my_output,
                                         level=my_level,
                                         dir=my_dir,
                                         file=my_file,
                                         bytes=my_bytes,
                                         backups=my_backups)
1106402
def init(name, description, bucket, timeout, memory, stages, requirements,
         function, runtime, config_file, **kwargs):
    """"""
    if os.path.exists(config_file):
        raise RuntimeError('Please delete the old version {} if you want to '
                           'reconfigure your project.'.format(config_file))

    module, app = function.split(':')
    if not name:
        name = module.replace('_', '-')
    if not re.match('^[a-zA-Z][-a-zA-Z0-9]*$', name):
        raise ValueError('The name {} is invalid, only letters, numbers and '
                         'dashes are allowed.'.format(name))
    if not bucket:
        random_suffix = ''.join(
            random.choice(string.ascii_uppercase + string.digits)
            for n in range(8))
        bucket = '{}-{}'.format(name, random_suffix)

    stages = [s.strip() for s in stages.split(',')]

    if runtime is None:
        if sys.version_info[0] == 2:  # pragma: no cover
            runtime = 'python2.7'
        else:
            runtime = 'python3.6'

    # generate slam.yaml
    template_file = os.path.join(os.path.dirname(__file__),
                                 'templates/slam.yaml')
    with open(template_file) as f:
        template = f.read()
    template = render_template(template, name=name, description=description,
                               module=module, app=app, bucket=bucket,
                               timeout=timeout, memory=memory,
                               requirements=requirements, stages=stages,
                               devstage=stages[0], runtime=runtime)
    with open(config_file, 'wt') as f:
        f.write(template)

    # plugins
    config = _load_config(config_file)
    for name, plugin in plugins.items():
        # write plugin documentation as a comment in config file
        with open(config_file, 'at') as f:
            f.write('\n\n# ' + (plugin.__doc__ or name).replace(
                '\n', '\n# ') + '\n')
        if hasattr(plugin, 'init'):
            arguments = {k: v for k, v in kwargs.items()
                         if k in getattr(plugin.init, '_argnames', [])}
            plugin_config = plugin.init.func(config=config, **arguments)
            if plugin_config:
                with open(config_file, 'at') as f:
                    yaml.dump({name: plugin_config}, f,
                              default_flow_style=False)

    print('The configuration file for your project has been generated. '
          'Remember to add {} to source control.'.format(config_file))
290224
public void init(Configuration conf, Path generatedModel) throws IOException, InterruptedException {
		FileSystem fileSystem = FileSystem.get(conf);
		for(Category category : Category.values()) {
			wordCountPerCategory.put(category, new HashMap<String, Integer>()); // init token count
		}
		// Use a HashSet to calculate the total vocabulary size
		Set<String> vocabulary = new HashSet<String>();
		// Read tuples from generate job
		for(FileStatus fileStatus : fileSystem.globStatus(generatedModel)) {
      TupleFile.Reader reader = new TupleFile.Reader(fileSystem, conf, fileStatus.getPath());
      Tuple tuple = new Tuple(reader.getSchema());
			while(reader.next(tuple)) {
				// Read Tuple
				Integer count = (Integer) tuple.get("count");
				Category category = (Category) tuple.get("category");
				String word = tuple.get("word").toString();
				vocabulary.add(word);
				tokensPerCategory.put(category, MapUtils.getInteger(tokensPerCategory, category, 0) + count);
				wordCountPerCategory.get(category).put(word, count);
			}
			reader.close();
		}
		V = vocabulary.size();
	}