<commit_before>#!/usr/bin/env ruby

require "json"
require "parallel"
require "parslet"
require "shellwords"
require "hotdog/commands/ssh"

module Hotdog
  module Commands
    class Pssh < SshAlike
      def define_options(optparse, options={})
        super
        default_option(options, :show_identifier, true)
        optparse.on("--[no-]identifier", "Each output line will be prepended with identifier.") do |identifier|
          options[:show_identifier] = identifier
        end
        optparse.on("--stop-on-error", "Stop execution when a remote command fails (valid only if -P is set)") do |v|
          options[:stop_on_error] = v
        end
      end

      private
      def run_main(hosts, options={})
        begin
          stats = Parallel.map(hosts.each_with_index.to_a, in_threads: parallelism(hosts)) { |host, i|
            cmdline = build_command_string(host, @remote_command, options)
            identifier = options[:show_identifier] ? host : nil
            success = exec_command(identifier, cmdline, index: i, output: true)
            if !success && options[:stop_on_error]
              raise StopException.new
            end
          }
          if stats.all?
            exit(0)
          else
            exit(1)
          end
        rescue StopException
          logger.info("stopped.")
          exit(1)
        end
      end

      class StopException < StandardError
      end
    end
  end
end<commit_msg>fix return code of pssh<commit_after>#!/usr/bin/env ruby

require "json"
require "parallel"
require "parslet"
require "shellwords"
require "hotdog/commands/ssh"

module Hotdog
  module Commands
    class Pssh < SshAlike
      def define_options(optparse, options={})
        super
        default_option(options, :show_identifier, true)
        optparse.on("--[no-]identifier", "Each output line will be prepended with identifier.") do |identifier|
          options[:show_identifier] = identifier
        end
        optparse.on("--stop-on-error", "Stop execution when a remote command fails (valid only if -P is set)") do |v|
          options[:stop_on_error] = v
        end
      end

      private
      def run_main(hosts, options={})
        begin
          stats = Parallel.map(hosts.each_with_index.to_a, in_threads: parallelism(hosts)) { |host, i|
            cmdline = build_command_string(host, @remote_command, options)
            identifier = options[:show_identifier] ? host : nil
            success = exec_command(identifier, cmdline, index: i, output: true)
            if !success && options[:stop_on_error]
              raise StopException.new
            end
            success
          }
          if stats.all?
            exit(0)
          else
            exit(1)
          end
        rescue StopException
          logger.info("stopped.")
          exit(1)
        end
      end

      class StopException < StandardError
      end
    end
  end
end
{'fraction_non_alphanumeric': 0.09283276450511946, 'fraction_numerical': 0.0020477815699658703, 'mean_word_length': 2.09830866807611, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 3, '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': '3191654', 'n_tokens_mistral': 833, 'n_tokens_neox': 812, 'n_words': 226}