<commit_before>#!/usr/bin/env bash

export PYTHONPATH=.

EXTRA_NOSE_ARGS="--with-xunit --xunit-file=logs/nosetests.xml"

# BEGIN subcommand functions

cmd_topology() {
    local zkclean
    echo "Shutting down supervisord: $(supervisor/supervisor.sh shutdown)"
    mkdir -p logs traces
    [ -e gen ] && rm -r gen
    if [ "$1" = "zkclean" ]; then
        shift
        zkclean="y"
    fi
    echo "Create topology, configuration, and execution files."
    topology/generator.py "$@" || exit 1
    if [ -n "$zkclean" ]; then
        echo "Deleting all Zookeeper state"
        rm -rf /run/shm/scion-zk
        tools/zkcleanslate --zk 127.0.0.1:2181
    fi
}

cmd_run() {
    if [ "$1" != "nobuild" ]; then
        echo "Compiling..."
        cmd_build || exit 1
    fi
    echo "Running the network..."
    if [ -e gen/zk_datalog_dirs.sh ]; then
        bash gen/zk_datalog_dirs.sh || exit 1
    fi
    supervisor/supervisor.sh start all
}

cmd_stop() {
    echo "Terminating this run of the SCION infrastructure"
    supervisor/supervisor.sh stop all
}

cmd_status() {
    supervisor/supervisor.sh status | grep -v RUNNING
    # If all tasks are running, then return 0. Else return 1.
    [ $? -eq 1 ]
    return
}

cmd_test(){
    set -e
    case "$1" in
        py) shift; py_test "$@";;
        go) shift; go_test "$@";;
        *) py_test; go_test;;
    esac
}

py_test() {
    nosetests3 ${EXTRA_NOSE_ARGS} "$@"
}

go_test() {
    # `make -C go` breaks if there are symlinks in $PWD
    ( cd go && make -s test )
}

cmd_coverage(){
    set -e
    case "$1" in
        py) shift; py_cover "$@";;<commit_msg>Remove stale sockets on shutdown (#1082)<commit_after>#!/usr/bin/env bash

export PYTHONPATH=.

EXTRA_NOSE_ARGS="--with-xunit --xunit-file=logs/nosetests.xml"

# BEGIN subcommand functions

cmd_topology() {
    local zkclean
    echo "Shutting down supervisord: $(supervisor/supervisor.sh shutdown)"
    mkdir -p logs traces
    [ -e gen ] && rm -r gen
    if [ "$1" = "zkclean" ]; then
        shift
        zkclean="y"
    fi
    echo "Create topology, configuration, and execution files."
    topology/generator.py "$@" || exit 1
    if [ -n "$zkclean" ]; then
        echo "Deleting all Zookeeper state"
        rm -rf /run/shm/scion-zk
        tools/zkcleanslate --zk 127.0.0.1:2181
    fi
}

cmd_run() {
    if [ "$1" != "nobuild" ]; then
        echo "Compiling..."
        cmd_build || exit 1
    fi
    echo "Running the network..."
    if [ -e gen/zk_datalog_dirs.sh ]; then
        bash gen/zk_datalog_dirs.sh || exit 1
    fi
    supervisor/supervisor.sh start all
}

cmd_stop() {
    echo "Terminating this run of the SCION infrastructure"
    supervisor/supervisor.sh stop all
    find /run/shm/dispatcher /run/shm/sciond -type s -print0 | xargs -r0 rm -v
}

cmd_status() {
    supervisor/supervisor.sh status | grep -v RUNNING
    # If all tasks are running, then return 0. Else return 1.
    [ $? -eq 1 ]
    return
}

cmd_test(){
    set -e
    case "$1" in
        py) shift; py_test "$@";;
        go) shift; go_test "$@";;
        *) py_test; go_test;;
    esac
}

py_test() {
    nosetests3 ${EXTRA_NOSE_ARGS} "$@"
}

go_test() {
    # `make -C go` breaks if there are symlinks in $PWD
    ( cd go && make -s test )
}

cmd_coverage(){
    set -e
    case "$1" in
        py) shift; py_cover "$@";;
{'fraction_non_alphanumeric': 0.13633633633633635, 'fraction_numerical': 0.014414414414414415, 'mean_word_length': 2.294757665677547, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, 'pii_count': 2, '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': '4748277', 'n_tokens_mistral': 1260, 'n_tokens_neox': 1207, 'n_words': 339}