Update pep8 dependency to v1.1

The latest release of pep8 adds stricter rules for extraneous
whitespace within lines. This patch also addresses these new
violations acoss the codebase.

Change-Id: Ib7e50281870473df1704ed50868c5c2e26bdb02e
This commit is contained in:
Brian Waldon
2012-05-24 06:56:15 -07:00
parent e3d7d3a805
commit 317378f742
19 changed files with 44 additions and 44 deletions

View File

@@ -270,7 +270,7 @@ class HostController(object):
vcpus = [i['vcpus'] for i in instance_refs vcpus = [i['vcpus'] for i in instance_refs
if i['project_id'] == project_id] if i['project_id'] == project_id]
mem = [i['memory_mb'] for i in instance_refs mem = [i['memory_mb'] for i in instance_refs
if i['project_id'] == project_id] if i['project_id'] == project_id]
disk = [i['root_gb'] + i['ephemeral_gb'] for i in instance_refs disk = [i['root_gb'] + i['ephemeral_gb'] for i in instance_refs

View File

@@ -82,7 +82,7 @@ class NetworkController(object):
authorize(context) authorize(context)
networks = self.network_api.get_all(context) networks = self.network_api.get_all(context)
result = [network_dict(net_ref) for net_ref in networks] result = [network_dict(net_ref) for net_ref in networks]
return {'networks': result} return {'networks': result}
def show(self, req, id): def show(self, req, id):
context = req.environ['nova.context'] context = req.environ['nova.context']

View File

@@ -17,7 +17,7 @@ import json
import webob import webob
from nova.api.openstack import compute as compute_api from nova.api.openstack import compute as compute_api
from nova import compute from nova import compute
from nova import context from nova import context
from nova import exception from nova import exception

View File

@@ -17,7 +17,7 @@
import datetime import datetime
from nova.api.openstack import compute from nova.api.openstack import compute
from nova.api.openstack.compute import extensions from nova.api.openstack.compute import extensions
from nova.api.openstack import wsgi from nova.api.openstack import wsgi
import nova.db.api import nova.db.api

View File

@@ -15,7 +15,7 @@
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
from nova.api.openstack import compute from nova.api.openstack import compute
from nova.api.openstack.compute import extensions from nova.api.openstack.compute import extensions
from nova.api.openstack import wsgi from nova.api.openstack import wsgi
import nova.db.api import nova.db.api

View File

@@ -815,7 +815,7 @@ class TestSecurityGroupRules(test.TestCase):
self.assertRaises(webob.exc.HTTPBadRequest, self.controller.create, self.assertRaises(webob.exc.HTTPBadRequest, self.controller.create,
req, {'security_group_rule': rule}) req, {'security_group_rule': rule})
def _test_create_with_no_ports(self, proto): def _test_create_with_no_ports(self, proto):
rule = {'ip_protocol': proto, 'parent_group_id': '2', 'group_id': '1'} rule = {'ip_protocol': proto, 'parent_group_id': '2', 'group_id': '1'}
req = fakes.HTTPRequest.blank('/v2/fake/os-security-group-rules') req = fakes.HTTPRequest.blank('/v2/fake/os-security-group-rules')
@@ -844,7 +844,7 @@ class TestSecurityGroupRules(test.TestCase):
self._test_create_with_no_ports_and_no_group('udp') self._test_create_with_no_ports_and_no_group('udp')
self._test_create_with_no_ports('udp') self._test_create_with_no_ports('udp')
def _test_create_with_ports(self, id_val, proto, from_port, to_port): def _test_create_with_ports(self, id_val, proto, from_port, to_port):
rule = { rule = {
'ip_protocol': proto, 'from_port': from_port, 'to_port': to_port, 'ip_protocol': proto, 'from_port': from_port, 'to_port': to_port,
'parent_group_id': '2', 'group_id': '1' 'parent_group_id': '2', 'group_id': '1'

View File

@@ -55,15 +55,15 @@ def fake_instance_type_get(self, context, instance_type_id):
def get_fake_db_instance(start, end, instance_id, tenant_id): def get_fake_db_instance(start, end, instance_id, tenant_id):
return {'id': instance_id, return {'id': instance_id,
'image_ref': '1', 'image_ref': '1',
'project_id': tenant_id, 'project_id': tenant_id,
'user_id': 'fakeuser', 'user_id': 'fakeuser',
'display_name': 'name', 'display_name': 'name',
'state_description': 'state', 'state_description': 'state',
'instance_type_id': 1, 'instance_type_id': 1,
'launched_at': start, 'launched_at': start,
'terminated_at': end} 'terminated_at': end}
def fake_instance_get_active_by_window(self, context, begin, end, project_id): def fake_instance_get_active_by_window(self, context, begin, end, project_id):

View File

@@ -34,7 +34,7 @@ FLAGS.register_opts(baremetal_opts)
def get_baremetal_nodes(): def get_baremetal_nodes():
d = FLAGS.baremetal_driver d = FLAGS.baremetal_driver
if d == 'tilera': if d == 'tilera':
return tilera.get_baremetal_nodes() return tilera.get_baremetal_nodes()
elif d == 'fake': elif d == 'fake':
return fake.get_baremetal_nodes() return fake.get_baremetal_nodes()

View File

@@ -666,9 +666,9 @@ class ProxyConnection(driver.ComputeDriver):
#TODO(mdragon): console proxy should be implemented for baremetal, #TODO(mdragon): console proxy should be implemented for baremetal,
# in case someone wants to use it. # in case someone wants to use it.
# For now return fake data. # For now return fake data.
return {'address': '127.0.0.1', return {'address': '127.0.0.1',
'username': 'fakeuser', 'username': 'fakeuser',
'password': 'fakepassword'} 'password': 'fakepassword'}
def refresh_security_group_rules(self, security_group_id): def refresh_security_group_rules(self, security_group_id):
# Bare metal doesn't currently support security groups # Bare metal doesn't currently support security groups

View File

@@ -225,9 +225,9 @@ class FakeConnection(driver.ComputeDriver):
'port': 6969} 'port': 6969}
def get_console_pool_info(self, console_type): def get_console_pool_info(self, console_type):
return {'address': '127.0.0.1', return {'address': '127.0.0.1',
'username': 'fakeuser', 'username': 'fakeuser',
'password': 'fakepassword'} 'password': 'fakepassword'}
def refresh_security_group_rules(self, security_group_id): def refresh_security_group_rules(self, security_group_id):
return True return True

View File

@@ -1900,7 +1900,7 @@ class LibvirtConnection(driver.ComputeDriver):
else: else:
avail = (int(m[idx1 + 1]) + int(m[idx2 + 1]) + int(m[idx3 + 1])) avail = (int(m[idx1 + 1]) + int(m[idx2 + 1]) + int(m[idx3 + 1]))
# Convert it to MB # Convert it to MB
return self.get_memory_mb_total() - avail / 1024 return self.get_memory_mb_total() - avail / 1024
def get_local_gb_used(self): def get_local_gb_used(self):
"""Get the free hdd size(GB) of physical computer. """Get the free hdd size(GB) of physical computer.
@@ -2021,9 +2021,9 @@ class LibvirtConnection(driver.ComputeDriver):
#TODO(mdragon): console proxy should be implemented for libvirt, #TODO(mdragon): console proxy should be implemented for libvirt,
# in case someone wants to use it with kvm or # in case someone wants to use it with kvm or
# such. For now return fake data. # such. For now return fake data.
return {'address': '127.0.0.1', return {'address': '127.0.0.1',
'username': 'fakeuser', 'username': 'fakeuser',
'password': 'fakepassword'} 'password': 'fakepassword'}
def refresh_security_group_rules(self, security_group_id): def refresh_security_group_rules(self, security_group_id):
self.firewall_driver.refresh_security_group_rules(security_group_id) self.firewall_driver.refresh_security_group_rules(security_group_id)

View File

@@ -793,7 +793,7 @@ class VMWareVMOps(object):
task_info = self._session._call_method(vim_util, task_info = self._session._call_method(vim_util,
"get_dynamic_property", "get_dynamic_property",
search_task, "Task", "info") search_task, "Task", "info")
if task_info.state in ['queued', 'running']: if task_info.state in ['queued', 'running']:
time.sleep(2) time.sleep(2)
continue continue
break break

View File

@@ -366,9 +366,9 @@ class XenAPIConnection(driver.ComputeDriver):
def get_console_pool_info(self, console_type): def get_console_pool_info(self, console_type):
xs_url = urlparse.urlparse(FLAGS.xenapi_connection_url) xs_url = urlparse.urlparse(FLAGS.xenapi_connection_url)
return {'address': xs_url.netloc, return {'address': xs_url.netloc,
'username': FLAGS.xenapi_connection_username, 'username': FLAGS.xenapi_connection_username,
'password': FLAGS.xenapi_connection_password} 'password': FLAGS.xenapi_connection_password}
def update_available_resource(self, ctxt, host): def update_available_resource(self, ctxt, host):
"""Updates compute manager resource info on ComputeNode table. """Updates compute manager resource info on ComputeNode table.

View File

@@ -373,7 +373,7 @@ def _get_target_port(iscsi_string):
"""Retrieve target port""" """Retrieve target port"""
if iscsi_string: if iscsi_string:
return iscsi_string[iscsi_string.find(':') + 1:] return iscsi_string[iscsi_string.find(':') + 1:]
elif iscsi_string is None or FLAGS.target_port: elif iscsi_string is None or FLAGS.target_port:
return FLAGS.target_port return FLAGS.target_port

View File

@@ -178,8 +178,8 @@ def get_wsgi_server():
LOG.audit(_("Starting nova-xvpvncproxy node (version %s)"), LOG.audit(_("Starting nova-xvpvncproxy node (version %s)"),
version.version_string_with_vcs()) version.version_string_with_vcs())
return wsgi.Server("XCP VNC Proxy", return wsgi.Server("XCP VNC Proxy",
XCPVNCProxy(), XCPVNCProxy(),
protocol=SafeHttpProtocol, protocol=SafeHttpProtocol,
host=FLAGS.xvpvncproxy_host, host=FLAGS.xvpvncproxy_host,
port=FLAGS.xvpvncproxy_port) port=FLAGS.xvpvncproxy_port)

View File

@@ -61,7 +61,7 @@ def import_normalize(line):
split_line[2] == "import" and split_line[3] != "*" and split_line[2] == "import" and split_line[3] != "*" and
split_line[1] != "__future__" and split_line[1] != "__future__" and
(len(split_line) == 4 or (len(split_line) == 4 or
(len(split_line) == 6 and split_line[4] == "as"))): (len(split_line) == 6 and split_line[4] == "as"))):
mod = split_line[3] mod = split_line[3]
return "import %s.%s" % (split_line[1], split_line[3]) return "import %s.%s" % (split_line[1], split_line[3])
else: else:
@@ -214,8 +214,8 @@ def nova_import_alphabetical(physical_line, line_number, lines):
).strip().lower().split() ).strip().lower().split()
# with or without "as y" # with or without "as y"
length = [2, 4] length = [2, 4]
if (len(split_line) in length and len(split_previous) in length and if (len(split_line) in length and len(split_previous) in length and
split_line[0] == "import" and split_previous[0] == "import"): split_line[0] == "import" and split_previous[0] == "import"):
if split_line[1] < split_previous[1]: if split_line[1] < split_previous[1]:
return (0, "NOVA N306: imports not in alphabetical order (%s, %s)" return (0, "NOVA N306: imports not in alphabetical order (%s, %s)"
% (split_previous[1], split_line[1])) % (split_previous[1], split_line[1]))
@@ -244,7 +244,7 @@ def nova_docstring_one_line(physical_line):
""" """
pos = max([physical_line.find(i) for i in DOCSTRING_TRIPLE]) # start pos = max([physical_line.find(i) for i in DOCSTRING_TRIPLE]) # start
end = max([physical_line[-4:-1] == i for i in DOCSTRING_TRIPLE]) # end end = max([physical_line[-4:-1] == i for i in DOCSTRING_TRIPLE]) # end
if (pos != -1 and end and len(physical_line) > pos + 4): if (pos != -1 and end and len(physical_line) > pos + 4):
if (physical_line[-5] != '.'): if (physical_line[-5] != '.'):
return pos, "NOVA N402: one line docstring needs a period" return pos, "NOVA N402: one line docstring needs a period"

View File

@@ -6,6 +6,6 @@ mox==0.5.3
nose nose
nosexcover nosexcover
openstack.nose_plugin openstack.nose_plugin
pep8==1.0.1 pep8==1.1
sphinx>=1.1.2 sphinx>=1.1.2
MySQL-python MySQL-python

View File

@@ -94,7 +94,7 @@ def main():
stdout = stdout.strip() stdout = stdout.strip()
if stdout.endswith('.vhd'): if stdout.endswith('.vhd'):
try: try:
descendents[stdout].append(fname) descendents[stdout].append(fname)
except KeyError: except KeyError:

View File

@@ -12,7 +12,7 @@ sitepackages = True
downloadcache = ~/cache/pip downloadcache = ~/cache/pip
[testenv:pep8] [testenv:pep8]
deps = pep8==1.0.1 deps = pep8==1.1
commands = /bin/bash run_tests.sh -N --pep8 commands = /bin/bash run_tests.sh -N --pep8
[testenv:coverage] [testenv:coverage]