forked from jdf/processing.py
-
Notifications
You must be signed in to change notification settings - Fork 0
/
processing-py.sh
executable file
·123 lines (104 loc) · 2.39 KB
/
processing-py.sh
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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
#!/usr/bin/env bash
####
#### The default script to run. Only used if none is given as an
#### optional argument
####
DEFAULT_SCRIPT="workspace/example.py"
####
#### JVM options to pass, such as requesting more RAM
####
JVM_ARGS="-Xmx1024m"
####
#
# Internal variables start here
#
####
JAVA=`which java`
THIS_FILE="$( readlink "$( which ${BASH_SOURCE[0]} )" || echo ${BASH_SOURCE[0]} )"
BASEDIR="$( cd "$( dirname $THIS_FILE )" && pwd )"
PLATFORM='unknown'
SPLASH="-splash:$BASEDIR/libraries/runtime/splash.png"
REDIRECT="--noredirect"
####
#
# Test which platform were are
#
####
if [ "$(expr $(uname -s) : 'Darwin')" != 0 ]; then
PLATFORM="mac"
elif [ "$(expr $(uname -s) : '.*CYGWIN.*')" != 0 ]; then
PLATFORM="win"
elif [ "$(expr $(uname -s) : '.*MINGW.*')" != 0 ]; then
PLATFORM="win"
else
echo "Linux / Unix support untested."
PLATFORM="linux"
fi
####
#
# Test if we run from a wrapper (e.g., Platypus wrapper, need to go 3x up)
#
####
if [ "$(expr "$BASEDIR" : '.*Contents/Resources.*')" != 0 ]; then
unset SPLASH
BASEDIR="$BASEDIR/../../../"
WRAPPED_WITH_CONSOLE=true
fi
####
#
# Check if there is a user supplied JRE
#
####
if [ -d "$BASEDIR/jre" ]; then
JAVA="$BASEDIR/jre/bin/java"
fi
####
#
# Check if we should run the default script or if arguments were given
#
####
if [ $# -eq 0 ]; then
DEFAULT_SCRIPT="$BASEDIR/$DEFAULT_SCRIPT"
if [ ! -f "$DEFAULT_SCRIPT" ];
then
echo "No script given and no default script present. Doing nothing."
exit
else
echo "No script supplied, running default."
fi
else
DEFAULT_SCRIPT=$1
if [ ! -f "$DEFAULT_SCRIPT" ];
then
echo "The script you supplied does not exist. Doing nothing."
exit
fi
fi
####
#
# Check if we are running in a terminal or not
#
####
if [ -t 2 ]; then
# In case we have a terminal connected
REDIRECT=--noredirect
else
# Or we don't ... In that case, redirect stdout / stderr, however
# we only do this when we are not actually wrapped with a console.
if $WRAPPED_WITH_CONSOLE; then
REDIRECT=--noredirect
else
REDIRECT=--redirect
fi
fi
####
#
# DJ, spin that!
#
####
if [ -f "$JAVA" ]; then
# I have to admit, the -Xmixed move is somewhat of a hack ...
"$JAVA" "${SPLASH:--Xmixed}" $JVM_ARGS -jar "$BASEDIR/processing-py.jar" $REDIRECT "$DEFAULT_SCRIPT"
else
echo "ERROR: Java not found!"
fi