From ec9759a6c009e32b4867eedd5f4e639416d10cba Mon Sep 17 00:00:00 2001 From: Antoine Prieels Date: Fri, 5 Jun 2020 06:30:20 +0000 Subject: [PATCH] [FIX] hw_drivers: Failed checkout and drivers loading - The checkout to switch to the branch of the connected DB was not processed correctly because the command used to clear the drivers failed, raising an exception: rm: cannot remove '/home/pi/odoo/addons/hw_drivers/drivers/__pycache__': Is a directory - The location of the drivers has been changed in master. So, even if we perform a checkout, the addons/hw_drivers/drivers directory doesn't exist. The get_resource_path('hw_drivers', 'drivers') then returned False instead of the correct path and the extraction of the zip file failed. closes odoo/odoo#52448 Signed-off-by: Quentin Lejeune (qle) --- addons/hw_drivers/tools/helpers.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/addons/hw_drivers/tools/helpers.py b/addons/hw_drivers/tools/helpers.py index 5641f46b8b3..225c0ea3599 100644 --- a/addons/hw_drivers/tools/helpers.py +++ b/addons/hw_drivers/tools/helpers.py @@ -79,8 +79,8 @@ def check_git_branch(): if db_branch != local_branch: subprocess.check_call(["sudo", "mount", "-o", "remount,rw", "/"]) - subprocess.check_call(["rm", "/home/pi/odoo/addons/hw_drivers/iot_handlers/drivers/*"]) - subprocess.check_call(["rm", "/home/pi/odoo/addons/hw_drivers/iot_handlers/interfaces/*"]) + subprocess.check_call(["rm", "-rf", "/home/pi/odoo/addons/hw_drivers/iot_handlers/drivers/*"]) + subprocess.check_call(["rm", "-rf", "/home/pi/odoo/addons/hw_drivers/iot_handlers/interfaces/*"]) subprocess.check_call(git + ['branch', '-m', db_branch]) subprocess.check_call(git + ['remote', 'set-branches', 'origin', db_branch]) os.system('/home/pi/odoo/addons/point_of_sale/tools/posbox/configuration/posbox_update.sh') @@ -209,8 +209,9 @@ def download_iot_handlers(auto=True): resp = pm.request('POST', server, fields={'mac': get_mac_address(), 'auto': auto}) if resp.data: subprocess.check_call(["sudo", "mount", "-o", "remount,rw", "/"]) + drivers_path = Path.home() / 'odoo/addons/hw_drivers/iot_handlers' zip_file = zipfile.ZipFile(io.BytesIO(resp.data)) - zip_file.extractall(get_resource_path('hw_drivers', 'iot_handlers')) + zip_file.extractall(drivers_path) subprocess.check_call(["sudo", "mount", "-o", "remount,ro", "/"]) subprocess.check_call(["sudo", "mount", "-o", "remount,rw", "/root_bypass_ramdisks/etc/cups"]) except Exception as e: