diff --git a/NEWS.rst b/NEWS.rst index 57306b630a9f45126c680834f54f10fb429d3706_TkVXUy5yc3Q=..b45dcc090821c42788bd79b910a8e1b5f47a5c72_TkVXUy5yc3Q= 100644 --- 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 index 57306b630a9f45126c680834f54f10fb429d3706_b2Rvb19zY3JpcHRzL2RvY2tlcl9kZXZfc3RhcnQucHk=..b45dcc090821c42788bd79b910a8e1b5f47a5c72_b2Rvb19zY3JpcHRzL2RvY2tlcl9kZXZfc3RhcnQucHk= 100755 --- a/odoo_scripts/docker_dev_start.py +++ b/odoo_scripts/docker_dev_start.py @@ -42,5 +42,5 @@ _logger = logging.getLogger(__name__) -__version__ = "3.6.1" +__version__ = "3.6.2" __date__ = "2017-08-11" @@ -46,5 +46,5 @@ __date__ = "2017-08-11" -__updated__ = "2022-09-07" +__updated__ = "2022-09-15" def __parser(project_name: str) -> ArgumentParser: @@ -891,6 +891,7 @@ 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}"') @@ -894,5 +895,6 @@ _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) @@ -897,3 +899,11 @@ 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( @@ -899,3 +909,11 @@ restore = call( - ["pg_restore", "-U", user, "-O", "-d", database, restore_filename] + [ + "pg_restore", + "--no-owner", + "--job=4", + "--dbname", + database, + restore_filename, + ], + env=env, ) @@ -901,5 +919,6 @@ ) - 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 index 57306b630a9f45126c680834f54f10fb429d3706_b2Rvb19zY3JpcHRzL2RvY2tlcl9weWxpbnQucHk=..b45dcc090821c42788bd79b910a8e1b5f47a5c72_b2Rvb19zY3JpcHRzL2RvY2tlcl9weWxpbnQucHk= 100644 --- 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,