Change CI to GitHub actions

Use copier template from oca/oca-addons-repo-template

Target Python3.8

Apply linting

Fix a missing call to super
This commit is contained in:
Yannick Payot
2023-05-24 16:09:11 +02:00
parent dc83bd74b3
commit 9ca3f6a710
83 changed files with 1714 additions and 912 deletions
-1
View File
@@ -1,2 +1 @@
from . import models
+12 -17
View File
@@ -1,20 +1,15 @@
# Copyright 2016-2019 Camptocamp SA
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html)
{'name': 'Monitoring: Statsd Metrics',
'version': "14.0.1.0.0",
'author': 'Camptocamp,Odoo Community Association (OCA)',
'license': 'AGPL-3',
'category': 'category',
'depends': ['base',
'web',
'server_environment',
],
'website': 'http://www.camptocamp.com',
'data': [],
'external_dependencies': {
'python': ['statsd'],
},
'installable': True,
}
{
"name": "Monitoring: Statsd Metrics",
"version": "14.0.1.0.0",
"author": "Camptocamp,Odoo Community Association (OCA)",
"license": "AGPL-3",
"category": "category",
"depends": ["base", "web", "server_environment"],
"website": "https://github.com/camptocamp/odoo-cloud-platform",
"data": [],
"external_dependencies": {"python": ["statsd"]},
"installable": True,
}
-1
View File
@@ -1,2 +1 @@
from . import ir_http
+29 -21
View File
@@ -4,38 +4,46 @@
from odoo import models
from odoo.http import request
from ..statsd_client import statsd, customer, environment
from ..statsd_client import customer, environment, statsd
class IrHttp(models.AbstractModel):
_inherit = 'ir.http'
_inherit = "ir.http"
@classmethod
def _dispatch(cls):
if not statsd:
return super()._dispatch()
path_info = request.httprequest.environ.get('PATH_INFO')
if path_info.startswith('/longpolling/'):
path_info = request.httprequest.environ.get("PATH_INFO")
if path_info.startswith("/longpolling/"):
return super()._dispatch()
parts = ['http', ]
if path_info.startswith('/web/dataset/call_button'):
parts += ['button',
customer, environment,
request.params['model'].replace('.', '_'),
request.params['method'],
]
elif path_info.startswith('/web/dataset/exec_workflow'):
parts += ['workflow',
customer, environment,
request.params['model'].replace('.', '_'),
request.params['signal'],
]
parts = [
"http",
]
if path_info.startswith("/web/dataset/call_button"):
parts += [
"button",
customer,
environment,
request.params["model"].replace(".", "_"),
request.params["method"],
]
elif path_info.startswith("/web/dataset/exec_workflow"):
parts += [
"workflow",
customer,
environment,
request.params["model"].replace(".", "_"),
request.params["signal"],
]
else:
parts += ['request',
customer, environment,
]
parts += [
"request",
customer,
environment,
]
with statsd.timer('.'.join(parts)):
with statsd.timer(".".join(parts)):
return super()._dispatch()
+20 -22
View File
@@ -3,7 +3,6 @@
import logging
import os
from distutils.util import strtobool
from odoo.tools.config import config
@@ -14,40 +13,39 @@ try:
from statsd import defaults
from statsd.client import StatsClient
except ImportError:
_logger.warning('statds must be installed')
_logger.warning("statds must be installed")
defaults = None # noqa
StatsClient = None # noqa
def is_true(strval):
return bool(strtobool(strval or '0'.lower()))
return bool(strtobool(strval or "0".lower()))
statsd_active = is_true(os.environ.get('ODOO_STATSD'))
statsd_active = is_true(os.environ.get("ODOO_STATSD"))
statsd = None
customer = None
environment = None
if statsd_active and statsd is None and StatsClient is not None:
if not os.environ.get('STATSD_CUSTOMER'):
raise Exception(
'STATSD_CUSTOMER must contain the name of the customer'
)
customer = os.environ.get('STATSD_CUSTOMER')
if os.environ.get('STATSD_ENVIRONMENT'):
environment = os.environ['STATSD_ENVIRONMENT']
elif config.get('running_env'):
environment = config['running_env']
if not os.environ.get("STATSD_CUSTOMER"):
raise Exception("STATSD_CUSTOMER must contain the name of the customer")
customer = os.environ.get("STATSD_CUSTOMER")
if os.environ.get("STATSD_ENVIRONMENT"):
environment = os.environ["STATSD_ENVIRONMENT"]
elif config.get("running_env"):
environment = config["running_env"]
else:
raise Exception(
'Either STATSD_ENVIRONMENT or configuration option running_env '
'must contain the environment (prod, integration, ...)'
"Either STATSD_ENVIRONMENT or configuration option running_env "
"must contain the environment (prod, integration, ...)"
)
host = os.getenv('STATSD_HOST', defaults.HOST)
port = int(os.getenv('STATSD_PORT', defaults.PORT))
prefix = os.getenv('STATSD_PREFIX', defaults.PREFIX)
maxudpsize = int(os.getenv('STATSD_MAXUDPSIZE', defaults.MAXUDPSIZE))
ipv6 = bool(int(os.getenv('STATSD_IPV6', defaults.IPV6)))
statsd = StatsClient(host=host, port=port, prefix='odoo',
maxudpsize=maxudpsize, ipv6=ipv6)
host = os.getenv("STATSD_HOST", defaults.HOST)
port = int(os.getenv("STATSD_PORT", defaults.PORT))
prefix = os.getenv("STATSD_PREFIX", defaults.PREFIX)
maxudpsize = int(os.getenv("STATSD_MAXUDPSIZE", defaults.MAXUDPSIZE))
ipv6 = bool(int(os.getenv("STATSD_IPV6", defaults.IPV6)))
statsd = StatsClient(
host=host, port=port, prefix="odoo", maxudpsize=maxudpsize, ipv6=ipv6
)