rubocop:enable Metrics/MethodLength
 Report is used by create, update and bootstrap commands
510328
def report
      if @topo['nodes'].empty?
        ui.info 'No nodes found'
      else
        report_msg(:bootstrapped, :info, false) if @bootstrap
        report_msg(:skipped, :info, true)
        report_msg(:skipped_ssh, :info, true)
        report_msg(:existed, :info, true)
        report_msg(:failed, :warn, true) if @bootstrap
      end
      ui.info("Topology: #{@topo.display_info}")
    end
42061
def bootstrap(command, conf, vars):
    """"""

    # <websetup.bootstrap.before.auth
    from sqlalchemy.exc import IntegrityError
    try:
        u = model.User()
        u.user_name = 'manager'
        u.display_name = 'Example manager'
        u.email_address = 'manager@somedomain.com'
        u.password = 'managepass'
    
        model.DBSession.add(u)
    
        g = model.Group()
        g.group_name = 'managers'
        g.display_name = 'Managers Group'
    
        g.users.append(u)
    
        model.DBSession.add(g)
    
        p = model.Permission()
        p.permission_name = 'manage'
        p.description = 'This permission give an administrative right to the bearer'
        p.groups.append(g)
    
        model.DBSession.add(p)
    
        u1 = model.User()
        u1.user_name = 'editor'
        u1.display_name = 'Example editor'
        u1.email_address = 'editor@somedomain.com'
        u1.password = 'editpass'
    
        model.DBSession.add(u1)
        model.DBSession.flush()
        transaction.commit()
    except IntegrityError:
        print('Warning, there was a problem adding your auth data, it may have already been added:')
        import traceback
        print(traceback.format_exc())
        transaction.abort()
        print('Continuing with bootstrapping...')
1209341
def validate_update(
        filepath: str,
        progress_callback: Callable[[float], None]) -> Tuple[str, str]:
    
    filenames = [ROOTFS_NAME, ROOTFS_HASH_NAME, BOOT_NAME, BOOT_HASH_NAME]

    def zip_callback(progress):
        progress_callback(progress/3.0)

    files, sizes = unzip_update(filepath, zip_callback, filenames, filenames)

    def rootfs_hash_callback(progress):
        progress_callback(progress/3.0 + 0.33)

    rootfs = files.get(ROOTFS_NAME)
    assert rootfs
    rootfs_calc_hash = hash_file(rootfs, rootfs_hash_callback,
                                 file_size=sizes[ROOTFS_NAME])
    rootfs_hashfile = files.get(ROOTFS_HASH_NAME)
    assert rootfs_hashfile
    rootfs_packaged_hash = open(rootfs_hashfile, 'rb').read().strip()
    if rootfs_calc_hash != rootfs_packaged_hash:
        msg = f"Hash mismatch (rootfs): calculated {rootfs_calc_hash} != "\
            f"packaged {rootfs_packaged_hash}"
        LOG.error(msg)
        raise HashMismatch(msg)

    def bootfs_hash_callback(progress):
        progress_callback(progress/3.0 + 0.66)

    bootfs = files.get(BOOT_NAME)
    assert bootfs
    bootfs_calc_hash = hash_file(bootfs, bootfs_hash_callback,
                                 file_size=sizes[BOOT_NAME])
    bootfs_hashfile = files.get(BOOT_HASH_NAME)
    assert bootfs_hashfile
    bootfs_packaged_hash = open(bootfs_hashfile, 'rb').read().strip()
    if bootfs_calc_hash != bootfs_packaged_hash:
        msg = f"Hash mismatch (bootfs): calculated {bootfs_calc_hash} != "\
            f"packged {bootfs_packaged_hash}"
        LOG.error(msg)
        raise HashMismatch(msg)

    return rootfs, bootfs
