summaryrefslogtreecommitdiff
path: root/include/pre-common.sh
blob: ac14f6f85a57266a9171054e6645b6f19ad4246e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
function cleanup
{
    # Not a fan of ultra-verbose. This message will get lost.
    set +x
    echo "Trapped common exit signal (SIGINT | SIGTERM)"
    /bin/echo
    echo "TESTS WILL NOT BE IMPORTED"
    /bin/echo
    echo "Exiting..."
    exit 1
}
trap cleanup SIGINT SIGTERM

test_from=/srv/rt
test_to=~/local/pillowfort

if [[ `uname -s` == Darwin ]]; then
    test_from=/Users/iraf/rt
fi

if [[ $HOSTNAME == *jwcalibdev* ]]; then
    test_from=/data1/jwst_rt
fi

if [[ ! -d $test_to ]]; then
    mkdir -p "$test_to"
fi

export PATH=~/miniconda3/bin:$PATH
#export PATH=$PATH:~/local/fakedokia/bin
#export PYTHONPATH=~/local/fakedokia/lib
export CDBS=/grp/hst/cdbs/
export crrefer=$CDBS
export PYSYN_CDBS=$CDBS

function mkrt_paths
{
    args=("$@")
    paths=""

    for elem in "${args[@]}"
    do
        path="$test_from/$elem"
        if [[ ! -d $path ]]; then
            echo "Warning: $path does not exist. Omitting."
            continue
        fi
        paths+=($path)
    done
    printf $paths | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//'
}

function svn_update()
{
    args=("$@")
    paths=""

    for elem in "${args[@]}"
    do
        if [[ ! -d $elem ]]; then
            echo "Warning: $elem does not exist. Omitting."
            continue
        fi

        pushd "$elem" &>/dev/null
            echo "Updating $elem ..."
            svn up --non-interactive --accept theirs-conflict
        popd &>/dev/null
        
    done
}