forked from dfki-ric/phobos
-
Notifications
You must be signed in to change notification settings - Fork 0
/
install_phobos.sh
executable file
·162 lines (152 loc) · 4.5 KB
/
install_phobos.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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
#! /bin/sh
# Copyright 2014, University of Bremen & DFKI GmbH Robotics Innovation Center
#
# This file is part of Phobos, a Blender Add-On to edit robot models.
#
# Phobos is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License
# as published by the Free Software Foundation, either version 3
# of the License, or (at your option) any later version.
#
# Phobos is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with Phobos. If not, see <http://www.gnu.org/licenses/>.
#
# File install_phobos.sh
#
# author: Kai von Szadkowski, Ole Schwiegert
#
# This script will install phobos into your user bound python addon repository.
# It also provides a way for blenders python to import your python3s yaml module.
#
# If you used the old install script you can delete the previous phobos folder
# You also have to delete the old installconfig.txt to run this script correctly.
###Config file name###
file="installconfig.txt"
###Phobos install flag###
installed=0
#####
writeConfig() {
#Creates the config and writes it to installconfig.txt
echo "Enter your blender version (e.g. '2.71')"
read blenderversion
echo "blenderversion=$blenderversion" >>installconfig.txt
echo "Do you want to use your python3 yaml library or do you want to use the yaml version
distributed with phobos? (p - use python3 library / d - use distributed package)"
read PD
case $PD in
p|P )
useP='yes'
echo "useP=$useP" >>installconfig.txt
echo "Please enter the command to run your python3 binary (e.g python3 or /usr/bin/python3)"
read pythoncom
pythoncom=$pythoncom
echo "pythoncom=$pythoncom" >>installconfig.txt
;;
d|D )
useP='no'
echo "useP=$useP" >>installconfig.txt;;
esac
#Getting OS
###BEGIN PYTHON SNIPPET###
python << END
import platform
f = open("installconfig.txt", 'a')
osys = platform.system()
if osys == "Linux":
f.write("addonpath=$HOME/.config/blender/$blenderversion/scripts/addons")
elif osys == "Darwin":
f.write("addonpath=$HOME/Library/Application\ Support/Blender/$blenderversion/scripts/addons")
f.close()
END
###END PYTHON SNIPPET###
}
#####
#####
initConfig() {
if [ -r $file ]
then
echo "Found install config file."
. ./$file
else
writeConfig
fi
. ./$file
}
installPhobos() {
echo "Check for phobos installation..."
phobospath="$addonpath/phobos"
if [ -d "$phobospath" ]
then
echo "Phobos installation found and updated."
cp -R src/* "$phobospath"
cp -R definitions "$phobospath"
installed=1
else
echo "Phobos folder does not exist, create phobos folder in $addonpath ? (y/n)"
read YN
case $YN in
y|Y )
mkdir -p "$phobospath"
cp -R src/* "$phobospath"
cp -R definitions "$phobospath"
installed=1
echo "Copied phobos to $phobospath"
;;
n|N ) echo "No folder for phobos created";;
esac
fi
}
#####
#####
installYAML() {
if [ "$useP" = "yes" ]
then
echo "Checking for yamlpath.conf"
yamlpath="$phobospath/yamlpath.conf"
if [ -r $yamlpath ]
then
echo "yamlpath.conf found! Done."
else
###BEGIN PYTHON SNIPPET###
$pythoncom << END
import sys
import os
dirs = sys.path
yamlpath="i"
for directory in dirs:
if os.path.isdir(directory):
modules = os.listdir(directory)
for module in modules:
if module == "yaml":
yamlpath=directory
print ("YAML module found!")
f = open("yamlpath.conf", 'w')
f.truncate()#Empty the file
f.write(yamlpath)
f.close()
exit(1)
END
###END PYTHON SNIPPET###
cp yamlpath.conf "$phobospath/yamlpath.conf"
echo "yamlpath.conf created and copied"
fi
else
cp -R yaml "$phobospath"
echo "YAML package was copied into $phobospath."
fi
}
#####
#####MAIN SCRIPT#####
initConfig
installPhobos
if [ "$installed" -eq "1" ]
then
installYAML
else
echo "Cannot install YAML, because Phobos wasn't installed."
fi