Fix E128 issues and enable E128

This commit fixes the issues reported by pep8 as
violation of E128, and enables E128 in tox.ini

Change-Id: If88653c3dbadffa63b5ba7c561f69ce893d670ac
This commit is contained in:
Ramakrishnan G 2015-08-13 12:55:09 +00:00
parent 95d9f03f45
commit f33d181430
4 changed files with 25 additions and 22 deletions

View File

@ -211,8 +211,9 @@ def is_block_device(dev):
s = os.stat(dev)
except OSError as e:
LOG.debug("Unable to stat device %(dev)s. Attempt %(attempt)d "
"out of %(total)d. Error: %(err)s", {"dev": dev,
"attempt": attempt + 1, "total": attempts, "err": e})
"out of %(total)d. Error: %(err)s",
{"dev": dev, "attempt": attempt + 1,
"total": attempts, "err": e})
time.sleep(1)
else:
return stat.S_ISBLK(s.st_mode)
@ -461,7 +462,7 @@ def work_on_disk(dev, root_mb, swap_mb, ephemeral_mb, ephemeral_format,
part_device = part_dict.get(part)
LOG.debug("Checking for %(part)s device (%(dev)s) on node "
"%(node)s.", {'part': part, 'dev': part_device,
'node': node_uuid})
'node': node_uuid})
if part_device and not is_block_device(part_device):
raise exception.InstanceDeployFailure(
_("'%(partition)s' device '%(part_device)s' not found") %

View File

@ -71,8 +71,8 @@ class DiskPartitionerTestCase(test_base.BaseTestCase):
'mkpart', 'fake-type', 'fake-fs-type', '1', '2',
'mkpart', 'fake-type', 'fake-fs-type', '2', '3',
'set', '2', 'boot', 'on')
mock_utils_exc.assert_called_once_with('fuser', '/dev/fake',
run_as_root=True, check_exit_code=[0, 1])
mock_utils_exc.assert_called_once_with(
'fuser', '/dev/fake', run_as_root=True, check_exit_code=[0, 1])
@mock.patch.object(disk_partitioner.DiskPartitioner, '_exec',
autospec=True)
@ -100,8 +100,8 @@ class DiskPartitionerTestCase(test_base.BaseTestCase):
'mkpart', 'fake-type', 'fake-fs-type', '1', '2',
'mkpart', 'fake-type', 'fake-fs-type', '2', '3',
'set', '2', 'boot', 'on')
mock_utils_exc.assert_called_with('fuser', '/dev/fake',
run_as_root=True, check_exit_code=[0, 1])
mock_utils_exc.assert_called_with(
'fuser', '/dev/fake', run_as_root=True, check_exit_code=[0, 1])
self.assertEqual(2, mock_utils_exc.call_count)
@mock.patch.object(disk_partitioner.DiskPartitioner, '_exec',
@ -129,8 +129,8 @@ class DiskPartitionerTestCase(test_base.BaseTestCase):
'mkpart', 'fake-type', 'fake-fs-type', '1', '2',
'mkpart', 'fake-type', 'fake-fs-type', '2', '3',
'set', '2', 'boot', 'on')
mock_utils_exc.assert_called_with('fuser', '/dev/fake',
run_as_root=True, check_exit_code=[0, 1])
mock_utils_exc.assert_called_with(
'fuser', '/dev/fake', run_as_root=True, check_exit_code=[0, 1])
self.assertEqual(20, mock_utils_exc.call_count)
@mock.patch.object(disk_partitioner.DiskPartitioner, '_exec',
@ -159,6 +159,6 @@ class DiskPartitionerTestCase(test_base.BaseTestCase):
'mkpart', 'fake-type', 'fake-fs-type', '1', '2',
'mkpart', 'fake-type', 'fake-fs-type', '2', '3',
'set', '2', 'boot', 'on')
mock_utils_exc.assert_called_with('fuser', '/dev/fake',
run_as_root=True, check_exit_code=[0, 1])
mock_utils_exc.assert_called_with(
'fuser', '/dev/fake', run_as_root=True, check_exit_code=[0, 1])
self.assertEqual(20, mock_utils_exc.call_count)

View File

@ -208,8 +208,8 @@ class MakePartitionsTestCase(test_base.BaseTestCase):
def _test_make_partitions(self, mock_exc, boot_option):
mock_exc.return_value = (None, None)
disk_utils.make_partitions(self.dev, self.root_mb, self.swap_mb,
self.ephemeral_mb, self.configdrive_mb,
boot_option=boot_option)
self.ephemeral_mb, self.configdrive_mb,
boot_option=boot_option)
expected_mkpart = ['mkpart', 'primary', 'linux-swap', '1', '513',
'mkpart', 'primary', '', '513', '1537']
@ -239,7 +239,7 @@ class MakePartitionsTestCase(test_base.BaseTestCase):
cmd = self._get_parted_cmd(self.dev) + expected_mkpart
mock_exc.return_value = (None, None)
disk_utils.make_partitions(self.dev, self.root_mb, self.swap_mb,
self.ephemeral_mb, self.configdrive_mb)
self.ephemeral_mb, self.configdrive_mb)
parted_call = mock.call(*cmd, run_as_root=True, check_exit_code=[0])
mock_exc.assert_has_calls([parted_call])
@ -255,8 +255,9 @@ class MakePartitionsTestCase(test_base.BaseTestCase):
'root': 'fake-dev3'}
cmd = self._get_parted_cmd(self.dev) + expected_mkpart
mock_exc.return_value = (None, None)
result = disk_utils.make_partitions(self.dev, self.root_mb,
self.swap_mb, self.ephemeral_mb, self.configdrive_mb)
result = disk_utils.make_partitions(
self.dev, self.root_mb, self.swap_mb, self.ephemeral_mb,
self.configdrive_mb)
parted_call = mock.call(*cmd, run_as_root=True, check_exit_code=[0])
mock_exc.assert_has_calls([parted_call])
@ -273,8 +274,9 @@ class MakePartitionsTestCase(test_base.BaseTestCase):
'root': self.dev + '-part3'}
cmd = self._get_parted_cmd(self.dev) + expected_mkpart
mock_exc.return_value = (None, None)
result = disk_utils.make_partitions(self.dev, self.root_mb,
self.swap_mb, self.ephemeral_mb, self.configdrive_mb)
result = disk_utils.make_partitions(
self.dev, self.root_mb, self.swap_mb, self.ephemeral_mb,
self.configdrive_mb)
parted_call = mock.call(*cmd, run_as_root=True, check_exit_code=[0])
mock_exc.assert_has_calls([parted_call])
@ -294,9 +296,9 @@ class MakePartitionsTestCase(test_base.BaseTestCase):
'root': self.dev + '-part4'}
cmd = self._get_parted_cmd_uefi(self.dev) + expected_mkpart
mock_exc.return_value = (None, None)
result = disk_utils.make_partitions(self.dev, self.root_mb,
self.swap_mb, self.ephemeral_mb, self.configdrive_mb,
boot_option='local', boot_mode='uefi')
result = disk_utils.make_partitions(
self.dev, self.root_mb, self.swap_mb, self.ephemeral_mb,
self.configdrive_mb, boot_option='local', boot_mode='uefi')
parted_call = mock.call(*cmd, run_as_root=True, check_exit_code=[0])
mock_exc.assert_has_calls([parted_call])

View File

@ -10,7 +10,7 @@ commands =
[flake8]
show-source = True
ignore = E128,E129
ignore = E129
exclude = .venv,.tox,dist,doc,*.egg,.update-venv
[testenv:pep8]