# -*- coding: utf-8 -*- # Part of Odoo, Flectra. See LICENSE file for full copyright and licensing details. import logging import os import subprocess import threading from flectra import http from flectra.addons.hw_proxy.controllers import main as hw_proxy _logger = logging.getLogger(__name__) upgrade_template = """
This tool will help you perform an upgrade of the PosBox's software over the internet.
However the preferred method to upgrade the posbox is to flash the sd-card with the latest image. The upgrade procedure is explained into to the PosBox manualTo upgrade the posbox, click on the upgrade button. The upgrade will take a few minutes. Do not reboot the PosBox during the upgrade.
Latest patch:
""" upgrade_template += subprocess.check_output("git --work-tree=/home/pi/flectra/ --git-dir=/home/pi/flectra/.git log -1", shell=True).replace("\n", """" class PosboxUpgrader(hw_proxy.Proxy): def __init__(self): super(PosboxUpgrader,self).__init__() self.upgrading = threading.Lock() @http.route('/hw_proxy/upgrade', type='http', auth='none', ) def upgrade(self): return upgrade_template @http.route('/hw_proxy/perform_upgrade', type='http', auth='none') def perform_upgrade(self): self.upgrading.acquire() os.system('/home/pi/flectra/addons/point_of_sale/tools/posbox/configuration/posbox_update.sh') self.upgrading.release() return 'SUCCESS'
") upgrade_template += """