Pylint: fix trivial issues 3

Change-Id: If141aba37568d102524242ef22bda1ab5e68f080
fix: unused variables, cycles formed as unassigned lists
Related-bug: #1556791
This commit is contained in:
Alexey Stepanov 2016-03-14 15:07:33 +03:00
parent b661d47b32
commit 41d761bfdc
22 changed files with 55 additions and 56 deletions

View File

@ -213,7 +213,7 @@ def update_rpm_packages(func):
' packages '
'repository failed')
centos_files_count, ubuntu_files_count = \
centos_files_count, _ = \
environment.admin_actions.upload_packages(
local_packages_dir=settings.UPDATE_FUEL_PATH,
centos_repo_path=settings.LOCAL_MIRROR_CENTOS,

View File

@ -64,9 +64,9 @@ class LogServer(threading.Thread):
@logwrap
def run(self):
while self.started():
r, w, e = select.select(self.rlist, [], [], 1)
r, _, _ = select.select(self.rlist, [], [], 1)
if self.socket in r:
message, addr = self.socket.recvfrom(2048)
message, _ = self.socket.recvfrom(2048)
self._handler(message)

View File

@ -372,7 +372,7 @@ class CustomRepo(object):
if err_deps_key not in err_deps:
err_deps[err_deps_key] = set()
elif ' Requires: ' in res_str and err_deps_key:
str0, str1, str2 = res_str.partition(' Requires: ')
_, str1, str2 = res_str.partition(' Requires: ')
err_deps[err_deps_key].add(str1 + str2)
else:
err_deps_key = ''

View File

@ -115,7 +115,7 @@ def add_centos_mirrors(repos=None, mirrors=help_data.MIRROR_CENTOS,
if not repos:
repos = []
# Add external Centos repositories
for x, repo_str in enumerate(mirrors.split('|')):
for repo_str in mirrors.split('|'):
repo_value = parse_centos_repo(repo_str, priority)
if repo_value and check_new_centos_repo(repos, repo_value):
repos.append(repo_value)
@ -147,7 +147,7 @@ def add_centos_extra_mirrors(repos=None,
if not repos:
repos = []
# Add extra Centos repositories
for x, repo_str in enumerate(mirrors.split('|')):
for repo_str in mirrors.split('|'):
repo_value = parse_centos_repo(repo_str, priority)
if repo_value and check_new_centos_repo(repos, repo_value):
# Remove repos that use the same name

View File

@ -293,7 +293,7 @@ class SSHManager(object):
return 0
files_count = 0
for rootdir, subdirs, files in os.walk(source):
for rootdir, _, files in os.walk(source):
targetdir = os.path.normpath(
os.path.join(
target,

View File

@ -357,7 +357,7 @@ def cond_upload(remote, source, target, condition=''):
return 0
files_count = 0
for rootdir, subdirs, files in os.walk(source):
for rootdir, _, files in os.walk(source):
targetdir = os.path.normpath(
os.path.join(
target,
@ -975,7 +975,7 @@ def upload_tarball(ip, tar_path, tar_target):
def install_plugin_check_code(ip, plugin, exit_code=0):
# Moved from checkers.py for improvement of code
cmd = "cd /var && fuel plugins --install {0} ".format(plugin)
chan, stdin, stderr, stdout = SSHManager().execute_async_on_remote(
chan, _, stderr, _ = SSHManager().execute_async_on_remote(
ip=ip,
cmd=cmd
)

View File

@ -243,17 +243,14 @@ class FuelWebClient(object):
)
)
[actual_failed_names.append(test['name'])
for test in set_result['tests']
if test['status'] not in ['success', 'disabled', 'skipped']]
[test_result.update({test['name']:test['status']})
for test in set_result['tests']]
[failed_tests_res.append(
{'%s (%s)' % (test['name'], test['status']): test['message']})
for test in set_result['tests']
if test['status'] not in ['success', 'disabled', 'skipped']]
for test in set_result['tests']:
test_result.update({test['name']: test['status']})
if test['status'] not in ['success', 'disabled', 'skipped']:
actual_failed_names.append(test['name'])
key = ('{name:s} ({status:s})'
''.format(name=test['name'], status=test['status']))
failed_tests_res.append(
{key: test['message']})
logger.info('OSTF test statuses are :\n{}\n'.format(
pretty_log(test_result, indent=1)))
@ -413,7 +410,7 @@ class FuelWebClient(object):
def create_cluster(self,
name,
settings=None,
release_name=help_data.OPENSTACK_RELEASE,
release_name=OPENSTACK_RELEASE,
mode=DEPLOYMENT_MODE_HA,
port=514,
release_id=None,
@ -942,7 +939,7 @@ class FuelWebClient(object):
return nailgun_node
# On deployed environment MAC addresses of bonded network interfaces
# are changes and don't match addresses associated with devops node
if help_data.BONDING:
if BONDING:
return self.get_nailgun_node_by_base_name(devops_node.name)
@logwrap
@ -1966,7 +1963,7 @@ class FuelWebClient(object):
test_path = ostf_test_mapping.OSTF_TEST_MAPPING.get(test_name_to_run)
logger.info('Test path is {0}'.format(test_path))
for i in range(0, retries):
for _ in range(retries):
result = self.run_single_ostf_test(
cluster_id=cluster_id, test_sets=['smoke', 'sanity'],
test_name=test_path,
@ -1976,12 +1973,11 @@ class FuelWebClient(object):
logger.info('full res is {0}'.format(res))
for element in res:
[passed_count.append(test)
for test in element if test.get(test_name) == 'success']
[failed_count.append(test)
for test in element if test.get(test_name) == 'failure']
[failed_count.append(test)
for test in element if test.get(test_name) == 'error']
for test in element:
if test.get(test_name) == 'success':
passed_count.append(test)
elif test.get(test_name) in {'failure', 'error'}:
failed_count.append(test)
if not checks:
assert_true(
@ -2432,7 +2428,6 @@ class FuelWebClient(object):
assert_true(plugin_data is not None, "Plugin {0} version {1} is not "
"found".format(plugin_name, version))
for option, value in data.items():
plugin_data = item
path = option.split("/")
for p in path[:-1]:
plugin_data = plugin_data[p]

View File

@ -332,7 +332,7 @@ class StatisticsGenerator(object):
if test_run:
html += '<h4>TestRun: "{0}"</h4>\n'.format(test_run[0]['name'])
for bug, values in stats.items():
for values in stats.values():
if values['status'].lower() in ('invalid',):
color = 'gray'
elif values['status'].lower() in ('new', 'confirmed', 'triaged'):
@ -381,7 +381,7 @@ class StatisticsGenerator(object):
bugs_table = ('|||:Failed|:Blocked|:Project|:Priority'
'|:Status|:Bug link|:Tests\n')
for bug_id, values in stats.items():
for values in stats.values():
title = re.sub(r'(Bug\s+#\d+\s+)(in\s+[^:]+:\s+)', '\g<1>',
values['title'])
title = re.sub(r'(.{100}).*', '\g<1>...', title)

View File

@ -554,7 +554,7 @@ def main():
action="store_true", dest="verbose", default=False,
help="Enable debug output")
(options, args) = parser.parse_args()
(options, _) = parser.parse_args()
if options.verbose:
logger.setLevel(DEBUG)

View File

@ -60,7 +60,7 @@ def main():
action="store_true", dest="verbose", default=False,
help="Enable debug output")
(options, args) = parser.parse_args()
(options, _) = parser.parse_args()
if options.verbose:
logger.setLevel(DEBUG)

View File

@ -170,7 +170,7 @@ def main():
dest='prefix', action='store_true', default='',
help='Add some prefix to test run')
(options, args) = parser.parse_args()
(options, _) = parser.parse_args()
if options.run_name is None:
raise optparse.OptionValueError('No run name was specified!')

View File

@ -226,7 +226,7 @@ def main():
help='Look for existing test case only in specified '
'section of test suite.')
(options, args) = parser.parse_args()
(options, _) = parser.parse_args()
if options.verbose:
logger.setLevel(DEBUG)

View File

@ -200,8 +200,10 @@ class EMCPlugin(TestBasic):
cinder_volume_comps = [self.check_service(compute, "cinder-volume")
for compute in compute_remotes]
# closing connections
[remote.clear() for remote in controller_remotes]
[remote.clear() for remote in compute_remotes]
for remote in controller_remotes:
remote.clear()
for remote in compute_remotes:
remote.clear()
asserts.assert_equal(sum(cinder_volume_comps), 0,
"Cluster has active cinder-volume on compute")

View File

@ -833,7 +833,8 @@ class UntaggedNetworksNegative(TestBasic):
self.fuel_web.update_node_networks(node['id'], interfaces)
# select networks that will be untagged:
[net.update(vlan_turn_off) for net in nets]
for net in nets:
net.update(vlan_turn_off)
# stop using VLANs:
self.fuel_web.client.update_network(cluster_id, networks=nets)

View File

@ -138,7 +138,7 @@ class NeutronGreHa(TestBasic):
logger.debug("devops node name is {0}".format(devops_node.name))
_ip = self.fuel_web.get_nailgun_node_by_name(devops_node.name)['ip']
with self.env.d_env.get_ssh_to_remote(_ip) as remote:
for i in range(5):
for _ in range(5):
try:
checkers.check_swift_ring(_ip)
break
@ -217,7 +217,7 @@ class NeutronVlanHa(TestBasic):
logger.debug("devops node name is {0}".format(devops_node.name))
_ip = self.fuel_web.get_nailgun_node_by_name(devops_node.name)['ip']
with self.env.d_env.get_ssh_to_remote(_ip) as remote:
for i in range(5):
for _ in range(5):
try:
checkers.check_swift_ring(_ip)
break

View File

@ -258,7 +258,7 @@ class TestHaNeutronScalability(TestBasic):
def _check_swift(node):
_ip = self.fuel_web.get_nailgun_node_by_name(node.name)['ip']
with self.fuel_web.get_ssh_for_node(node.name) as remote:
for i in range(5):
for _ in range(5):
try:
checkers.check_swift_ring(_ip)
break

View File

@ -60,7 +60,7 @@ class NeutronTunHaBase(TestBasic):
logger.debug("devops node name is {0}".format(devops_node.name))
_ip = self.fuel_web.get_nailgun_node_by_devops_node(devops_node)['ip']
with self.fuel_web.get_ssh_for_node(devops_node.name) as remote:
for i in range(5):
for _ in range(5):
try:
checkers.check_swift_ring(_ip)
break

View File

@ -98,8 +98,10 @@ class MongoMultirole(TestBasic):
for node in nailgun_nodes:
self.fuel_web.update_node_networks(node['id'], interfaces)
[net.update(vlan_turn_on) for net in nets
if net['name'] == 'storage']
for net in nets:
if net['name'] == 'storage':
net.update(vlan_turn_on)
self.fuel_web.client.update_network(cluster_id, networks=nets)
self.show_step(9)

View File

@ -74,7 +74,7 @@ class RepeatableImageBased(TestBasic):
self.env.make_snapshot("deploy_after_delete", is_make=True)
for i in range(0, 10):
for _ in range(10):
self.env.revert_snapshot("deploy_after_delete")
for node in self.env.d_env.nodes().slaves[:5]:
node.start()

View File

@ -305,15 +305,14 @@ def replace_fuel_nailgun_rpm():
# stop services
service_list = ['assassind', 'receiverd', 'nailgun', 'statsenderd']
[ssh.execute_on_remote(
ip=ssh.admin_ip,
cmd='systemctl stop {0}'.format(service)) for service in service_list]
for service in service_list:
ssh.execute_on_remote(
ip=ssh.admin_ip, cmd='systemctl stop {0}'.format(service))
logger.info('statistic services {0}'.format(get_oswl_services_names()))
# stop statistic services
[ssh.execute_on_remote(
ip=ssh.admin_ip,
cmd='systemctl stop {0}'.format(service))
for service in get_oswl_services_names()]
for service in get_oswl_services_names():
ssh.execute_on_remote(
ip=ssh.admin_ip, cmd='systemctl stop {0}'.format(service))
# Drop nailgun db manage.py dropdb
cmd = 'manage.py dropdb'

View File

@ -196,7 +196,7 @@ class BaseActions(PrepareActions, HealthCheckActions, PluginsActions):
num = iter(xrange(1, slaves + 1))
nodes = {}
for new in nodes_list:
for one in xrange(new['count']):
for _ in xrange(new['count']):
name = names.format(next(num))
while name in self.assigned_slaves:
name = names.format(next(num))

View File

@ -49,7 +49,7 @@ def get_path_to_template():
def collect_yamls(path):
"""Walk through config directory and find all yaml files"""
ret = []
for r, d, f in os.walk(path):
for r, _, f in os.walk(path):
for one in f:
if os.path.splitext(one)[1] in ('.yaml', '.yml'):
ret.append(os.path.join(r, one))
@ -129,7 +129,7 @@ def discover_test_files(basedir, dirs):
ret = []
for path in dirs:
path = os.path.join(basedir, path)
for r, d, f in os.walk(path):
for r, _, f in os.walk(path):
for one in f:
if one.startswith('test_') and one.endswith('.py'):
ret.append(os.path.join(r, one))