servo_test: Fix lint error
This includes:
- logging style
- bad indention
- unused import
- unnecessary semicolon
- redefined name
BUG=chromium-os:35902
TEST=Run FAFT suite and still work.
Change-Id: I7d50176f12b2815f53b0aba762f4b6243b706206
Reviewed-on: https://gerrit.chromium.org/gerrit/37520
Reviewed-by: Vadim Bendebury <vbendeb@chromium.org>
Reviewed-by: Mike Truty <truty@chromium.org>
Reviewed-by: Tom Wai-Hong Tam <waihong@chromium.org>
Commit-Ready: Vic Yang <victoryang@chromium.org>
Tested-by: Vic Yang <victoryang@chromium.org>
diff --git a/server/cros/servo.py b/server/cros/servo.py
index c163ab4..bba32b1 100644
--- a/server/cros/servo.py
+++ b/server/cros/servo.py
@@ -5,8 +5,7 @@
# Expects to be run in an environment with sudo and no interactive password
# prompt, such as within the Chromium OS development chroot.
-import logging, os, re, select, subprocess, sys, time, xmlrpclib
-from autotest_lib.client.bin import utils as client_utils
+import logging, re, time, xmlrpclib
from autotest_lib.client.common_lib import error
from autotest_lib.server import utils
@@ -104,14 +103,14 @@
"""
servo_host = Servo._make_servo_hostname(target_hostname)
if utils.host_is_in_lab_zone(servo_host):
- try:
- return Servo(servo_host=servo_host)
- except:
- # TODO(jrbarnette): Long-term, if we can't get to
- # a servo in the lab, we want to fail, so we should
- # pass any exceptions along. Short-term, we're not
- # ready to rely on servo, so we ignore failures.
- pass
+ try:
+ return Servo(servo_host=servo_host)
+ except: # pylint: disable=W0702
+ # TODO(jrbarnette): Long-term, if we can't get to
+ # a servo in the lab, we want to fail, so we should
+ # pass any exceptions along. Short-term, we're not
+ # ready to rely on servo, so we ignore failures.
+ pass
return None
@@ -547,8 +546,8 @@
logging.info('Recovery process completed successfully in '
'%d seconds.', time.time() - start_time)
else:
- logger.error('Host failed to come back up in the allotted '
- 'time: %d seconds.', wait_timeout)
+ logging.error('Host failed to come back up in the allotted '
+ 'time: %d seconds.', wait_timeout)
logging.info('Removing the usb key from the DUT.')
self.disable_usb_hub()
except:
diff --git a/server/cros/servo_test.py b/server/cros/servo_test.py
index 46dab0a..469b471 100644
--- a/server/cros/servo_test.py
+++ b/server/cros/servo_test.py
@@ -11,7 +11,7 @@
import xmlrpclib
from autotest_lib.client.common_lib import error
-from autotest_lib.server import autotest, site_host_attributes, test, utils
+from autotest_lib.server import autotest, site_host_attributes, test
from autotest_lib.server.cros import servo
class ServoTest(test.test):
@@ -126,7 +126,7 @@
launched and connected.
"""
# Initialize servotest args.
- self._client = host;
+ self._client = host
self._remote_infos['pyauto']['used'] = use_pyauto
self._remote_infos['faft']['used'] = use_faft
@@ -196,11 +196,11 @@
# Launch RPC server remotely.
self._kill_remote_process(info)
- logging.info('Client command: %s' % info['remote_command'])
+ logging.info('Client command: %s', info['remote_command'])
if 'remote_log_file' in info:
- log_file = info['remote_log_file']
+ log_file = info['remote_log_file']
else:
- log_file = '/dev/null'
+ log_file = '/dev/null'
logging.info("Logging to %s", log_file)
info['remote_process'] = subprocess.Popen([
'ssh -n -q %s root@%s \'%s &> %s\'' % (info['ssh_config'],
@@ -212,7 +212,7 @@
remote_url = 'http://localhost:%s' % info['port']
setattr(self, info['ref_name'],
xmlrpclib.ServerProxy(remote_url, allow_none=True))
- logging.info('Server proxy: %s' % remote_url)
+ logging.info('Server proxy: %s', remote_url)
# We found that the following RPC call retrial doesn't work all the
# time and causes timeout error happened. So add this delay to wait
@@ -223,7 +223,7 @@
# Poll for client RPC server to come online.
timeout = 20
succeed = False
- error = None
+ rpc_error = None
while timeout > 0 and not succeed:
time.sleep(1)
try:
@@ -234,15 +234,15 @@
except (socket.error, xmlrpclib.ProtocolError) as e:
# The client RPC server may not come online fast enough. Retry.
timeout -= 1
- error = e
+ rpc_error = e
if not succeed:
- if isinstance(error, xmlrpclib.ProtocolError):
+ if isinstance(rpc_error, xmlrpclib.ProtocolError):
logging.info("A protocol error occurred")
- logging.info("URL: %s", error.url)
- logging.info("HTTP/HTTPS headers: %s", error.headers)
- logging.info("Error code: %d", error.errcode)
- logging.info("Error message: %s", error.errmsg)
+ logging.info("URL: %s", rpc_error.url)
+ logging.info("HTTP/HTTPS headers: %s", rpc_error.headers)
+ logging.info("Error code: %d", rpc_error.errcode)
+ logging.info("Error message: %s", rpc_error.errmsg)
if 'remote_log_file' in info:
p = subprocess.Popen([
'ssh -n -q %s root@%s \'cat %s\'' % (info['ssh_config'],
@@ -278,7 +278,7 @@
self._autotest_client = autotest.Autotest(self._client)
self._autotest_client.run_test(info['client_test'])
self.launch_client(info)
- logging.info('Server: Relaunched remote %s.' % name)
+ logging.info('Server: Relaunched remote %s.', name)
def wait_for_client_offline(self, timeout=60):