# HG changeset patch # User Vincent Hatakeyama <vincent.hatakeyama@xcg-consulting.fr> # Date 1663242134 -7200 # Thu Sep 15 13:42:14 2022 +0200 # Node ID b45dcc090821c42788bd79b910a8e1b5f47a5c72 # Parent 57306b630a9f45126c680834f54f10fb429d3706 🚑 docker_dev_start: fix restore and pre script options In the case of a database not started by the script, some information was missing. diff --git a/NEWS.rst b/NEWS.rst --- a/NEWS.rst +++ b/NEWS.rst @@ -2,6 +2,11 @@ History ======= +16.7.3 +------ + +docker_dev_start: Fix restoring database and applying script. + 16.7.2 ------ diff --git a/odoo_scripts/docker_dev_start.py b/odoo_scripts/docker_dev_start.py --- a/odoo_scripts/docker_dev_start.py +++ b/odoo_scripts/docker_dev_start.py @@ -42,9 +42,9 @@ _logger = logging.getLogger(__name__) -__version__ = "3.6.1" +__version__ = "3.6.2" __date__ = "2017-08-11" -__updated__ = "2022-09-07" +__updated__ = "2022-09-15" def __parser(project_name: str) -> ArgumentParser: @@ -891,15 +891,34 @@ host=db_host, port=dbport, ) as connection: + connection.autocommit = True _logger.info("Creating database %s", database) with connection.cursor() as cursor: cursor.execute(f'CREATE DATABASE "{database}"') + connection.close() if not start_postgresql and not odoo_help and restore_filename: _logger.info("Restoring database %s", database) + env = { + "PGHOST": db_host, + "PGPASSWORD": password, + "PGUSER": user, + "PG_COLOR": "always", + } + if dbport is not None: + env["PGPORT"] = dbport restore = call( - ["pg_restore", "-U", user, "-O", "-d", database, restore_filename] + [ + "pg_restore", + "--no-owner", + "--job=4", + "--dbname", + database, + restore_filename, + ], + env=env, ) - if not restore: + if restore != 0: + _logger.fatal("Errors during restoration") return 15 # --- Pre SQL script --- @@ -932,8 +951,16 @@ # remove script pg.exec_run(["rm", inside_pre_sql_script]) else: - _logger.info("Running SQL script %s in %s", pre_sql_script, database) - script = call(["psql", "-U", user, "-d", database, "-f", pre_sql_script]) + _logger.info("Running SQL script %s on %s", pre_sql_script, database) + env = { + "PGHOST": db_host, + "PGPASSWORD": password, + "PGUSER": user, + "PG_COLOR": "always", + } + if dbport is not None: + env["PGPORT"] = dbport + script = call(["psql", "--dbname", database, "-f", pre_sql_script], env=env) if script > 0: _logger.fatal("Error when running SQL script %s", script) return 16 diff --git a/odoo_scripts/docker_pylint.py b/odoo_scripts/docker_pylint.py --- a/odoo_scripts/docker_pylint.py +++ b/odoo_scripts/docker_pylint.py @@ -126,7 +126,8 @@ config.local_tag, { "entrypoint": "pylint", - "command": modules + ["--load-plugins=pylint_odoo"], + # "command": modules + ["--load-plugins=pylint_odoo"], + "command": modules, # needed to write in the cache "user": "root", "mounts": mounts,