Skip to content
Snippets Groups Projects
Commit 3833c899 authored by Xavier Morel's avatar Xavier Morel
Browse files

[FIX] P3: removed commands module

parent b9c3365d
No related branches found
No related tags found
No related merge requests found
...@@ -2,7 +2,6 @@ ...@@ -2,7 +2,6 @@
# Part of Odoo. See LICENSE file for full copyright and licensing details. # Part of Odoo. See LICENSE file for full copyright and licensing details.
from __future__ import print_function from __future__ import print_function
import commands
import logging import logging
import math import math
import os import os
...@@ -196,7 +195,7 @@ class EscposDriver(Thread): ...@@ -196,7 +195,7 @@ class EscposDriver(Thread):
hosting_ap = os.system('pgrep hostapd') == 0 hosting_ap = os.system('pgrep hostapd') == 0
ssid = subprocess.check_output('iwconfig 2>&1 | grep \'ESSID:"\' | sed \'s/.*"\\(.*\\)"/\\1/\'', shell=True).rstrip() ssid = subprocess.check_output('iwconfig 2>&1 | grep \'ESSID:"\' | sed \'s/.*"\\(.*\\)"/\\1/\'', shell=True).rstrip()
mac = subprocess.check_output('ifconfig | grep -B 1 \'inet addr\' | grep -o \'HWaddr .*\' | sed \'s/HWaddr //\'', shell=True).rstrip() mac = subprocess.check_output('ifconfig | grep -B 1 \'inet addr\' | grep -o \'HWaddr .*\' | sed \'s/HWaddr //\'', shell=True).rstrip()
ips = [ c.split(':')[1].split(' ')[0] for c in commands.getoutput("/sbin/ifconfig").split('\n') if 'inet addr' in c ] ips = [ c.split(':')[1].split(' ')[0] for c in subprocess.check_output("/sbin/ifconfig").split('\n') if 'inet addr' in c ]
ips = [ ip for ip in ips if ip not in localips ] ips = [ ip for ip in ips if ip not in localips ]
eprint.text('\n\n') eprint.text('\n\n')
eprint.set(align='center',type='b',height=2,width=2) eprint.set(align='center',type='b',height=2,width=2)
......
...@@ -2,8 +2,8 @@ ...@@ -2,8 +2,8 @@
# Part of Odoo. See LICENSE file for full copyright and licensing details. # Part of Odoo. See LICENSE file for full copyright and licensing details.
from __future__ import print_function from __future__ import print_function
import commands
import logging import logging
import subprocess
import time import time
from threading import Lock from threading import Lock
...@@ -16,11 +16,11 @@ _logger = logging.getLogger(__name__) ...@@ -16,11 +16,11 @@ _logger = logging.getLogger(__name__)
# Those are the builtin raspberry pi USB modules, they should # Those are the builtin raspberry pi USB modules, they should
# not appear in the list of connected devices. # not appear in the list of connected devices.
BANNED_DEVICES = set([ BANNED_DEVICES = {
"0424:9514", # Standard Microsystem Corp. Builtin Ethernet module "0424:9514", # Standard Microsystem Corp. Builtin Ethernet module
"1d6b:0002", # Linux Foundation 2.0 root hub "1d6b:0002", # Linux Foundation 2.0 root hub
"0424:ec00", # Standard Microsystem Corp. Other Builtin Ethernet module "0424:ec00", # Standard Microsystem Corp. Other Builtin Ethernet module
]) }
# drivers modules must add to drivers an object with a get_status() method # drivers modules must add to drivers an object with a get_status() method
...@@ -99,14 +99,14 @@ class Proxy(http.Controller): ...@@ -99,14 +99,14 @@ class Proxy(http.Controller):
""" """
if debug is None: if debug is None:
resp += """(<a href="/hw_proxy/status?debug">debug version</a>)""" resp += """(<a href="/hw_proxy/status?debug">debug version</a>)"""
devices = commands.getoutput("lsusb").split('\n') devices = subprocess.check_output("lsusb").split('\n')
count = 0 count = 0
resp += "<div class='devices'>\n" resp += "<div class='devices'>\n"
for device in devices: for device in devices:
device_name = device[device.find('ID')+2:] device_name = device[device.find('ID')+2:]
device_id = device_name.split()[0] device_id = device_name.split()[0]
if not (device_id in BANNED_DEVICES): if not (device_id in BANNED_DEVICES):
resp+= "<div class='device' data-device='"+device+"'>"+device_name+"</div>\n" resp += "<div class='device' data-device='"+device+"'>"+device_name+"</div>\n"
count += 1 count += 1
if count == 0: if count == 0:
......
...@@ -42,6 +42,7 @@ class TestPyLint(TransactionCase): ...@@ -42,6 +42,7 @@ class TestPyLint(TransactionCase):
'parameter-unpacking', 'parameter-unpacking',
'metaclass-assignment', 'metaclass-assignment',
'deprecated-module',
'exception-message-attribute', 'exception-message-attribute',
'indexing-exception', 'indexing-exception',
...@@ -70,6 +71,11 @@ class TestPyLint(TransactionCase): ...@@ -70,6 +71,11 @@ class TestPyLint(TransactionCase):
'reduce', 'reduce',
] ]
BAD_MODULES = [
'commands',
'types',
]
def _skip_test(self, reason): def _skip_test(self, reason):
_logger.warn(reason) _logger.warn(reason)
self.skipTest(reason) self.skipTest(reason)
...@@ -93,6 +99,7 @@ class TestPyLint(TransactionCase): ...@@ -93,6 +99,7 @@ class TestPyLint(TransactionCase):
"--msg-template='{msg} ({msg_id}) at {path}:{line}'", "--msg-template='{msg} ({msg_id}) at {path}:{line}'",
'--load-plugins=pylint.extensions.bad_builtin', '--load-plugins=pylint.extensions.bad_builtin',
'--bad-functions=%s' % ','.join(self.BAD_FUNCTIONS), '--bad-functions=%s' % ','.join(self.BAD_FUNCTIONS),
'--deprecated-modules=%s' % ','.join(self.BAD_MODULES)
] ]
try: try:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment