[REF] hw_posbox_homepage: Use helpers to get mac address in homepage

We use a library to get mac address of IoT in homepage.

however we already have a function that does this in the helper in hw_drivers

closes odoo/odoo#46631

X-original-commit: ae78e9cdde777ffac6f08a35dd00a540c92130bb
Signed-off-by: Quentin Lejeune (qle) <qle@odoo.com>
This commit is contained in:
lejeune quentin
2020-03-02 09:01:11 +00:00
parent 159699b09c
commit ee519c222f
3 changed files with 2 additions and 12 deletions
+1 -6
View File
@@ -12,7 +12,6 @@ import base64
import re
import subprocess
import tempfile
from uuid import getnode as get_mac
from PIL import Image, ImageOps
from odoo import http, _
@@ -251,14 +250,10 @@ class PrinterDriver(Driver):
else:
ip = '\nIP Addresses:\n%s\n' % '\n'.join(ips)
mac_addr = get_mac()
h = iter(hex(mac_addr)[2:].zfill(12))
mac_addr = ":".join(i + next(h) for i in h)
if len(ips) >= 1:
ips_filtered = [i for i in ips if i != '127.0.0.1']
main_ips = ips_filtered and ips_filtered[0] or '127.0.0.1'
mac = '\nMAC Address:\n%s\n' % mac_addr
mac = '\nMAC Address:\n%s\n' % helpers.get_mac_address()
homepage = '\nHomepage:\nhttp://%s:8069\n\n' % main_ips
center = b'\x1b\x61\x01'
-2
View File
@@ -32,8 +32,6 @@ except ImportError:
from odoo import http, _
from odoo.addons.hw_proxy.controllers import main as hw_proxy
from uuid import getnode as get_mac
_logger = logging.getLogger(__name__)
# workaround https://bugs.launchpad.net/openobject-server/+bug/947231
@@ -15,7 +15,6 @@ from odoo.tools import misc
from pathlib import Path
import threading
from uuid import getnode as get_mac
from odoo.addons.hw_proxy.controllers import main as hw_proxy
from odoo.addons.web.controllers import main as web
from odoo.modules.module import get_resource_path
@@ -59,8 +58,6 @@ class IoTboxHomepage(web.Home):
def get_homepage_data(self):
hostname = str(socket.gethostname())
mac = get_mac()
h = iter(hex(mac)[2:].zfill(12))
ssid = helpers.get_ssid()
wired = subprocess.check_output(['cat', '/sys/class/net/eth0/operstate']).decode('utf-8').strip('\n')
if wired == 'up':
@@ -84,7 +81,7 @@ class IoTboxHomepage(web.Home):
return {
'hostname': hostname,
'ip': helpers.get_ip(),
'mac': ":".join(i + next(h) for i in h),
'mac': helpers.get_mac_address(),
'iot_device_status': iot_device,
'server_status': helpers.get_odoo_server_url() or 'Not Configured',
'network_status': network,