Skip to content
Snippets Groups Projects

Support marabunta that is in the images

Merged Vincent Hatakeyama requested to merge topic/default/marabunta-anthem into branch/default
+ 61
43
@@ -22,24 +22,19 @@ from .parsing import apply, basic_parser
_logger = logging.getLogger(__name__)
__version__ = "3.0.1"
__version__ = "4.0.0"
__date__ = "2018-04-13"
__updated__ = "2022-01-27"
__updated__ = "2022-03-22"
def main(argv=None): # IGNORE:C0111
"""Parse arguments and docker build"""
program_version = __version__
program_build_date = str(__updated__)
program_version_message = "%%(prog)s %s (%s)" % (
program_version,
program_build_date,
)
program_shortdesc = __doc__.split(".", maxsplit=1)[0]
program_license = """%s
program_version_message = f"%(prog)s {__version__} ({__updated__})"
program_short_description = __doc__.split(".", maxsplit=1)[0]
program_license = f"""{program_short_description}
Created by Vincent Hatakeyama on %s.
Copyright 2018, 2020 XCG Consulting. All rights reserved.
Created by Vincent Hatakeyama on {__date__}.
Copyright 2018, 2020, 2022 XCG Consulting. All rights reserved.
Licensed under the MIT License
@@ -47,10 +42,7 @@ def main(argv=None): # IGNORE:C0111
or conditions of any kind, either express or implied.
USAGE
""" % (
program_shortdesc,
str(__date__),
)
"""
# the script assume it is launched from the super project
project_path = os.path.realpath(".")
@@ -139,7 +131,7 @@ USAGE
)
parser.add_argument(
"--load-language",
help="specifies the languages for the translations you want to be" " loaded",
help="specifies the languages for the translations you want to be loaded",
default=None,
dest="LOAD_LANGUAGE",
)
@@ -197,6 +189,7 @@ USAGE
extensions.append("unaccent")
else:
_logger.debug("No sample configuration %s", sample_conf)
# our base images have unaccent activated
extensions.append("unaccent")
if not odoo_db_user:
@@ -228,6 +221,9 @@ USAGE
"--no-flake8",
"--no-isort",
"--no-dev",
"--no-marabunta",
"--without-demo",
"",
]
if odoo_db_user:
args.append("--db_user")
@@ -254,6 +250,30 @@ USAGE
args.append("--chown")
# also pass build options
args.extend(get_build_options(nmspc))
module_list = (
override_installed_module.split(",")
if override_installed_module
else config.module_list
)
module_list_tests = (
override_tested_module.split(",")
if override_tested_module
else config.module_list_tests
)
install_modules = ",".join(
module for module in module_list if module not in module_list_tests
)
tested_non_installed_modules = [
module for module in module_list_tests if module not in module_list
]
if tested_non_installed_modules:
_logger.error(
"Modules to tests but not in module list: %s",
", ".join(tested_non_installed_modules),
)
if recreate_db:
if start_postgresql:
container, stop_method, socket_path = docker_run_postgresql(
@@ -289,23 +309,25 @@ USAGE
)
connection.commit()
connection.close()
odoo_connection = connect(
with connect(
user=pg_user, database="postgres", host=socket_path, port=5432
)
odoo_connection.autocommit = True
with odoo_connection.cursor() as cursor:
_logger.debug("Drop database %s", dbname)
cursor.execute('DROP DATABASE IF EXISTS "%s"' % dbname)
_logger.debug("Create database %s", dbname)
cursor.execute('CREATE DATABASE "%s" OWNER %s' % (dbname, odoo_db_user))
odoo_connection = connect(
) as odoo_connection:
odoo_connection.autocommit = True
with odoo_connection.cursor() as cursor:
_logger.debug("Drop database %s", dbname)
cursor.execute('DROP DATABASE IF EXISTS "%s"' % dbname)
_logger.debug("Create database %s", dbname)
cursor.execute(
'CREATE DATABASE "%s" OWNER %s' % (dbname, odoo_db_user)
)
with connect(
user=pg_user, database=dbname, host=socket_path, port=5432
)
odoo_connection.autocommit = True
with odoo_connection.cursor() as cursor:
for extension in extensions:
_logger.info("Adding extension %s", extension)
cursor.execute("CREATE EXTENSION %s" % extension)
) as odoo_connection:
odoo_connection.autocommit = True
with odoo_connection.cursor() as cursor:
for extension in extensions:
_logger.info("Adding extension %s", extension)
cursor.execute("CREATE EXTENSION %s" % extension)
# TODO do we really need to stop the container each time?
# that seems faster
# stop_method()
@@ -348,14 +370,12 @@ USAGE
if result:
return result
# TODO start odoo and detect if install fails
_logger.info("Installing modules %s in database %s", install_modules, dbname)
# install modules that are not to be tested
if nmspc.docker:
install_args = list(args)
if override_installed_module:
install_args.append("--install")
install_args.append(override_installed_module)
else:
install_args.append("--install-default")
install_args.append("--install")
install_args.append(install_modules)
if languages:
install_args.append("--load-language")
install_args.append(languages)
@@ -370,12 +390,10 @@ USAGE
raise NotImplementedError
# start odoo and detect if test fails
if nmspc.docker:
module_list_tests = ",".join(module_list_tests)
test_args = list(args)
if override_tested_module:
test_args.append("--test")
test_args.append(override_tested_module)
else:
test_args.append("--test-default")
test_args.append("--install-test")
test_args.append(module_list_tests)
if test_log_level:
test_args.append("--log-level")
test_args.append(test_log_level)
Loading