Skip to content
Snippets Groups Projects
Commit 95538713 authored by lejeune quentin's avatar lejeune quentin
Browse files

[FIX] hw_drivers: Restart Odoo after IoT has connected


When the route '/hw_drivers/box/connect' is called to connect an IoT Box to a DB,
the checkout on the branch of the DB is not performed and incompatibility can occur.

With this fix we relaunch Odoo via a parallel thread in order to be able to respond to the request...

closes odoo/odoo#52513

X-original-commit: 9aca7c46
Signed-off-by: default avatarQuentin Lejeune (qle) <qle@odoo.com>
parent 82afffac
Branches
Tags
No related merge requests found
......@@ -80,10 +80,9 @@ class StatusController(http.Controller):
helpers.add_credential(db_uuid, enterprise_code)
try:
subprocess.check_call([get_resource_path('point_of_sale', 'tools/posbox/configuration/connect_to_server.sh'), url, '', token, 'noreboot'])
helpers.check_certificate()
m.send_alldevices()
m.load_iot_handlers()
image = get_resource_path('hw_drivers', 'static/img', 'True.jpg')
helpers.odoo_restart(3)
except subprocess.CalledProcessError as e:
_logger.error('A error encountered : %s ' % e.output)
if os.path.isfile(image):
......
......@@ -12,6 +12,8 @@ import logging
import os
import subprocess
import zipfile
from threading import Thread
import time
from odoo import _
from odoo.modules.module import get_resource_path
......@@ -22,6 +24,18 @@ _logger = logging.getLogger(__name__)
# Helper
#----------------------------------------------------------
class IoTRestart(Thread):
"""
Thread to restart odoo server in IoT Box when we must return a answer before
"""
def __init__(self, delay):
Thread.__init__(self)
self.delay = delay
def run(self):
time.sleep(self.delay)
subprocess.check_call(["sudo", "service", "odoo", "restart"])
def access_point():
return get_ip() == '10.11.12.1'
......@@ -218,6 +232,10 @@ def download_iot_handlers(auto=True):
_logger.error('Could not reach configured server')
_logger.error('A error encountered : %s ' % e)
def odoo_restart(delay):
IR = IoTRestart(delay)
IR.start()
def read_file_first_line(filename):
path = Path.home() / filename
path = Path('/home/pi/' + filename)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment