Contributors mailing list archives
contributors@odoo-community.org
Browse archives
Re: Escape python lint
by
Vauxoo, Moisés López Calderón
I have created the following script in a file:
```python
import logging
_logger = logging.getLogger(__name__)
query = """SELECT
'Hello World'"""
self.env.cr.execute(query)
_logger.warn("Query error %s", self.env.cr.query)
```
So, I called it using the following command:
`~/odoo-12.0/odoo-bin shell -d openerp_test --log-level=warn < query_test.py`
The output was:
Since that python3 is using bytes by default it is printed using bytes (Notice the "\n" instead of a real newline).
Using `print` the output is ignored for `--log-file=out.txt` parameter or a odoo started using a service.
So it is better using a logger.
But if you like skip this pylint check you can use a comment:
`# pylint: disable=print-used`
More info about:
- https://docs.pylint.org/en/latest/faq.html#do-i-have-to-remember-all-these-numbers
import logging
_logger = logging.getLogger(__name__)
query = """SELECT
'Hello World'"""
self.env.cr.execute(query)
_logger.warn("Query error %s", self.env.cr.query)
```
So, I called it using the following command:
`~/odoo-12.0/odoo-bin shell -d openerp_test --log-level=warn < query_test.py`
The output was:
Since that python3 is using bytes by default it is printed using bytes (Notice the "\n" instead of a real newline).
Using `print` the output is ignored for `--log-file=out.txt` parameter or a odoo started using a service.
So it is better using a logger.
But if you like skip this pylint check you can use a comment:
`# pylint: disable=print-used`
More info about:
- https://docs.pylint.org/en/latest/faq.html#do-i-have-to-remember-all-these-numbers
El mié., 23 oct. 2019 a las 12:57, David Beal (<david.beal@akretion.com>) escribió:
Thanks Pedro.For my information about ways to escape python lint.- no way- documented somewhere or exampleThanks
David BEALLe mer. 23 oct. 2019 à 19:12, Pedro M. Baeza (Tecnativa) <pedro.baeza@tecnativa.com> a écrit :Answered in the PR as well: Why not emit it as logger.warning or similar?_______________________________________________
Mailing-List: https://odoo-community.org/groups/contributors-15
Post to: mailto:contributors@odoo-community.org
Unsubscribe: https://odoo-community.org/groups?unsubscribe
_______________________________________________
Mailing-List: https://odoo-community.org/groups/contributors-15
Post to: mailto:contributors@odoo-community.org
Unsubscribe: https://odoo-community.org/groups?unsubscribe
Moisés López Calderón
Mobile: (+521) 477-752-22-30
Twitter: @moylop260
Twitter: @vauxoo