-
Notifications
You must be signed in to change notification settings - Fork 4
/
gen.bash
executable file
·117 lines (94 loc) · 2.33 KB
/
gen.bash
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
#!/bin/bash
# Script for setting up the development environment.
#source /usr/share/virtualenvwrapper/virtualenvwrapper.sh
NAME=py_trees
##############################################################################
# Colours
##############################################################################
BOLD="\e[1m"
CYAN="\e[36m"
GREEN="\e[32m"
RED="\e[31m"
YELLOW="\e[33m"
RESET="\e[0m"
padded_message ()
{
line="........................................"
printf "%s%s${2}\n" ${1} "${line:${#1}}"
}
pretty_header ()
{
echo -e "${BOLD}${1}${RESET}"
}
pretty_print ()
{
echo -e "${GREEN}${1}${RESET}"
}
pretty_warning ()
{
echo -e "${YELLOW}${1}${RESET}"
}
pretty_error ()
{
echo -e "${RED}${1}${RESET}"
}
##############################################################################
# Methods
##############################################################################
install_package ()
{
PACKAGE_NAME=$1
dpkg -s ${PACKAGE_NAME} > /dev/null
if [ $? -ne 0 ]; then
sudo apt-get -q -y install ${PACKAGE_NAME} > /dev/null
else
pretty_print " $(padded_message ${PACKAGE_NAME} "found")"
return 0
fi
if [ $? -ne 0 ]; then
pretty_error " $(padded_message ${PACKAGE_NAME} "failed")"
return 1
fi
pretty_warning " $(padded_message ${PACKAGE_NAME} "installed")"
return 0
}
generate_ui ()
{
NAME=$1
pyuic5 --from-imports -o ${NAME}_ui.py ${NAME}.ui
if [ $? -ne 0 ]; then
pretty_error " $(padded_message ${NAME} "failed")"
return 1
fi
pretty_print " $(padded_message ${NAME} "generated")"
return 0
}
generate_qrc ()
{
NAME=$1
pyrcc5 -o ${NAME}_rc.py ${NAME}.qrc
if [ $? -ne 0 ]; then
pretty_error " $(padded_message ${NAME} "failed")"
return 1
fi
pretty_print " $(padded_message ${NAME} "generated")"
return 0
}
##############################################################################
# Ensure reproducible results so we can avoid committing ad-nauseum to github
# https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=872285
export QT_HASH_SEED=0
echo ""
echo -e "${CYAN}Dependencies${RESET}"
install_package pyqt5-dev-tools || return
echo ""
echo -e "${CYAN}Generating UIs${RESET}"
generate_ui main_window
generate_ui web_view
echo ""
echo -e "${CYAN}Generating QRCs${RESET}"
generate_qrc images
generate_qrc web_app
echo ""
echo "I'm grooty, you should be too."
echo ""