<commit_before>import sys
import os
import logging
import subprocess
from shutil import copy, rmtree
from .helpers import get_rhino_ironpython_path

logging.basicConfig(format='%(levelname)s:%(message)s', level=logging.INFO)

if __name__ == '__main__':
    location = None
    if len(sys.argv) > 1:
        location = sys.argv[1]
        try:
            location = int(location)
        except ValueError:
            pass

    rhino_ironpython_path = get_rhino_ironpython_path(location=location)

    # Install the package to Rhino IronPython Users lib
    package_name = 'gh-python-remote'
    pip_cmd = [sys.executable, '-m', 'pip', 'install', '--upgrade',
               '--target=' + rhino_ironpython_path,
               '--no-binary=:all:', '--no-compile', '--ignore-requires-python',
               package_name, ]
    print('\n\nThis will install ghpythonremote in Rhino IronPython with the command:')
    print(' '.join(pip_cmd))
    subprocess.call(pip_cmd)

    # Get the Grasshopper libraries base dir
    gh_userobjects_path = os.path.join(os.getenv('APPDATA', ''), 'Grasshopper', 'UserObjects')
    if os.path.isdir(gh_userobjects_path):
        dest_dir_path = os.path.join(gh_userobjects_path, package_name)
    else:
        logging.warning('Could not find Grasshopper "UserObjects" special folder; '
                        + 'example files will be installed to default temp dir.')
        dest_dir_path = os.path.join(os.getenv('TEMP', 'C:\\'), package_name)
    # Get the filepath in the installed package
    source_dir_path = os.path.dirname(os.path.realpath(__file__))
    # Send the files there
    if os.path.isdir(dest_dir_path):
        rmtree(dest_dir_path)
    os.mkdir(dest_dir_path)
    copy_pairs = [
        ('examples', [
            'examples/curves.3dm',
            'examples/GH_python_remote.ghx',
            'examples/IronPython_to_CPython.py'
            'examples/GH_to_python.py',
            'examples/python_to_GH.py',
        ]),
        ('', [
            'ghcluster/GHPythonRemote.ghuser',<commit_msg>Use check_call to fail on subprocess error<commit_after>import sys
import os
import logging
import subprocess
from shutil import copy, rmtree
from .helpers import get_rhino_ironpython_path

logging.basicConfig(format='%(levelname)s:%(message)s', level=logging.INFO)

if __name__ == '__main__':
    location = None
    if len(sys.argv) > 1:
        location = sys.argv[1]
        try:
            location = int(location)
        except ValueError:
            pass

    rhino_ironpython_path = get_rhino_ironpython_path(location=location)

    # Install the package to Rhino IronPython Users lib
    package_name = 'gh-python-remote'
    pip_cmd = [sys.executable, '-m', 'pip', 'install', '--upgrade',
               '--target=' + rhino_ironpython_path,
               '--no-binary=:all:', '--no-compile', '--ignore-requires-python',
               package_name, ]
    print('\n\nThis will install ghpythonremote in Rhino IronPython with the command:')
    print(' '.join(pip_cmd))
    subprocess.check_call(pip_cmd)

    # Get the Grasshopper libraries base dir
    gh_userobjects_path = os.path.join(os.getenv('APPDATA', ''), 'Grasshopper', 'UserObjects')
    if os.path.isdir(gh_userobjects_path):
        dest_dir_path = os.path.join(gh_userobjects_path, package_name)
    else:
        logging.warning('Could not find Grasshopper "UserObjects" special folder; '
                        + 'example files will be installed to default temp dir.')
        dest_dir_path = os.path.join(os.getenv('TEMP', 'C:\\'), package_name)
    # Get the filepath in the installed package
    source_dir_path = os.path.dirname(os.path.realpath(__file__))
    # Send the files there
    if os.path.isdir(dest_dir_path):
        rmtree(dest_dir_path)
    os.mkdir(dest_dir_path)
    copy_pairs = [
        ('examples', [
            'examples/curves.3dm',
            'examples/GH_python_remote.ghx',
            'examples/IronPython_to_CPython.py'
            'examples/GH_to_python.py',
            'examples/python_to_GH.py',
        ]),
        ('', [
            'ghcluster/GHPythonRemote.ghuser',
{'fraction_non_alphanumeric': 0.11795987430505198, 'fraction_numerical': 0.0014503263234227702, 'mean_word_length': 2.772105742935278, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '367357', 'n_tokens_mistral': 1352, 'n_tokens_neox': 1293, 'n_words': 271}