Commit a00f954f9ef31d19fb87906a248809f0028c1cc2
1 parent
1bf5a7bb
Exists in
dev
Update install for Windows
Showing
1 changed file
with
22 additions
and
4 deletions
Show diff stats
install/install.py
... | ... | @@ -178,7 +178,14 @@ def install_python_modules(venv): |
178 | 178 | python = 'py' |
179 | 179 | pip = '\Scripts\pip' |
180 | 180 | REQUIREMENTS = 'REQUIREMENTS_WINDOWS.txt' |
181 | - sql_request=req + " |\"C:\Program Files\MySQL\MySQL Server 5.7\\bin\mysql\" -u root -p" | |
181 | + mysql_exe_path = "C:/Program Files (x86)/MySQL/MySQL Server 5.0/bin" | |
182 | + question = "Enter the path of the MySQL server if it is not the following name (" + mysql_exe_path + "): " | |
183 | + res = input(question) | |
184 | + if res!="": | |
185 | + mysql_exe_path = res | |
186 | + sql_req = "drop database pyros ; CREATE DATABASE pyros; drop database pyros_test ; CREATE DATABASE pyros_test; CREATE USER pyros ; GRANT USAGE ON *.* TO 'pyros'@'localhost' IDENTIFIED BY 'DjangoPyros' WITH GRANT OPTION; DROP USER 'pyros'@'localhost'; GRANT ALL ON pyros.* TO 'pyros'@'localhost' IDENTIFIED BY 'DjangoPyros'; GRANT ALL PRIVILEGES ON pyros.* TO 'pyros'@'localhost' IDENTIFIED BY 'DjangoPyros' WITH GRANT OPTION; GRANT ALL PRIVILEGES ON pyros_test.* TO pyros@localhost IDENTIFIED BY 'DjangoPyros' WITH GRANT OPTION;" | |
187 | + mysql_call_root = "\"" + mysql_exe_path+ "/mysql\" -u root -p" | |
188 | + mysql_call_pyros = "\"" + mysql_exe_path+ "/mysql\" -u pyros -p" | |
182 | 189 | |
183 | 190 | if REINSTALL: |
184 | 191 | print(Colors.LOG_BLUE + "-----------------------------Creating venv " + venv + "-----------------------------"+end_of_line + Colors.END) |
... | ... | @@ -203,9 +210,20 @@ def install_python_modules(venv): |
203 | 210 | ## creating database and creating and granting user pyros |
204 | 211 | # |
205 | 212 | print(Colors.LOG_BLUE + end_of_line+"-----------------------------Launching mysql to create database and create and grant user pyros-----------------------------" + Colors.END) |
206 | - print(Colors.LOG_BLUE +"-----------------------------Please enter your MYSQL root password-----------------------------" + Colors.END) | |
207 | - process = subprocess.Popen("echo " + sql_request, shell=True) | |
208 | - process.wait() | |
213 | + if (platform.system() == "Windows"): | |
214 | + print(Colors.LOG_BLUE +"------------------ Check if the user pyros exists in MYSQL (type the pyros password) -----------------------------" + Colors.END) | |
215 | + # We are testing if user pyros already exists in the database | |
216 | + process = subprocess.Popen("echo quit |" + mysql_call_pyros, shell=True) | |
217 | + process.wait() | |
218 | + if (process.returncode != 0): | |
219 | + # The user pyros must be created in the database | |
220 | + print(Colors.LOG_BLUE +"-----------------------------Please enter your MYSQL root password-----------------------------" + Colors.END) | |
221 | + process = subprocess.Popen("echo " + sql_req + " |"+ mysql_call_root, shell=True) | |
222 | + process.wait() | |
223 | + else: | |
224 | + print(Colors.LOG_BLUE +"-----------------------------Please enter your MYSQL root password-----------------------------" + Colors.END) | |
225 | + process = subprocess.Popen("echo " + sql_request, shell=True) | |
226 | + process.wait() | |
209 | 227 | if (process.returncode != 0): |
210 | 228 | stderr.write(Colors.ERROR + "ERROR !: db configuration failed !" + Colors.END + "\r\n") |
211 | 229 | return -1 | ... | ... |