<commit_before>from utils.ssh import *
import os
import time

class K3Peer:
  def __init__(self,config):
    self.local_binary_path = config.get("local_binary_path")
    self.ip = config["ip"]
    self.port = config["k3_port"]
    self.remote_binary_path = "/tmp/"
    self.binary_name = "k3_" + str(self.ip) + str(self.port)
    self.remote_log_dir  = "/tmp/log/" + self.binary_name + "/"

    self.remote_log_file = self.remote_log_dir + "stdouterr.log"
    self.remote_script_path = "/tmp/run" + self.binary_name + ".txt"
    self.k3_bindings = config.get("k3_bindings",{})
    self.loggingEnabled = bool(config.get("enable_logging", False))
    self.stashOutput = bool(config.get("stash_output", False))
    self.local_output_dir = config["output_dir"]
    output_dir_str = '"%s"' % self.remote_log_dir
    self.k3_bindings["output_dir"] = output_dir_str

    # Constants
    self.local_script_path =  "%s.txt" % self.binary_name
    self.host = "root@%s" % self.ip

  def deployBinary(self):
    # Kill any running instance of the binary to unlock all files
    local_kill_file = "kill_" + self.binary_name + ".txt"
    remote_kill_file = self.remote_binary_path + "kill_" + self.binary_name;
    script = ("""#!/bin/bash\n"""
              """for j in `pgrep -f "/tmp/run.*"`;do kill -9 $j; done\n""")


    # Dump to a local file
    with open(local_kill_file,"wb") as script_file:
      script_file.write(script)

    # copy local to remote
    scpTo(self.host, local_kill_file, remote_kill_file)

    # chmod +x remote_script
    chmod_cmd = "chmod +x %s" % remote_kill_file
    ssh(self.host, chmod_cmd)

    # cleanup the local file
    cleanup_cmd = "rm %s" % local_kill_file
    os.system(cleanup_cmd)

    # call kill command
    ssh(self.host, remote_kill_file)

    # give the poor process time to die in peace (and unlock the script file)
    time.sleep(10)

    # copy run script over to remote<commit_msg>Minor Improvements to deployment (less output)<commit_after>from utils.ssh import *
import os
import time

class K3Peer:
  def __init__(self,config):
    self.local_binary_path = config.get("local_binary_path")
    self.ip = config["ip"]
    self.port = config["k3_port"]
    self.remote_binary_path = "/tmp/"
    self.binary_name = "k3binary_" + str(self.ip) + str(self.port)
    self.remote_log_dir  = "/tmp/log/" + self.binary_name + "/"

    self.remote_log_file = self.remote_log_dir + "stdouterr.log"
    self.remote_script_path = "/tmp/run" + self.binary_name + ".txt"
    self.k3_bindings = config.get("k3_bindings",{})
    self.loggingEnabled = bool(config.get("enable_logging", False))
    self.stashOutput = bool(config.get("stash_output", False))
    self.local_output_dir = config["output_dir"]
    output_dir_str = '"%s"' % self.remote_log_dir
    self.k3_bindings["output_dir"] = output_dir_str

    # Constants
    self.local_script_path =  "%s.txt" % self.binary_name
    self.host = "root@%s" % self.ip

  def deployBinary(self):
    # Kill any running instance of the binary to unlock all files
    local_kill_file = "kill_" + self.binary_name + ".txt"
    remote_kill_file = self.remote_binary_path + "kill_" + self.binary_name;
    script = ("""#!/bin/bash\n"""
              """pkill -f k3binary\n""")


    # Dump to a local file
    with open(local_kill_file,"wb") as script_file:
      script_file.write(script)

    # copy local to remote
    scpTo(self.host, local_kill_file, remote_kill_file)

    # chmod +x remote_script
    chmod_cmd = "chmod +x %s" % remote_kill_file
    ssh(self.host, chmod_cmd)

    # cleanup the local file
    cleanup_cmd = "rm %s" % local_kill_file
    os.system(cleanup_cmd)

    # call kill command
    ssh(self.host, remote_kill_file)

    # give the poor process time to die in peace (and unlock the script file)
    time.sleep(10)

    # copy run script over to remote
{'fraction_non_alphanumeric': 0.1272066458982347, 'fraction_numerical': 0.004672897196261682, 'mean_word_length': 3.4338319907940162, 'pattern_counts': {'":': 0, '<': 3, '<?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': '6629357', 'n_tokens_mistral': 1372, 'n_tokens_neox': 1331, 'n_words': 297}