Commit a71270ee authored by Alexis PASQUIER's avatar Alexis PASQUIER
Browse files

[LINT] passage black, isort, autoflake

parent 48f53f2a
Pipeline #73243 failed with stages
in 38 seconds
import logging
import os
import sys
from . import api, mapper, config_section # noqa
from .odoo_config_maker import OdooConfig # noqa
from . import laucher # noqa
import logging
from . import api, config_section, mapper # noqa
from .odoo_config_maker import OdooConfig # noqa
_logger = logging.getLogger(__name__)
def main():
env_vars = dict(os.environ)
launcher = laucher.Launcher(
......
......@@ -79,4 +79,3 @@ class OdooConfigSection(ConfigConvert, Dictable, abc.ABC):
if not self.enable:
return {}
return self.get_info()
......@@ -2,8 +2,7 @@ import enum
from typing import Dict, Union
from addons_installer import addons_installer
from api import OdooConfigSection, OdooConfigABC
from api import OdooConfigABC, OdooConfigSection
class WorkersOdooConfigSection(OdooConfigSection):
......@@ -253,7 +252,6 @@ class UpdateInstallSection(OdooConfigSection):
self.force_stop_after_init = False
self.force_save_config_file = False
def to_dict(self):
default_res = {}
if self.force_save_config_file:
......@@ -262,12 +260,15 @@ class UpdateInstallSection(OdooConfigSection):
default_res["--stop-after-init"] = self.force_stop_after_init
if not self.enable:
return default_res
return dict({
"--update": ",".join(self.update),
"--install": ",".join(self.install),
"--stop-after-init": self.stop_after_init,
"--save": self.save_config_file,
}, **default_res)
return dict(
{
"--update": ",".join(self.update),
"--install": ",".join(self.install),
"--stop-after-init": self.stop_after_init,
"--save": self.save_config_file,
},
**default_res
)
class AddonsPathConfigSection(OdooConfigSection):
......
......@@ -5,7 +5,7 @@ import os
import subprocess
import sys
import uuid
from typing import List, Optional, Dict
from typing import Dict, List, Optional
from odoo_launcher import OdooConfig
......@@ -71,8 +71,6 @@ class Launcher(object):
default_config.set(section, "root_path", str(False))
return default_config
def launch_config_file(self, env_vars):
self._get_default_config_file(env_vars)
config = self.create_config_file_args(env_vars)
......@@ -123,7 +121,8 @@ class Launcher(object):
_logger.info("Run -> %s", " ".join([str(s) for s in cmd]))
return subprocess.Popen(cmd)
if __name__ == '__main__':
if __name__ == "__main__":
_logger.info("create config")
launcher = Launcher(sys.argv[1:])
if os.getenv("UPDATE") or os.getenv("INSTALL"):
......@@ -138,4 +137,4 @@ if __name__ == '__main__':
sys.exit(return_code)
_logger.info("#############################################")
_logger.info("Run Odoo")
sys.exit(launcher.launch().wait())
\ No newline at end of file
sys.exit(launcher.launch().wait())
......@@ -5,15 +5,15 @@ from typing import Dict, List, Optional
from api import ConfigConvert, Dictable, EnvMapper, OdooConfigABC
from config_section import (
DatabaseOdooConfigSection,
AddonsPathConfigSection,
DatabaseOdooConfigSection,
HttpOdooConfigSection,
LimitOdooConfigSection,
LoggerSection,
OtherSection,
ServerWideModuleConfigSection,
WorkersOdooConfigSection,
UpdateInstallSection,
LoggerSection,
WorkersOdooConfigSection,
)
from mapper import (
CleverCloudCellarCompatibilityMapper,
......
import os
import sys
import unittest
from laucher import Launcher
from odoo_launcher import OdooConfig
env_vars = {
# Env in Dockerfile Odoo
......@@ -52,8 +50,8 @@ env_vars = {
"S3_FILESTORE_SECRET_KEY": "filestore-secret-key",
"UPDATE": "base,my_erp",
"INSTALL": "my_erp",
"STOP_AFTER_INIT":"False",
"SAVE": "False"
"STOP_AFTER_INIT": "False",
"SAVE": "False",
}
......@@ -90,13 +88,17 @@ class TestOdooLauncher(unittest.TestCase):
addons_path = result.pop()
opt_name, opt_value = addons_path.split("=")
self.assertEqual("--addons-path", opt_name)
self.assertSetEqual(set(opt_value.split(',')),
{'/opt/addons/common_modules',
'/opt/addons/community_addons',
'/opt/addons/local_src',
'/odoo/odoo/addons',
'/odoo/addons',
'/opt/addons/cloud_modules'})
self.assertSetEqual(
set(opt_value.split(",")),
{
"/opt/addons/common_modules",
"/opt/addons/community_addons",
"/opt/addons/local_src",
"/odoo/odoo/addons",
"/odoo/addons",
"/opt/addons/cloud_modules",
},
)
# TODO test opt_value
self.assertEqual("--stop-after-init", result.pop())
......@@ -139,4 +141,3 @@ class TestOdooLauncher(unittest.TestCase):
self.assertEqual("--addons-path=/fake/server/path", result.pop())
self.assertEqual("/home/apasquier/workspace/odoo/v14/odoo14/odoo-bin", result.pop())
self.assertEqual(sys.executable, result.pop())
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment