<commit_before>from subprocess import PIPE, STDOUT, Popen
from seed.exceptions import ShellCommandError

def run_command(command, ok_statuses=(0,)):
    p = Popen(command, shell=True, stdout=PIPE, stderr=STDOUT, close_fds=True)
    captured = p.stdout.read().decode("utf-8")
    rc = p.poll()
    
    if rc not in ok_statuses:
        raise ShellCommandError("Command returned exit status %d: %s" % (rc, command), output=captured)

    return captured.strip()<commit_msg>Fixing occasional error encountered when running commands<commit_after>from subprocess import PIPE, STDOUT, Popen
from seed.exceptions import ShellCommandError

def run_command(command, ok_statuses=(0,)):
    p = Popen(command, shell=True, stdout=PIPE, stderr=STDOUT, close_fds=True)
    captured = p.stdout.read().decode("utf-8")
    rc = p.wait()
    
    if rc not in ok_statuses:
        raise ShellCommandError("Command returned exit status %s: %s" % (rc, command), output=captured)

    return captured.strip()
{'fraction_non_alphanumeric': 0.11538461538461539, 'fraction_numerical': 0.004048582995951417, 'mean_word_length': 4.5875706214689265, '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': '1154738', 'n_tokens_mistral': 318, 'n_tokens_neox': 313, 'n_words': 85}