623376
def require!
      unless required?
        while updates_required?
          Origen.log.info '*******************************************************************************'
          Origen.log.info 'The following remotes need to be updated, this will now happen automatically:'
          dirty_remotes.each do |name, remote|
            if remote[:path]
              Origen.log.info "  #{name} - #{remote[:path]} (included by #{remote[:importer].name})".green
            else
              Origen.log.info "  #{name} - #{remote[:version]} (included by #{remote[:importer].name})".green
            end
          end
          Origen.log.info ''

          update!

          Origen.log.info ''
          Origen.log.info 'Finished updating remotes.'
          Origen.log.info '*******************************************************************************'
        end
        @required = true
      end
    end
864032
function Bootstrap() {
        this.initalized = false;
        this.listenPort = 8080;
        this.listenHost = null;
        this.controllersPath = '@{appPath}/controllers/';
        this.modulesPath = '@{appPath}/modules/';
        this.modelsPath = '@{appPath}/models/';
        this.isCompressionEnabled = false;
    }
1239956
def execute
      args = ['rubocop'] + arguments
      todo = target_directory.join('.rubocop_todo.yml')

      replacements = []

      # if adding the .rb extension is enabled, remove the extension again from
      # any output so it matches the actual files names we are linting
      replacements << [/\.erb\.rb/, '.erb'] if rb_extension_enabled

      result = Dir.chdir(target_directory) do
        replacements.unshift([/^#{Regexp.quote(Dir.pwd)}/, current_directory.to_s])
        stdout, stderr, status = Open3.capture3(*args)

        munge_output(stdout, stderr, replacements)

        status.exitstatus
      end

      # copy the todo file back for the case where we've used --auto-gen-config
      FileUtils.cp(todo, current_directory) if todo.exist?

      result
    end
125298
def summarize
        success = @task.color(:green)
        success << ": "
        success << "[#{@output[:lint_warnings].length}]".color(:yellow)
        success << " [#{@output[:lint_errors].length}]".color(:red)
        if @task == 'rubocop'
          success << " [#{@output[:lint_conventions].length}]".color(:cyan)
          success << " [#{@output[:lint_refactors].length}]".color(:white)
          success << " [#{@output[:lint_fatals].length}]".color(:magenta)
        end
        success << "\n#{'Warning'.color(:red)}: #{@output[:lint_errors].length} errors found in #{@task}" if @output[:lint_errors].length > 0

        success
      end
605104
def create(cls, bootstrap_options):
    
    binary_tool_fetcher = BinaryToolFetcher(
      bootstrap_dir=bootstrap_options.pants_bootstrapdir,
      timeout_secs=bootstrap_options.binaries_fetch_timeout_secs)
    binary_util = BinaryUtil(
      baseurls=bootstrap_options.binaries_baseurls,
      binary_tool_fetcher=binary_tool_fetcher,
      path_by_id=bootstrap_options.binaries_path_by_id,
      allow_external_binary_tool_downloads=bootstrap_options.allow_external_binary_tool_downloads)

    return WatchmanLauncher(
      binary_util,
      bootstrap_options.level,
      bootstrap_options.watchman_version,
      bootstrap_options.watchman_supportdir,
      bootstrap_options.watchman_startup_timeout,
      bootstrap_options.watchman_socket_timeout,
      bootstrap_options.watchman_socket_path,
      bootstrap_options.pants_subprocessdir
    )
315758
def create_new_spec(class_or_module, dry_run, rails_mode, file_path, spec_path)
      # These names are used in ERB template, don't delete.
      # rubocop:disable Lint/UselessAssignment
      methods_to_generate = class_or_module.method_list.select { |m| m.visibility == :public }
      c = class_or_module
      self_path = to_string_value_to_require(file_path)
      # rubocop:enable Lint/UselessAssignment

      erb = RSpecKickstarter::ERBFactory.new(@full_template).get_instance_for_new_spec(rails_mode, file_path)
      code = erb.result(binding)

      if dry_run
        puts "----- #{spec_path} -----"
        puts code
      else
        if File.exist?(spec_path)
          puts "#{spec_path} already exists."
        else
          FileUtils.mkdir_p(File.dirname(spec_path))
          File.open(spec_path, 'w') { |f| f.write(code) }
          puts "#{spec_path} created."
        end
      end
    end
19944
def result
      @task = 'jshint'
      @path = discover_path(@config.working_dir, 'javascripts', 'js')

      return unless temp_config(@task) && path_exists?(@path)

      node_module_exists(@task)

      jshint_cli = "jshint #{@path} --config=#{temp_config(@task)} --reporter=#{reporter_path('jshint.js')}"
      jshint_cli << " --exclude-path=#{temp_config(@settings[:jshintignore])}" if @settings.key?(:jshintignore)
      jshint = `#{jshint_cli}`

      @output[:files_inspected] ||= files_inspected('js')
      refine jshint
    end
329177
def map_gems_to_specs(gems)
      gems.map.with_index do |gemfile, index|
        # rubocop:disable Metrics/LineLength
        Utils.logger.info("[#{index + 1}/#{gems.size}]: Processing #{gemfile.split('/')[-1]}")
        # rubocop:enable Metrics/LineLength

        if File.size(gemfile).zero?
          Utils.logger.warn("Skipping zero-length gem: #{gemfile}")
          next
        end

        begin
          spec = if ::Gem::Package.respond_to? :open
                   ::Gem::Package
                     .open(File.open(gemfile, 'rb'), 'r', &:metadata)
                 else
                   ::Gem::Package.new(gemfile).spec
                 end

          spec.loaded_from = gemfile

          # HACK: fuck this shit - borks all tests that use pl1
          if File.basename(gemfile, '.gem') != spec.original_name
            exp = spec.full_name
            exp << " (#{spec.original_name})" if
              spec.original_name != spec.full_name
            msg = "Skipping misnamed gem: #{gemfile} should be named #{exp}"
            Utils.logger.warn(msg)
            next
          end

          version = spec.version.version
          unless version =~ /^\d+\.\d+\.\d+.*/
            msg = "Skipping gem #{spec.full_name} - invalid version #{version}"
            Utils.logger.warn(msg)
            next
          end

          if ::Gem::VERSION >= '2.5.0'
            spec.abbreviate
            spec.sanitize
          else
            abbreviate spec
            sanitize spec
          end

          spec
        rescue SignalException
          msg = 'Received signal, exiting'
          Utils.logger.error(msg)
          raise
        rescue StandardError => e
          msg = ["Unable to process #{gemfile}",
                 "#{e.message} (#{e.class})",
                 "\t#{e.backtrace.join "\n\t"}"].join("\n")
          Utils.logger.debug(msg)
        end
      end.compact
    end
1230770
def gather_bootstrap_script(bootstrap=None):
    '''
    
    '''
    if not HAS_CLOUD:
        return False, 'config.gather_bootstrap_script is unavailable'
    ret = salt.utils.cloud.update_bootstrap(__opts__, url=bootstrap)
    if 'Success' in ret and ret['Success']['Files updated']:
        return ret['Success']['Files updated'][0]
802212
def check_commit_message_length(message)
      check_label = 'Commit message length'

      if message.length >= @min_length && message.length <= @max_length
        Status.report(check_label, true)
      else
        @errors.push "Commit messages should be between #{@min_length} "\
          "and #{@max_length} characters."
        Status.report(check_label, false)
      end
    end
1046914
def call(env)
      status       = env["PATH_INFO"][1..-1]
      request      = ActionDispatch::Request.new(env)
      content_type = request.formats.first
      body         = {  status: status,
                        error: Rack::Utils::HTTP_STATUS_CODES.fetch(status.to_i, Rack::Utils::HTTP_STATUS_CODES[500]) }

      Errdo::Exception.new(env) if Errdo.log404 || status.to_i != 404
      render(status, content_type, body)
    end
521963
def execute!
      begin
        options   = Options.new(argv)

        generator = ErbGenerator.new(Data.new(options.data_sources))
        generator.compile(options.source, options.destination)

        exitstatus = 0
      rescue Interrupt
        Filegen::Ui.warning 'You told me to stop command execution.'
        exitstatus = 2
      rescue Exceptions::ErbTemplateHasSyntaxErrors => e
        Filegen::Ui.error "Syntax error in ERB-Template: \n" + e.message
        exitstatus = 3
      rescue Exceptions::YamlFileNotFound => e
        Filegen::Ui.error "Yaml-file \"#{JSON.parse(e.message)['file']}\" not found."
        exitstatus = 4
      rescue StandardError => e
        Filegen::Ui.error "#{e.class} - #{e.message}"
        exitstatus = 99
      end

      @kernel.exit(exitstatus)
    end
1220713
def output_html_errors
      require 'erubis'
      template = @options['template'] ? File.read(File.expand_path(@options['template'])) : File.read(File.join(File.dirname(__FILE__), '..', '..', 'assets', 'result.html.erb'))

      if @options['with-github']
        last_commit_id = @options['last-commit-id'] || `cd #{@runner.class.base_path} && git rev-parse HEAD`.chomp
        unless @options['github-name'].start_with?('https')
          @options['github-name'] = GITHUB_URL + @options['github-name']
        end
      end
      File.open(@options['output-file'], 'w+') do |file|
        eruby = Erubis::Eruby.new(template)
        file.puts eruby.evaluate(
          errors: errors,
          error_types: error_types,
          textmate: @options['with-textmate'],
          sublime: @options['with-sublime'],
          mvim: @options['with-mvim'],
          github: @options['with-github'],
          github_name: @options['github-name'],
          last_commit_id: last_commit_id,
          git: @options['with-git'],
          hg: @options['with-hg']
        )
      end
    end
658339
def init!(plugins, repair=false)
      if !@initial_specifications
        @initial_specifications = Gem::Specification.find_all{true}
      else
        Gem::Specification.all = @initial_specifications
        Gem::Specification.reset
      end

      # Add HashiCorp RubyGems source
      if !Gem.sources.include?(HASHICORP_GEMSTORE)
        current_sources = Gem.sources.sources.dup
        Gem.sources.clear
        Gem.sources << HASHICORP_GEMSTORE
        current_sources.each do |src|
          Gem.sources << src
        end
      end

      # Generate dependencies for all registered plugins
      plugin_deps = plugins.map do |name, info|
        Gem::Dependency.new(name, info['installed_gem_version'].to_s.empty? ? '> 0' : info['installed_gem_version'])
      end

      @logger.debug("Current generated plugin dependency list: #{plugin_deps}")

      # Load dependencies into a request set for resolution
      request_set = Gem::RequestSet.new(*plugin_deps)
      # Never allow dependencies to be remotely satisfied during init
      request_set.remote = false

      repair_result = nil
      begin
        # Compose set for resolution
        composed_set = generate_vagrant_set
        # Resolve the request set to ensure proper activation order
        solution = request_set.resolve(composed_set)
      rescue Gem::UnsatisfiableDependencyError => failure
        if repair
          raise failure if @init_retried
          @logger.debug("Resolution failed but attempting to repair. Failure: #{failure}")
          install(plugins)
          @init_retried = true
          retry
        else
          raise
        end
      end

      # Activate the gems
      activate_solution(solution)

      full_vagrant_spec_list = @initial_specifications +
        solution.map(&:full_spec)

      if(defined?(::Bundler))
        @logger.debug("Updating Bundler with full specification list")
        ::Bundler.rubygems.replace_entrypoints(full_vagrant_spec_list)
      end

      Gem.post_reset do
        Gem::Specification.all = full_vagrant_spec_list
      end

      Gem::Specification.reset
      nil
    end