[FIX] P3: removed commands module

This commit is contained in:
Xavier Morel
2017-05-15 12:26:16 +02:00
parent b9c3365d21
commit 3833c8997d
3 changed files with 13 additions and 7 deletions
+1 -2
View File
@@ -2,7 +2,6 @@
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from __future__ import print_function
import commands
import logging
import math
import os
@@ -196,7 +195,7 @@ class EscposDriver(Thread):
hosting_ap = os.system('pgrep hostapd') == 0
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()
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 ]
eprint.text('\n\n')
eprint.set(align='center',type='b',height=2,width=2)
+5 -5
View File
@@ -2,8 +2,8 @@
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from __future__ import print_function
import commands
import logging
import subprocess
import time
from threading import Lock
@@ -16,11 +16,11 @@ _logger = logging.getLogger(__name__)
# Those are the builtin raspberry pi USB modules, they should
# not appear in the list of connected devices.
BANNED_DEVICES = set([
BANNED_DEVICES = {
"0424:9514", # Standard Microsystem Corp. Builtin Ethernet module
"1d6b:0002", # Linux Foundation 2.0 root hub
"0424:ec00", # Standard Microsystem Corp. Other Builtin Ethernet module
])
}
# drivers modules must add to drivers an object with a get_status() method
@@ -99,14 +99,14 @@ class Proxy(http.Controller):
"""
if debug is None:
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
resp += "<div class='devices'>\n"
for device in devices:
device_name = device[device.find('ID')+2:]
device_id = device_name.split()[0]
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
if count == 0:
@@ -42,6 +42,7 @@ class TestPyLint(TransactionCase):
'parameter-unpacking',
'metaclass-assignment',
'deprecated-module',
'exception-message-attribute',
'indexing-exception',
@@ -70,6 +71,11 @@ class TestPyLint(TransactionCase):
'reduce',
]
BAD_MODULES = [
'commands',
'types',
]
def _skip_test(self, reason):
_logger.warn(reason)
self.skipTest(reason)
@@ -93,6 +99,7 @@ class TestPyLint(TransactionCase):
"--msg-template='{msg} ({msg_id}) at {path}:{line}'",
'--load-plugins=pylint.extensions.bad_builtin',
'--bad-functions=%s' % ','.join(self.BAD_FUNCTIONS),
'--deprecated-modules=%s' % ','.join(self.BAD_MODULES)
]
try: