Skip to content

Commit

Permalink
[FIX] common.commands.odoobin: Escape markup in odoo-bin logs
Browse files Browse the repository at this point in the history
Escape Rich's markup-like substrings in odoo-bin logs to avoid having
information stripped from the logs when displayed in the console.

For example, the following log line:
```
Element '<xpath expr="//field[@name=&#39;test&#39;]">' cannot be located in parent view
```

Was previously stripped down to:
```
Element '<xpath expr="//field">' cannot be located in parent view
```

Additionally, a new argument is passed to the odoo-bin command
and children to allow disabling pretty-printing of the logs.
  • Loading branch information
brinkflew committed Oct 17, 2024
1 parent abfc3ef commit 8d4eecd
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
2 changes: 1 addition & 1 deletion odev/_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@
# or merged change.
# ------------------------------------------------------------------------------

__version__ = "4.8.3"
__version__ = "4.8.4"

Check notice on line 25 in odev/_version.py

View workflow job for this annotation

GitHub Actions / version-bump

Patch Update
11 changes: 9 additions & 2 deletions odev/common/commands/odoobin.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
from pathlib import Path
from typing import Mapping, Optional, Union

from rich import markup

from odev.common import args, string
from odev.common.commands import LocalDatabaseCommand
from odev.common.databases import LocalDatabase
Expand Down Expand Up @@ -68,6 +70,11 @@ class OdoobinCommand(LocalDatabaseCommand, ABC):
If not specified, defaults to the common worktree for the current Odoo version.
""",
)
pretty = args.Flag(
aliases=["--no-pretty"],
description="Do not pretty print the output of odoo-bin but rather display logs as output by the subprocess.",
default=True,
)

# --------------------------------------------------------------------------
# Properties
Expand Down Expand Up @@ -186,8 +193,8 @@ def odoobin_progress(self, line: str):
"""Beautify odoo logs on the fly."""
match = self._parse_progress_log_line(line)

if match is None:
return self.print(line, highlight=False, soft_wrap=False)
if match is None or not self.args.pretty:
return self.print(markup.escape(line), highlight=False, soft_wrap=False)

self.last_level = match.group("level").lower()
self._print_progress_log_line(match)
Expand Down

0 comments on commit 8d4eecd

Please sign in to comment.