<commit_before>#!/usr/bin/env python
# -*- coding: utf-8 -*-

import subprocess
import sys
import os

from .serialization import Serializer


def run_script(script, object=None):
    """
    run a given script
    """
    os.environ['PYTHONPATH'] = os.pathsep.join(sys.path)
    if object:
        os.environ[object.__class__.__name__] = Serializer.serialize(
            object).decode()

    proc = subprocess.Popen(
        [sys.executable, script],
        stdin=subprocess.PIPE,
        stdout=subprocess.PIPE,
        stderr=subprocess.PIPE,
        env=os.environ
    )

    result = proc.communicate()

    exit_status = proc.wait()
    if exit_status != 0:
        raise Exception("script failed (exit status: %d)" % exit_status)

    return result<commit_msg>remove the env argument from Popen call<commit_after>#!/usr/bin/env python
# -*- coding: utf-8 -*-

import subprocess
import sys
import os

from .serialization import Serializer


def run_script(script, object=None):
    """
    run a given script
    """
    os.environ['PYTHONPATH'] = os.pathsep.join(sys.path)
    if object:
        os.environ[object.__class__.__name__] = Serializer.serialize(
            object).decode()

    proc = subprocess.Popen(
        [sys.executable, script],
        stdin=subprocess.PIPE,
        stdout=subprocess.PIPE,
        stderr=subprocess.PIPE,
    )

    result = proc.communicate()

    exit_status = proc.wait()
    if exit_status != 0:
        raise Exception("script failed (exit status: %d)" % exit_status)

    return result
{'fraction_non_alphanumeric': 0.11940298507462686, 'fraction_numerical': 0.0025957170668397143, 'mean_word_length': 2.697841726618705, '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': '4002277', 'n_tokens_mistral': 491, 'n_tokens_neox': 477, 'n_words': 108}