<commit_before>require 'veewee/provider/core/helper/ssh'
module Veewee
  module Provider
    module  Core
      module BoxCommand

        def ssh_command_string
         "ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -p #{ssh_options[:port]} -l #{definition.ssh_user} #{self.ip_address}"
        end

        def winrm_command_string
          "knife winrm -m #{self.ip_address} -P #{winrm_options[:port]} -x #{definition.winrm_user}" +
            " -P #{definition.winrm_password} COMMAND"
        end

        def exec(command,options={})
          raise Veewee::Error,"Box is not running" unless self.running?
          if definition.winrm_user && definition.winrm_password
            begin
              new_options=winrm_options.merge(options)
              self.when_winrm_login_works(self.ip_address,winrm_options.merge(options)) do
                result = self.winrm_execute(self.ip_address,command,new_options)
                return result
              end
            rescue RuntimeError => ex
              env.ui.error "Error executing command #{command} : #{ex}"
              raise Veewee::WinrmError, ex
            end
          else # definition.ssh_user && definition.ssh_password
            begin
              new_options=ssh_options.merge(options)
              self.when_ssh_login_works(self.ip_address,new_options) do
                begin
                  env.logger.info "About to execute remote command #{command} on box #{name} - #{self.ip_address} - #{new_options}"
                  result=self.ssh_execute(self.ip_address,command,new_options)
                  return result
                rescue RuntimeError => ex
                  env.ui.error "Error executing command #{command} : #{ex}"
                  raise Veewee::SshError, ex
                end
              end
            rescue Net::SSH::AuthenticationFailed => ex # may want to catch winrm auth fails as well
              env.ui.error "Authentication failure"
              raise Veewee::SshError, "Authentication failure\n"+ex
            end
          end


        end
      end # Module
    end # Module
  end # Module
end # Module<commit_msg>Fix "can't convert Net::SSH::AuthenticationFailed into String (TypeError)"<commit_after>require 'veewee/provider/core/helper/ssh'
module Veewee
  module Provider
    module  Core
      module BoxCommand

        def ssh_command_string
         "ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -p #{ssh_options[:port]} -l #{definition.ssh_user} #{self.ip_address}"
        end

        def winrm_command_string
          "knife winrm -m #{self.ip_address} -P #{winrm_options[:port]} -x #{definition.winrm_user}" +
            " -P #{definition.winrm_password} COMMAND"
        end

        def exec(command,options={})
          raise Veewee::Error,"Box is not running" unless self.running?
          if definition.winrm_user && definition.winrm_password
            begin
              new_options=winrm_options.merge(options)
              self.when_winrm_login_works(self.ip_address,winrm_options.merge(options)) do
                result = self.winrm_execute(self.ip_address,command,new_options)
                return result
              end
            rescue RuntimeError => ex
              env.ui.error "Error executing command #{command} : #{ex}"
              raise Veewee::WinrmError, ex
            end
          else # definition.ssh_user && definition.ssh_password
            begin
              new_options=ssh_options.merge(options)
              self.when_ssh_login_works(self.ip_address,new_options) do
                begin
                  env.logger.info "About to execute remote command #{command} on box #{name} - #{self.ip_address} - #{new_options}"
                  result=self.ssh_execute(self.ip_address,command,new_options)
                  return result
                rescue RuntimeError => ex
                  env.ui.error "Error executing command #{command} : #{ex}"
                  raise Veewee::SshError, ex
                end
              end
            rescue Net::SSH::AuthenticationFailed => ex # may want to catch winrm auth fails as well
              env.ui.error "Authentication failure"
              raise Veewee::SshError, "Authentication failure\n"+ex.inspect
            end
          end


        end
      end # Module
    end # Module
  end # Module
end # Module
{'fraction_non_alphanumeric': 0.08837525492861999, 'fraction_numerical': 0.0, 'mean_word_length': 1.994572591587517, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3814410', 'n_tokens_mistral': 1236, 'n_tokens_neox': 1176, 'n_words': 281}