Commit a593ae2476c011c256f45c930f350e5fbc2d5f08
1 parent
a61943b5
Exists in
dev
Modification in pyros.py to adapt windows install
Showing
1 changed file
with
14 additions
and
8 deletions
Show diff stats
pyros.py
... | ... | @@ -248,6 +248,7 @@ def execProcess(command, from_venv=False, is_async=False): |
248 | 248 | log.debug("Executing command" + " [" + command + "]" + from_venv_str) |
249 | 249 | if from_venv: |
250 | 250 | command = VENV_PYTHON+' ' + command |
251 | + print(f"EXECUTING {command}") | |
251 | 252 | process = subprocess.Popen(command, shell=True) |
252 | 253 | if is_async: |
253 | 254 | # current_processes.append(process) |
... | ... | @@ -629,7 +630,7 @@ def install_or_update(UPDATE: bool = False, with_packages: bool = True, with_dat |
629 | 630 | |
630 | 631 | # Guitastro |
631 | 632 | GUITASTRO_PATH = os.path.join(os.getcwd(), "./vendor/guitastro") |
632 | - if not WITH_DOCKER: | |
633 | + if with_packages and not WITH_DOCKER : | |
633 | 634 | #GUITASTRO_PATH = os.path.join(os.getcwd(), "../vendor/guitastro") |
634 | 635 | change_dir("..") |
635 | 636 | print(os.getcwd()) |
... | ... | @@ -674,7 +675,8 @@ def install_or_update(UPDATE: bool = False, with_packages: bool = True, with_dat |
674 | 675 | # 4) Update Sphinx API doc |
675 | 676 | num += 1 |
676 | 677 | printFullTerm(Colors.BLUE, f"{num}) UPDATING API DOC (with Sphinx)") |
677 | - _update_api_doc() or die() | |
678 | + if not IS_WINDOWS: | |
679 | + _update_api_doc() or die() | |
678 | 680 | |
679 | 681 | # 5) Install/Update database structure (make migrations + migrate) |
680 | 682 | if with_database: |
... | ... | @@ -1415,10 +1417,9 @@ def install_database(venv): |
1415 | 1417 | # 1) Create databases pyros and pyros_test (but not test_pyros because will be automatically created by django) |
1416 | 1418 | # TODO: Pour mysql < 5.5, comment éviter un "drop database" inutile (si la BD n'existe pas encore) qui va provoquer un plantage mysql ? |
1417 | 1419 | IF_EXISTS = '' if sql_version < 5.5 else 'IF EXISTS' |
1418 | - sql_query = \ | |
1419 | - f"DROP DATABASE {IF_EXISTS} {SQL_DATABASE}; CREATE DATABASE {SQL_DATABASE}; " +\ | |
1420 | - f"DROP DATABASE {IF_EXISTS} {SQL_DATABASE_SIMU}; CREATE DATABASE {SQL_DATABASE_SIMU}; " +\ | |
1421 | - f"DROP DATABASE {IF_EXISTS} {SQL_DATABASE_TEST}; CREATE DATABASE {SQL_DATABASE_TEST}; " | |
1420 | + sql_query = f"DROP DATABASE {IF_EXISTS} {SQL_DATABASE}; CREATE DATABASE {SQL_DATABASE};" | |
1421 | + sql_query += f"DROP DATABASE {IF_EXISTS} {SQL_DATABASE_SIMU}; CREATE DATABASE {SQL_DATABASE_SIMU};" | |
1422 | + sql_query += f"DROP DATABASE {IF_EXISTS} {SQL_DATABASE_TEST}; CREATE DATABASE {SQL_DATABASE_TEST};" | |
1422 | 1423 | |
1423 | 1424 | # 2) Create user pyros and give it all rights on 3 databases |
1424 | 1425 | # Ne marche pas si l'utilisateur existe déjà => erreur |
... | ... | @@ -1511,7 +1512,11 @@ def install_database(venv): |
1511 | 1512 | # --- The user pyros must be created in the database |
1512 | 1513 | print(Colors.LOG_BLUE + "-----------------------------Please enter your MYSQL root password-----------------------------" + Colors.END) |
1513 | 1514 | # process = subprocess.Popen("echo \"" + sql_query + "\" |"+ mysql_call_root, shell=True) |
1514 | - sql_cmd = 'echo "' + sql_query + '" | ' + mysql_call_root | |
1515 | + if IS_WINDOWS: | |
1516 | + mysql_call_root = f"mysql -h {mysql_host} -u '{mysql_login}' -p{mysql_root_password}" | |
1517 | + sql_cmd = 'echo ' + sql_query + ' | ' + mysql_call_root | |
1518 | + else: | |
1519 | + sql_cmd = 'echo "' + sql_query + '" | ' + mysql_call_root | |
1515 | 1520 | print("Executing sql cmd: ", sql_cmd) |
1516 | 1521 | process = subprocess.Popen(sql_cmd, shell=True) |
1517 | 1522 | process.wait() |
... | ... | @@ -1541,7 +1546,8 @@ def install_database(venv): |
1541 | 1546 | # TODO: from venv !!! |
1542 | 1547 | try: |
1543 | 1548 | # os.system(GLOBAL_PYTHON+" pyros.py init_database") |
1544 | - res = os.system(GLOBAL_PYTHON+" pyros.py initdb") | |
1549 | + res = execProcessFromVenv("pyros.py initdb") | |
1550 | + #res = os.system(GLOBAL_PYTHON+" pyros.py initdb") | |
1545 | 1551 | return res |
1546 | 1552 | ''' |
1547 | 1553 | process = subprocess.Popen(GLOBAL_PYTHON + " pyros.py init_database" , shell=True) | ... | ... |