-
Notifications
You must be signed in to change notification settings - Fork 45
/
jcv
executable file
·57 lines (47 loc) · 1.35 KB
/
jcv
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
#!/bin/bash
set -eu
usage() {
echo "Usage: $0 [-p <zmq port>] [-w <width>] [-h <height>] [-d] [-g]" 1>&2;
exit 1;
}
export THEME="light"
while getopts ":p:w:h:dg" o; do
case "${o}" in
p)
export ZMQ_PORT=${OPTARG}
;;
w)
export CAD_WIDTH=${OPTARG}
;;
h)
export CAD_HEIGHT=${OPTARG}
;;
d)
export THEME="dark"
;;
g)
export GLASS_MODE=1
;;
*)
usage
;;
esac
done
echo "[JCV] Creating a Jupyter kernel specification called 'jcv' for this conda environment"
python -m ipykernel install --user --name jcv --display-name jcv
JCV_PATH=~/.jcv
VIEWER_PATH=$(python -c "import os, jupyter_cadquery.viewer.server as c; print(os.path.dirname(c.__file__))")
echo "[JCV] Copying the voila notebook to $JCV_PATH"
mkdir -p $JCV_PATH
cp $VIEWER_PATH/viewer.ipynb $JCV_PATH
echo "[JCV] Signing the volia notebook"
jupyter trust $JCV_PATH/viewer.ipynb
echo "[JCV] Starting Jupyter CadQuery Viewer"
voila --theme $THEME \
--Voila.ip=0.0.0.0 \
--show_tracebacks=True \
--enable_nbextensions=True \
--VoilaExecutor.kernel_name=jcv \
--VoilaConfiguration.file_whitelist="favicon.ico" \
--VoilaConfiguration.file_whitelist=".*\.js" \
$JCV_PATH/viewer.ipynb