<commit_before>"""Wrapper script to set-up proper environment to run GRASS

Before importing the grass package, the correct environment variables
must be set. This script sets up the environment for a Linux system,
then calls the processing script in a subprocess.

"""
import os
import subprocess

def prepend_env_var(key, val):
    """Prepend `val` to an environment variable

    A new variable is created if `key` doesn't exist, otherwise `val`
    is prepended to the existing environment variable.

    """
    if key in os.environ.keys():
        print('Key %s exists:' % key)
        print(os.environ[key])

        old_val = os.environ[key]

        os.environ[key] = ':'.join([val, old_val])
    else:
        os.environ[key] = val

    print('Edited %s:' % key)
    print(os.environ[key])

# To Do: Find out how to discover the GRASS installation directory and
# avoid hard-coding this
gis_base = '/usr/lib/grass64'
home = os.environ['HOME']

prepend_env_var('PATH', '%s/bin:%s/scripts' % (gis_base, gis_base))
prepend_env_var('PYTHONPATH', '%s/etc/python' % gis_base)
prepend_env_var('GISRC', '%s/.grassrc6' % home)

cmd = ['python', 'process-catchment.py']
subprocess.call(cmd)<commit_msg>REF: Avoid printing information about environ variables<commit_after>"""Wrapper script to set-up proper environment to run GRASS

Before importing the grass package, the correct environment variables
must be set. This script sets up the environment for a Linux system,
then calls the processing script in a subprocess.

"""
import os
import subprocess

def prepend_env_var(key, val):
    """Prepend `val` to an environment variable

    A new variable is created if `key` doesn't exist, otherwise `val`
    is prepended to the existing environment variable.

    """
    if key in os.environ.keys():
        old_val = os.environ[key]

        os.environ[key] = ':'.join([val, old_val])
    else:
        os.environ[key] = val

# To Do: Find out how to discover the GRASS installation directory and
# avoid hard-coding this
gis_base = '/usr/lib/grass64'
home = os.environ['HOME']

prepend_env_var('PATH', '%s/bin:%s/scripts' % (gis_base, gis_base))
prepend_env_var('PYTHONPATH', '%s/etc/python' % gis_base)
prepend_env_var('GISRC', '%s/.grassrc6' % home)

cmd = ['python', 'process-catchment.py']
subprocess.call(cmd)
{'fraction_non_alphanumeric': 0.12036238136324418, 'fraction_numerical': 0.0025884383088869713, 'mean_word_length': 4.01948051948052, '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': '3683400', 'n_tokens_mistral': 746, 'n_tokens_neox': 731, 'n_words': 244}