[toolchain-utils] Fix remaining lint errors in toolchain-utils.
In addition to fixing the lint errors, this also fixes the Python
formatting issues (ran tc_pyformat on nearly all the files).
BUG=chromium:570450
TEST=Ran all crosperf & bisect tool unit tests.
Ran afe_lock_machine.py (check machine status)
Ran full crosperf test (octane, speedometer, BootPerf) on alex.
Change-Id: Ic86f9192801ac67769f3de30f1c5f0d203ce0831
Reviewed-on: https://chromium-review.googlesource.com/471886
Commit-Ready: Caroline Tice <cmtice@chromium.org>
Tested-by: Caroline Tice <cmtice@chromium.org>
Reviewed-by: Manoj Gupta <manojgupta@chromium.org>
diff --git a/afe_lock_machine.py b/afe_lock_machine.py
index 125ac97..370579d 100755
--- a/afe_lock_machine.py
+++ b/afe_lock_machine.py
@@ -1,4 +1,4 @@
-#!/usr/bin/python2
+#!/usr/bin/env python2
#
# Copyright 2015 Google INc. All Rights Reserved.
"""This module controls locking and unlocking of test machines."""
@@ -97,6 +97,7 @@
machines that are not in the ChromeOS HW lab.
local: A Boolean indicating whether or not to use/allow a local AFE
server to be used (see local_server argument).
+ use_local: Use the local server instead of the official one.
log: If not None, this is the logger object to be used for writing out
informational output messages. It is expected to be an instance of
Logger class from cros_utils/logger.py.
@@ -272,9 +273,9 @@
for m in self.machines:
for cros_name in [m, m + '.cros']:
if cros_name in self.toolchain_lab_machines:
- raise UpdateNonLocalMachine('Machine %s is already in the ChromeOS HW'
- 'Lab. Cannot add it to local server.' %
- cros_name)
+ raise UpdateNonLocalMachine(
+ 'Machine %s is already in the ChromeOS HW'
+ 'Lab. Cannot add it to local server.' % cros_name)
host_info = self.local_afe.get_hosts(hostname=m)
if host_info:
raise DuplicateAdd('Machine %s is already on the local server.' % m)
@@ -380,9 +381,10 @@
afe_server = self.local_afe
try:
- afe_server.run('modify_hosts',
- host_filter_data={'hostname__in': [m]},
- update_data=kwargs)
+ afe_server.run(
+ 'modify_hosts',
+ host_filter_data={'hostname__in': [m]},
+ update_data=kwargs)
except Exception as e:
traceback.print_exc()
raise LockingError('Unable to %s machine %s. %s' % (action, m, str(e)))
@@ -426,8 +428,9 @@
if machine.find('.cros') == -1:
cros_machine = cros_machine + '.cros'
- self.machines = [m for m in self.machines
- if m != cros_machine and m != machine]
+ self.machines = [
+ m for m in self.machines if m != cros_machine and m != machine
+ ]
def CheckMachineLocks(self, machine_states, cmd):
"""Check that every machine in requested list is in the proper state.
@@ -456,8 +459,8 @@
'else (%s).' % (k, state['locked_by']))
elif cmd == 'lock':
if state['locked']:
- self.logger.LogWarning('Attempt to lock already locked machine (%s)' %
- k)
+ self.logger.LogWarning(
+ 'Attempt to lock already locked machine (%s)' % k)
self._InternalRemoveMachine(k)
def HasAFEServer(self, local):