<commit_before>require 'json'

module Kitchen

  class SSH
    attr_writer :session

    def download!(remote, local, options = {}, &progress)
      if progress.nil?
        progress = lambda { |ch, name, sent, total|
          if sent == total
            logger.info("Downloaded #{name} (#{total} bytes)")
          end
        }
      end

      session.scp.download!(remote, local, options, &progress)
    end

    def download_path!(remote, local, options = {}, &progress)
      options = {:recursive => true}.merge(options)

      download!(remote, local, options, &progress)
    end
  end

  module Driver

    class SSHBase
      default_config :remote_results_source, "serverspec_results.xml"
      default_config :local_results_destination, "."
      default_config :chef_handler_json_source, "/var/chef/reports"
      default_config :check_for_idempotency, false
    end

    module FtaBase

      attr_reader :config

      def create(state)
        super

        unless (config[:post_create_commands].nil? || config[:post_create_commands].empty?)
          executeSSH(state) do |conn|
            config[:post_create_commands].each do |post_create_command|
              cmd = "#{sudo} #{post_create_command}"
              puts "-- Executing #{cmd}"
              run_remote(cmd, conn)
            end
          end
        end
      end

      def verify(state)<commit_msg>[SP] - KS  - added driver_config: lang: environment variable<commit_after>require 'json'

module Kitchen

  class SSH
    attr_writer :session

    def download!(remote, local, options = {}, &progress)
      if progress.nil?
        progress = lambda { |ch, name, sent, total|
          if sent == total
            logger.info("Downloaded #{name} (#{total} bytes)")
          end
        }
      end

      session.scp.download!(remote, local, options, &progress)
    end

    def download_path!(remote, local, options = {}, &progress)
      options = {:recursive => true}.merge(options)

      download!(remote, local, options, &progress)
    end
  end

  module Driver

    class SSHBase
      default_config :remote_results_source, "serverspec_results.xml"
      default_config :local_results_destination, "."
      default_config :chef_handler_json_source, "/var/chef/reports"
      default_config :check_for_idempotency, false

      def env_cmd(cmd)
        env = "env"
        env << " http_proxy=#{config[:http_proxy]}"   if config[:http_proxy]
        env << " https_proxy=#{config[:https_proxy]}" if config[:https_proxy]
        env << " LANG=#{config[:lang]}"  if config[:lang]

        env == "env" ? cmd : "#{env} #{cmd}"
      end

    end

    module FtaBase

      attr_reader :config

      def create(state)
        super

        unless (config[:post_create_commands].nil? || config[:post_create_commands].empty?)
          executeSSH(state) do |conn|
            config[:post_create_commands].each do |post_create_command|
              cmd = "#{sudo} #{post_create_command}"
              puts "-- Executing #{cmd}"
              run_remote(cmd, conn)
            end
          end
        end
      end

      def verify(state)
{'fraction_non_alphanumeric': 0.11245619624084104, 'fraction_numerical': 0.0, 'mean_word_length': 2.405639913232104, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 10, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2988922', 'n_tokens_mistral': 931, 'n_tokens_neox': 888, 'n_words': 217}