-
Notifications
You must be signed in to change notification settings - Fork 0
/
start-pywt.command
executable file
·179 lines (162 loc) · 3.97 KB
/
start-pywt.command
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
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
file='./worddata/letter_ranks.txt'
#!/bin/bash
# akseidel 06/08/22
# https://github.com/akseidel/
# A script automating the steps to run pywordletool
#
# To use from the residing folder:
# First mark as executable with "chmod +x start-pywt.command".
# In OSX run by entering "./start-pywt.command".
# In Linux run by entering "./start-pywt.command"
#
# Script arguments:
# none
# globals
s=0 # proceed flag 0=yes, 1=no
# print name header if needed
doheader(){
doline
printf " start-pywt \n"
}
doline(){
printf "======================================================================\n"
}
dotrailer(){
printf "Ok, launching the wordle helper ... \n"
doline
sleep .3
}
doerror(){
printf " Not starting the helper! Some required parts were not found. \n"
doline
printf "%s " "Press return to close."
read -r ans
}
# check for python3 on this system
# note to file: 2> suppresses the assertion error but does not discard the
# standard output. sh in linux kde required the 2 instead of &
chk4python3(){
printf " Checking for python3"
if ! python3 -c 'import sys; assert sys.version_info >= (3, )' 2> /dev/null;
then
printf "\n======================================================================\n"
printf " ! A problem. Python3 is required for pywordletool to work.\n"
printf " Search the internet for how to install it for your computer.\n"
printf "======================================================================\n"
s=1
else
printf " .... found "
python3 --version
fi
}
# check for python package customtkinter on this system
chk4customtkinter(){
printf " Checking for customtkinter"
test="$(pip3 list | grep 'customtkinter' | xargs)"
if ! [ "$test" ]> /dev/null;
then
printf "\n======================================================================\n"
printf " ! A problem. The 'customtkinter' package for python is required\n"
printf " for pywordletool to work. This package needs to be installed using\n"
printf " pip. \n"
printf "\n It can be installed using the command:\n"
printf "\n pip3 install --upgrade customtkinter==4.6.3\n"
printf "======================================================================\n"
s=1
else
printf " .... found "
printf '%s\n' "$test"
fi
}
# initial cleanup
initclean(){
reset
clear
cd -- "$(dirname "$0")" || return
}
# checking for needed parts
chk4parts(){
printf " Checking for ./worddata/helpinfo.txt"
file='./worddata/helpinfo.txt'
if [ ! -f "$file" ]
then
notfound $file 0
else
printf " .... found.\n"
fi
printf " Checking for ./worddata/letter_ranks.txt"
if [ ! -f "$file" ]
then
notfound $file 0
else
printf " .... found.\n"
fi
printf " Checking for ./pywt.py"
file='./pywt.py'
if [ ! -f "$file" ]
then
notfound $file 1
s=1
else
printf " .... found.\n"
fi
printf " Checking for ./helpers.py"
file='./helpers.py'
if [ ! -f "$file" ]
then
notfound $file 1
s=1
else
printf " .... found.\n"
fi
printf " Checking for ./worddata/nyt_wordlist.txt"
file='./worddata/nyt_wordlist.txt'
if [ ! -f "$file" ]
then
notfound $file 1
s=1
else
printf " .... found.\n"
fi
printf " Checking for ./worddata/wo_nyt_wordlist.txt"
file='./worddata/wo_nyt_wordlist.txt'
if [ ! -f "$file" ]
then
notfound $file 1
s=1
else
printf " .... found.\n"
fi
}
notfound(){
f=$1
n=$2
printf "\n %s not found." "${f}"
if [ "$n" -eq 0 ]
then
printf " It is not needed.\n"
else
printf " It is needed.\n"
fi
}
startitup(){
sleep 1
cd -- "$(dirname "$0")" || exit
if [ $s -eq 0 ]
then
dotrailer
python3 pywt.py &
else
doerror
fi
}
# program section
initclean
doheader
doline
chk4python3
chk4customtkinter
chk4parts
doline
startitup
# end