From eaf32be11af70b4f6deffb4bb4b807ae25c31b34 Mon Sep 17 00:00:00 2001 From: Jorge Obiols Date: Sun, 8 Oct 2023 09:54:23 -0300 Subject: [PATCH 01/48] [FIX] Upgrade warning with pipx --- odoo_env/config.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/odoo_env/config.py b/odoo_env/config.py index ee6afd3..5905ea4 100644 --- a/odoo_env/config.py +++ b/odoo_env/config.py @@ -145,8 +145,8 @@ def check_version(self): f"however version {version} is available. " ) Msg().warn( - 'You should consider upgrading via the "pip3 ' - 'install --upgrade odoo-env" command.' + 'You should consider upgrading via the "pipx ' + ' upgrade odoo-env" command.' ) except Exception: Msg().inf( From 7ed4cb441b94a2075bcc2bb56acaf04983836f99 Mon Sep 17 00:00:00 2001 From: Jorge Obiols Date: Tue, 10 Oct 2023 14:04:07 -0300 Subject: [PATCH 02/48] [UPD] improve docker installation --- install_vps.sh | 40 ++++++++++++++++++++++++++++++++-------- 1 file changed, 32 insertions(+), 8 deletions(-) diff --git a/install_vps.sh b/install_vps.sh index 24433f4..d97ed9d 100644 --- a/install_vps.sh +++ b/install_vps.sh @@ -17,28 +17,52 @@ python3 -V sudo apt install python3-distutils -y # install pip -curl -fsSL https://bootstrap.pypa.io/get-pip.py -o get-pip.py -sudo python3 get-pip.py -rm get-pip.py +#curl -fsSL https://bootstrap.pypa.io/get-pip.py -o get-pip.py +#sudo python3 get-pip.py +#rm get-pip.py # install pipx -#sudo apt install pipx +sudo apt install pipx +pipx --version # test pip #pip -V # install sd and oe -echo -echo "installing oe" -pip install odoo-env +pipx install ensurepath +pipx install odoo-env -# install docker +# install docker en desarrollo echo echo "installing docker" curl -fsSL get.docker.com -o get-docker.sh sh get-docker.sh rm get-docker.sh +# install docker en produccion Ubuntu +# https://docs.docker.com/engine/install/ubuntu/ + +# Add Docker's official GPG key: +sudo apt-get update +sudo apt-get install ca-certificates curl gnupg +sudo install -m 0755 -d /etc/apt/keyrings +curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg +sudo chmod a+r /etc/apt/keyrings/docker.gpg + +# Add the repository to Apt sources: +echo \ + "deb [arch="$(dpkg --print-architecture)" signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu \ + "$(. /etc/os-release && echo "$VERSION_CODENAME")" stable" | \ + sudo tee /etc/apt/sources.list.d/docker.list > /dev/null +sudo apt-get update + +# install latest versin +sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin + +# Verificar docker +sudo docker run hello-world + + # install composer # Run this command to download the current stable release of Docker Compose: sudo curl -L "https://github.com/docker/compose/releases/download/v2.22.0/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose From 98b6353f1546589b5eaf96c3f24a0509a2b2234d Mon Sep 17 00:00:00 2001 From: Jorge Obiols Date: Thu, 12 Oct 2023 23:06:28 -0300 Subject: [PATCH 03/48] [FIX] bajar repositorios con submodulos --- .vscode/launch.json | 2 +- odoo_env/odooenv.py | 19 +++++++++---------- odoo_env/repos.py | 22 ++++++++++++++++------ 3 files changed, 26 insertions(+), 17 deletions(-) diff --git a/.vscode/launch.json b/.vscode/launch.json index 399ece1..f2051e2 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -9,7 +9,7 @@ "type": "python", "request": "launch", "python": "/usr/bin/python3", - "args": ["-c", "emafi", "-w"], + "args": ["-i", "-c", "emafi"], "justMyCode": true, "module": "odoo_env.oe" } diff --git a/odoo_env/odooenv.py b/odoo_env/odooenv.py index 9daf94e..b7621b4 100644 --- a/odoo_env/odooenv.py +++ b/odoo_env/odooenv.py @@ -48,9 +48,9 @@ def _process_repos(self): ############################################################## cmd = CloneRepo( self, - usr_msg="cloning %s" % repo.formatted, - command="git -C %s %s" % (self.client.sources_dir, repo.clone), - args="%s%s" % (self.client.sources_dir, repo.dir_name), + usr_msg=f"cloning {repo.formatted}", + command=f"git -C {self.client.sources_dir} {repo.clone}", + args=f"{self.client.sources_dir}{repo.dir_name}", ) ret.append(cmd) @@ -59,10 +59,9 @@ def _process_repos(self): ############################################################## cmd = PullRepo( self, - usr_msg="pulling %s" % repo.formatted, - command="git -C %s%s %s" - % (self.client.sources_dir, repo.dir_name, repo.pull), - args="%s%s" % (self.client.sources_dir, repo.dir_name), + usr_msg=f"pulling {repo.formatted}", + command=f"git -C {self.client.sources_dir}{repo.dir_name} {repo.pull}", + args=f"{self.client.sources_dir}{repo.dir_name}", ) ret.append(cmd) @@ -207,7 +206,7 @@ def install(self, client_name): ################################################################## msg = "Installing client %s" % client_name cmd = MakedirCommand( - self, command="sudo mkdir %s" % BASE_DIR, args=BASE_DIR, usr_msg=msg + self, command=f"sudo mkdir {BASE_DIR}", args=BASE_DIR, usr_msg=msg ) ret.append(cmd) @@ -232,7 +231,7 @@ def install(self, client_name): "log", "sources", ]: - r_dir = "%s%s" % (self.client.base_dir, w_dir) + r_dir = f"{self.client.base_dir}{w_dir}" cmd = MakedirCommand(self, command="mkdir -p %s" % r_dir, args="%s" % r_dir) ret.append(cmd) @@ -241,7 +240,7 @@ def install(self, client_name): ################################################################## if self.debug: for w_dir in self._get_packs(): - r_dir = "%s%s" % (self.client.version_dir, w_dir) + r_dir = f"{self.client.version_dir}{w_dir}" cmd = MakedirCommand( self, command="mkdir -p %s" % r_dir, args="%s" % r_dir ) diff --git a/odoo_env/repos.py b/odoo_env/repos.py index b496cb3..6e26698 100644 --- a/odoo_env/repos.py +++ b/odoo_env/repos.py @@ -44,7 +44,7 @@ def pull(self): class Repo2: def __init__(self, value, branch): - """Sintaxis [[/] [-b ] + """Sintaxis [[/] [-b ] [optios] El branch debe estar despues del repo, si no esta se toma el branch que viene como parametro, si no viene nada es una excepcion. El directorio va despues del repo y puede no estar @@ -53,6 +53,13 @@ def __init__(self, value, branch): parsed = value.split(" ") # eliminar los espacios parsed = [i for i in parsed if i != ""] + + if "--recurse-submodules" in parsed: + parsed.remove("--recurse-submodules") + self._recurse_submodules = True + else: + self._recurse_submodules = False + # obtener el branch si es que existe if "-b" in parsed: index = parsed.index("-b") @@ -86,21 +93,24 @@ def branch(self): @property def url(self): if self._extra_dir: - return "%s %s" % (self._url, self._dir) + return f"{self._url} {self._dir}" else: return self._url @property def formatted(self): + recurse = "recursive" if self._recurse_submodules else "" if self._extra_dir: - return "b %s %s >> %s" % (self.branch, self._url, self._dir) + return f"b {self.branch} {recurse} {self._url} >> {self._dir}" else: - return "b %s %s" % (self.branch, self.url) + return f"b {self.branch} {recurse} {self.url}" @property def clone(self): - return "clone --depth 1 -b %s %s" % (self.branch, self.url) + recurse = "--recurse-submodules" if self._recurse_submodules else "" + return f"clone --depth 1 {recurse} -b {self.branch} {self.url}" @property def pull(self): - return "pull" + recurse = "--recurse-submodules" if self._recurse_submodules else "" + return f"pull {recurse}" From 0bfacda2a9340ffb856df30711f4c815e9109d70 Mon Sep 17 00:00:00 2001 From: Jorge Obiols Date: Thu, 12 Oct 2023 23:20:31 -0300 Subject: [PATCH 04/48] [FIX] Bump version --- README.md | 3 ++- odoo_env/__init__.py | 2 +- pyproject.toml | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index cf8be45..2a2820e 100644 --- a/README.md +++ b/README.md @@ -95,6 +95,7 @@ Installation Changelog --------- + - 0.11.4 - FIX now can download repositories with submodules - 0.11.3 - Support for submodules, oe -w can write paths for a submodule structure - 0.10.24 - Small patch that allows to use postgres with versions greater than 10. - 0.10.23 - The postgres docker image is not required anymore it is not necessary. @@ -102,7 +103,7 @@ Changelog - new parameter -E to install external dependences in manifest.py - 0.10.22 find manifest with exact name instaed of part of name. - 0.10.21 change dbtools version to 1.3.0 - - 0.10.20 fix --restore --from-server if does not work when base_dir is not default + - 0.10.20 fix --restore --from-server does not work when base_dir is not default - 0.10.19 dbtools for postgres 14.2 - 0.10.18 ADD warning if --nginx issued and there are no nginx image on proyect - 0.10.16 FIX overwrite workers in odoo.conf diff --git a/odoo_env/__init__.py b/odoo_env/__init__.py index 1bebb74..350cbe9 100644 --- a/odoo_env/__init__.py +++ b/odoo_env/__init__.py @@ -1 +1 @@ -__version__ = "0.11.3" +__version__ = "0.11.4" diff --git a/pyproject.toml b/pyproject.toml index 7071107..e178d2c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -7,7 +7,7 @@ build-backend = "hatchling.build" [project] name = "odoo-env" -version = "0.11.3" +version = "0.11.4" authors = [ { name="Jorge Obiols", email="jorge.obiols@gmail.com" }, ] From b741bed34faa590278083f1544cc7d2ab5507765 Mon Sep 17 00:00:00 2001 From: Jorge Obiols Date: Sat, 28 Oct 2023 09:40:18 -0300 Subject: [PATCH 05/48] No funciona --from-server (#87) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Se corrigió el directorio del server que apuntaba a BASE_DIR --- .vscode/launch.json | 2 +- README.md | 1 + docs/_includes/manifest_example.md | 2 +- odoo_env/__init__.py | 2 +- odoo_env/client.py | 8 +++++--- pyproject.toml | 2 +- 6 files changed, 10 insertions(+), 7 deletions(-) diff --git a/.vscode/launch.json b/.vscode/launch.json index f2051e2..e553eef 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -9,7 +9,7 @@ "type": "python", "request": "launch", "python": "/usr/bin/python3", - "args": ["-i", "-c", "emafi"], + "args": ["--restore", "--from-prod", "-c", "lopez"], "justMyCode": true, "module": "odoo_env.oe" } diff --git a/README.md b/README.md index 2a2820e..6ac2dc8 100644 --- a/README.md +++ b/README.md @@ -95,6 +95,7 @@ Installation Changelog --------- + - 0.11.5 - FIX --from-server does not download the database - 0.11.4 - FIX now can download repositories with submodules - 0.11.3 - Support for submodules, oe -w can write paths for a submodule structure - 0.10.24 - Small patch that allows to use postgres with versions greater than 10. diff --git a/docs/_includes/manifest_example.md b/docs/_includes/manifest_example.md index e9c74f7..97991d2 100644 --- a/docs/_includes/manifest_example.md +++ b/docs/_includes/manifest_example.md @@ -267,7 +267,7 @@ our sources. # suelos13 is the alias you set in .ssh/config # i.e. you can access the server typing ssh suelos13 # ec2-user is the user who is accessing the server, then when you perform a - # oe --restore --from-server + # oe --restore --from-prod # the backup will be transferred from server to your local with scp 'prod_server': 'ec2-user@suelos13', diff --git a/odoo_env/__init__.py b/odoo_env/__init__.py index 350cbe9..91df974 100644 --- a/odoo_env/__init__.py +++ b/odoo_env/__init__.py @@ -1 +1 @@ -__version__ = "0.11.4" +__version__ = "0.11.5" diff --git a/odoo_env/client.py b/odoo_env/client.py index a02b880..0a4d771 100644 --- a/odoo_env/client.py +++ b/odoo_env/client.py @@ -251,23 +251,25 @@ def version_dir(self): def server_version_dir(self): """/odoo_ar/odoo-13.0/ /odoo_ar/odoo-13.0e/ + Esta funcion no tiene que tomar BASE_DIR porque en el servidor es siempre + /odoo_ar/ """ lic = "e" if self._license == "EE" else "" - return f"{BASE_DIR}odoo-{self._version}{lic}/" + return f"/odoo_ar/odoo-{self._version}{lic}/" @property def base_dir(self): """/odoo_ar/odoo-13.0/clientname/ /odoo_ar/odoo-13.0e/clientname/ """ - return "%s%s/" % (self.version_dir, self._name) + return f"{self.version_dir}{self._name}/" @property def server_base_dir(self): """/odoo_ar/odoo-13.0/clientname/ /odoo_ar/odoo-13.0e/clientname/ """ - return "%s%s/" % (self.server_version_dir, self._name) + return f"{self.server_version_dir}{self._name}/" @property def backup_dir(self): diff --git a/pyproject.toml b/pyproject.toml index e178d2c..39b1dc2 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -7,7 +7,7 @@ build-backend = "hatchling.build" [project] name = "odoo-env" -version = "0.11.4" +version = "0.11.5" authors = [ { name="Jorge Obiols", email="jorge.obiols@gmail.com" }, ] From 03167d52dd1e0732865e8f262379755c43bfbd66 Mon Sep 17 00:00:00 2001 From: Jorge Obiols Date: Fri, 24 Nov 2023 22:04:22 -0300 Subject: [PATCH 06/48] [FIX] version 0.11.6 --- .vscode/launch.json | 2 +- README.md | 1 + install_vps.sh | 4 ++-- odoo_env/__init__.py | 2 +- odoo_env/command.py | 6 ++++++ odoo_env/odooenv.py | 20 +++++++++++++++++--- 6 files changed, 28 insertions(+), 7 deletions(-) diff --git a/.vscode/launch.json b/.vscode/launch.json index e553eef..81992f8 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -9,7 +9,7 @@ "type": "python", "request": "launch", "python": "/usr/bin/python3", - "args": ["--restore", "--from-prod", "-c", "lopez"], + "args": ["-i", "--extract-sources", "-c", "lopez"], "justMyCode": true, "module": "odoo_env.oe" } diff --git a/README.md b/README.md index 6ac2dc8..24be277 100644 --- a/README.md +++ b/README.md @@ -95,6 +95,7 @@ Installation Changelog --------- + - 0.11.6 - FIX --extract-sources now can remove directory packages - 0.11.5 - FIX --from-server does not download the database - 0.11.4 - FIX now can download repositories with submodules - 0.11.3 - Support for submodules, oe -w can write paths for a submodule structure diff --git a/install_vps.sh b/install_vps.sh index d97ed9d..35c6cb5 100644 --- a/install_vps.sh +++ b/install_vps.sh @@ -17,8 +17,8 @@ python3 -V sudo apt install python3-distutils -y # install pip -#curl -fsSL https://bootstrap.pypa.io/get-pip.py -o get-pip.py -#sudo python3 get-pip.py +curl -fsSL https://bootstrap.pypa.io/get-pip.py -o get-pip.py +sudo python3 get-pip.py #rm get-pip.py # install pipx diff --git a/odoo_env/__init__.py b/odoo_env/__init__.py index 91df974..be37974 100644 --- a/odoo_env/__init__.py +++ b/odoo_env/__init__.py @@ -1 +1 @@ -__version__ = "0.11.5" +__version__ = "0.11.6" diff --git a/odoo_env/command.py b/odoo_env/command.py index dfed16c..016213a 100644 --- a/odoo_env/command.py +++ b/odoo_env/command.py @@ -101,6 +101,12 @@ def check_args(self): return not os.path.isdir(self._args) +class RemovedirCommand(Command): + def check_args(self): + # si el directorio existe lo borramos + return os.path.isdir(self._args) + + class ExtractSourcesCommand(Command): @staticmethod def check_args(): diff --git a/odoo_env/odooenv.py b/odoo_env/odooenv.py index b7621b4..26270ce 100644 --- a/odoo_env/odooenv.py +++ b/odoo_env/odooenv.py @@ -235,6 +235,20 @@ def install(self, client_name): cmd = MakedirCommand(self, command="mkdir -p %s" % r_dir, args="%s" % r_dir) ret.append(cmd) + ################################################################## + # removing dirs for extracting sources, only for debug + ################################################################## + if self.debug: + for w_dir in self._get_packs(): + r_dir = f"{self.client.version_dir}{w_dir}" + cmd = RemovedirCommand( + self, + command=f"sudo rm -r {r_dir}", + args=r_dir, + usr_msg=f"Removing {r_dir}", + ) + ret.append(cmd) + ################################################################## # create dirs for extracting sources, only for debug ################################################################## @@ -330,11 +344,11 @@ def install(self, client_name): # agregar un gitignore for module in self._get_packs(): - r_dir = "{}{}".format(self.client.version_dir, module) + r_dir = f"{self.client.version_dir}{module}" cmd = CreateGitignore( self, - command="%s/.gitignore" % r_dir, - usr_msg="Creating gitignore file in %s" % r_dir, + command=f"{r_dir}/.gitignore", + usr_msg=f"Creating gitignore file in {r_dir}", ) ret.append(cmd) From f7194996218f54b0d218747650655240877a5c49 Mon Sep 17 00:00:00 2001 From: Jorge Obiols Date: Fri, 24 Nov 2023 23:11:37 -0300 Subject: [PATCH 07/48] [FIX] version 0.11.6 --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 39b1dc2..826b954 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -7,7 +7,7 @@ build-backend = "hatchling.build" [project] name = "odoo-env" -version = "0.11.5" +version = "0.11.6" authors = [ { name="Jorge Obiols", email="jorge.obiols@gmail.com" }, ] From b4e93d3acfb26a4c0a76a7b4a27f1ca98fe2a98a Mon Sep 17 00:00:00 2001 From: Jorge Obiols Date: Sat, 2 Dec 2023 10:35:13 -0300 Subject: [PATCH 08/48] [FIX] version 0.11.7 --- .vscode/launch.json | 2 +- README.md | 1 + odoo_env/__init__.py | 2 +- odoo_env/odooenv.py | 70 ++++++++++++-------------------------------- odoo_env/oe.py | 49 +++++++++++++++---------------- pyproject.toml | 2 +- 6 files changed, 45 insertions(+), 81 deletions(-) diff --git a/.vscode/launch.json b/.vscode/launch.json index 81992f8..f866610 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -9,7 +9,7 @@ "type": "python", "request": "launch", "python": "/usr/bin/python3", - "args": ["-i", "--extract-sources", "-c", "lopez"], + "args": ["-s",], "justMyCode": true, "module": "odoo_env.oe" } diff --git a/README.md b/README.md index 24be277..aae200c 100644 --- a/README.md +++ b/README.md @@ -95,6 +95,7 @@ Installation Changelog --------- + - 0.11.7 - FIX -i is no longer removing directory packages - 0.11.6 - FIX --extract-sources now can remove directory packages - 0.11.5 - FIX --from-server does not download the database - 0.11.4 - FIX now can download repositories with submodules diff --git a/odoo_env/__init__.py b/odoo_env/__init__.py index be37974..eec2a4d 100644 --- a/odoo_env/__init__.py +++ b/odoo_env/__init__.py @@ -1 +1 @@ -__version__ = "0.11.6" +__version__ = "0.11.7" diff --git a/odoo_env/odooenv.py b/odoo_env/odooenv.py index 26270ce..22496e9 100644 --- a/odoo_env/odooenv.py +++ b/odoo_env/odooenv.py @@ -213,11 +213,8 @@ def install(self, client_name): ################################################################## # change ownership of base dir ################################################################## - username = pwd.getpwuid(os.getuid()).pw_name - cmd = Command( - self, command="sudo chown %s:%s %s" % (username, username, BASE_DIR) - ) + cmd = Command(self, command=f"sudo chown {username}:{username} {BASE_DIR}") ret.append(cmd) ################################################################## @@ -238,7 +235,7 @@ def install(self, client_name): ################################################################## # removing dirs for extracting sources, only for debug ################################################################## - if self.debug: + if self.debug and self.extract_sources: for w_dir in self._get_packs(): r_dir = f"{self.client.version_dir}{w_dir}" cmd = RemovedirCommand( @@ -252,22 +249,20 @@ def install(self, client_name): ################################################################## # create dirs for extracting sources, only for debug ################################################################## - if self.debug: + if self.debug and self.extract_sources: for w_dir in self._get_packs(): r_dir = f"{self.client.version_dir}{w_dir}" - cmd = MakedirCommand( - self, command="mkdir -p %s" % r_dir, args="%s" % r_dir - ) + cmd = MakedirCommand(self, command=f"mkdir -p {r_dir}", args=r_dir) ret.append(cmd) ################################################################## # change og+w for those dirs ################################################################## - if self.debug: + if self.debug and self.extract_sources: for w_dir in self._get_packs(): - r_dir = "%s%s" % (self.client.version_dir, w_dir) - cmd = Command(self, command="chmod og+w %s" % r_dir) + r_dir = f"{self.client.version_dir}{w_dir}" + cmd = Command(self, command=f"chmod og+w {r_dir}") ret.append(cmd) ################################################################## @@ -275,8 +270,8 @@ def install(self, client_name): ################################################################## for w_dir in ["config", "data_dir", "log", "backup_dir"]: - r_dir = "%s%s" % (self.client.base_dir, w_dir) - cmd = Command(self, command="chmod o+w %s" % r_dir) + r_dir = f"{self.client.base_dir}{w_dir}" + cmd = Command(self, command=f"chmod o+w {r_dir}") ret.append(cmd) ################################################################## @@ -286,9 +281,7 @@ def install(self, client_name): if self.nginx: for w_dir in ["cert", "conf", "log"]: r_dir = "%s%s" % (BASE_DIR, "nginx/" + w_dir) - cmd = MakedirCommand( - self, command="mkdir -p %s" % r_dir, args="%s" % r_dir - ) + cmd = MakedirCommand(self, command=f"mkdir -p {r_dir}", args=r_dir) ret.append(cmd) ################################################################## @@ -400,9 +393,9 @@ def _add_debug_mountings(self, version): cvd = self.client.version_dir - ret = "-v {}extra-addons:{} ".format(cvd, iea) - ret += "-v {}dist-packages:{} ".format(cvd, idp) - ret += "-v {}dist-local-packages:{} ".format(cvd, idlp) + ret = f"-v {cvd}extra-addons:{iea} " + ret += f"-v {cvd}dist-packages:{idp} " + ret += f"-v {cvd}dist-local-packages:{idlp} " return ret def _add_normal_mountings(self): @@ -462,7 +455,7 @@ def run_environment(self, client_name): image = self.client.get_image("postgres") if image: - msg = "Starting postgres image v{}".format(image.version) + msg = f"Starting postgres image v{image.version}" command = "sudo docker run -d " if self.debug: @@ -470,9 +463,9 @@ def run_environment(self, client_name): command += "-e POSTGRES_USER=odoo " command += "-e POSTGRES_PASSWORD=odoo " command += "-e POSTGRES_DB=postgres " - command += "-v {}:/var/lib/postgresql/data ".format(self.client.psql_dir) + command += f"-v {self.client.psql_dir}:/var/lib/postgresql/data " command += "--restart=always " - command += "--name pg-{} ".format(self.client.name) + command += f"--name pg-{self.client.name} " command += image.name cmd = Command( @@ -519,42 +512,15 @@ def run_environment(self, client_name): return ret - def install_external_dependencies(self, client_name): - ret = [] - self._client = Client(self, client_name) - external_dependencies = self.client.external_dependencies - if "python" in external_dependencies and len(external_dependencies["python"]): - pip_names = (" ").join(external_dependencies["python"]) - - cmd = Command( - self, - command="sudo docker exec {} pip install --upgrade {}".format( - client_name, pip_names - ), - usr_msg="{} installing pip packages {} please wait...".format( - client_name, pip_names - ), - ) - ret.append(cmd) - - return ret - def stop_client(self, client_name): ret = [] cmd = Command( self, - command="sudo docker stop {}".format(client_name), - usr_msg="Stopping image {} please wait...".format(client_name), + command=f"sudo docker stop {client_name}", + usr_msg=f"Stopping image {client_name} please wait...", ) ret.append(cmd) - cmd = Command( - self, - command="sudo docker rm {}".format(client_name), - usr_msg="Removing image {}".format(client_name), - ) - ret.append(cmd) - if self.nginx: cmd = Command( self, diff --git a/odoo_env/oe.py b/odoo_env/oe.py index 30ff950..7da0ce7 100755 --- a/odoo_env/oe.py +++ b/odoo_env/oe.py @@ -24,9 +24,9 @@ def main(): "-i", "--install", action="store_true", - help="Install. Creates dir structure, and pull all the repositories " - "declared in the client manifest. Use with --debug to copy Odoo " - "image sources to host", + help="Install. The first time id creates dir structure, and pull all the " + "repositories declared in the client manifest. Use with --extract-sources to " + "copy Odoo image sources to host (needed for debug purpouses)", ) parser.add_argument( @@ -44,26 +44,25 @@ def main(): ) parser.add_argument( - "-R", "--run-env", action="store_true", help="Run postgres and aeroo images." + "-R", + "--run-env", + action="store_true", + help="Run postgres, wdb and aeroo images (aeroo only for old odoo versions).", ) parser.add_argument("-r", "--run-cli", action="store_true", help="Run odoo image") parser.add_argument( - "-S", "--stop-env", action="store_true", help="Stop postgres and aeroo images." + "-S", + "--stop-env", + action="store_true", + help="Stop postgres, wdb and aeroo images.", ) parser.add_argument( "-s", "--stop-cli", action="store_true", help="Stop odoo image." ) - parser.add_argument( - "-E", - "--ext-dep", - action="store_true", - help="Update manifest external dependecies.", - ) - parser.add_argument( "-u", "--update", @@ -103,25 +102,27 @@ def main(): parser.add_argument( "--debug", action="store_true", - help="Set default environment mode to debug" + help="Set default environment mode to debug " "This option has the following efects: " "1.- When doing an install it copies the image sources to host " - "and clones repos with depth=100" + "and clones repos with depth=1 " "2.- When doing an update all, (option -u) it forces update with " - "image sources." - "This option is persistent.", + "image sources. " + "This option is persistent. ", ) parser.add_argument( "--prod", action="store_true", - help="Set default environment mode to production" - "This option is intended to install a production environment." - "This option is persistent.", + help="Set default environment mode to production " + "This option is intended to install a production environment. " + "This option is persistent. " + "Warning this option is deprecated in favor of docker-compose installations", ) parser.add_argument( "--from-prod", action="store_true", - help="Restore backup from production server. Use with --restore", + help="Restore backup from production server. Use with --restore. " + "it needs the option 'prod_server': 'user@vps-alias' in the manifest", ) parser.add_argument( "--no-repos", @@ -164,9 +165,8 @@ def main(): nargs=1, dest="quality_assurance", help="Perform QA running tests, argument are repository to test. " - "Need -d, -m and -c options Note: for the test to run the " - "database must be created with demo data and must have " - "admin user with password admin.", + "Need -d, -m and -c options Note: for the test to run the database must be" + "created with demo data and must have admin user with password admin.", ) parser.add_argument( @@ -278,9 +278,6 @@ def main(): if args.stop_cli: commands += OdooEnv(options).stop_client(client_name) - if args.ext_dep: - commands += OdooEnv(options).install_external_dependencies(client_name) - if args.run_cli: commands += OdooEnv(options).run_client(client_name) diff --git a/pyproject.toml b/pyproject.toml index 826b954..100e634 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -7,7 +7,7 @@ build-backend = "hatchling.build" [project] name = "odoo-env" -version = "0.11.6" +version = "0.11.7" authors = [ { name="Jorge Obiols", email="jorge.obiols@gmail.com" }, ] From e1793aaedbf184f4db46b224044357ddd74a68ce Mon Sep 17 00:00:00 2001 From: Jorge Obiols Date: Fri, 8 Dec 2023 10:03:08 -0300 Subject: [PATCH 09/48] [IMP] change version warning --- .vscode/launch.json | 2 +- odoo_env/config.py | 23 ++++++++++++++--------- pyproject.toml | 4 ++-- 3 files changed, 17 insertions(+), 12 deletions(-) diff --git a/.vscode/launch.json b/.vscode/launch.json index f866610..94fe673 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -9,7 +9,7 @@ "type": "python", "request": "launch", "python": "/usr/bin/python3", - "args": ["-s",], + "args": ["-c lopez",], "justMyCode": true, "module": "odoo_env.oe" } diff --git a/odoo_env/config.py b/odoo_env/config.py index 5905ea4..14f4886 100644 --- a/odoo_env/config.py +++ b/odoo_env/config.py @@ -108,7 +108,7 @@ def save_base_dir(self, value): self.save_config_data(config) def check_version(self): - """me traigo la configuracion""" + """Chequea si la vcersion de odoo-env es la última""" config = self.get_config_data() dt_today = datetime.today() @@ -134,24 +134,29 @@ def check_version(self): try: response = http.fetch( "https://pypi.python.org/pypi/odoo-env/json", - connect_timeout=1, - request_timeout=1, + connect_timeout=5, + request_timeout=5, ) info = json.loads(response.buffer.read().decode("utf-8")) version = info["info"]["version"] if version != __version__: Msg().warn( - f"WARNING you are using odoo-env version {__version__} " - f"however version {version} is available. " + f"BE CAREFUL, you are using version {__version__} of odoo-env " + "however version {version} is already available." ) Msg().warn( - 'You should consider upgrading via the "pipx ' - ' upgrade odoo-env" command.' + 'You should update using "pipx upgrade odoo-env" or "pip ' + 'install --upgrade odoo-env" (old style).\n' ) + Msg().warn( + "Do it right now before chaos knocks your digital door. Dont risk it." + ) + except Exception: Msg().inf( - "Can not check odoo-env Version, do you have internet " - "connectivity?" + "Oops! It seems my cowboy hat ran out of internet connection. " + "Did you feed coins to the internet ranch, or did the Wi-Fi birds " + "fly away?" ) return True diff --git a/pyproject.toml b/pyproject.toml index 100e634..1eba685 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -13,7 +13,7 @@ authors = [ ] description = "A Dockerized environment for Odoo" readme = "README.md" -requires-python = ">=3.4" +requires-python = ">=3.5" classifiers=[ "Programming Language :: Python :: 3.5", "Programming Language :: Python :: 3.6", @@ -28,7 +28,7 @@ requires-python = ">=3.4" ] dependencies = [ "PyYAML >= 6.0.1", - "tornado >= 6.3.3", + "tornado >= 6.4", ] [project.scripts] From 70310ef444ae64e4495eaa3e9dc03f669fc65fa3 Mon Sep 17 00:00:00 2001 From: Jorge Obiols Date: Sat, 26 Oct 2024 17:10:14 -0300 Subject: [PATCH 10/48] Cuando se hace un test tiene que tomar por defecto la base test (#96) --- .pre-commit-config.yaml | 10 +++---- .vscode/launch.json | 5 ++-- README.md | 1 + odoo_env/__init__.py | 2 +- odoo_env/client.py | 2 +- odoo_env/create_database.py | 1 + odoo_env/odooenv.py | 5 ---- odoo_env/oe.py | 55 +++++++++++++++++++------------------ odoo_env/options.py | 7 +++-- pyproject.toml | 2 +- 10 files changed, 45 insertions(+), 45 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 19d4fd3..6e3c6d0 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -23,18 +23,18 @@ repos: args: ["--fix=lf"] - repo: https://github.com/psf/black - rev: 23.3.0 + rev: 24.10.0 hooks: - id: black - repo: https://github.com/asottile/pyupgrade - rev: v3.3.2 + rev: v3.19.0 hooks: - id: pyupgrade args: ["--keep-percent-format"] - repo: https://github.com/PyCQA/isort - rev: 5.12.0 + rev: 5.13.2 hooks: - id: isort name: isort except __init__.py @@ -43,7 +43,7 @@ repos: exclude: /__init__\.py$ - repo: https://github.com/PyCQA/pylint - rev: v2.17.3 + rev: v3.3.1 hooks: - id: pylint name: ejecutar pylint @@ -51,7 +51,7 @@ repos: exclude: data - repo: https://github.com/myint/autoflake - rev: v2.1.1 + rev: v2.3.1 hooks: - id: autoflake args: diff --git a/.vscode/launch.json b/.vscode/launch.json index 94fe673..a6e4713 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -4,12 +4,13 @@ // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 "version": "0.2.0", "configurations": [ + { "name": "Debug oe myproject", "type": "python", "request": "launch", - "python": "/usr/bin/python3", - "args": ["-c lopez",], + "python": "/odoo/vs_env/bin/python3.12", + "args": ["-Q dan_website_delivery_date -d danone16_test",], "justMyCode": true, "module": "odoo_env.oe" } diff --git a/README.md b/README.md index aae200c..3d99639 100644 --- a/README.md +++ b/README.md @@ -95,6 +95,7 @@ Installation Changelog --------- + - 0.12.0 - When running tests, if no database is specified, it will use the default database, which is the project name + test. - 0.11.7 - FIX -i is no longer removing directory packages - 0.11.6 - FIX --extract-sources now can remove directory packages - 0.11.5 - FIX --from-server does not download the database diff --git a/odoo_env/__init__.py b/odoo_env/__init__.py index eec2a4d..ea370a8 100644 --- a/odoo_env/__init__.py +++ b/odoo_env/__init__.py @@ -1 +1 @@ -__version__ = "0.11.7" +__version__ = "0.12.0" diff --git a/odoo_env/client.py b/odoo_env/client.py index 0a4d771..8adce55 100644 --- a/odoo_env/client.py +++ b/odoo_env/client.py @@ -199,7 +199,7 @@ def image(self, image_name): if ver: ret += ":" + ver return ret - msg.err("There is no %s image found in this manifest" % image_name) + msg.err(f"There is no {image_name} image found in this manifest") def get_image(self, value): for image in self._images: diff --git a/odoo_env/create_database.py b/odoo_env/create_database.py index 427892f..bf72c23 100644 --- a/odoo_env/create_database.py +++ b/odoo_env/create_database.py @@ -1,4 +1,5 @@ """ Crear base de datos de con datos demo""" + import os import subprocess diff --git a/odoo_env/odooenv.py b/odoo_env/odooenv.py index 22496e9..3c261d6 100644 --- a/odoo_env/odooenv.py +++ b/odoo_env/odooenv.py @@ -6,11 +6,6 @@ from odoo_env.constants import * from odoo_env.messages import Msg -# from odoo_env.command import (CloneRepo, Command, CreateGitignore, -# CreateNginxTemplate, ExtractSourcesCommand, -# MakedirCommand, MessageOnly, PullImage, PullRepo, -# WriteConfigFile) - class OdooEnv: """ diff --git a/odoo_env/oe.py b/odoo_env/oe.py index 7da0ce7..1d14306 100755 --- a/odoo_env/oe.py +++ b/odoo_env/oe.py @@ -24,9 +24,11 @@ def main(): "-i", "--install", action="store_true", - help="Install. The first time id creates dir structure, and pull all the " - "repositories declared in the client manifest. Use with --extract-sources to " - "copy Odoo image sources to host (needed for debug purpouses)", + help="The first time it runs, it creates the directory structure and " + "clones all repositories declared in the project. If run again, it " + "updates the repositories. Use together with --extract-sources to copy " + "the sources from the Odoo image to the host, which is essential for " + "working in debug mode.", ) parser.add_argument( @@ -67,10 +69,11 @@ def main(): "-u", "--update", action="store_true", - help="Update modules to database. Use --debug to force update with " - "image sources. use -m modulename to update this only module " - "default is all use -d databasename to update this database, " - "default is clientname_default", + help="Updates modules in the database. With no parameters, all modules " + "are updated. Use -m modulename to update only the specified module; " + "you can also pass a list of modules separated by commas (without " + "spaces). Use -d databasename to update a database other than the " + "default database.", ) parser.add_argument( @@ -90,39 +93,34 @@ def main(): parser.add_argument( "--no-deactivate", action="store_true", - help="No Deactivate database before restore. WARNING this may be a potential risk", + help="No Deactivate database before restore. WARNING this command is " + "deprecated", ) parser.add_argument( "--extract-sources", action="store_true", - help="Extract sources from images on -i", + help="Extracts the sources from the Odoo image to the host; it can only " + "be used together with -i.", ) parser.add_argument( - "--debug", - action="store_true", - help="Set default environment mode to debug " - "This option has the following efects: " - "1.- When doing an install it copies the image sources to host " - "and clones repos with depth=1 " - "2.- When doing an update all, (option -u) it forces update with " - "image sources. " - "This option is persistent. ", + "--debug", action="store_true", help="Set default environment mode to debug " ) parser.add_argument( "--prod", action="store_true", - help="Set default environment mode to production " - "This option is intended to install a production environment. " - "This option is persistent. " - "Warning this option is deprecated in favor of docker-compose installations", + help="Set default environment mode to production ", ) parser.add_argument( "--from-prod", action="store_true", help="Restore backup from production server. Use with --restore. " - "it needs the option 'prod_server': 'user@vps-alias' in the manifest", + "it needs the option 'prod_server': 'user@vps-alias' in the manifest" + "WARNING: This options may download an exact backup please deactivate" + "before use." + "You can deactivate a database running odoo with those parameters" + "odoo deactivate -d database", ) parser.add_argument( "--no-repos", @@ -155,7 +153,8 @@ def main(): "Used with -r starts an nginx container linked to odoo." "Used with -s stops nginx container. " "If you want to add certificates review nginx.conf file located " - "in /odoo_ar/nginx/conf", + "in /odoo_ar/nginx/conf NOTE: This option will be deprecated in the" + "near future", ) parser.add_argument( @@ -164,9 +163,11 @@ def main(): metavar="repo", nargs=1, dest="quality_assurance", - help="Perform QA running tests, argument are repository to test. " - "Need -d, -m and -c options Note: for the test to run the database must be" - "created with demo data and must have admin user with password admin.", + help="Run the tests. Required parameters: -m . Optional " + "parameters: -d ; if omitted, the default database will be " + "used, which is the project name + _test. NOTE: The database used for " + "testing must be created with demo data and should have admin/admin " + "credentials.", ) parser.add_argument( diff --git a/odoo_env/options.py b/odoo_env/options.py index 76a9aab..6674918 100644 --- a/odoo_env/options.py +++ b/odoo_env/options.py @@ -20,10 +20,11 @@ def get_database(args): else: client = get_client(args) if client: - default_database = client + "_prod" + suffix = "_test" if args.quality_assurance else "_prod" + default_database = client + suffix Msg().inf( - "Using default database: %s, use -d to " - "specify another database" % default_database + f"Using default database: {default_database}, use -d to " + "specify another database." ) return default_database else: diff --git a/pyproject.toml b/pyproject.toml index 1eba685..0cae729 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -27,7 +27,7 @@ requires-python = ">=3.5" "Topic :: System :: Software Distribution", ] dependencies = [ - "PyYAML >= 6.0.1", + "PyYAML >= 6.0.2", "tornado >= 6.4", ] From f65eeb38ef6fde06d098295067af92475df5c596 Mon Sep 17 00:00:00 2001 From: Jorge Obiols Date: Sat, 26 Oct 2024 17:21:33 -0300 Subject: [PATCH 11/48] [REBUILD] From 1511822568dee3fe0197d8df1c0cb2e4b7792693 Mon Sep 17 00:00:00 2001 From: Jorge Obiols Date: Sat, 26 Oct 2024 17:39:01 -0300 Subject: [PATCH 12/48] [pre-commit] --- .pre-commit-config.yaml | 2 +- .pylintrc | 10 +++++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 6e3c6d0..cff7379 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -43,7 +43,7 @@ repos: exclude: /__init__\.py$ - repo: https://github.com/PyCQA/pylint - rev: v3.3.1 + rev: v3.1.1 hooks: - id: pylint name: ejecutar pylint diff --git a/.pylintrc b/.pylintrc index 65a9446..2f560f5 100644 --- a/.pylintrc +++ b/.pylintrc @@ -1,7 +1,15 @@ +# ######################################################## +# Chequeos obligatorios +# ######################################################## + +[MASTER] +score=n + [MESSAGES CONTROL] disable=all -enable=anomalous-backslash-in-string, +enable= + anomalous-backslash-in-string, api-one-deprecated, api-one-multi-together, assignment-from-none, From 772d9e6cb5b243085b26f5cb9e30f64841699a56 Mon Sep 17 00:00:00 2001 From: Jorge Obiols Date: Sat, 26 Oct 2024 19:00:28 -0300 Subject: [PATCH 13/48] Update pre-commit.yml --- .github/workflows/pre-commit.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pre-commit.yml b/.github/workflows/pre-commit.yml index 218670a..e58f4ae 100644 --- a/.github/workflows/pre-commit.yml +++ b/.github/workflows/pre-commit.yml @@ -16,7 +16,7 @@ jobs: - uses: actions/setup-python@v4 name: Instalar Python with: - python-version: '3.8' + python-version: '3.12' - uses: actions/cache@v3 name: Preparar cache para reducir tiempo de ejecución From b43c286ab47bcb9d9c8400e77e79084363dfb177 Mon Sep 17 00:00:00 2001 From: Jorge Obiols Date: Sat, 26 Oct 2024 19:28:44 -0300 Subject: [PATCH 14/48] publish workflow --- .github/workflows/python-publish.yml | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/.github/workflows/python-publish.yml b/.github/workflows/python-publish.yml index b909dc7..921c807 100644 --- a/.github/workflows/python-publish.yml +++ b/.github/workflows/python-publish.yml @@ -16,19 +16,27 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Set up Python - uses: actions/setup-python@v3 + uses: actions/setup-python@v5 with: - python-version: '3.8' + python-version: '3.12' - name: Install dependencies run: | python -m pip install --upgrade pip pip install build - name: Build package run: python -m build + - name: Publish package - uses: pypa/gh-action-pypi-publish@v1.8.10 + if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags') + uses: pypa/gh-action-pypi-publish@release/v1 with: user: __token__ password: ${{ secrets.UPLOAD_ODOO_ENV }} + + # - name: Publish package + # uses: pypa/gh-action-pypi-publish@v1.10.3 + # with: + # user: __token__ + # password: ${{ secrets.UPLOAD_ODOO_ENV }} From d59f1335823980151a1f489c5e596c533dd07908 Mon Sep 17 00:00:00 2001 From: Jorge Obiols Date: Sat, 26 Oct 2024 19:34:44 -0300 Subject: [PATCH 15/48] publish workflow --- .github/workflows/python-publish.yml | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/.github/workflows/python-publish.yml b/.github/workflows/python-publish.yml index 921c807..4913435 100644 --- a/.github/workflows/python-publish.yml +++ b/.github/workflows/python-publish.yml @@ -29,14 +29,7 @@ jobs: run: python -m build - name: Publish package - if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags') - uses: pypa/gh-action-pypi-publish@release/v1 + uses: pypa/gh-action-pypi-publish@release/v1.10.3 with: user: __token__ password: ${{ secrets.UPLOAD_ODOO_ENV }} - - # - name: Publish package - # uses: pypa/gh-action-pypi-publish@v1.10.3 - # with: - # user: __token__ - # password: ${{ secrets.UPLOAD_ODOO_ENV }} From df4058151942a60c57cb0597c5817c164f3f5c20 Mon Sep 17 00:00:00 2001 From: Jorge Obiols Date: Sat, 26 Oct 2024 19:36:33 -0300 Subject: [PATCH 16/48] publish workflow --- .github/workflows/python-publish.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/python-publish.yml b/.github/workflows/python-publish.yml index 4913435..a4d5b5e 100644 --- a/.github/workflows/python-publish.yml +++ b/.github/workflows/python-publish.yml @@ -29,7 +29,7 @@ jobs: run: python -m build - name: Publish package - uses: pypa/gh-action-pypi-publish@release/v1.10.3 + uses: pypa/gh-action-pypi-publish@release/v1 with: user: __token__ password: ${{ secrets.UPLOAD_ODOO_ENV }} From ed62a49a512e471df3762b6612dcc97d467df997 Mon Sep 17 00:00:00 2001 From: Jorge Obiols Date: Sat, 26 Oct 2024 19:46:09 -0300 Subject: [PATCH 17/48] publish workflow --- pyproject.toml | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 0cae729..e078115 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -7,18 +7,17 @@ build-backend = "hatchling.build" [project] name = "odoo-env" -version = "0.11.7" +version = "0.12.0" authors = [ { name="Jorge Obiols", email="jorge.obiols@gmail.com" }, ] description = "A Dockerized environment for Odoo" readme = "README.md" -requires-python = ">=3.5" +requires-python = ">=3.7" classifiers=[ - "Programming Language :: Python :: 3.5", - "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.7", "Programming Language :: Python :: 3.8", + "Programming Language :: Python :: 3.9", "Development Status :: 5 - Production/Stable", "Intended Audience :: Developers", "License :: OSI Approved :: MIT License", From d33d4f65da3da4c3594ed7ba561b0549e0902b08 Mon Sep 17 00:00:00 2001 From: Jorge Obiols Date: Sat, 26 Oct 2024 19:52:01 -0300 Subject: [PATCH 18/48] publish workflow --- README.md | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 3d99639..3bd951b 100644 --- a/README.md +++ b/README.md @@ -95,26 +95,33 @@ Installation Changelog --------- - - 0.12.0 - When running tests, if no database is specified, it will use the default database, which is the project name + test. + - 0.12.0 - When running tests, if no database is specified, it will use the + default database, which is the project name + test. - 0.11.7 - FIX -i is no longer removing directory packages - 0.11.6 - FIX --extract-sources now can remove directory packages - 0.11.5 - FIX --from-server does not download the database - 0.11.4 - FIX now can download repositories with submodules - - 0.11.3 - Support for submodules, oe -w can write paths for a submodule structure - - 0.10.24 - Small patch that allows to use postgres with versions greater than 10. - - 0.10.23 - The postgres docker image is not required anymore it is not necessary. + - 0.11.3 - Support for submodules, oe -w can write paths for a submodule + structure + - 0.10.24 - Small patch that allows to use postgres with versions greater + than 10. + - 0.10.23 - The postgres docker image is not required anymore it is not + necessary. - new longpolling port exposed if declared in manifest - new parameter -E to install external dependences in manifest.py - 0.10.22 find manifest with exact name instaed of part of name. - 0.10.21 change dbtools version to 1.3.0 - - 0.10.20 fix --restore --from-server does not work when base_dir is not default + - 0.10.20 fix --restore --from-server does not work when base_dir is not + default - 0.10.19 dbtools for postgres 14.2 - - 0.10.18 ADD warning if --nginx issued and there are no nginx image on proyect + - 0.10.18 ADD warning if --nginx issued and there are no nginx image on + proyect - 0.10.16 FIX overwrite workers in odoo.conf - 0.10.15 base_dir parameter on oe_config.yaml - 0.10.14 add --extract-sources option - 0.10.13 fix -w to take into account submodules - - 0.10.12 fix -w to take into account not standard repo structure and odoo.conf rights + - 0.10.12 fix -w to take into account not standard repo structure and + odoo.conf rights - 0.10.11 ask before overwriting local image sources - 0.10.10 minor refactoring, improving doc - 0.10.9 minor fixes, more documentation From 368f8e180e0101043089f7fc695ea224e364c762 Mon Sep 17 00:00:00 2001 From: Jorge Obiols Date: Sat, 26 Oct 2024 22:10:15 -0300 Subject: [PATCH 19/48] Mejoras en parametro -p (#97) --- .github/workflows/pre-commit.yml | 4 +- .vscode/launch.json | 4 +- README.md | 381 ++++++++++++++++--------------- odoo_env/__init__.py | 2 +- odoo_env/client.py | 10 +- odoo_env/command.py | 2 +- odoo_env/images.py | 7 +- odoo_env/odooenv.py | 248 ++++++++++---------- odoo_env/oe.py | 19 +- 9 files changed, 349 insertions(+), 328 deletions(-) diff --git a/.github/workflows/pre-commit.yml b/.github/workflows/pre-commit.yml index e58f4ae..bfcc3a8 100644 --- a/.github/workflows/pre-commit.yml +++ b/.github/workflows/pre-commit.yml @@ -10,7 +10,7 @@ jobs: pre-commit: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 name: Hacer checkout del repositorio - uses: actions/setup-python@v4 @@ -18,7 +18,7 @@ jobs: with: python-version: '3.12' - - uses: actions/cache@v3 + - uses: actions/cache@v4 name: Preparar cache para reducir tiempo de ejecución with: path: ~/.cache/pre-commit diff --git a/.vscode/launch.json b/.vscode/launch.json index a6e4713..035ac7e 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -7,10 +7,10 @@ { "name": "Debug oe myproject", - "type": "python", + "type": "debugpy", "request": "launch", "python": "/odoo/vs_env/bin/python3.12", - "args": ["-Q dan_website_delivery_date -d danone16_test",], + "args": ["-h"], "justMyCode": true, "module": "odoo_env.oe" } diff --git a/README.md b/README.md index 3bd951b..73904ae 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ odoo-env ========= -jeo Software (c) 2023 jorge.obiols@gmail.com +jeo Software (c) 2024 jorge.obiols@gmail.com This code is distributed under the MIT license. Tool to manage docker based odoo environments. This is a Dockerized @@ -14,78 +14,92 @@ Environment to manage Odoo. Two environments are provided debug and prod. Directory structure /odoo_ar - ├── odoo-16.0 - │   ├── client_one - │   │ ├── config odoo.conf - │   │ ├── data_dir filestore - │ │ ├── backup_dir zip files with backups - │   │ ├── log odoo.log - │   │ ├── postgresql postgres database - │   │ └── sources custom sources - │ ├── dist-local-packages packages from image for debug - │ └── dist-packages pagkages from image for debug - └── nginx - ├── conf - ├── log - └── cert + └── odoo-16.0 +    ├── client_one +    │ ├── config odoo.conf +    │ ├── data_dir filestore + │ ├── backup_dir zip files with backups +    │ ├── log odoo.log +    │ ├── postgresql postgres database +     │ └── sources custom sources + ├── dist-local-packages packages from image for debug + └── dist-packages pagkages from image for debug Functionality ------------- - usage: oe [-h] [-i] [-p] [-w] [-R] [-r] [-S] [-s] [-E] [-u] [-c CLIENT] [-v] [--no-deactivate] - [--extract-sources] [--debug] [--prod] [--from-prod] [--no-repos] [-d DATABASE] - [-m MODULE] [--nginx] [-Q repo] [--backup-list] [--restore] [-f BACKUP_FILE] [-H] - [-V] + usage: oe.py [-h] [-i] [-p] [-w] [-R] [-r] [-S] [-s] [-u] [-c CLIENT] [-v] + [--no-deactivate] [--extract-sources] [--debug] [--prod] + [--from-prod] [--no-repos] [-d DATABASE] + [-m MODULE] [--nginx] [-Q repo] [--backup-list] [--restore] + [-f BACKUP_FILE] [-H] [-V] [--create-test-db] [--force-create] + [--base-dir BASE_DIR] - Odoo Environment Manager v0.10.24 - by jeo Software + Odoo Environment Manager v0.12.1 - by jeo Software - optional arguments: - -h, --help show this help message and exit - -i, --install Install. Creates dir structure, and pull all the repositories declared in - the client manifest. Use with --debug to copy Odoo image sources to host - -p, --pull-images Pull Images. Download all images declared in client manifest. - -w, --write-config Create / Overwrite config file. - -R, --run-env Run postgres and aeroo images. - -r, --run-cli Run odoo image - -S, --stop-env Stop postgres and aeroo images. - -s, --stop-cli Stop odoo image. - -E, --ext-dep Update manifest external dependecies. - -u, --update Update modules to database. Use --debug to force update with image - sources. use -m modulename to update this only module default is all use - -d databasename to update this database, default is clientname_default - -c CLIENT Set default client name. This option is persistent - -v, --verbose Go verbose mode. Prints every command - --no-deactivate No Deactivate database before restore. WARNING this may be a potential - risk - --extract-sources Extract sources from images on -i - --debug Set default environment mode to debugThis option has the following - efects: 1.- When doing an install it copies the image sources to host and - clones repos with depth=1002.- When doing an update all, (option -u) it - forces update with image sources.This option is persistent. - --prod Set default environment mode to productionThis option is intended to - install a production environment.This option is persistent. - --from-prod Restore backup from production server. Use with --restore - --no-repos Does not clone or pull repos when doing -i (install) - -d DATABASE Set default Database name.This option is persistent - -m MODULE Module to update. Used with -u (update) i.e. -m sale for updating sale - module -m all for updating all modules. NOTE: if you perform -u without - -m it asumes all modules - --nginx Add nginx to installation: Used with -i creates nginx dir with config - file. Used with -r starts an nginx container linked to odoo.Used with -s - stops nginx container. If you want to add certificates review nginx.conf - file located in /odoo_ar/nginx/conf - -Q repo Perform QA running tests, argument are repository to test. Need -d, -m - and -c options Note: for the test to run the database must be created - with demo data and must have admin user with password admin. - --backup-list List all backup files available for restore - --restore Restores a backup. it uses last backup and restores to default database. - You can change the backup file to restore with -f option and change - database name -d option - -f BACKUP_FILE Filename to restore. Used with --restore. To get the name of this file - issue a --backup-list command.If ommited the newest file will be restored - -H, --server-help Show odoo server help, it shows the help from the odoo imagedeclared in - the cliente manifest - -V, --version Show version number and exit. + options: + -h, --help show this help message and exit + -i, --install The first time it runs, it creates the directory structure + and clones all repositories declared in the project. If + run again, it updates the repositories. + Use together with --extract-sources to copy the sources + from the Odoo image to the host, which is essential for + working in debug mode. + -p, --pull-images Pull Images. Download all images declared in client manifest. + -w, --write-config Create / Overwrite config file. + -R, --run-env Run postgres, wdb and aeroo images (aeroo only for old odoo + versions). + -r, --run-cli Run odoo image + -S, --stop-env Stop postgres, wdb and aeroo images. + -s, --stop-cli Stop odoo image. + -u, --update Updates modules in the database. With no parameters, all + modules are updated. Use -m modulename to update only the + specified module; you can also pass a list of modules + separated by commas (without spaces). Use -d databasename + to update a database other than the default database. + -c CLIENT Set default client name. This option is persistent + -v, --verbose Go verbose mode. Prints every command + --no-deactivate No Deactivate database before restore. WARNING this + command is deprecated + it can only be used together with -i. + --debug Set default environment mode to debug + --prod Set default environment mode to production + --from-prod Restore backup from production server. Use with --restore. + it needs the option 'prod_server': 'user@vps-alias' in + the manifestWARNING: This options may download an exact + backup please deactivatebefore use.You can deactivate a + database running odoo with those parameters odoo deactivate + -d database + --no-repos Does not clone or pull repos when doing -i (install) + -d DATABASE Set default Database name.This option is persistent + -m MODULE Module to update. Used with -u (update) i.e. -m sale for + updating sale module -m all for updating all modules. + NOTE: if you perform -u without -m it asumes all modules + --nginx Add nginx to installation: Used with -i creates nginx dir + with config file. Used with -r starts an nginx container + linked to odoo.Used with -s stops nginx container. If you + want to add certificates review nginx.conf file located + in /odoo_ar/nginx/conf NOTE: This option will be deprecated + in thenear future + -Q repo Run the tests. Required parameters: -m . + Optional parameters: -d ; if omitted, the + default database will be used, which is the project + name + _test. NOTE: The database used for testing must be + created with demo data and should have admin/admin + credentials. + --backup-list List all backup files available for restore + --restore Restores a backup. it uses last backup and restores to + default database. You can change the backup file to restore + with -f option and change database name -d option + -f BACKUP_FILE Filename to restore. Used with --restore. To get the name + of this file issue a --backup-list command.If ommited + the newest file will be restored + -H, --server-help Show odoo server help, it shows the help from the odoo + imagedeclared in the cliente manifest + -V, --version Show version number and exit. + --create-test-db Create database with demo data. + --force-create Force database creation. + --base-dir BASE_DIR Set default base-dir This option is persistent. Installation @@ -95,118 +109,121 @@ Installation Changelog --------- - - 0.12.0 - When running tests, if no database is specified, it will use the - default database, which is the project name + test. - - 0.11.7 - FIX -i is no longer removing directory packages - - 0.11.6 - FIX --extract-sources now can remove directory packages - - 0.11.5 - FIX --from-server does not download the database - - 0.11.4 - FIX now can download repositories with submodules - - 0.11.3 - Support for submodules, oe -w can write paths for a submodule - structure - - 0.10.24 - Small patch that allows to use postgres with versions greater - than 10. - - 0.10.23 - The postgres docker image is not required anymore it is not - necessary. - - new longpolling port exposed if declared in manifest - - new parameter -E to install external dependences in manifest.py - - 0.10.22 find manifest with exact name instaed of part of name. - - 0.10.21 change dbtools version to 1.3.0 - - 0.10.20 fix --restore --from-server does not work when base_dir is not - default - - 0.10.19 dbtools for postgres 14.2 - - 0.10.18 ADD warning if --nginx issued and there are no nginx image on - proyect - - 0.10.16 FIX overwrite workers in odoo.conf - - 0.10.15 base_dir parameter on oe_config.yaml - - 0.10.14 add --extract-sources option - - 0.10.13 fix -w to take into account submodules - - 0.10.12 fix -w to take into account not standard repo structure and - odoo.conf rights - - 0.10.11 ask before overwriting local image sources - - 0.10.10 minor refactoring, improving doc - - 0.10.9 minor fixes, more documentation - - 0.10.8 improving in writing the odoo.conf - - 0.10.7 Fix bug creating odoo.conf missing data_dir in config. - - 0.10.6 Fix bug creating odoo.conf when there are no config spec is manifest - - 0.10.5 Set parameters in odoo.conf from manifest file. - - 0.10.4 IMP creation of odoo.conf improved in V11 also. - - 0.10.3 FIX nginx config now works behind port redirections - - 0.10.2 FIX collision field in manifest "license" - - 0.10.1 FIX bad filestore dir - - 0.10.0 New manifest syntax, backward compatible. - - 0.9.14 improved creation of odoo.conf, i.e. detect cpu number and - calculate workers. - - 0.9.13 solved bug when creating nginx config file - - 0.9.12 Get last wdb vesion. Added a check to verify if there is - a new version available in pypi. Fixed copy sources to host. - - 0.9.11 The commands -c and --debug now are persistent. - - 0.8.35 Workaround for mdillon gis database - - 0.8.32 Fix issue with first time installation - - 0.8.30 Add cache file to fix performance issues when we have more - than 15 clients. - - 0.8.29 Modify ssl certificate directories from letsencrypt, - support for oca/letsencript. - - 0.8.27 Fix compatibility issues w/ python3 - - 0.8.22 When using the options -i together with --debug, the - dist_packages and extra_addons directories were created with the - image sources but in read-only mode. Now we give them write - permission and a git repository is added to verify if there were - modifications. Option -V is added to show the version. - - 0.8.21 Many improvements on restore database. - - 0.8.20 When option -d not present assume database = client_name + - "_prod" when option -m is not present asume default "all" - - 0.8.19 Allow options -i and -w to work together - - 0.8.18 add -p command - - 0.8.17 Fix bug in python3 installation - - 0.8.13 Removing edm option (it was a bad idea), rewrite nginx - config to block /database/manager and /database/selector - - 0.8.12 fix version of wdb image to 3.2.5, latest does not work - - 0.8.11 Fix --nginx installation - - 0.8.10 Add --edm option to allow database manager on production - - 0.8.9 When installed from pip --nginx does not work - - 0.8.8 Disable database manager on login page in prod environment - - 0.8.7 Working on Python 2.7 to 3.7 - - 0.8.6 Fix: when installing on prod make a Shallow Clone - - 0.8.5 Fix test (option -Q) failing to run - - 0.8.4 PyPi version increment - - 0.8.3 PyPi version increment - - 0.8.2 Docker installs at the end allowing abort - - 0.8.1 Fix starting debug mode. - - 0.8.0 Use kozera image for wdb, write the nginx.conf with the - proper client name. - - 0.7.4 New parameter to attach to a running containcer in sd. - Support for debug image in v11 (python3) - data/install_scripts.sh improvements and fixes - - 0.7.3 if odoo not in manifest do not start image instead showing - an error - - 0.7.2 start aeroo on v > 9 - - 0.7.1 Revert again go https - - 0.7.0 Change protocol from https to ssh in order to use ssh keys. - - 0.6.1 FIX working directory with version > 9. If odoo main - version was > 9 the directory added a dot ie /odoo-10.0./ - - 0.6.0 deprecate dbfilter. - - 0.5.4 illformed manifest causing crash - - 0.5.3 Restore database with bad image - - 0.5.2 sd was not copied to /usr/local/bin - - 0.5.1 change postgres container name to pg- - - 0.5.0 support for non github repos, i.e. bitbucket, gitlab, etc - - 0.4.6 Odoo v10 do not run aeroo, find manifest - - 0.4.5 Install_scripts now installs python and docker - - 0.4.4 Do not expose 8072 when using Nginx - - 0.4.3 No more rewriting config on update all - - 0.4.2 Expose longpolling port in debug mode - - 0.4.1 Fixes in test invocation - - 0.4.0 Change QA invocation - - 0.3.2 do not overwrite config while making QA - - 0.3.1 Stop images instead of kill them on -s or -S - - 0.3.0 Restore any automatic backup made with database_tools module. - List all available backup files write config file add help - option -H (odoo help) - - 0.2.1 bug On QA, expose port 1984 for debug purpoes with WDB - - 0.2.0 Quality Assurance support, Add command sd rmall for removing - all docker images in memory - - 0.1.0 Nginx support, Script to install docker (in script folder, - for now you have to execute manually) sd command (short for - sudo docker plus some enhacements) - - 0.0.2 Minor fixes - - 0.0.1 Starting project + +- 0.12.1 - When the -p command is run in debug mode, it pulls the debug + image and performs an extract-sources; in production mode, it + pulls the production image. +- 0.12.0 - When running tests, if no database is specified, it will use the + default database, which is the project name + test. +- 0.11.7 - FIX -i is no longer removing directory packages +- 0.11.6 - FIX --extract-sources now can remove directory packages +- 0.11.5 - FIX --from-server does not download the database +- 0.11.4 - FIX now can download repositories with submodules +- 0.11.3 - Support for submodules, oe -w can write paths for a submodule structure +- 0.10.24 - Small patch that allows to use postgres with versions greater + than 10. +- 0.10.23 - The postgres docker image is not required anymore it is not + necessary. + - new longpolling port exposed if declared in manifest + - new parameter -E to install external dependences in manifest.py +- 0.10.22 find manifest with exact name instaed of part of name. +- 0.10.21 change dbtools version to 1.3.0 +- 0.10.20 fix --restore --from-server does not work when base_dir is not + default +- 0.10.19 dbtools for postgres 14.2 +- 0.10.18 ADD warning if --nginx issued and there are no nginx image on + proyect +- 0.10.16 FIX overwrite workers in odoo.conf +- 0.10.15 base_dir parameter on oe_config.yaml +- 0.10.14 add --extract-sources option +- 0.10.13 fix -w to take into account submodules +- 0.10.12 fix -w to take into account not standard repo structure and + odoo.conf rights +- 0.10.11 ask before overwriting local image sources +- 0.10.10 minor refactoring, improving doc +- 0.10.9 minor fixes, more documentation +- 0.10.8 improving in writing the odoo.conf +- 0.10.7 Fix bug creating odoo.conf missing data_dir in config. +- 0.10.6 Fix bug creating odoo.conf when there are no config spec is manifest +- 0.10.5 Set parameters in odoo.conf from manifest file. +- 0.10.4 IMP creation of odoo.conf improved in V11 also. +- 0.10.3 FIX nginx config now works behind port redirections +- 0.10.2 FIX collision field in manifest "license" +- 0.10.1 FIX bad filestore dir +- 0.10.0 New manifest syntax, backward compatible. +- 0.9.14 improved creation of odoo.conf, i.e. detect cpu number and + calculate workers. +- 0.9.13 solved bug when creating nginx config file +- 0.9.12 Get last wdb vesion. Added a check to verify if there is +a new version available in pypi. Fixed copy sources to host. +- 0.9.11 The commands -c and --debug now are persistent. +- 0.8.35 Workaround for mdillon gis database +- 0.8.32 Fix issue with first time installation +- 0.8.30 Add cache file to fix performance issues when we have more + than 15 clients. +- 0.8.29 Modify ssl certificate directories from letsencrypt, + support for oca/letsencript. +- 0.8.27 Fix compatibility issues w/ python3 +- 0.8.22 When using the options -i together with --debug, the + dist_packages and extra_addons directories were created with the + image sources but in read-only mode. Now we give them write + permission and a git repository is added to verify if there were + modifications. Option -V is added to show the version. +- 0.8.21 Many improvements on restore database. +- 0.8.20 When option -d not present assume database = client_name + + "_prod" when option -m is not present asume default "all" +- 0.8.19 Allow options -i and -w to work together +- 0.8.18 add -p command +- 0.8.17 Fix bug in python3 installation +- 0.8.13 Removing edm option (it was a bad idea), rewrite nginx + config to block /database/manager and /database/selector +- 0.8.12 fix version of wdb image to 3.2.5, latest does not work +- 0.8.11 Fix --nginx installation +- 0.8.10 Add --edm option to allow database manager on production +- 0.8.9 When installed from pip --nginx does not work +- 0.8.8 Disable database manager on login page in prod environment +- 0.8.7 Working on Python 2.7 to 3.7 +- 0.8.6 Fix: when installing on prod make a Shallow Clone +- 0.8.5 Fix test (option -Q) failing to run +- 0.8.4 PyPi version increment +- 0.8.3 PyPi version increment +- 0.8.2 Docker installs at the end allowing abort +- 0.8.1 Fix starting debug mode. +- 0.8.0 Use kozera image for wdb, write the nginx.conf with the + proper client name. +- 0.7.4 New parameter to attach to a running containcer in sd. + Support for debug image in v11 (python3) + data/install_scripts.sh improvements and fixes +- 0.7.3 if odoo not in manifest do not start image instead showing + an error +- 0.7.2 start aeroo on v > 9 +- 0.7.1 Revert again go https +- 0.7.0 Change protocol from https to ssh in order to use ssh keys. +- 0.6.1 FIX working directory with version > 9. If odoo main + version was > 9 the directory added a dot ie /odoo-10.0./ +- 0.6.0 deprecate dbfilter. +- 0.5.4 illformed manifest causing crash +- 0.5.3 Restore database with bad image +- 0.5.2 sd was not copied to /usr/local/bin +- 0.5.1 change postgres container name to pg- +- 0.5.0 support for non github repos, i.e. bitbucket, gitlab, etc +- 0.4.6 Odoo v10 do not run aeroo, find manifest +- 0.4.5 Install_scripts now installs python and docker +- 0.4.4 Do not expose 8072 when using Nginx +- 0.4.3 No more rewriting config on update all +- 0.4.2 Expose longpolling port in debug mode +- 0.4.1 Fixes in test invocation +- 0.4.0 Change QA invocation +- 0.3.2 do not overwrite config while making QA +- 0.3.1 Stop images instead of kill them on -s or -S +- 0.3.0 Restore any automatic backup made with database_tools module. + List all available backup files write config file add help + option -H (odoo help) +- 0.2.1 bug On QA, expose port 1984 for debug purpoes with WDB +- 0.2.0 Quality Assurance support, Add command sd rmall for removing + all docker images in memory +- 0.1.0 Nginx support, Script to install docker (in script folder, + for now you have to execute manually) sd command (short for + sudo docker plus some enhacements) +- 0.0.2 Minor fixes +- 0.0.1 Starting project diff --git a/odoo_env/__init__.py b/odoo_env/__init__.py index ea370a8..def467e 100644 --- a/odoo_env/__init__.py +++ b/odoo_env/__init__.py @@ -1 +1 @@ -__version__ = "0.12.0" +__version__ = "0.12.1" diff --git a/odoo_env/client.py b/odoo_env/client.py index 8adce55..0ba82b6 100644 --- a/odoo_env/client.py +++ b/odoo_env/client.py @@ -90,17 +90,15 @@ def check_v1(self, manifest): def check_v2(self, manifest): # Chequar que el manifiesto tenga bien las cosas if not manifest.get("docker-images"): - msg.err( - "No images in manifest %s please " "add a docker-images key" % self.name - ) + msg.err(f"No images in manifest {self.name} please add a docker-images key") if not manifest.get("git-repos"): - msg.err("No repos in manifest %s please add a git-repos key" % self.name) + msg.err(f"No repos in manifest {self.name} please add a git-repos key") # leer si es enterprise o community, default community self._license = manifest.get("odoo-license", "CE") - if self._license not in ["EE", "CE"]: + if self._license not in {"EE", "CE"}: msg.err("License must be EE or CE") # Crear imagenes y repos @@ -108,7 +106,7 @@ def check_v2(self, manifest): self._repos.append(Repo2(rep, self._version)) for img in manifest.get("docker-images"): - self._images.append(Image2(img)) + self._images.append(Image2(img, self._parent.debug)) # levantar el nombre del user server self._prod_server = manifest.get("prod_server", "ubuntu") diff --git a/odoo_env/command.py b/odoo_env/command.py index 016213a..c49f86c 100644 --- a/odoo_env/command.py +++ b/odoo_env/command.py @@ -67,7 +67,7 @@ def subrpocess_call(self, params, shell=True): msg.run(" ") ret = subprocess.call(cmd, shell=shell) if ret: - return msg.err("The command %s returned with %s" % (cmd, str(ret))) + return msg.err(f"The command {cmd} returned with {str(ret)}") @property def args(self): diff --git a/odoo_env/images.py b/odoo_env/images.py index 8a4dcf0..96674e2 100644 --- a/odoo_env/images.py +++ b/odoo_env/images.py @@ -30,12 +30,15 @@ def name(self): class Image2: - def __init__(self, values): + def __init__(self, values, debug=False): + _odoo_image = "odoo" in values values = values.split() if len(values) != 2: - msg.err("Bad image definition %s" % values) + msg.err(f"Bad image definition {values}") self._name = values[0] self._url = values[1] + if _odoo_image and debug: + self._url += ".debug" @property def short_name(self): diff --git a/odoo_env/odooenv.py b/odoo_env/odooenv.py index 3c261d6..a5475c6 100644 --- a/odoo_env/odooenv.py +++ b/odoo_env/odooenv.py @@ -185,10 +185,115 @@ def pull_images(self, client_name): for image in self._client._images: cmd = PullImage( self, - command="sudo docker pull %s" % image.name, - usr_msg="Pulling Image %s" % image.short_name, + command=f"sudo docker pull {image.name}", + usr_msg=f"Pulling Image {image.short_name}", ) ret.append(cmd) + + if self.debug: + cmd = self.do_extract_sources(client_name) + ret.extend(cmd) + return ret + + def do_extract_sources(self, client_name): + """Extrae los fuentes de la imagen debug""" + + self._client = Client(self, client_name) + ret = [] + + ################################################################## + # removing dirs for extracting sources + ################################################################## + for w_dir in self._get_packs(): + r_dir = f"{self.client.version_dir}{w_dir}" + cmd = RemovedirCommand( + self, + command=f"sudo rm -r {r_dir}", + args=r_dir, + usr_msg=f"Removing {r_dir}", + ) + ret.append(cmd) + + ################################################################## + # create dirs for extracting sources, only for debug + ################################################################## + for w_dir in self._get_packs(): + r_dir = f"{self.client.version_dir}{w_dir}" + cmd = MakedirCommand(self, command=f"mkdir -p {r_dir}", args=r_dir) + ret.append(cmd) + + ################################################################## + # change og+w for those dirs + ################################################################## + for w_dir in self._get_packs(): + r_dir = f"{self.client.version_dir}{w_dir}" + cmd = Command(self, command=f"chmod og+w {r_dir}") + ret.append(cmd) + + ################################################################## + # Extracting sources + ################################################################## + for module in self._get_packs(): + msg = ( + f"Extracting {module} from image {self.client.get_image("odoo").name} " + ) + command = "sudo docker run -it --rm " + command += f"--entrypoint=/extract_{module}.sh " + command += f"-v {self.client.version_dir}{module}/:/mnt/{module} " + command += f"{self.client.get_image("odoo").name} " + + cmd = ExtractSourcesCommand( + self, + command=command, + args=f"{self.client.version_dir}{module}", + usr_msg=msg, + ) + ret.append(cmd) + + # poner permisos de escritura + for module in self._get_packs(): + r_dir = "%s%s" % (self.client.version_dir, module) + cmd = Command( + self, + command="sudo chmod -R og+w %s/" % r_dir, + usr_msg="Making writable %s" % r_dir, + ) + ret.append(cmd) + + # agregar un gitignore + for module in self._get_packs(): + r_dir = f"{self.client.version_dir}{module}" + cmd = CreateGitignore( + self, + command=f"{r_dir}/.gitignore", + usr_msg=f"Creating gitignore file in {r_dir}", + ) + ret.append(cmd) + + for module in self._get_packs(): + # create git repo + command = f"git -C {self._client.version_dir}{module}/ init " + cmd = Command( + self, command=command, usr_msg=f"Init repository for {module}" + ) + ret.append(cmd) + + for module in self._get_packs(): + command = f"git -C {self._client.version_dir}{module}/ add . " + cmd = Command( + self, + command=command, + usr_msg=f"Add files to repository for {module}", + ) + ret.append(cmd) + + for module in self._get_packs(): + command = f"git -C {self._client.version_dir}{module}/ commit -m inicial " + cmd = Command( + self, command=command, usr_msg=f"Commit repository for {module}" + ) + ret.append(cmd) + return ret def install(self, client_name): @@ -227,43 +332,9 @@ def install(self, client_name): cmd = MakedirCommand(self, command="mkdir -p %s" % r_dir, args="%s" % r_dir) ret.append(cmd) - ################################################################## - # removing dirs for extracting sources, only for debug - ################################################################## - if self.debug and self.extract_sources: - for w_dir in self._get_packs(): - r_dir = f"{self.client.version_dir}{w_dir}" - cmd = RemovedirCommand( - self, - command=f"sudo rm -r {r_dir}", - args=r_dir, - usr_msg=f"Removing {r_dir}", - ) - ret.append(cmd) - - ################################################################## - # create dirs for extracting sources, only for debug - ################################################################## - if self.debug and self.extract_sources: - for w_dir in self._get_packs(): - r_dir = f"{self.client.version_dir}{w_dir}" - cmd = MakedirCommand(self, command=f"mkdir -p {r_dir}", args=r_dir) - ret.append(cmd) - - ################################################################## - # change og+w for those dirs - ################################################################## - - if self.debug and self.extract_sources: - for w_dir in self._get_packs(): - r_dir = f"{self.client.version_dir}{w_dir}" - cmd = Command(self, command=f"chmod og+w {r_dir}") - ret.append(cmd) - ################################################################## # change o+w for config, data, log and backup_dir ################################################################## - for w_dir in ["config", "data_dir", "log", "backup_dir"]: r_dir = f"{self.client.base_dir}{w_dir}" cmd = Command(self, command=f"chmod o+w {r_dir}") @@ -272,7 +343,6 @@ def install(self, client_name): ################################################################## # create dirs for nginx if needed ################################################################## - if self.nginx: for w_dir in ["cert", "conf", "log"]: r_dir = "%s%s" % (BASE_DIR, "nginx/" + w_dir) @@ -282,7 +352,6 @@ def install(self, client_name): ################################################################## # create nginx.conf template if needed. Do not overwrite ################################################################## - if self.nginx: r_dir = "%s%s" % (BASE_DIR, "nginx/conf/") cmd = CreateNginxTemplate( @@ -297,74 +366,9 @@ def install(self, client_name): ################################################################## # Extracting sources from image if debug enabled ################################################################## - if self.debug and self.extract_sources: - for module in self._get_packs(): - msg = "Extracting %s from image %s.debug" % ( - module, - self.client.get_image("odoo").name, - ) - command = "sudo docker run -it --rm " - command += "--entrypoint=/extract_%s.sh " % module - command += "-v %s%s/:/mnt/%s " % ( - self.client.version_dir, - module, - module, - ) - command += "%s.debug " % self.client.get_image("odoo").name - - cmd = ExtractSourcesCommand( - self, - command=command, - args="%s%s" % (self.client.version_dir, module), - usr_msg=msg, - ) - ret.append(cmd) - - # poner permisos de escritura - for module in self._get_packs(): - r_dir = "%s%s" % (self.client.version_dir, module) - cmd = Command( - self, - command="sudo chmod -R og+w %s/" % r_dir, - usr_msg="Making writable %s" % r_dir, - ) - ret.append(cmd) - - # agregar un gitignore - for module in self._get_packs(): - r_dir = f"{self.client.version_dir}{module}" - cmd = CreateGitignore( - self, - command=f"{r_dir}/.gitignore", - usr_msg=f"Creating gitignore file in {r_dir}", - ) - ret.append(cmd) - - for module in self._get_packs(): - # create git repo - command = "git -C {}{}/ init ".format(self._client.version_dir, module) - cmd = Command( - self, command=command, usr_msg="Init repository for %s" % module - ) - ret.append(cmd) - - for module in self._get_packs(): - command = "git -C {}{}/ add . ".format(self._client.version_dir, module) - cmd = Command( - self, - command=command, - usr_msg="Add files to repository for %s" % module, - ) - ret.append(cmd) - - for module in self._get_packs(): - command = "git -C {}{}/ commit -m inicial ".format( - self._client.version_dir, module - ) - cmd = Command( - self, command=command, usr_msg="Commit repository for %s" % module - ) - ret.append(cmd) + # if self.debug and self.extract_sources: + # cmd = self.do_extract_sources(client_name) + # ret.append(cmd) ################################################################## # Clone or update repos as needed @@ -591,8 +595,8 @@ def set_config_environment(self): return command def run_client(self, client_name, write_config=False): - """El run_client se usa tambien para escribir el config file en las versiones - definidas en WRITE_CONFIG_OLD_MODE + """El run_client se usa tambien para escribir el config file en las + versiones definidas en WRITE_CONFIG_OLD_MODE """ self._client = Client(self, client_name) @@ -647,12 +651,11 @@ def run_client(self, client_name, write_config=False): else: command += "-e ODOO_CONF=/dev/null " - # si estamos en modo debug agregarlo al nombre de la imagen + # si estamos en modo debug agregarlo el WDB if self.debug: command += "-e WDB_SOCKET_SERVER=wdb " - command += "%s.debug " % self.client.get_image("odoo").name - else: - command += "%s " % self.client.get_image("odoo").name + + command += f"{self.client.get_image("odoo").name} " if not self.debug: command += "--logfile=/var/log/odoo/odoo.log " @@ -749,20 +752,19 @@ def qa(self, client_name, database, module_name, client_test=False): command += self._add_normal_mountings() if self.debug: command += self._add_debug_mountings(self.client.numeric_ver) - command += "--link wdb " # linkeamos con test y setamos nombre + command += "--link wdb " command += "-e WDB_SOCKET_SERVER=wdb " command += "-e ODOO_CONF=/dev/null " - command += "--link pg-{}:db ".format(self.client.name) - command += "{}.debug -- ".format(self.client.get_image("odoo").name) - command += "-d {} ".format(database) + command += f"--link pg-{self.client.name}:db " + command += f"{self.client.get_image("odoo").name} -- " + command += f"-d {database} " command += "--stop-after-init " command += "--log-level=test " command += "--test-enable " - command += "-u {} ".format(module_name) + command += f"-u {module_name} " + + msg = f"Performing tests on module {module_name} for client {client_name} and database {database}" - msg = "Performing tests on module {} for client {} " "and database {}".format( - module_name, client_name, database - ) cmd = Command(self, command=command, usr_msg=msg) ret.append(cmd) return ret @@ -787,9 +789,9 @@ def no_repos(self): def nginx(self): return self._options["nginx"] - @property - def extract_sources(self): - return self._options["extract_sources"] + # @property + # def extract_sources(self): + # return self._options["extract_sources"] @property def force_create(self): diff --git a/odoo_env/oe.py b/odoo_env/oe.py index 1d14306..299257b 100755 --- a/odoo_env/oe.py +++ b/odoo_env/oe.py @@ -97,12 +97,12 @@ def main(): "deprecated", ) - parser.add_argument( - "--extract-sources", - action="store_true", - help="Extracts the sources from the Odoo image to the host; it can only " - "be used together with -i.", - ) + # parser.add_argument( + # "--extract-sources", + # action="store_true", + # help="Extracts the sources from the Odoo image to the host; it can only " + # "be used together with -i.", + # ) parser.add_argument( "--debug", action="store_true", help="Set default environment mode to debug " @@ -220,7 +220,7 @@ def main(): "--base-dir", action="append", dest="base_dir", - help="Set default base-dir" "This option is persistent.", + help="Set default base-dir This option is persistent.", ) args = parser.parse_args() @@ -240,7 +240,7 @@ def main(): "no-repos": args.no_repos, "nginx": args.nginx, "backup_file": args.backup_file, - "extract_sources": args.extract_sources, + # "extract_sources": args.extract_sources, "force-create": args.force_create, } commands = [] @@ -301,8 +301,9 @@ def main(): create_database(OdooEnv(options=options), client_name) sys.exit() - # Verificar la version del script en pypi conf = OeConfig() + + # Verificar la version del script en pypi conf.check_version() # ##################################################################### From 8f3fa2b3d7bbf16315c3f07021f6757c9906abd8 Mon Sep 17 00:00:00 2001 From: Jorge Obiols Date: Sat, 26 Oct 2024 22:13:23 -0300 Subject: [PATCH 20/48] FIX version --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index e078115..6fb210e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -7,7 +7,7 @@ build-backend = "hatchling.build" [project] name = "odoo-env" -version = "0.12.0" +version = "0.12.1" authors = [ { name="Jorge Obiols", email="jorge.obiols@gmail.com" }, ] From 2ae3b2c0ec96867666bb06d76040aee7fe5c6d91 Mon Sep 17 00:00:00 2001 From: Jorge Obiols Date: Mon, 28 Oct 2024 20:28:59 -0300 Subject: [PATCH 21/48] FIX now works from python 3.8 --- README.md | 1 + odoo_env/__init__.py | 2 +- odoo_env/odooenv.py | 12 ++++++------ pyproject.toml | 8 +++++--- 4 files changed, 13 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 73904ae..55fa1be 100644 --- a/README.md +++ b/README.md @@ -110,6 +110,7 @@ Installation Changelog --------- +- 0.12.2 - Fix bug that prevented Python versions lower than 3.12. - 0.12.1 - When the -p command is run in debug mode, it pulls the debug image and performs an extract-sources; in production mode, it pulls the production image. diff --git a/odoo_env/__init__.py b/odoo_env/__init__.py index def467e..76da4a9 100644 --- a/odoo_env/__init__.py +++ b/odoo_env/__init__.py @@ -1 +1 @@ -__version__ = "0.12.1" +__version__ = "0.12.2" diff --git a/odoo_env/odooenv.py b/odoo_env/odooenv.py index a5475c6..cc5d703 100644 --- a/odoo_env/odooenv.py +++ b/odoo_env/odooenv.py @@ -235,12 +235,12 @@ def do_extract_sources(self, client_name): ################################################################## for module in self._get_packs(): msg = ( - f"Extracting {module} from image {self.client.get_image("odoo").name} " + f"Extracting {module} from image {self.client.get_image('odoo').name} " ) command = "sudo docker run -it --rm " command += f"--entrypoint=/extract_{module}.sh " command += f"-v {self.client.version_dir}{module}/:/mnt/{module} " - command += f"{self.client.get_image("odoo").name} " + command += f"{self.client.get_image('odoo').name} " cmd = ExtractSourcesCommand( self, @@ -536,9 +536,9 @@ def server_help(self, client_name): command = "sudo docker run --rm -it " # command += self._add_normal_mountings() - command += "--link pg-{}:db ".format(self.client.name) + command += f"--link pg-{self.client.name}:db " command += "--name help " - command += "{} ".format(self.client.get_image("odoo").name) + command += f"{self.client.get_image('odoo').name} " command += "-- " command += "--help " @@ -655,7 +655,7 @@ def run_client(self, client_name, write_config=False): if self.debug: command += "-e WDB_SOCKET_SERVER=wdb " - command += f"{self.client.get_image("odoo").name} " + command += f"{self.client.get_image('odoo').name} " if not self.debug: command += "--logfile=/var/log/odoo/odoo.log " @@ -756,7 +756,7 @@ def qa(self, client_name, database, module_name, client_test=False): command += "-e WDB_SOCKET_SERVER=wdb " command += "-e ODOO_CONF=/dev/null " command += f"--link pg-{self.client.name}:db " - command += f"{self.client.get_image("odoo").name} -- " + command += f"{self.client.get_image('odoo').name} -- " command += f"-d {database} " command += "--stop-after-init " command += "--log-level=test " diff --git a/pyproject.toml b/pyproject.toml index 6fb210e..eb4cd18 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -7,17 +7,19 @@ build-backend = "hatchling.build" [project] name = "odoo-env" -version = "0.12.1" +version = "0.12.2" authors = [ { name="Jorge Obiols", email="jorge.obiols@gmail.com" }, ] description = "A Dockerized environment for Odoo" readme = "README.md" -requires-python = ">=3.7" +requires-python = ">=3.8" classifiers=[ - "Programming Language :: Python :: 3.7", "Programming Language :: Python :: 3.8", "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", "Development Status :: 5 - Production/Stable", "Intended Audience :: Developers", "License :: OSI Approved :: MIT License", From 3df74204bdcfc4f7182ed38ee2f11f151ea84fe8 Mon Sep 17 00:00:00 2001 From: Jorge Obiols Date: Fri, 29 Nov 2024 12:27:00 -0300 Subject: [PATCH 22/48] [FIX] considerar instalacion en debian --- .vscode/launch.json | 2 +- install_vps.sh | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.vscode/launch.json b/.vscode/launch.json index 035ac7e..8f14db9 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -10,7 +10,7 @@ "type": "debugpy", "request": "launch", "python": "/odoo/vs_env/bin/python3.12", - "args": ["-h"], + "args": ["-i", "-c","maveric"], "justMyCode": true, "module": "odoo_env.oe" } diff --git a/install_vps.sh b/install_vps.sh index 35c6cb5..5296a96 100644 --- a/install_vps.sh +++ b/install_vps.sh @@ -14,7 +14,7 @@ python3 -V #sudo apt install python3 -y # instalar distutils -sudo apt install python3-distutils -y +#sudo apt install python3-distutils -y en el ultimo ubuntu no tiene candidato # install pip curl -fsSL https://bootstrap.pypa.io/get-pip.py -o get-pip.py @@ -42,16 +42,16 @@ rm get-docker.sh # install docker en produccion Ubuntu # https://docs.docker.com/engine/install/ubuntu/ -# Add Docker's official GPG key: +# Add Docker's official GPG key: EN DEBIAN sudo apt-get update sudo apt-get install ca-certificates curl gnupg sudo install -m 0755 -d /etc/apt/keyrings -curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg +curl -fsSL https://download.docker.com/linux/debian/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg sudo chmod a+r /etc/apt/keyrings/docker.gpg -# Add the repository to Apt sources: +# Add the repository to Apt sources: EN DEBIAN echo \ - "deb [arch="$(dpkg --print-architecture)" signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu \ + "deb [arch="$(dpkg --print-architecture)" signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/debian \ "$(. /etc/os-release && echo "$VERSION_CODENAME")" stable" | \ sudo tee /etc/apt/sources.list.d/docker.list > /dev/null sudo apt-get update From 4ebedbc68e4f038b3317873714622a609f99112e Mon Sep 17 00:00:00 2001 From: Jorge Obiols Date: Wed, 11 Dec 2024 14:09:00 -0300 Subject: [PATCH 23/48] [WIP] falla en entorno lopez el oe -i (#100) --- README.md | 8 ++++++-- odoo_env/__init__.py | 2 +- odoo_env/command.py | 8 +++++++- pyproject.toml | 2 +- 4 files changed, 15 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 55fa1be..889f7a6 100644 --- a/README.md +++ b/README.md @@ -35,7 +35,7 @@ Functionality [-f BACKUP_FILE] [-H] [-V] [--create-test-db] [--force-create] [--base-dir BASE_DIR] - Odoo Environment Manager v0.12.1 - by jeo Software + Odoo Environment Manager v0.12.3 - by jeo Software options: -h, --help show this help message and exit @@ -109,7 +109,11 @@ Installation Changelog --------- - +- 0.12.3 - A bug was found when oe attempts to change permissions on the + backup_dir folder. In some cases, this folder is an S3 or OBS bucket, + depending on the cloud provider. In such cases, the error is caught, + and only a warning is displayed, as changing the permissions is not + necessary. - 0.12.2 - Fix bug that prevented Python versions lower than 3.12. - 0.12.1 - When the -p command is run in debug mode, it pulls the debug image and performs an extract-sources; in production mode, it diff --git a/odoo_env/__init__.py b/odoo_env/__init__.py index 76da4a9..8e1395b 100644 --- a/odoo_env/__init__.py +++ b/odoo_env/__init__.py @@ -1 +1 @@ -__version__ = "0.12.2" +__version__ = "0.12.3" diff --git a/odoo_env/command.py b/odoo_env/command.py index c49f86c..9395a13 100644 --- a/odoo_env/command.py +++ b/odoo_env/command.py @@ -39,7 +39,13 @@ def check_args(self): def execute(self): cmd = self.command - self.subrpocess_call(cmd) + if "chmod o+w" in cmd: + try: + self.subrpocess_call(cmd) + except Exception as e: + msg.warning(str(e)) + return + msg.warning(str(e)) def subrpocess_call(self, params, shell=True): """Run command or command list with arguments. Wait for commands to diff --git a/pyproject.toml b/pyproject.toml index eb4cd18..ac572ea 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -7,7 +7,7 @@ build-backend = "hatchling.build" [project] name = "odoo-env" -version = "0.12.2" +version = "0.12.3" authors = [ { name="Jorge Obiols", email="jorge.obiols@gmail.com" }, ] From 7fb2253c5a1957e80b442098e275c1776a186036 Mon Sep 17 00:00:00 2001 From: Jorge Obiols Date: Wed, 11 Dec 2024 14:22:16 -0300 Subject: [PATCH 24/48] 99 error en lopez tratando de cambiar permisos (#101) --- README.md | 5 +++-- odoo_env/__init__.py | 2 +- odoo_env/command.py | 5 +++-- pyproject.toml | 3 ++- 4 files changed, 9 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 889f7a6..cabbef7 100644 --- a/README.md +++ b/README.md @@ -35,7 +35,7 @@ Functionality [-f BACKUP_FILE] [-H] [-V] [--create-test-db] [--force-create] [--base-dir BASE_DIR] - Odoo Environment Manager v0.12.3 - by jeo Software + Odoo Environment Manager v0.12.4 - by jeo Software options: -h, --help show this help message and exit @@ -109,7 +109,8 @@ Installation Changelog --------- -- 0.12.3 - A bug was found when oe attempts to change permissions on the + +- 0.12.4 - A bug was found when oe attempts to change permissions on the backup_dir folder. In some cases, this folder is an S3 or OBS bucket, depending on the cloud provider. In such cases, the error is caught, and only a warning is displayed, as changing the permissions is not diff --git a/odoo_env/__init__.py b/odoo_env/__init__.py index 8e1395b..6dd4954 100644 --- a/odoo_env/__init__.py +++ b/odoo_env/__init__.py @@ -1 +1 @@ -__version__ = "0.12.3" +__version__ = "0.12.4" diff --git a/odoo_env/command.py b/odoo_env/command.py index 9395a13..ad72800 100644 --- a/odoo_env/command.py +++ b/odoo_env/command.py @@ -43,9 +43,10 @@ def execute(self): try: self.subrpocess_call(cmd) except Exception as e: - msg.warning(str(e)) + msg.warn(str(e)) return - msg.warning(str(e)) + else: + self.subrpocess_call(cmd) def subrpocess_call(self, params, shell=True): """Run command or command list with arguments. Wait for commands to diff --git a/pyproject.toml b/pyproject.toml index ac572ea..eb906e0 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -7,7 +7,8 @@ build-backend = "hatchling.build" [project] name = "odoo-env" -version = "0.12.3" +version = "0.12.4" + authors = [ { name="Jorge Obiols", email="jorge.obiols@gmail.com" }, ] From 72b94c5d959b83fc1ff7450fa1fd7a0eec73cc96 Mon Sep 17 00:00:00 2001 From: Jorge Obiols Date: Wed, 11 Dec 2024 14:35:37 -0300 Subject: [PATCH 25/48] FIX correccion de excepcion al hacer chmod+w --- README.md | 4 ++-- odoo_env/__init__.py | 2 +- odoo_env/command.py | 11 ++++------- pyproject.toml | 2 +- 4 files changed, 8 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index cabbef7..6572314 100644 --- a/README.md +++ b/README.md @@ -35,7 +35,7 @@ Functionality [-f BACKUP_FILE] [-H] [-V] [--create-test-db] [--force-create] [--base-dir BASE_DIR] - Odoo Environment Manager v0.12.4 - by jeo Software + Odoo Environment Manager v0.12.5 - by jeo Software options: -h, --help show this help message and exit @@ -110,7 +110,7 @@ Installation Changelog --------- -- 0.12.4 - A bug was found when oe attempts to change permissions on the +- 0.12.5 - A bug was found when oe attempts to change permissions on the backup_dir folder. In some cases, this folder is an S3 or OBS bucket, depending on the cloud provider. In such cases, the error is caught, and only a warning is displayed, as changing the permissions is not diff --git a/odoo_env/__init__.py b/odoo_env/__init__.py index 6dd4954..8e377d6 100644 --- a/odoo_env/__init__.py +++ b/odoo_env/__init__.py @@ -1 +1 @@ -__version__ = "0.12.4" +__version__ = "0.12.5" diff --git a/odoo_env/command.py b/odoo_env/command.py index ad72800..2239096 100644 --- a/odoo_env/command.py +++ b/odoo_env/command.py @@ -39,14 +39,11 @@ def check_args(self): def execute(self): cmd = self.command - if "chmod o+w" in cmd: - try: - self.subrpocess_call(cmd) - except Exception as e: - msg.warn(str(e)) - return - else: + try: self.subrpocess_call(cmd) + except Exception as e: + msg.warn(str(e)) + return def subrpocess_call(self, params, shell=True): """Run command or command list with arguments. Wait for commands to diff --git a/pyproject.toml b/pyproject.toml index eb906e0..02163c9 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -7,7 +7,7 @@ build-backend = "hatchling.build" [project] name = "odoo-env" -version = "0.12.4" +version = "0.12.5" authors = [ { name="Jorge Obiols", email="jorge.obiols@gmail.com" }, From 292e7ec17beae3ee30d22713308eb9284bbc16a8 Mon Sep 17 00:00:00 2001 From: Jorge Obiols Date: Wed, 11 Dec 2024 14:47:05 -0300 Subject: [PATCH 26/48] FIX correccion de excepcion al hacer chmod+w --- README.md | 4 ++-- odoo_env/__init__.py | 2 +- odoo_env/command.py | 11 +++++------ pyproject.toml | 2 +- 4 files changed, 9 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 6572314..ed3de18 100644 --- a/README.md +++ b/README.md @@ -35,7 +35,7 @@ Functionality [-f BACKUP_FILE] [-H] [-V] [--create-test-db] [--force-create] [--base-dir BASE_DIR] - Odoo Environment Manager v0.12.5 - by jeo Software + Odoo Environment Manager v0.12.6 - by jeo Software options: -h, --help show this help message and exit @@ -110,7 +110,7 @@ Installation Changelog --------- -- 0.12.5 - A bug was found when oe attempts to change permissions on the +- 0.12.6 - A bug was found when oe attempts to change permissions on the backup_dir folder. In some cases, this folder is an S3 or OBS bucket, depending on the cloud provider. In such cases, the error is caught, and only a warning is displayed, as changing the permissions is not diff --git a/odoo_env/__init__.py b/odoo_env/__init__.py index 8e377d6..8e2394f 100644 --- a/odoo_env/__init__.py +++ b/odoo_env/__init__.py @@ -1 +1 @@ -__version__ = "0.12.5" +__version__ = "0.12.6" diff --git a/odoo_env/command.py b/odoo_env/command.py index 2239096..2883bab 100644 --- a/odoo_env/command.py +++ b/odoo_env/command.py @@ -39,11 +39,7 @@ def check_args(self): def execute(self): cmd = self.command - try: - self.subrpocess_call(cmd) - except Exception as e: - msg.warn(str(e)) - return + self.subrpocess_call(cmd) def subrpocess_call(self, params, shell=True): """Run command or command list with arguments. Wait for commands to @@ -71,7 +67,10 @@ def subrpocess_call(self, params, shell=True): msg.run(" ") ret = subprocess.call(cmd, shell=shell) if ret: - return msg.err(f"The command {cmd} returned with {str(ret)}") + if "hmod o+w" in cmd: + return msg.warn(f"The command {cmd} returned with {str(ret)}") + else: + return msg.err(f"The command {cmd} returned with {str(ret)}") @property def args(self): diff --git a/pyproject.toml b/pyproject.toml index 02163c9..223a00c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -7,7 +7,7 @@ build-backend = "hatchling.build" [project] name = "odoo-env" -version = "0.12.5" +version = "0.12.6" authors = [ { name="Jorge Obiols", email="jorge.obiols@gmail.com" }, From 1757364361284427b660b62d71876a3ac451051d Mon Sep 17 00:00:00 2001 From: Jorge Obiols Date: Thu, 19 Dec 2024 15:22:00 -0300 Subject: [PATCH 27/48] [FIX] version variable warning --- odoo_env/config.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/odoo_env/config.py b/odoo_env/config.py index 14f4886..01c077d 100644 --- a/odoo_env/config.py +++ b/odoo_env/config.py @@ -142,7 +142,7 @@ def check_version(self): if version != __version__: Msg().warn( f"BE CAREFUL, you are using version {__version__} of odoo-env " - "however version {version} is already available." + f"however version {version} is already available." ) Msg().warn( 'You should update using "pipx upgrade odoo-env" or "pip ' From bdba59e2f4a90ab7d9074d6467347c0d73b16adc Mon Sep 17 00:00:00 2001 From: Jorge Obiols Date: Sat, 28 Dec 2024 19:19:47 -0300 Subject: [PATCH 28/48] actualizar manual --- install_vps.sh | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/install_vps.sh b/install_vps.sh index 5296a96..25b9985 100644 --- a/install_vps.sh +++ b/install_vps.sh @@ -56,19 +56,20 @@ echo \ sudo tee /etc/apt/sources.list.d/docker.list > /dev/null sudo apt-get update +# Add the repository to Apt sources: EN UBUNTU +echo \ + "deb [arch="$(dpkg --print-architecture)" signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu \ + "$(. /etc/os-release && echo "$VERSION_CODENAME")" stable" | \ + sudo tee /etc/apt/sources.list.d/docker.list > /dev/null +sudo apt-get update + + + # install latest versin sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin # Verificar docker sudo docker run hello-world - -# install composer -# Run this command to download the current stable release of Docker Compose: -sudo curl -L "https://github.com/docker/compose/releases/download/v2.22.0/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose - -# Apply executable permissions to the binary: -sudo chmod +x /usr/local/bin/docker-compose - # test docker-compose --version From 5d4013b14b106d2a438f551f6f6a94d9ec7ebd9a Mon Sep 17 00:00:00 2001 From: Jorge Obiols Date: Tue, 31 Dec 2024 09:39:39 -0300 Subject: [PATCH 29/48] [FIX] doble config (#102) --- .vscode/launch.json | 2 +- README.md | 6 ++++- docs/_includes/manifest_example.md | 43 +++++++++++++++++++++--------- odoo_env/__init__.py | 2 +- odoo_env/client.py | 12 +++++---- odoo_env/command.py | 33 +++++++---------------- odoo_env/odoo_conf.py | 4 +-- 7 files changed, 56 insertions(+), 46 deletions(-) diff --git a/.vscode/launch.json b/.vscode/launch.json index 8f14db9..25e3d05 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -10,7 +10,7 @@ "type": "debugpy", "request": "launch", "python": "/odoo/vs_env/bin/python3.12", - "args": ["-i", "-c","maveric"], + "args": ["-w", "-c","maverick"], "justMyCode": true, "module": "odoo_env.oe" } diff --git a/README.md b/README.md index ed3de18..0252207 100644 --- a/README.md +++ b/README.md @@ -109,7 +109,11 @@ Installation Changelog --------- - +- 0.13.0 - A second configuration section is defined. The original is used when + setting up a server, while the other, called config-local, is used + to define the configuration for the local environment. + This way, the server configuration file can be defined along with + the configuration used when working in local mode. - 0.12.6 - A bug was found when oe attempts to change permissions on the backup_dir folder. In some cases, this folder is an S3 or OBS bucket, depending on the cloud provider. In such cases, the error is caught, diff --git a/docs/_includes/manifest_example.md b/docs/_includes/manifest_example.md index 97991d2..b02a4f1 100644 --- a/docs/_includes/manifest_example.md +++ b/docs/_includes/manifest_example.md @@ -149,28 +149,47 @@ our sources. 'installable': True, 'application': False, + ####################################################################### # Here begins odoo-env manifest configuration - # =========================================== + ####################################################################### - # manifest version, if omitted it is backward compatible with v1 but - # oe will show a deprecation warning + # Manifest version: If omitted, version 1 is used for backward + # compatibility. However, this will trigger a deprecation warning since + # version 2 is now predominantly used. Support for backward compatibility + # will be removed soon. 'env-ver': '2', - # Configuration data for odoo.conf, if ommited oe will create an odoo.conf - # with default values and with a proper addon_path. - 'config': [ + # =================================================================== + # In this section, the odoo.conf file for the instance is configured. + # There are two sections: one for local installation and another for + # server installation, as they obviously require different parameters. + # =================================================================== + + # in both cases the "addons path" cannot be modified; it will always be + # overwritten by the repositories found in the sources directory. + # "data_dir" is a fixed location inside the image + + # Local configuration applies when Odoo is in debug mode. + 'config-local': [ - # 'addons_path' you can not modify this is always computed looking for the - # repositories in sources + # Seting an easy password for debug mode + 'admin_passwd = admin', - # 'data_dir' you can not modify this, is a fixed location inside docker odoo - # image + # OVERIDEN PARAMETERS + # The following parameters will be overwritten with these values: + # "workers = 0" + # "max_cron_threads = 0" + # "limit_time_cpu = 0" + # "limit_time_real = 0" + ] + + # Production configuration applies when Odoo is in production mode. + 'config': [ # WORKERS and MAX_CRON_WORKERS # If ommited it will default the calculation # workers = 2 per available CPU - # max_cron_threads = 1 per available CPU - # In DEBUG mode both are forced to Zero + # max_cron_threads = 1 'workers = 2', 'max_cron_threads = 1', diff --git a/odoo_env/__init__.py b/odoo_env/__init__.py index 8e2394f..f23a6b3 100644 --- a/odoo_env/__init__.py +++ b/odoo_env/__init__.py @@ -1 +1 @@ -__version__ = "0.12.6" +__version__ = "0.13.0" diff --git a/odoo_env/client.py b/odoo_env/client.py index 0ba82b6..a83b00e 100644 --- a/odoo_env/client.py +++ b/odoo_env/client.py @@ -41,7 +41,6 @@ def __init__(self, odooenv, name): ) # mantener compatibilidad con python2 - input("Hit Enter to continue or CTRL C to exit") manifest, _ = self.get_manifest_from_struct(os.getcwd()) if not manifest: @@ -117,7 +116,7 @@ def check_common(self, manifest): self._external_dependencies = manifest.get("external_dependencies", {}) ver = manifest.get("version") if not ver: - msg.err("No version tag in manifest %s" % self.name) + msg.err(f"No version tag in manifest {self.name}") _x = ver.find(".") + 1 _y = ver[_x:].find(".") + _x @@ -126,12 +125,15 @@ def check_common(self, manifest): name = manifest.get("name").lower() if not self._name == name.split()[0]: msg.err( - "You intend to install client %s but in manifest, " - "the name is %s" % (self._name, manifest.get("name")) + f"You intend to install client {self._name} but in manifest, " + f"the name is {manifest.get("name")}" ) # Tomar los datos para odoo.conf - self.config = manifest.get("config", []) + if self._parent.debug: + self.config = manifest.get("config-local", []) + else: + self.config = manifest.get("config", []) def get_manifest_from_struct(self, path): """leer un manifest que esta dentro de una estructura de directorios diff --git a/odoo_env/command.py b/odoo_env/command.py index 2883bab..7982696 100644 --- a/odoo_env/command.py +++ b/odoo_env/command.py @@ -1,6 +1,7 @@ import os import stat import subprocess +from pathlib import Path from odoo_env.messages import Msg from odoo_env.odoo_conf import OdooConf @@ -162,26 +163,12 @@ def check_item(self, search_item, search_list): return False def execute(self): - # obtener el cliente a partir del nombre arg = self._args client = arg["client"] # obtener los repositorios que hay en sources, para eso se recorre souces y se # obtienen todos los directorios que tienen un .git adentro. - repos = list() - # sources = client.sources_dir - # for root, dirs, files in os.walk(sources): - # # si tiene un directorio .git es un repositorio - # if ".git" in dirs: - # repos.append(root.replace(sources, "")) - # # si tiene un archivo .git es un repositorio - # if ".git" in files: - # repos.append(root.replace(sources, "")) - # recorrer todos los archivos buscando un __manifest__.py si lo encuentro entonces - # agrego a repos un path al directorio que contiene ese archivo sin repetir y salteo - # ese directorio - from pathlib import Path - + repos = [] base = Path(client.sources_dir) manifest_files = list(base.rglob("__manifest__.py")) @@ -193,15 +180,13 @@ def execute(self): repos = ["/opt/odoo/custom-addons/" + x for x in repos] repos = ",".join(repos) - # obtener la configuracion definida en el manifiesto - conf = client.config or [] - # Actualizar el archivo odoo.conf # Leer el archivo de configuracion original odoo_conf = OdooConf(client.config_file) odoo_conf.read_config() - odoo_conf.add_list_data(conf) + + odoo_conf.add_list_data(client.config) # siempre sobreescribimos estas tres cosas. odoo_conf.add_line("addons_path = %s" % repos) @@ -217,20 +202,20 @@ def execute(self): else: # no estoy en modo debug, # si no defino workers en el manifiesto lo calculo - line = self.check_item("workers", conf) + line = self.check_item("workers", client.config) if not line: # Calculo los workers - # You should use 2 worker threads CPU - odoo_conf.add_line("workers = %s" % (os.cpu_count() * 2)) + # You should use 2 worker threads per CPU + odoo_conf.add_line(f"workers = {(os.cpu_count() * 2)}") else: odoo_conf.add_line(line) # si no defino cron_threads en el manifiesto lo calculo - line = self.check_item("max_cron_threads", conf) + line = self.check_item("max_cron_threads", client.config) if not line: # Calculo los cron threads # You should use 1 cron thread per available CPU - odoo_conf.add_line("max_cron_threads = %s" % os.cpu_count()) + odoo_conf.add_line("max_cron_threads = 1") else: odoo_conf.add_line(line) diff --git a/odoo_env/odoo_conf.py b/odoo_env/odoo_conf.py index 7dfc03d..cde1b87 100644 --- a/odoo_env/odoo_conf.py +++ b/odoo_env/odoo_conf.py @@ -10,7 +10,7 @@ class OdooConf: def __init__(self, filename): self._filename = filename - self.config = dict() + self.config = {} def read_config(self): """lee el odoo.conf del archivo y lo vuelca a un diccionario""" @@ -50,5 +50,5 @@ def add_line(self, line): """Agrega al config una linea de configuración, con la forma 'key = value'""" key, value = self._parse(line) if "options" not in self.config: - self.config["options"] = dict() + self.config["options"] = {} self.config["options"][key] = value From 007f121c4f1ded87efb57af6da94d818f60331fb Mon Sep 17 00:00:00 2001 From: Jorge Obiols Date: Tue, 31 Dec 2024 10:02:10 -0300 Subject: [PATCH 30/48] [FIX] doble config --- .github/workflows/python-publish.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/python-publish.yml b/.github/workflows/python-publish.yml index a4d5b5e..50a9d33 100644 --- a/.github/workflows/python-publish.yml +++ b/.github/workflows/python-publish.yml @@ -20,7 +20,7 @@ jobs: - name: Set up Python uses: actions/setup-python@v5 with: - python-version: '3.12' + python-version: '3.13' - name: Install dependencies run: | python -m pip install --upgrade pip From ffcf460d08a39655a02b2759a146431e974877fd Mon Sep 17 00:00:00 2001 From: Jorge Obiols Date: Tue, 31 Dec 2024 10:09:19 -0300 Subject: [PATCH 31/48] [FIX] version --- README.md | 2 +- odoo_env/__init__.py | 2 +- pyproject.toml | 5 +++-- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 0252207..3995cb0 100644 --- a/README.md +++ b/README.md @@ -109,7 +109,7 @@ Installation Changelog --------- -- 0.13.0 - A second configuration section is defined. The original is used when +- 0.13.1 - A second configuration section is defined. The original is used when setting up a server, while the other, called config-local, is used to define the configuration for the local environment. This way, the server configuration file can be defined along with diff --git a/odoo_env/__init__.py b/odoo_env/__init__.py index f23a6b3..7e0dc0e 100644 --- a/odoo_env/__init__.py +++ b/odoo_env/__init__.py @@ -1 +1 @@ -__version__ = "0.13.0" +__version__ = "0.13.1" diff --git a/pyproject.toml b/pyproject.toml index 223a00c..279228d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -7,7 +7,7 @@ build-backend = "hatchling.build" [project] name = "odoo-env" -version = "0.12.6" +version = "0.13.1" authors = [ { name="Jorge Obiols", email="jorge.obiols@gmail.com" }, @@ -21,6 +21,7 @@ requires-python = ">=3.8" "Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3.11", "Programming Language :: Python :: 3.12", + "Programming Language :: Python :: 3.13", "Development Status :: 5 - Production/Stable", "Intended Audience :: Developers", "License :: OSI Approved :: MIT License", @@ -30,7 +31,7 @@ requires-python = ">=3.8" ] dependencies = [ "PyYAML >= 6.0.2", - "tornado >= 6.4", + "tornado >= 6.4.2", ] [project.scripts] From e4cdcc2a39b92b6d009c64c76233922871f9258c Mon Sep 17 00:00:00 2001 From: Jorge Obiols Date: Tue, 31 Dec 2024 10:15:47 -0300 Subject: [PATCH 32/48] [DIC] pipx --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 3995cb0..a8d5248 100644 --- a/README.md +++ b/README.md @@ -104,7 +104,7 @@ Functionality Installation ------------ - sudo pip install odoo-env + sudo pipx install odoo-env see proyect in https://pypi.org/project/odoo-env/ Changelog From 1c6b8e46ada66addfe8f84843a6a96ef4abce23c Mon Sep 17 00:00:00 2001 From: Jorge Obiols Date: Fri, 3 Jan 2025 11:47:30 -0300 Subject: [PATCH 33/48] [FIX] comillas dobles dentro de comillas dobles --- README.md | 1 + odoo_env/__init__.py | 2 +- odoo_env/client.py | 2 +- pyproject.toml | 2 +- 4 files changed, 4 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index a8d5248..a0961b6 100644 --- a/README.md +++ b/README.md @@ -109,6 +109,7 @@ Installation Changelog --------- +- 0.13.2 - Correction of a paragraph with double quotes inside double quotes. - 0.13.1 - A second configuration section is defined. The original is used when setting up a server, while the other, called config-local, is used to define the configuration for the local environment. diff --git a/odoo_env/__init__.py b/odoo_env/__init__.py index 7e0dc0e..83ce76f 100644 --- a/odoo_env/__init__.py +++ b/odoo_env/__init__.py @@ -1 +1 @@ -__version__ = "0.13.1" +__version__ = "0.13.2" diff --git a/odoo_env/client.py b/odoo_env/client.py index a83b00e..01f873f 100644 --- a/odoo_env/client.py +++ b/odoo_env/client.py @@ -126,7 +126,7 @@ def check_common(self, manifest): if not self._name == name.split()[0]: msg.err( f"You intend to install client {self._name} but in manifest, " - f"the name is {manifest.get("name")}" + f"the name is {manifest.get('name')}" ) # Tomar los datos para odoo.conf diff --git a/pyproject.toml b/pyproject.toml index 279228d..122b35a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -7,7 +7,7 @@ build-backend = "hatchling.build" [project] name = "odoo-env" -version = "0.13.1" +version = "0.13.2" authors = [ { name="Jorge Obiols", email="jorge.obiols@gmail.com" }, From b39c635c621cd6b060700f541f0b04582e1957b6 Mon Sep 17 00:00:00 2001 From: Jorge Obiols Date: Thu, 27 Feb 2025 09:18:39 -0300 Subject: [PATCH 34/48] conectar servidor a multiples repositorios privados (#106) --- .vscode/launch.json | 2 +- README.md | 137 ++++++++++++++++++------------------ odoo_env/__init__.py | 2 +- odoo_env/create_database.py | 2 +- odoo_env/deploy_keys.py | 98 ++++++++++++++++++++++++++ odoo_env/oe.py | 87 ++++++++++++----------- odoo_env/repos.py | 29 +++++++- pyproject.toml | 2 +- 8 files changed, 244 insertions(+), 115 deletions(-) create mode 100644 odoo_env/deploy_keys.py diff --git a/.vscode/launch.json b/.vscode/launch.json index 25e3d05..678974d 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -10,7 +10,7 @@ "type": "debugpy", "request": "launch", "python": "/odoo/vs_env/bin/python3.12", - "args": ["-w", "-c","maverick"], + "args": ["--deploy-keys", "-c", "miltonia", "--prod"], "justMyCode": true, "module": "odoo_env.oe" } diff --git a/README.md b/README.md index a0961b6..c9c8549 100644 --- a/README.md +++ b/README.md @@ -28,78 +28,76 @@ Directory structure Functionality ------------- - usage: oe.py [-h] [-i] [-p] [-w] [-R] [-r] [-S] [-s] [-u] [-c CLIENT] [-v] - [--no-deactivate] [--extract-sources] [--debug] [--prod] - [--from-prod] [--no-repos] [-d DATABASE] - [-m MODULE] [--nginx] [-Q repo] [--backup-list] [--restore] - [-f BACKUP_FILE] [-H] [-V] [--create-test-db] [--force-create] - [--base-dir BASE_DIR] + usage: oe [-h] [-i] [-p] [-w] [-R] [-r] [-S] [-s] [-u] [-c CLIENT] [-v] + [--no-deactivate] [--deploy-keys] [--debug] [--prod] [--from-prod] + [--no-repos] [-d DATABASE] [-m MODULE] [--nginx] [-Q repo] [--backup-list] + [--restore] [-f BACKUP_FILE] [-H] [-V] [--create-test-db] [--force-create] + [--base-dir BASE_DIR] - Odoo Environment Manager v0.12.6 - by jeo Software + Odoo Environment Manager v0.14.0 - by jeo Software options: - -h, --help show this help message and exit - -i, --install The first time it runs, it creates the directory structure - and clones all repositories declared in the project. If - run again, it updates the repositories. - Use together with --extract-sources to copy the sources - from the Odoo image to the host, which is essential for - working in debug mode. - -p, --pull-images Pull Images. Download all images declared in client manifest. - -w, --write-config Create / Overwrite config file. - -R, --run-env Run postgres, wdb and aeroo images (aeroo only for old odoo - versions). - -r, --run-cli Run odoo image - -S, --stop-env Stop postgres, wdb and aeroo images. - -s, --stop-cli Stop odoo image. - -u, --update Updates modules in the database. With no parameters, all - modules are updated. Use -m modulename to update only the - specified module; you can also pass a list of modules - separated by commas (without spaces). Use -d databasename - to update a database other than the default database. - -c CLIENT Set default client name. This option is persistent - -v, --verbose Go verbose mode. Prints every command - --no-deactivate No Deactivate database before restore. WARNING this - command is deprecated - it can only be used together with -i. - --debug Set default environment mode to debug - --prod Set default environment mode to production - --from-prod Restore backup from production server. Use with --restore. - it needs the option 'prod_server': 'user@vps-alias' in - the manifestWARNING: This options may download an exact - backup please deactivatebefore use.You can deactivate a - database running odoo with those parameters odoo deactivate - -d database - --no-repos Does not clone or pull repos when doing -i (install) - -d DATABASE Set default Database name.This option is persistent - -m MODULE Module to update. Used with -u (update) i.e. -m sale for - updating sale module -m all for updating all modules. - NOTE: if you perform -u without -m it asumes all modules - --nginx Add nginx to installation: Used with -i creates nginx dir - with config file. Used with -r starts an nginx container - linked to odoo.Used with -s stops nginx container. If you - want to add certificates review nginx.conf file located - in /odoo_ar/nginx/conf NOTE: This option will be deprecated - in thenear future - -Q repo Run the tests. Required parameters: -m . - Optional parameters: -d ; if omitted, the - default database will be used, which is the project - name + _test. NOTE: The database used for testing must be - created with demo data and should have admin/admin - credentials. - --backup-list List all backup files available for restore - --restore Restores a backup. it uses last backup and restores to - default database. You can change the backup file to restore - with -f option and change database name -d option - -f BACKUP_FILE Filename to restore. Used with --restore. To get the name - of this file issue a --backup-list command.If ommited - the newest file will be restored - -H, --server-help Show odoo server help, it shows the help from the odoo - imagedeclared in the cliente manifest - -V, --version Show version number and exit. - --create-test-db Create database with demo data. - --force-create Force database creation. - --base-dir BASE_DIR Set default base-dir This option is persistent. + -h, --help show this help message and exit + -i, --install The first time it runs, it creates the directory structure and + clones all repositories declared in the project. If run again, + it updates the repositories. Use together with --extract-sources + to copy the sources from the Odoo image to the host, which is + essential for working in debug mode. + -p, --pull-images Pull Images. Download all images declared in client manifest. + -w, --write-config Create / Overwrite config file. + -R, --run-env Run postgres, wdb and aeroo images (aeroo only for old odoo + versions). + -r, --run-cli Run odoo image + -S, --stop-env Stop postgres, wdb and aeroo images. + -s, --stop-cli Stop odoo image. + -u, --update Updates modules in the database. With no parameters, all modules + are updated. Use -m modulename to update only the specified + module; you can also pass a list of modules separated by commas + (without spaces). Use -d databasename to update a database other + than the default database. + -c CLIENT Set default client name. This option is persistent + -v, --verbose Go verbose mode. Prints every command + --no-deactivate No Deactivate database before restore. WARNING this command is + deprecated + --deploy-keys Available only in production mode. It creates a pair of deploy + keys for each private repository found in the manifest, lists + the public keys for adding to the repositories. + --debug Set default environment mode to debug + --prod Set default environment mode to production + --from-prod Restore backup from production server. Use with --restore. it + needs the option 'prod_server': 'user@vps-alias' in the + manifestWARNING: This options may download an exact backup + please deactivatebefore use.You can deactivate a database + running odoo with those parametersodoo deactivate -d database + --no-repos Does not clone or pull repos when doing -i (install) + -d DATABASE Set default Database name.This option is persistent + -m MODULE Module to update. Used with -u (update) i.e. -m sale for + updating sale module -m all for updating all modules. NOTE: if + you perform -u without -m it asumes all modules + --nginx Add nginx to installation: Used with -i creates nginx dir with + config file. Used with -r starts an nginx container linked to + odoo.Used with -s stops nginx container. If you want to add + certificates review nginx.conf file located in + /odoo_ar/nginx/conf NOTE: This option will be deprecated in + thenear future + -Q repo Run the tests. Required parameters: -m . Optional + parameters: -d ; if omitted, the default database will + be used, which is the project name + _test. NOTE: The database + used for testing must be created with demo data and should have + admin/admin credentials. + --backup-list List all backup files available for restore + --restore Restores a backup. it uses last backup and restores to default + database. You can change the backup file to restore with -f + option and change database name -d option + -f BACKUP_FILE Filename to restore. Used with --restore. To get the name of + this file issue a --backup-list command.If ommited the newest + file will be restored + -H, --server-help Show odoo server help, it shows the help from the odoo + imagedeclared in the cliente manifest + -V, --version Show version number and exit. + --create-test-db Create database with demo data. + --force-create Force database creation. + --base-dir BASE_DIR Set default base-dir This option is persistent. Installation @@ -109,6 +107,7 @@ Installation Changelog --------- +- 0.14.0 - Support for installation on a server with multiple private repositories. - 0.13.2 - Correction of a paragraph with double quotes inside double quotes. - 0.13.1 - A second configuration section is defined. The original is used when setting up a server, while the other, called config-local, is used diff --git a/odoo_env/__init__.py b/odoo_env/__init__.py index 83ce76f..9e78220 100644 --- a/odoo_env/__init__.py +++ b/odoo_env/__init__.py @@ -1 +1 @@ -__version__ = "0.13.2" +__version__ = "0.14.0" diff --git a/odoo_env/create_database.py b/odoo_env/create_database.py index bf72c23..380ffa5 100644 --- a/odoo_env/create_database.py +++ b/odoo_env/create_database.py @@ -36,7 +36,7 @@ def create_database(_oe, client_name): create_backup_db(cli) if not os.path.exists(db_bkp_file): - Msg().inf("I can't find the backup creating databas") + Msg().inf("I can't find the backup creating database") create_backup_db(cli) restore_database(cli) diff --git a/odoo_env/deploy_keys.py b/odoo_env/deploy_keys.py new file mode 100644 index 0000000..03c0fdb --- /dev/null +++ b/odoo_env/deploy_keys.py @@ -0,0 +1,98 @@ +import re +import subprocess +from pathlib import Path +import shutil +from odoo_env.client import Client +from odoo_env.messages import Msg + + +def generate_ssh_keypair(key_name="id_ed25519", passphrase=""): + ssh_dir = Path.home() / ".ssh" + ssh_dir.mkdir(mode=0o700, exist_ok=True) + + private_key_path = ssh_dir / key_name + + if private_key_path.exists(): + Msg().inf(f"Key '{private_key_path}' already exists.") + return + + # Buscar la ruta absoluta de ssh-keygen + ssh_keygen_path = shutil.which("ssh-keygen") + if not ssh_keygen_path: + raise FileNotFoundError("ssh-keygen not found in the system.") + + # Ejecutar ssh-keygen de manera silenciosa + with open("/dev/null", "w") as devnull: + subprocess.run( + [ + ssh_keygen_path, + "-t", "ed25519", + "-f", str(private_key_path), + "-N", passphrase, + ], + stdout=devnull, + stderr=devnull, + check=True, + ) + + +def update_ssh_config(key_name): + ssh_config_path = Path.home() / ".ssh" / "config" + host_alias = f"{key_name}.github.com" + + # Bloque a añadir (incluye salto de línea inicial para separar los bloques) + config_entry = f"\nHost {host_alias}\n HostName github.com\n IdentityFile ~/.ssh/{key_name}\n IdentitiesOnly yes\n" + + # Crear el archivo si no existe + if not ssh_config_path.exists(): + ssh_config_path.touch(mode=0o600) + + # Leer el contenido del archivo + with ssh_config_path.open("r") as f: + config_content = f.read() + + # Patrón para buscar el bloque exacto del alias + pattern = re.compile(rf"(?m)^Host {re.escape(host_alias)}\n(?:[ \t]+.*\n?)*") + + # Verificar si el alias ya existe + if pattern.search(config_content): + Msg().inf(f"Alias '{host_alias}' already exists in {ssh_config_path}.") + else: + with ssh_config_path.open("a") as f: + f.write(config_entry) + Msg().inf(f"Alias '{host_alias}' added to {ssh_config_path}.") + + +def list_public_keys(name): + ssh_dir = Path.home() / ".ssh" + path_key = ssh_dir / f"{name}.pub" + + Msg().inf(name) + try: + with path_key.open("r", encoding="utf-8") as file: + Msg().inf(file.read()) + except Exception as ex: + Msg().err(ex) + + +def deploy_keys(_oe, client_name): + Msg().inf("Creating / Reviewing deploy keys.") + cli = Client(_oe, client_name) + + # Detectar cuales son los repositorios que están en protocolo SSH asumiendo que son privados + ssh_repos = [] + for repo in cli.repos: + if repo.protocol == "ssh": + ssh_repos.append(repo) + + # Verificar si están generadas las claves publica/privada para cada repositorio, si no están las crea + # Editar el archivo .ssh/config para agregar los alias correspondientes si no existen + for repo in ssh_repos: + name = repo.code_name + generate_ssh_keypair(name) + update_ssh_config(name) + + # Listar las claves públicas para que las pongan en los repositorios + Msg().inf("Available Public Keys:") + for repo in ssh_repos: + list_public_keys(repo.code_name) diff --git a/odoo_env/oe.py b/odoo_env/oe.py index 299257b..c5301d5 100755 --- a/odoo_env/oe.py +++ b/odoo_env/oe.py @@ -7,6 +7,7 @@ from odoo_env.__init__ import __version__ from odoo_env.config import OeConfig from odoo_env.create_database import create_database +from odoo_env.deploy_keys import deploy_keys from odoo_env.messages import Msg from odoo_env.odooenv import OdooEnv from odoo_env.options import get_param @@ -90,6 +91,14 @@ def main(): help="Go verbose mode. Prints every command", ) + parser.add_argument( + "-d", + action="store", + nargs=1, + dest="database", + help="Set default Database name. This option is persistent", + ) + parser.add_argument( "--no-deactivate", action="store_true", @@ -97,12 +106,12 @@ def main(): "deprecated", ) - # parser.add_argument( - # "--extract-sources", - # action="store_true", - # help="Extracts the sources from the Odoo image to the host; it can only " - # "be used together with -i.", - # ) + parser.add_argument( + "--deploy-keys", + action="store_true", + help="Available only in production mode. It creates a pair of deploy keys for each private " + "repository found in the manifest, lists the public keys for adding to the repositories.", + ) parser.add_argument( "--debug", action="store_true", help="Set default environment mode to debug " @@ -128,14 +137,6 @@ def main(): help="Does not clone or pull repos when doing -i (install)", ) - parser.add_argument( - "-d", - action="store", - nargs=1, - dest="database", - help="Set default Database name." "This option is persistent", - ) - parser.add_argument( "-m", action="append", @@ -145,18 +146,6 @@ def main(): "you perform -u without -m it asumes all modules", ) - parser.add_argument( - "--nginx", - action="store_true", - help="Add nginx to installation: Used with -i creates nginx dir " - "with config file. " - "Used with -r starts an nginx container linked to odoo." - "Used with -s stops nginx container. " - "If you want to add certificates review nginx.conf file located " - "in /odoo_ar/nginx/conf NOTE: This option will be deprecated in the" - "near future", - ) - parser.add_argument( "-Q", action="store", @@ -170,20 +159,6 @@ def main(): "credentials.", ) - parser.add_argument( - "--backup-list", - action="store_true", - help="List all backup files available for restore", - ) - - parser.add_argument( - "--restore", - action="store_true", - help="Restores a backup. it uses last backup and restores to default " - "database. You can change the backup file to restore with -f " - "option and change database name -d option", - ) - parser.add_argument( "-f", action="append", @@ -205,6 +180,32 @@ def main(): "-V", "--version", action="store_true", help="Show version number and exit." ) + parser.add_argument( + "--nginx", + action="store_true", + help="Add nginx to installation: Used with -i creates nginx dir " + "with config file. " + "Used with -r starts an nginx container linked to odoo." + "Used with -s stops nginx container. " + "If you want to add certificates review nginx.conf file located " + "in /odoo_ar/nginx/conf NOTE: This option will be deprecated in the" + "near future", + ) + + parser.add_argument( + "--backup-list", + action="store_true", + help="List all backup files available for restore", + ) + + parser.add_argument( + "--restore", + action="store_true", + help="Restores a backup. it uses last backup and restores to default " + "database. You can change the backup file to restore with -f " + "option and change database name -d option", + ) + parser.add_argument( "--create-test-db", action="store_true", @@ -240,7 +241,6 @@ def main(): "no-repos": args.no_repos, "nginx": args.nginx, "backup_file": args.backup_file, - # "extract_sources": args.extract_sources, "force-create": args.force_create, } commands = [] @@ -301,6 +301,11 @@ def main(): create_database(OdooEnv(options=options), client_name) sys.exit() + if args.deploy_keys: + if options["debug"]: + Msg().err("Must be in prod mode in order to create deploy keys.") + deploy_keys(OdooEnv(options=options), client_name) + conf = OeConfig() # Verificar la version del script en pypi diff --git a/odoo_env/repos.py b/odoo_env/repos.py index 6e26698..7775139 100644 --- a/odoo_env/repos.py +++ b/odoo_env/repos.py @@ -1,3 +1,8 @@ +import re + +from odoo_env.messages import Msg + + class Repo: def __init__(self, value): self._dict = value @@ -35,7 +40,7 @@ def formatted(self): @property def clone(self): - return "clone --depth 1 -b {} {}".format(self.branch, self.url) + return f"clone --depth 1 -b {self.branch} {self.url}" @property def pull(self): @@ -72,6 +77,10 @@ def __init__(self, value, branch): self._url = parsed[0] + # agregarle a la url el prefijo de ssh si es requerido. + if self.protocol == "ssh": + self._url = re.sub(r"@(github)", f"@{self.code_name}.\\1", self._url) + # si me quedan dos parametros tengo un directorio if len(parsed) > 1: self._dir = parsed[1] @@ -114,3 +123,21 @@ def clone(self): def pull(self): recurse = "--recurse-submodules" if self._recurse_submodules else "" return f"pull {recurse}" + + @property + def protocol(self): + if self._url.startswith("git@"): + return "ssh" + if self._url.startswith("https:"): + return "https" + Msg().err(f"Unknown git protocol {self._url}") + + @property + def code_name(self): + """Obtener el nombre del repositorio del""" + pattern = r"[:/](?P[^/]+?)(?:\.git|\s|$)" + match = re.search(pattern, self._url) + if match: + return match.group("name") + + Msg.err(f"invalid repository URL {self._url}") diff --git a/pyproject.toml b/pyproject.toml index 122b35a..a9b8194 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -7,7 +7,7 @@ build-backend = "hatchling.build" [project] name = "odoo-env" -version = "0.13.2" +version = "0.14.0" authors = [ { name="Jorge Obiols", email="jorge.obiols@gmail.com" }, From 3518590197752945a322e2d6f450982b51415ec2 Mon Sep 17 00:00:00 2001 From: Jorge Obiols Date: Thu, 27 Feb 2025 09:21:33 -0300 Subject: [PATCH 35/48] [FIX] pre-commit --- odoo_env/deploy_keys.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/odoo_env/deploy_keys.py b/odoo_env/deploy_keys.py index 03c0fdb..55e797d 100644 --- a/odoo_env/deploy_keys.py +++ b/odoo_env/deploy_keys.py @@ -1,7 +1,8 @@ import re +import shutil import subprocess from pathlib import Path -import shutil + from odoo_env.client import Client from odoo_env.messages import Msg @@ -26,9 +27,12 @@ def generate_ssh_keypair(key_name="id_ed25519", passphrase=""): subprocess.run( [ ssh_keygen_path, - "-t", "ed25519", - "-f", str(private_key_path), - "-N", passphrase, + "-t", + "ed25519", + "-f", + str(private_key_path), + "-N", + passphrase, ], stdout=devnull, stderr=devnull, From 4cb74f32bd05c6554d48e93b8f6ed2394f75dbd6 Mon Sep 17 00:00:00 2001 From: Jorge Obiols Date: Mon, 3 Mar 2025 11:10:06 -0300 Subject: [PATCH 36/48] [FIX] en modo debug poner siempre admin_passw = admin --- .vscode/launch.json | 2 +- odoo_env/command.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.vscode/launch.json b/.vscode/launch.json index 678974d..6cba81e 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -10,7 +10,7 @@ "type": "debugpy", "request": "launch", "python": "/odoo/vs_env/bin/python3.12", - "args": ["--deploy-keys", "-c", "miltonia", "--prod"], + "args": ["-w"], "justMyCode": true, "module": "odoo_env.oe" } diff --git a/odoo_env/command.py b/odoo_env/command.py index 7982696..6ffa2a3 100644 --- a/odoo_env/command.py +++ b/odoo_env/command.py @@ -199,6 +199,7 @@ def execute(self): odoo_conf.add_line("max_cron_threads = 0") odoo_conf.add_line("limit_time_cpu = 0") odoo_conf.add_line("limit_time_real = 0") + odoo_conf.add_line("admin_password = admin") else: # no estoy en modo debug, # si no defino workers en el manifiesto lo calculo @@ -214,7 +215,6 @@ def execute(self): line = self.check_item("max_cron_threads", client.config) if not line: # Calculo los cron threads - # You should use 1 cron thread per available CPU odoo_conf.add_line("max_cron_threads = 1") else: odoo_conf.add_line(line) From 6f924a1ae476905537f6be5c66e5b12f56c2373d Mon Sep 17 00:00:00 2001 From: Jorge Obiols Date: Mon, 3 Mar 2025 11:10:06 -0300 Subject: [PATCH 37/48] [FIX] Correccion de bug en --debug No bajaban los repositorios --- .vscode/launch.json | 2 +- odoo_env/client.py | 2 +- odoo_env/command.py | 2 +- odoo_env/odooenv.py | 18 ++++++------------ odoo_env/repos.py | 6 +++--- 5 files changed, 12 insertions(+), 18 deletions(-) diff --git a/.vscode/launch.json b/.vscode/launch.json index 678974d..4de392d 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -10,7 +10,7 @@ "type": "debugpy", "request": "launch", "python": "/odoo/vs_env/bin/python3.12", - "args": ["--deploy-keys", "-c", "miltonia", "--prod"], + "args": ["-i","--debug"], "justMyCode": true, "module": "odoo_env.oe" } diff --git a/odoo_env/client.py b/odoo_env/client.py index 01f873f..7a740d8 100644 --- a/odoo_env/client.py +++ b/odoo_env/client.py @@ -102,7 +102,7 @@ def check_v2(self, manifest): # Crear imagenes y repos for rep in manifest.get("git-repos"): - self._repos.append(Repo2(rep, self._version)) + self._repos.append(Repo2(rep, self._version, self._parent._options)) for img in manifest.get("docker-images"): self._images.append(Image2(img, self._parent.debug)) diff --git a/odoo_env/command.py b/odoo_env/command.py index 7982696..6ffa2a3 100644 --- a/odoo_env/command.py +++ b/odoo_env/command.py @@ -199,6 +199,7 @@ def execute(self): odoo_conf.add_line("max_cron_threads = 0") odoo_conf.add_line("limit_time_cpu = 0") odoo_conf.add_line("limit_time_real = 0") + odoo_conf.add_line("admin_password = admin") else: # no estoy en modo debug, # si no defino workers en el manifiesto lo calculo @@ -214,7 +215,6 @@ def execute(self): line = self.check_item("max_cron_threads", client.config) if not line: # Calculo los cron threads - # You should use 1 cron thread per available CPU odoo_conf.add_line("max_cron_threads = 1") else: odoo_conf.add_line(line) diff --git a/odoo_env/odooenv.py b/odoo_env/odooenv.py index cc5d703..b40e1be 100644 --- a/odoo_env/odooenv.py +++ b/odoo_env/odooenv.py @@ -329,7 +329,7 @@ def install(self, client_name): "sources", ]: r_dir = f"{self.client.base_dir}{w_dir}" - cmd = MakedirCommand(self, command="mkdir -p %s" % r_dir, args="%s" % r_dir) + cmd = MakedirCommand(self, command=f"mkdir -p {r_dir}", args=r_dir) ret.append(cmd) ################################################################## @@ -713,20 +713,18 @@ def update(self, client_name, database, modules): command += self._add_normal_mountings() if self.debug: command += self._add_debug_mountings(self.client.numeric_ver) - command += "--link pg-{}:db ".format(self.client.name) + command += f"--link pg-{self.client.name}:db " command += "-e ODOO_CONF=/dev/null " - command += "{} -- ".format(self.client.get_image("odoo").name) + command += f"{self.client.get_image("odoo").name} -- " command += "--stop-after-init " command += "--logfile=false " - command += "-d {} ".format(database) - command += "-u {} ".format(", ".join(modules)) + command += f"-d {database} " + command += f"-u {', '.join()} " cmd = Command( self, command=command, - usr_msg="Performing update of {} on database {}".format( - ", ".join(modules), database - ), + usr_msg=f"Performing update of {', '.join(modules)} on database {database}" ) ret.append(cmd) return ret @@ -789,10 +787,6 @@ def no_repos(self): def nginx(self): return self._options["nginx"] - # @property - # def extract_sources(self): - # return self._options["extract_sources"] - @property def force_create(self): return self._options["force-create"] diff --git a/odoo_env/repos.py b/odoo_env/repos.py index 7775139..5dba63e 100644 --- a/odoo_env/repos.py +++ b/odoo_env/repos.py @@ -48,7 +48,7 @@ def pull(self): class Repo2: - def __init__(self, value, branch): + def __init__(self, value, branch, options): """Sintaxis [[/] [-b ] [optios] El branch debe estar despues del repo, si no esta se toma el branch que viene como parametro, si no viene nada es una excepcion. @@ -77,8 +77,8 @@ def __init__(self, value, branch): self._url = parsed[0] - # agregarle a la url el prefijo de ssh si es requerido. - if self.protocol == "ssh": + # agregarle a la url el prefijo de ssh si es requerido solo si estamos en produccion + if self.protocol == "ssh" and not options['debug']: self._url = re.sub(r"@(github)", f"@{self.code_name}.\\1", self._url) # si me quedan dos parametros tengo un directorio From 39193fdc30c1b836fc955ab08d768b325fb9e012 Mon Sep 17 00:00:00 2001 From: Jorge Obiols Date: Sat, 8 Mar 2025 15:55:34 -0300 Subject: [PATCH 38/48] missing imports --- odoo_env/odooenv.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/odoo_env/odooenv.py b/odoo_env/odooenv.py index b40e1be..329a4d8 100644 --- a/odoo_env/odooenv.py +++ b/odoo_env/odooenv.py @@ -5,7 +5,7 @@ from odoo_env.command import * from odoo_env.constants import * from odoo_env.messages import Msg - +from odoo_env.constants import IN_CUSTOM_ADDONS, IN_CONFIG, IN_DATA, IN_LOG, IN_BACKUP_DIR class OdooEnv: """ From 47b163f628c5184da81bdcf01e475ea3585b6903 Mon Sep 17 00:00:00 2001 From: Jorge Obiols Date: Sat, 8 Mar 2025 16:03:40 -0300 Subject: [PATCH 39/48] doc --- odoo_env/odooenv.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/odoo_env/odooenv.py b/odoo_env/odooenv.py index 329a4d8..f5e43f9 100644 --- a/odoo_env/odooenv.py +++ b/odoo_env/odooenv.py @@ -12,9 +12,9 @@ class OdooEnv: Implementa metodos que corresponden a cada una de las acciones que se proveen en la interfase argparse. - corresponde a una opcion, devuelve una lista de tuplas con accion y - mensaje. El mensaje puede estar o no. - Si hay mensaje se muestra antes de ejecutar la accion + corresponde a una opcion, devuelve una lista de tuplas con accion y + mensaje. El mensaje puede estar o no. + Si hay mensaje se muestra antes de ejecutar la accion """ def __init__(self, options): From b1a10c17aa45986b2f68de44776bbe91b2c010c6 Mon Sep 17 00:00:00 2001 From: Jorge Obiols Date: Sat, 8 Mar 2025 16:17:34 -0300 Subject: [PATCH 40/48] pre-commit --- odoo_env/odooenv.py | 6 ++++-- odoo_env/repos.py | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/odoo_env/odooenv.py b/odoo_env/odooenv.py index f5e43f9..25b44d0 100644 --- a/odoo_env/odooenv.py +++ b/odoo_env/odooenv.py @@ -4,8 +4,10 @@ from odoo_env.client import Client from odoo_env.command import * from odoo_env.constants import * +from odoo_env.constants import (IN_BACKUP_DIR, IN_CONFIG, IN_CUSTOM_ADDONS, + IN_DATA, IN_LOG) from odoo_env.messages import Msg -from odoo_env.constants import IN_CUSTOM_ADDONS, IN_CONFIG, IN_DATA, IN_LOG, IN_BACKUP_DIR + class OdooEnv: """ @@ -724,7 +726,7 @@ def update(self, client_name, database, modules): cmd = Command( self, command=command, - usr_msg=f"Performing update of {', '.join(modules)} on database {database}" + usr_msg=f"Performing update of {', '.join(modules)} on database {database}", ) ret.append(cmd) return ret diff --git a/odoo_env/repos.py b/odoo_env/repos.py index 5dba63e..9176780 100644 --- a/odoo_env/repos.py +++ b/odoo_env/repos.py @@ -78,7 +78,7 @@ def __init__(self, value, branch, options): self._url = parsed[0] # agregarle a la url el prefijo de ssh si es requerido solo si estamos en produccion - if self.protocol == "ssh" and not options['debug']: + if self.protocol == "ssh" and not options["debug"]: self._url = re.sub(r"@(github)", f"@{self.code_name}.\\1", self._url) # si me quedan dos parametros tengo un directorio From 23710efdc62c33a495151b0b4018ef01b6906554 Mon Sep 17 00:00:00 2001 From: Jorge Obiols Date: Sat, 8 Mar 2025 16:28:32 -0300 Subject: [PATCH 41/48] version 0.14.1 --- README.md | 3 ++- odoo_env/__init__.py | 2 +- pyproject.toml | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index c9c8549..5e2d856 100644 --- a/README.md +++ b/README.md @@ -34,7 +34,7 @@ Functionality [--restore] [-f BACKUP_FILE] [-H] [-V] [--create-test-db] [--force-create] [--base-dir BASE_DIR] - Odoo Environment Manager v0.14.0 - by jeo Software + Odoo Environment Manager v0.14.1 - by jeo Software options: -h, --help show this help message and exit @@ -107,6 +107,7 @@ Installation Changelog --------- +- 0.14.1 - Fix install bug in debug mode - 0.14.0 - Support for installation on a server with multiple private repositories. - 0.13.2 - Correction of a paragraph with double quotes inside double quotes. - 0.13.1 - A second configuration section is defined. The original is used when diff --git a/odoo_env/__init__.py b/odoo_env/__init__.py index 9e78220..f075dd3 100644 --- a/odoo_env/__init__.py +++ b/odoo_env/__init__.py @@ -1 +1 @@ -__version__ = "0.14.0" +__version__ = "0.14.1" diff --git a/pyproject.toml b/pyproject.toml index a9b8194..682cc93 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -7,7 +7,7 @@ build-backend = "hatchling.build" [project] name = "odoo-env" -version = "0.14.0" +version = "0.14.1" authors = [ { name="Jorge Obiols", email="jorge.obiols@gmail.com" }, From 6e9e45a149e60d7acf0a47342b511c22e9f97b96 Mon Sep 17 00:00:00 2001 From: Jorge Obiols Date: Sun, 9 Mar 2025 12:08:58 -0300 Subject: [PATCH 42/48] FIX -u --- README.md | 4 ++-- odoo_env/__init__.py | 2 +- odoo_env/odooenv.py | 2 +- pyproject.toml | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 5e2d856..cf43a21 100644 --- a/README.md +++ b/README.md @@ -34,7 +34,7 @@ Functionality [--restore] [-f BACKUP_FILE] [-H] [-V] [--create-test-db] [--force-create] [--base-dir BASE_DIR] - Odoo Environment Manager v0.14.1 - by jeo Software + Odoo Environment Manager v0.14.2 - by jeo Software options: -h, --help show this help message and exit @@ -107,7 +107,7 @@ Installation Changelog --------- -- 0.14.1 - Fix install bug in debug mode +- 0.14.2 - Fix install bug in debug mode - 0.14.0 - Support for installation on a server with multiple private repositories. - 0.13.2 - Correction of a paragraph with double quotes inside double quotes. - 0.13.1 - A second configuration section is defined. The original is used when diff --git a/odoo_env/__init__.py b/odoo_env/__init__.py index f075dd3..745162e 100644 --- a/odoo_env/__init__.py +++ b/odoo_env/__init__.py @@ -1 +1 @@ -__version__ = "0.14.1" +__version__ = "0.14.2" diff --git a/odoo_env/odooenv.py b/odoo_env/odooenv.py index 25b44d0..b452587 100644 --- a/odoo_env/odooenv.py +++ b/odoo_env/odooenv.py @@ -721,7 +721,7 @@ def update(self, client_name, database, modules): command += "--stop-after-init " command += "--logfile=false " command += f"-d {database} " - command += f"-u {', '.join()} " + command += f"-u {', '.join(modules)} " cmd = Command( self, diff --git a/pyproject.toml b/pyproject.toml index 682cc93..390b6ef 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -7,7 +7,7 @@ build-backend = "hatchling.build" [project] name = "odoo-env" -version = "0.14.1" +version = "0.14.2" authors = [ { name="Jorge Obiols", email="jorge.obiols@gmail.com" }, From 1a13ecc8ecfae15e98228e34602c2541f4c66644 Mon Sep 17 00:00:00 2001 From: Jorge Obiols Date: Mon, 10 Mar 2025 10:56:35 -0300 Subject: [PATCH 43/48] Compatiblidad con python 3.11 --- odoo_env/odooenv.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/odoo_env/odooenv.py b/odoo_env/odooenv.py index b452587..54d2e9d 100644 --- a/odoo_env/odooenv.py +++ b/odoo_env/odooenv.py @@ -717,7 +717,7 @@ def update(self, client_name, database, modules): command += self._add_debug_mountings(self.client.numeric_ver) command += f"--link pg-{self.client.name}:db " command += "-e ODOO_CONF=/dev/null " - command += f"{self.client.get_image("odoo").name} -- " + command += f"{self.client.get_image('odoo').name} -- " command += "--stop-after-init " command += "--logfile=false " command += f"-d {database} " From a79317bf342f4ba53b0546ad556cbd966498ed19 Mon Sep 17 00:00:00 2001 From: Jorge Obiols Date: Mon, 10 Mar 2025 10:58:12 -0300 Subject: [PATCH 44/48] Compatiblidad con python 3.11 --- README.md | 3 ++- odoo_env/__init__.py | 2 +- pyproject.toml | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index cf43a21..cc18f3d 100644 --- a/README.md +++ b/README.md @@ -34,7 +34,7 @@ Functionality [--restore] [-f BACKUP_FILE] [-H] [-V] [--create-test-db] [--force-create] [--base-dir BASE_DIR] - Odoo Environment Manager v0.14.2 - by jeo Software + Odoo Environment Manager v0.14.3 - by jeo Software options: -h, --help show this help message and exit @@ -107,6 +107,7 @@ Installation Changelog --------- +- 0.14.3 - Compatibility with python 3.11 - 0.14.2 - Fix install bug in debug mode - 0.14.0 - Support for installation on a server with multiple private repositories. - 0.13.2 - Correction of a paragraph with double quotes inside double quotes. diff --git a/odoo_env/__init__.py b/odoo_env/__init__.py index 745162e..23f0070 100644 --- a/odoo_env/__init__.py +++ b/odoo_env/__init__.py @@ -1 +1 @@ -__version__ = "0.14.2" +__version__ = "0.14.3" diff --git a/pyproject.toml b/pyproject.toml index 390b6ef..e532434 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -7,7 +7,7 @@ build-backend = "hatchling.build" [project] name = "odoo-env" -version = "0.14.2" +version = "0.14.3" authors = [ { name="Jorge Obiols", email="jorge.obiols@gmail.com" }, From f44f73d16c1d3ec976156ced03d0e3e18c259034 Mon Sep 17 00:00:00 2001 From: Jorge Obiols Date: Fri, 21 Mar 2025 13:40:34 -0300 Subject: [PATCH 45/48] [DOC] detalle --- install_vps.sh | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/install_vps.sh b/install_vps.sh index 25b9985..1583b33 100644 --- a/install_vps.sh +++ b/install_vps.sh @@ -8,6 +8,9 @@ sudo apt update && sudo apt upgrade -y # verificar si esta python 3 instalado python3 -V +# Verificar version de linux +lsb_release -a + # si no esta instalado instalar python 3 # echo #echo "installing python" @@ -42,7 +45,7 @@ rm get-docker.sh # install docker en produccion Ubuntu # https://docs.docker.com/engine/install/ubuntu/ -# Add Docker's official GPG key: EN DEBIAN +# Add Docker's official GPG key: EN DEBIAN / UBUNTU sudo apt-get update sudo apt-get install ca-certificates curl gnupg sudo install -m 0755 -d /etc/apt/keyrings From 6f8dc58279bc100e6ae5536cc33d6ab8e0fb6c3f Mon Sep 17 00:00:00 2001 From: Jorge Obiols Date: Sat, 14 Jun 2025 15:15:10 -0300 Subject: [PATCH 46/48] [FIX] bump version 0.15.0 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Se agreaga sopoerte para WDB 3.3.1 Corrección bug parametro admin_passwd en odoo.conf --- .vscode/launch.json | 2 +- README.md | 3 ++- install_vps.sh | 2 -- odoo_env/__init__.py | 2 +- odoo_env/command.py | 2 +- odoo_env/config.py | 2 +- odoo_env/odooenv.py | 6 +++++- pyproject.toml | 37 +++++++++++++++---------------------- 8 files changed, 26 insertions(+), 30 deletions(-) diff --git a/.vscode/launch.json b/.vscode/launch.json index 4de392d..cb16537 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -10,7 +10,7 @@ "type": "debugpy", "request": "launch", "python": "/odoo/vs_env/bin/python3.12", - "args": ["-i","--debug"], + "args": ["-R","--debug","-c","testpy18"], "justMyCode": true, "module": "odoo_env.oe" } diff --git a/README.md b/README.md index cc18f3d..db222ac 100644 --- a/README.md +++ b/README.md @@ -34,7 +34,7 @@ Functionality [--restore] [-f BACKUP_FILE] [-H] [-V] [--create-test-db] [--force-create] [--base-dir BASE_DIR] - Odoo Environment Manager v0.14.3 - by jeo Software + Odoo Environment Manager v0.15.0 - by jeo Software options: -h, --help show this help message and exit @@ -107,6 +107,7 @@ Installation Changelog --------- +- 0.15.0 - Added support for WDB 3.3.1 for Odoo versions > 17.0. - 0.14.3 - Compatibility with python 3.11 - 0.14.2 - Fix install bug in debug mode - 0.14.0 - Support for installation on a server with multiple private repositories. diff --git a/install_vps.sh b/install_vps.sh index 1583b33..7bc4b18 100644 --- a/install_vps.sh +++ b/install_vps.sh @@ -74,5 +74,3 @@ sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin # Verificar docker sudo docker run hello-world -# test -docker-compose --version diff --git a/odoo_env/__init__.py b/odoo_env/__init__.py index 23f0070..9da2f8f 100644 --- a/odoo_env/__init__.py +++ b/odoo_env/__init__.py @@ -1 +1 @@ -__version__ = "0.14.3" +__version__ = "0.15.0" diff --git a/odoo_env/command.py b/odoo_env/command.py index 6ffa2a3..e7943c6 100644 --- a/odoo_env/command.py +++ b/odoo_env/command.py @@ -199,7 +199,7 @@ def execute(self): odoo_conf.add_line("max_cron_threads = 0") odoo_conf.add_line("limit_time_cpu = 0") odoo_conf.add_line("limit_time_real = 0") - odoo_conf.add_line("admin_password = admin") + odoo_conf.add_line("admin_passwd = admin") else: # no estoy en modo debug, # si no defino workers en el manifiesto lo calculo diff --git a/odoo_env/config.py b/odoo_env/config.py index 01c077d..514c162 100644 --- a/odoo_env/config.py +++ b/odoo_env/config.py @@ -108,7 +108,7 @@ def save_base_dir(self, value): self.save_config_data(config) def check_version(self): - """Chequea si la vcersion de odoo-env es la última""" + """Chequea si la version de odoo-env es la última""" config = self.get_config_data() dt_today = datetime.today() diff --git a/odoo_env/odooenv.py b/odoo_env/odooenv.py index 54d2e9d..98f557b 100644 --- a/odoo_env/odooenv.py +++ b/odoo_env/odooenv.py @@ -503,7 +503,11 @@ def run_environment(self, client_name): command += "-p 1984:1984 " command += "--name=wdb " command += "--restart=always " - command += "kozea/wdb" + if self.client.numeric_ver < 18.0: + command += "kozea/wdb" + else: + command += "jobiols/wdb-server:3.3.1" + cmd = Command( self, command=command, diff --git a/pyproject.toml b/pyproject.toml index e532434..09d5945 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,34 +1,30 @@ -# https://packaging.python.org/en/latest/tutorials/packaging-projects/ -# https://setuptools.pypa.io/en/latest/ - [build-system] requires = ["hatchling"] build-backend = "hatchling.build" [project] name = "odoo-env" -version = "0.14.3" +version = "0.15.0" authors = [ { name="Jorge Obiols", email="jorge.obiols@gmail.com" }, ] description = "A Dockerized environment for Odoo" readme = "README.md" -requires-python = ">=3.8" - classifiers=[ - "Programming Language :: Python :: 3.8", - "Programming Language :: Python :: 3.9", - "Programming Language :: Python :: 3.10", - "Programming Language :: Python :: 3.11", - "Programming Language :: Python :: 3.12", - "Programming Language :: Python :: 3.13", - "Development Status :: 5 - Production/Stable", - "Intended Audience :: Developers", - "License :: OSI Approved :: MIT License", - "Operating System :: POSIX :: Linux", - "Topic :: Software Development :: Testing :: Unit", - "Topic :: System :: Software Distribution", - ] +requires-python = ">=3.9" +classifiers = [ + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", + "Programming Language :: Python :: 3.13", + "Development Status :: 5 - Production/Stable", + "Intended Audience :: Developers", + "License :: OSI Approved :: MIT License", + "Operating System :: POSIX :: Linux", + "Topic :: Software Development :: Testing :: Unit", + "Topic :: System :: Software Distribution", +] dependencies = [ "PyYAML >= 6.0.2", "tornado >= 6.4.2", @@ -41,6 +37,3 @@ sd = "odoo_env.sd:main" [project.urls] "Homepage" = "https://jobiols.github.io/odoo-env/" "Bug Tracker" = "https://github.com/jobiols/odoo-env/issues" - -[tool.setuptools.dynamic] -dependencies = {file = ["requirements.txt"]} From 0baebe1bec58944158897a87bffe82e0f9d60073 Mon Sep 17 00:00:00 2001 From: Jorge Obiols Date: Sat, 14 Jun 2025 15:21:32 -0300 Subject: [PATCH 47/48] [FIX] pre-commit --- .pre-commit-config.yaml | 3 +-- install_vps.sh | 1 - odoo_env/odooenv.py | 9 +++++++-- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index cff7379..df3e17f 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -38,8 +38,7 @@ repos: hooks: - id: isort name: isort except __init__.py - args: - - --settings=. + args: ["--profile", "black", "--filter-files", "--skip-gitignore"] exclude: /__init__\.py$ - repo: https://github.com/PyCQA/pylint diff --git a/install_vps.sh b/install_vps.sh index 7bc4b18..c606dfe 100644 --- a/install_vps.sh +++ b/install_vps.sh @@ -73,4 +73,3 @@ sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin # Verificar docker sudo docker run hello-world - diff --git a/odoo_env/odooenv.py b/odoo_env/odooenv.py index 98f557b..5d2aa22 100644 --- a/odoo_env/odooenv.py +++ b/odoo_env/odooenv.py @@ -4,8 +4,13 @@ from odoo_env.client import Client from odoo_env.command import * from odoo_env.constants import * -from odoo_env.constants import (IN_BACKUP_DIR, IN_CONFIG, IN_CUSTOM_ADDONS, - IN_DATA, IN_LOG) +from odoo_env.constants import ( + IN_BACKUP_DIR, + IN_CONFIG, + IN_CUSTOM_ADDONS, + IN_DATA, + IN_LOG, +) from odoo_env.messages import Msg From 1269547f0e378216bfd92cd69b5612e294a8646e Mon Sep 17 00:00:00 2001 From: Jorge Obiols Date: Sun, 22 Jun 2025 17:19:25 -0300 Subject: [PATCH 48/48] FIX nombre de la imagen v0.15.1 --- README.md | 3 ++- odoo_env/__init__.py | 2 +- odoo_env/odooenv.py | 2 +- pyproject.toml | 2 +- 4 files changed, 5 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index db222ac..084a428 100644 --- a/README.md +++ b/README.md @@ -34,7 +34,7 @@ Functionality [--restore] [-f BACKUP_FILE] [-H] [-V] [--create-test-db] [--force-create] [--base-dir BASE_DIR] - Odoo Environment Manager v0.15.0 - by jeo Software + Odoo Environment Manager v0.15.1 - by jeo Software options: -h, --help show this help message and exit @@ -107,6 +107,7 @@ Installation Changelog --------- +- 0.15.1 - Fix wdb image name. - 0.15.0 - Added support for WDB 3.3.1 for Odoo versions > 17.0. - 0.14.3 - Compatibility with python 3.11 - 0.14.2 - Fix install bug in debug mode diff --git a/odoo_env/__init__.py b/odoo_env/__init__.py index 9da2f8f..903e77c 100644 --- a/odoo_env/__init__.py +++ b/odoo_env/__init__.py @@ -1 +1 @@ -__version__ = "0.15.0" +__version__ = "0.15.1" diff --git a/odoo_env/odooenv.py b/odoo_env/odooenv.py index 5d2aa22..d76937d 100644 --- a/odoo_env/odooenv.py +++ b/odoo_env/odooenv.py @@ -511,7 +511,7 @@ def run_environment(self, client_name): if self.client.numeric_ver < 18.0: command += "kozea/wdb" else: - command += "jobiols/wdb-server:3.3.1" + command += "jobiols/wdb:3.3.1" cmd = Command( self, diff --git a/pyproject.toml b/pyproject.toml index 09d5945..047de13 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "hatchling.build" [project] name = "odoo-env" -version = "0.15.0" +version = "0.15.1" authors = [ { name="Jorge Obiols", email="jorge.obiols@gmail.com" },