<commit_before>require 'shellwords'
require 'travis/worker/utils/buffer'
require 'travis/worker/utils/hard_timeout'
require 'travis/worker/ssh/connector/net_ssh'
require 'travis/support/logging'
require 'base64'
require 'hashr'

module Travis
  module Worker
    module Ssh
      # Encapsulates an SSH connection to a remote host.
      class Session
        include Logging

        class NoOutputReceivedError < StandardError
          def initialize(seconds)
            super("No output has been received in the last #{(seconds / 60).to_i} minutes, this potentially indicates a stalled build or something wrong with the build itself.\n\nThe build has been terminated")
          end
        end

        log_header { "#{name}:shell:session" }

        attr_reader :name, :config
        attr_accessor :log_silence_timeout

        # Initialize a shell Session
        #
        # config - A hash containing the timeouts, shell buffer time and ssh connection information
        # block - An optional block of commands to be excuted within the session. If
        #         a block is provided then the session will be started, block evaluated,
        #         and then the session will be closed.
        def initialize(name, config)
          @name = name
          @config = Hashr.new(config)
          @connector = Connector::NetSSH.new(@config)
        end

        # Connects to the remote host.
        #
        # Returns the Net::SSH::Shell
        def connect(silent = false)
          info "starting ssh session to #{config.host}:#{config.port} ..." unless silent
          Travis::Worker::Utils::HardTimeout.timeout(15) do
            @connector.connect
          end<commit_msg>add link to docs when there's a log timeout error<commit_after>require 'shellwords'
require 'travis/worker/utils/buffer'
require 'travis/worker/utils/hard_timeout'
require 'travis/worker/ssh/connector/net_ssh'
require 'travis/support/logging'
require 'base64'
require 'hashr'

module Travis
  module Worker
    module Ssh
      # Encapsulates an SSH connection to a remote host.
      class Session
        include Logging

        class NoOutputReceivedError < StandardError
          def initialize(seconds)
            super("No output has been received in the last #{(seconds / 60).to_i} minutes, this potentially indicates a stalled build or something wrong with the build itself.\nCheck the details on how to adjust your build configuration on: https://docs.travis-ci.com/user/common-build-problems/#Build-times-out-because-no-output-was-received\n\nThe build has been terminated")
          end
        end

        log_header { "#{name}:shell:session" }

        attr_reader :name, :config
        attr_accessor :log_silence_timeout

        # Initialize a shell Session
        #
        # config - A hash containing the timeouts, shell buffer time and ssh connection information
        # block - An optional block of commands to be excuted within the session. If
        #         a block is provided then the session will be started, block evaluated,
        #         and then the session will be closed.
        def initialize(name, config)
          @name = name
          @config = Hashr.new(config)
          @connector = Connector::NetSSH.new(@config)
        end

        # Connects to the remote host.
        #
        # Returns the Net::SSH::Shell
        def connect(silent = false)
          info "starting ssh session to #{config.host}:#{config.port} ..." unless silent
          Travis::Worker::Utils::HardTimeout.timeout(15) do
            @connector.connect
          end
{'fraction_non_alphanumeric': 0.07788595271210014, 'fraction_numerical': 0.003337969401947149, 'mean_word_length': 2.487875848690592, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 1, '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': '7535661', 'n_tokens_mistral': 958, 'n_tokens_neox': 926, 'n_words': 331}