We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
[8.0][dead_mans_switch_client] Module crashes runbots
I'm seeing more and more runbots with :x: because of this module. [This seems the offending line](https://github.com/OCA/server-tools/blob/8.0/dead_mans_switch_client/models/dead_mans_switch_client.py#L54). Any clue on how to fix it?

Example runbot: https://runbot.odoo-community.org/runbot/build/3137787

CC @hbrunn.


--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `dead_mans_switch_client/__openerp__.py`
Content:
```
1 # -*- coding: utf-8 -*-
2 # © 2015 Therp BV <http://therp.nl>
3 # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
4 {
5     "name": "Dead man's switch (client)",
6     "version": "8.0.1.0.0",
7     "author": "Therp BV,Odoo Community Association (OCA)",
8     "license": "AGPL-3",
9     "category": "Monitoring",
10     "summary": "Be notified when customers' odoo instances go down",
11     "depends": [
12         'base',
13     ],
14     "data": [
15         "data/ir_actions.xml",
16         "data/ir_cron.xml",
17     ],
18 }
19
```

Path: `dead_mans_switch_client/models/dead_mans_switch_client.py`
Content:
```
1 # -*- coding: utf-8 -*-
2 # © 2015 Therp BV <http://therp.nl>
3 # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
4 import json
5 import logging
6 import os
7 try:
8     import psutil
9 except ImportError:
10     psutil = None
11 import urllib2
12 from openerp import api, models
13 
14 
15 class DeadMansSwitchClient(models.AbstractModel):
16     _name = 'dead.mans.switch.client'
17     _register = True
18 
19     @api.model
20     def _get_data(self):
21         ram = 0
22         cpu = 0
23         if psutil:
24             process = psutil.Process(os.getpid())
25             # psutil changed its api through versions
26             if process.parent:
27                 if hasattr(process.parent, '__call__'):
28                     process = process.parent()
29                 else:
30                     process = process.parent
31             if hasattr(process, 'memory_percent'):
32                 ram = process.memory_percent()
33             if hasattr(process, 'cpu_percent'):
34                 cpu = process.cpu_percent()
35         user_count = 0
36         if 'im_chat.presence' in self.env.registry:
37             user_count = len(self.env['im_chat.presence'].search([
38                 ('status', '!=', 'offline'),
39             ]))
40         return {
41             'database_uuid': self.env['ir.config_parameter'].get_param(
42                 'database.uuid'),
43             'cpu': cpu,
44             'ram': ram,
45             'user_count': user_count,
46         }
47 
48     @api.model
49     def alive(self):
50         url = self.env['ir.config_parameter'].get_param(
51             'dead_mans_switch_client.url')
52         logger = logging.getLogger(__name__)
53         if not url:
54             logger.error('No server configured!')
55             return
56         data = self._get_data()
57         logger.debug('sending %s', data)
58         urllib2.urlopen(
59             urllib2.Request(
60                 url,
61                 json.dumps({
62                     'jsonrpc': '2.0',
63                     'method': 'call',
64                     'params': data,
65                 }),
66                 {
67                     'Content-Type': 'application/json',
68                 }))
69
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/dead_mans_switch_client/__openerp__.py b/dead_mans_switch_client/__openerp__.py
--- a/dead_mans_switch_client/__openerp__.py
+++ b/dead_mans_switch_client/__openerp__.py
@@ -3,7 +3,7 @@
 # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
 {
     "name": "Dead man's switch (client)",
-    "version": "8.0.1.0.0",
+    "version": "8.0.1.0.1",
     "author": "Therp BV,Odoo Community Association (OCA)",
     "license": "AGPL-3",
     "category": "Monitoring",
@@ -15,4 +15,7 @@
         "data/ir_actions.xml",
         "data/ir_cron.xml",
     ],
+    "demo": [
+        "demo/dead_mans_switch_client_demo.yml",
+    ],
 }
diff --git a/dead_mans_switch_client/models/dead_mans_switch_client.py b/dead_mans_switch_client/models/dead_mans_switch_client.py
--- a/dead_mans_switch_client/models/dead_mans_switch_client.py
+++ b/dead_mans_switch_client/models/dead_mans_switch_client.py
@@ -1,5 +1,6 @@
 # -*- coding: utf-8 -*-
 # © 2015 Therp BV <http://therp.nl>
+# © 2015 Grupo ESOC Ingeniería de Servicios, S.L.U. - Jairo Llopis
 # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
 import json
 import logging
@@ -66,3 +67,19 @@
                 {
                     'Content-Type': 'application/json',
                 }))
+
+    @api.model
+    def _install_default_url(self):
+        """Set up a default URL."""
+        conf = self.env["ir.config_parameter"]
+        name = "dead_mans_switch_client.url"
+        param = conf.get_param(name)
+
+        if not param:
+            url = "{}/dead_mans_switch/alive".format(
+                conf.get_param(
+                    "report.url",
+                    conf.get_param(
+                        "web.base.url",
+                        "http://localhost")))
+            conf.set_param(name, url)

{"golden_diff": "diff --git a/dead_mans_switch_client/__openerp__.py b/dead_mans_switch_client/__openerp__.py\n--- a/dead_mans_switch_client/__openerp__.py\n+++ b/dead_mans_switch_client/__openerp__.py\n@@ -3,7 +3,7 @@\n # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).\n {\n     \"name\": \"Dead man's switch (client)\",\n-    \"version\": \"8.0.1.0.0\",\n+    \"version\": \"8.0.1.0.1\",\n     \"author\": \"Therp BV,Odoo Community Association (OCA)\",\n     \"license\": \"AGPL-3\",\n     \"category\": \"Monitoring\",\n@@ -15,4 +15,7 @@\n         \"data/ir_actions.xml\",\n         \"data/ir_cron.xml\",\n     ],\n+    \"demo\": [\n+        \"demo/dead_mans_switch_client_demo.yml\",\n+    ],\n }\ndiff --git a/dead_mans_switch_client/models/dead_mans_switch_client.py b/dead_mans_switch_client/models/dead_mans_switch_client.py\n--- a/dead_mans_switch_client/models/dead_mans_switch_client.py\n+++ b/dead_mans_switch_client/models/dead_mans_switch_client.py\n@@ -1,5 +1,6 @@\n # -*- coding: utf-8 -*-\n # \u00a9 2015 Therp BV <http://therp.nl>\n+# \u00a9 2015 Grupo ESOC Ingenier\u00eda de Servicios, S.L.U. - Jairo Llopis\n # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).\n import json\n import logging\n@@ -66,3 +67,19 @@\n                 {\n                     'Content-Type': 'application/json',\n                 }))\n+\n+    @api.model\n+    def _install_default_url(self):\n+        \"\"\"Set up a default URL.\"\"\"\n+        conf = self.env[\"ir.config_parameter\"]\n+        name = \"dead_mans_switch_client.url\"\n+        param = conf.get_param(name)\n+\n+        if not param:\n+            url = \"{}/dead_mans_switch/alive\".format(\n+                conf.get_param(\n+                    \"report.url\",\n+                    conf.get_param(\n+                        \"web.base.url\",\n+                        \"http://localhost\")))\n+            conf.set_param(name, url)\n", "issue": "[8.0][dead_mans_switch_client] Module crashes runbots\nI'm seeing more and more runbots with :x: because of this module. [This seems the offending line](https://github.com/OCA/server-tools/blob/8.0/dead_mans_switch_client/models/dead_mans_switch_client.py#L54). Any clue on how to fix it?\n\nExample runbot: https://runbot.odoo-community.org/runbot/build/3137787\n\nCC @hbrunn.\n\n", "before_files": [{"content": "# -*- coding: utf-8 -*-\n# \u00a9 2015 Therp BV <http://therp.nl>\n# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).\n{\n    \"name\": \"Dead man's switch (client)\",\n    \"version\": \"8.0.1.0.0\",\n    \"author\": \"Therp BV,Odoo Community Association (OCA)\",\n    \"license\": \"AGPL-3\",\n    \"category\": \"Monitoring\",\n    \"summary\": \"Be notified when customers' odoo instances go down\",\n    \"depends\": [\n        'base',\n    ],\n    \"data\": [\n        \"data/ir_actions.xml\",\n        \"data/ir_cron.xml\",\n    ],\n}\n", "path": "dead_mans_switch_client/__openerp__.py"}, {"content": "# -*- coding: utf-8 -*-\n# \u00a9 2015 Therp BV <http://therp.nl>\n# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).\nimport json\nimport logging\nimport os\ntry:\n    import psutil\nexcept ImportError:\n    psutil = None\nimport urllib2\nfrom openerp import api, models\n\n\nclass DeadMansSwitchClient(models.AbstractModel):\n    _name = 'dead.mans.switch.client'\n    _register = True\n\n    @api.model\n    def _get_data(self):\n        ram = 0\n        cpu = 0\n        if psutil:\n            process = psutil.Process(os.getpid())\n            # psutil changed its api through versions\n            if process.parent:\n                if hasattr(process.parent, '__call__'):\n                    process = process.parent()\n                else:\n                    process = process.parent\n            if hasattr(process, 'memory_percent'):\n                ram = process.memory_percent()\n            if hasattr(process, 'cpu_percent'):\n                cpu = process.cpu_percent()\n        user_count = 0\n        if 'im_chat.presence' in self.env.registry:\n            user_count = len(self.env['im_chat.presence'].search([\n                ('status', '!=', 'offline'),\n            ]))\n        return {\n            'database_uuid': self.env['ir.config_parameter'].get_param(\n                'database.uuid'),\n            'cpu': cpu,\n            'ram': ram,\n            'user_count': user_count,\n        }\n\n    @api.model\n    def alive(self):\n        url = self.env['ir.config_parameter'].get_param(\n            'dead_mans_switch_client.url')\n        logger = logging.getLogger(__name__)\n        if not url:\n            logger.error('No server configured!')\n            return\n        data = self._get_data()\n        logger.debug('sending %s', data)\n        urllib2.urlopen(\n            urllib2.Request(\n                url,\n                json.dumps({\n                    'jsonrpc': '2.0',\n                    'method': 'call',\n                    'params': data,\n                }),\n                {\n                    'Content-Type': 'application/json',\n                }))\n", "path": "dead_mans_switch_client/models/dead_mans_switch_client.py"}], "after_files": [{"content": "# -*- coding: utf-8 -*-\n# \u00a9 2015 Therp BV <http://therp.nl>\n# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).\n{\n    \"name\": \"Dead man's switch (client)\",\n    \"version\": \"8.0.1.0.1\",\n    \"author\": \"Therp BV,Odoo Community Association (OCA)\",\n    \"license\": \"AGPL-3\",\n    \"category\": \"Monitoring\",\n    \"summary\": \"Be notified when customers' odoo instances go down\",\n    \"depends\": [\n        'base',\n    ],\n    \"data\": [\n        \"data/ir_actions.xml\",\n        \"data/ir_cron.xml\",\n    ],\n    \"demo\": [\n        \"demo/dead_mans_switch_client_demo.yml\",\n    ],\n}\n", "path": "dead_mans_switch_client/__openerp__.py"}, {"content": "# -*- coding: utf-8 -*-\n# \u00a9 2015 Therp BV <http://therp.nl>\n# \u00a9 2015 Grupo ESOC Ingenier\u00eda de Servicios, S.L.U. - Jairo Llopis\n# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).\nimport json\nimport logging\nimport os\ntry:\n    import psutil\nexcept ImportError:\n    psutil = None\nimport urllib2\nfrom openerp import api, models\n\n\nclass DeadMansSwitchClient(models.AbstractModel):\n    _name = 'dead.mans.switch.client'\n    _register = True\n\n    @api.model\n    def _get_data(self):\n        ram = 0\n        cpu = 0\n        if psutil:\n            process = psutil.Process(os.getpid())\n            # psutil changed its api through versions\n            if process.parent:\n                if hasattr(process.parent, '__call__'):\n                    process = process.parent()\n                else:\n                    process = process.parent\n            if hasattr(process, 'memory_percent'):\n                ram = process.memory_percent()\n            if hasattr(process, 'cpu_percent'):\n                cpu = process.cpu_percent()\n        user_count = 0\n        if 'im_chat.presence' in self.env.registry:\n            user_count = len(self.env['im_chat.presence'].search([\n                ('status', '!=', 'offline'),\n            ]))\n        return {\n            'database_uuid': self.env['ir.config_parameter'].get_param(\n                'database.uuid'),\n            'cpu': cpu,\n            'ram': ram,\n            'user_count': user_count,\n        }\n\n    @api.model\n    def alive(self):\n        url = self.env['ir.config_parameter'].get_param(\n            'dead_mans_switch_client.url')\n        logger = logging.getLogger(__name__)\n        if not url:\n            logger.error('No server configured!')\n            return\n        data = self._get_data()\n        logger.debug('sending %s', data)\n        urllib2.urlopen(\n            urllib2.Request(\n                url,\n                json.dumps({\n                    'jsonrpc': '2.0',\n                    'method': 'call',\n                    'params': data,\n                }),\n                {\n                    'Content-Type': 'application/json',\n                }))\n\n    @api.model\n    def _install_default_url(self):\n        \"\"\"Set up a default URL.\"\"\"\n        conf = self.env[\"ir.config_parameter\"]\n        name = \"dead_mans_switch_client.url\"\n        param = conf.get_param(name)\n\n        if not param:\n            url = \"{}/dead_mans_switch/alive\".format(\n                conf.get_param(\n                    \"report.url\",\n                    conf.get_param(\n                        \"web.base.url\",\n                        \"http://localhost\")))\n            conf.set_param(name, url)\n", "path": "dead_mans_switch_client/models/dead_mans_switch_client.py"}]}