Browse Source

[11.0][MIG] Migrate dead_mans_switch_client to 11.0

- Model ir.cron has changed slightly
- urllib2 no longer exists in Python 3
- Strings given to urllib.requests.Request must be encoded as bytes
pull/1277/head
Atte Isopuro 6 years ago
committed by Miku Laitinen
parent
commit
a748e4a9cc
  1. 1
      dead_mans_switch_client/__init__.py
  2. 2
      dead_mans_switch_client/__manifest__.py
  3. 1
      dead_mans_switch_client/data/ir_actions.xml
  4. 5
      dead_mans_switch_client/data/ir_cron.xml
  5. 15
      dead_mans_switch_client/models/dead_mans_switch_client.py
  6. 1
      dead_mans_switch_client/tests/test_dead_mans_switch_client.py

1
dead_mans_switch_client/__init__.py

@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
# © 2015 Therp BV <http://therp.nl>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from . import models

2
dead_mans_switch_client/__manifest__.py

@ -4,7 +4,7 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
{
"name": "Dead man's switch (client)",
"version": "10.0.1.0.0",
"version": "11.0.1.0.0",
"author": "Therp BV, Odoo Community Association (OCA)",
"license": "AGPL-3",
"category": "Monitoring",

1
dead_mans_switch_client/data/ir_actions.xml

@ -5,7 +5,6 @@
context="{'default_key': 'dead_mans_switch_client.url'}"/>
<record id="todo_setup" model="ir.actions.todo">
<field name="name">Configure the dead man's switch server</field>
<field name="type">automatic</field>
<field name="action_id" ref="action_setup"/>
</record>
</odoo>

5
dead_mans_switch_client/data/ir_cron.xml

@ -5,7 +5,8 @@
<field name="interval_number">5</field>
<field name="interval_type">minutes</field>
<field name="numbercall">-1</field>
<field name="model">dead.mans.switch.client</field>
<field name="function">alive</field>
<field name="model_id" ref="dead_mans_switch_client.model_dead_mans_switch_client"/>
<field name="state">code</field>
<field name="code">model.alive()</field>
</record>
</odoo>

15
dead_mans_switch_client/models/dead_mans_switch_client.py

@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
# © 2015-2016 Therp BV <http://therp.nl>
# © 2015 Grupo ESOC Ingeniería de Servicios, S.L.U. - Jairo Llopis
# © 2017 Avoin.Systems - Miku Laitinen
@ -10,7 +9,7 @@ try:
import psutil
except ImportError: # pragma: no cover
psutil = None
import urllib2
import urllib
from odoo import api, models
from odoo.tools.config import config
@ -72,15 +71,15 @@ class DeadMansSwitchClient(models.AbstractModel):
'dead_mans_switch_client.send_timeout', SEND_TIMEOUT)
data = self._get_data()
logger.debug('sending %s', data)
urllib2.urlopen(
urllib2.Request(
url,
json.dumps({
urllib.request.urlopen(
urllib.request.Request(
url=url,
data=json.dumps({
'jsonrpc': '2.0',
'method': 'call',
'params': data,
}),
{
}).encode('utf-8'),
headers={
'Content-Type': 'application/json',
}),
timeout=timeout)

1
dead_mans_switch_client/tests/test_dead_mans_switch_client.py

@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
# © 2015 Therp BV <http://therp.nl>
# © 2017 Avoin.Systems - Miku Laitinen
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

Loading…
Cancel
Save