From afaa72185cf2e1a41ef685778111d8f51515e050 Mon Sep 17 00:00:00 2001 From: simon Date: Thu, 5 Sep 2013 15:49:35 +0800 Subject: [PATCH] PEP8 E126 has been resolved Change-Id: Ic5d3b96b6061b7a34e7620d8d09418bd6976fbb1 Partial-Bug: #1085346 --- horizon/browsers/breadcrumb.py | 2 +- horizon/middleware.py | 2 +- horizon/templatetags/sizeformat.py | 8 +- horizon/utils/fields.py | 8 +- horizon/workflows/base.py | 4 +- openstack_dashboard/api/cinder.py | 2 +- openstack_dashboard/api/nova.py | 25 +-- openstack_dashboard/api/vpn.py | 78 ++++---- .../dashboards/admin/defaults/views.py | 2 +- .../dashboards/admin/flavors/workflows.py | 4 +- .../dashboards/admin/images/forms.py | 2 +- .../dashboards/admin/images/tests.py | 6 +- .../dashboards/admin/images/views.py | 2 +- .../dashboards/admin/instances/tests.py | 4 +- .../dashboards/admin/instances/views.py | 10 +- .../dashboards/admin/metering/tabs.py | 14 +- .../dashboards/admin/metering/views.py | 6 +- .../dashboards/admin/networks/tests.py | 2 +- .../dashboards/admin/projects/views.py | 2 +- .../dashboards/admin/projects/workflows.py | 10 +- .../dashboards/admin/users/tests.py | 8 +- .../access_and_security/keypairs/tests.py | 6 +- .../security_groups/forms.py | 22 +-- .../security_groups/tests.py | 8 +- .../security_groups/views.py | 2 +- .../images_and_snapshots/images/forms.py | 2 +- .../images_and_snapshots/images/tests.py | 12 +- .../dashboards/project/instances/tests.py | 8 +- .../dashboards/project/instances/views.py | 6 +- .../instances/workflows/create_instance.py | 16 +- .../dashboards/project/loadbalancers/tests.py | 2 +- .../dashboards/project/loadbalancers/views.py | 2 +- .../project/loadbalancers/workflows.py | 4 +- .../project/networks/subnets/workflows.py | 20 +- .../dashboards/project/networks/workflows.py | 24 +-- .../dashboards/project/routers/views.py | 2 +- .../dashboards/project/stacks/api.py | 6 +- .../dashboards/project/volumes/forms.py | 13 +- .../dashboards/project/vpn/tables.py | 8 +- .../dashboards/project/vpn/tests.py | 186 +++++++++--------- .../dashboards/settings/user/views.py | 27 +-- openstack_dashboard/settings.py | 2 +- .../test/api_tests/lbaas_tests.py | 60 +++--- .../test/api_tests/vpnaas_tests.py | 79 ++++---- .../test/test_data/neutron_data.py | 4 +- openstack_dashboard/test/tests/quotas.py | 8 +- openstack_dashboard/test/tests/templates.py | 18 +- tox.ini | 3 +- 48 files changed, 367 insertions(+), 384 deletions(-) diff --git a/horizon/browsers/breadcrumb.py b/horizon/browsers/breadcrumb.py index ba1ca748f52..9ce1abd83bd 100644 --- a/horizon/browsers/breadcrumb.py +++ b/horizon/browsers/breadcrumb.py @@ -33,7 +33,7 @@ def __init__(self, request, template, root, def get_subfolders(self): if self.subfolder_path and not self._subfolders: (parent, slash, folder) = self.subfolder_path.strip('/') \ - .rpartition('/') + .rpartition('/') while folder: path = "%s%s%s/" % (parent, slash, folder) self._subfolders.insert(0, (folder, path)) diff --git a/horizon/middleware.py b/horizon/middleware.py index 58a3cecb176..03ee9045d0e 100644 --- a/horizon/middleware.py +++ b/horizon/middleware.py @@ -63,7 +63,7 @@ def process_request(self, request): if last_activity and (timestamp - last_activity).seconds > timeout: request.session.pop('last_activity') response = HttpResponseRedirect( - '%s?next=%s' % (settings.LOGOUT_URL, request.path)) + '%s?next=%s' % (settings.LOGOUT_URL, request.path)) reason = _("Session timed out.") utils.add_logout_reason(request, response, reason) return response diff --git a/horizon/templatetags/sizeformat.py b/horizon/templatetags/sizeformat.py index ee2ba41abd7..f342126b864 100644 --- a/horizon/templatetags/sizeformat.py +++ b/horizon/templatetags/sizeformat.py @@ -50,16 +50,16 @@ def filesizeformat(bytes, filesize_number_format): "%(size)d", bytes) % {'size': bytes} if bytes < 1024 * 1024: return translation.ugettext_lazy("%s KB") % \ - filesize_number_format(bytes / 1024) + filesize_number_format(bytes / 1024) if bytes < 1024 * 1024 * 1024: return translation.ugettext_lazy("%s MB") % \ - filesize_number_format(bytes / (1024 * 1024)) + filesize_number_format(bytes / (1024 * 1024)) if bytes < 1024 * 1024 * 1024 * 1024: return translation.ugettext_lazy("%s GB") % \ - filesize_number_format(bytes / (1024 * 1024 * 1024)) + filesize_number_format(bytes / (1024 * 1024 * 1024)) if bytes < 1024 * 1024 * 1024 * 1024 * 1024: return translation.ugettext_lazy("%s TB") % \ - filesize_number_format(bytes / (1024 * 1024 * 1024 * 1024)) + filesize_number_format(bytes / (1024 * 1024 * 1024 * 1024)) return translation.ugettext_lazy("%s PB") % \ filesize_number_format(bytes / (1024 * 1024 * 1024 * 1024 * 1024)) diff --git a/horizon/utils/fields.py b/horizon/utils/fields.py index 39f98c248c6..f9e15a0d845 100644 --- a/horizon/utils/fields.py +++ b/horizon/utils/fields.py @@ -119,12 +119,12 @@ def render_option(self, selected_choices, option_value, option_label): if not isinstance(option_label, (basestring, Promise)): for data_attr in self.data_attrs: data_value = conditional_escape( - force_unicode(getattr(option_label, - data_attr, ""))) + force_unicode(getattr(option_label, + data_attr, ""))) other_html += ' data-%s="%s"' % (data_attr, data_value) if self.transform: option_label = self.transform(option_label) return u'' % ( - escape(option_value), other_html, - conditional_escape(force_unicode(option_label))) + escape(option_value), other_html, + conditional_escape(force_unicode(option_label))) diff --git a/horizon/workflows/base.py b/horizon/workflows/base.py index 9412a35241b..0c8c2004bf0 100644 --- a/horizon/workflows/base.py +++ b/horizon/workflows/base.py @@ -775,8 +775,8 @@ def is_valid(self): missing = self.depends_on - set(self.context.keys()) if missing: raise exceptions.WorkflowValidationError( - "Unable to complete the workflow. The values %s are " - "required but not present." % ", ".join(missing)) + "Unable to complete the workflow. The values %s are " + "required but not present." % ", ".join(missing)) # Validate each step. Cycle through all of them to catch all errors # in one pass before returning. diff --git a/openstack_dashboard/api/cinder.py b/openstack_dashboard/api/cinder.py index 6dc599d7bdc..22ce7d24304 100644 --- a/openstack_dashboard/api/cinder.py +++ b/openstack_dashboard/api/cinder.py @@ -115,7 +115,7 @@ def volume_snapshot_list(request): def volume_snapshot_create(request, volume_id, name, description): return cinderclient(request).volume_snapshots.create( - volume_id, display_name=name, display_description=description) + volume_id, display_name=name, display_description=description) def volume_snapshot_delete(request, snapshot_id): diff --git a/openstack_dashboard/api/nova.py b/openstack_dashboard/api/nova.py index 57a2589e974..22272cb95aa 100644 --- a/openstack_dashboard/api/nova.py +++ b/openstack_dashboard/api/nova.py @@ -232,9 +232,10 @@ def list_by_instance(self, instance_id): % instance_id) if body: # Wrap data in SG objects as novaclient would. - sg_objs = [nova_security_groups.SecurityGroup( - nclient.security_groups, sg, loaded=True) - for sg in body.get('security_groups', [])] + sg_objs = [ + nova_security_groups.SecurityGroup( + nclient.security_groups, sg, loaded=True) + for sg in body.get('security_groups', [])] # Then wrap novaclient's object with our own. Yes, sadly wrapping # with two layers of objects is necessary. security_groups = [SecurityGroup(sg) for sg in sg_objs] @@ -365,7 +366,7 @@ def server_vnc_console(request, instance_id, console_type='novnc'): def server_spice_console(request, instance_id, console_type='spice-html5'): return SPICEConsole(novaclient(request).servers.get_spice_console( - instance_id, console_type)['console']) + instance_id, console_type)['console']) def flavor_create(request, name, memory, vcpu, disk, flavorid='auto', @@ -402,13 +403,13 @@ def flavor_access_list(request, flavor=None): def add_tenant_to_flavor(request, flavor, tenant): """Add a tenant to the given flavor access list.""" return novaclient(request).flavor_access.add_tenant_access( - flavor=flavor, tenant=tenant) + flavor=flavor, tenant=tenant) def remove_tenant_from_flavor(request, flavor, tenant): """Remove a tenant from the given flavor access list.""" return novaclient(request).flavor_access.remove_tenant_access( - flavor=flavor, tenant=tenant) + flavor=flavor, tenant=tenant) def flavor_get_extras(request, flavor_id, raw=False): @@ -460,12 +461,12 @@ def server_create(request, name, image, flavor, key_name, user_data, block_device_mapping_v2=None, nics=None, availability_zone=None, instance_count=1, admin_pass=None): return Server(novaclient(request).servers.create( - name, image, flavor, userdata=user_data, - security_groups=security_groups, - key_name=key_name, block_device_mapping=block_device_mapping, - block_device_mapping_v2=block_device_mapping_v2, - nics=nics, availability_zone=availability_zone, - min_count=instance_count, admin_pass=admin_pass), request) + name, image, flavor, userdata=user_data, + security_groups=security_groups, + key_name=key_name, block_device_mapping=block_device_mapping, + block_device_mapping_v2=block_device_mapping_v2, + nics=nics, availability_zone=availability_zone, + min_count=instance_count, admin_pass=admin_pass), request) def server_delete(request, instance): diff --git a/openstack_dashboard/api/vpn.py b/openstack_dashboard/api/vpn.py index c2cf767b82b..0e8e56f8bb0 100644 --- a/openstack_dashboard/api/vpn.py +++ b/openstack_dashboard/api/vpn.py @@ -136,12 +136,12 @@ def vpnservice_create(request, **kwargs): :param router_id: router id for router of VPNService :param subnet_id: subnet id for subnet of VPNService """ - body = {'vpnservice': { - 'admin_state_up': kwargs['admin_state_up'], - 'name': kwargs['name'], - 'description': kwargs['description'], - 'router_id': kwargs['router_id'], - 'subnet_id': kwargs['subnet_id']} + body = {'vpnservice': + {'admin_state_up': kwargs['admin_state_up'], + 'name': kwargs['name'], + 'description': kwargs['description'], + 'router_id': kwargs['router_id'], + 'subnet_id': kwargs['subnet_id']} } vpnservice = neutronclient(request).create_vpnservice(body).get( 'vpnservice') @@ -182,17 +182,15 @@ def ikepolicy_create(request, **kwargs): :param pfs: Perfect Forward Secrecy for IKEPolicy :param phase1_negotiation_mode: IKE Phase1 negotiation mode for IKEPolicy """ - body = {'ikepolicy': { - 'name': kwargs['name'], - 'description': kwargs['description'], - 'auth_algorithm': kwargs['auth_algorithm'], - 'encryption_algorithm': kwargs[ - 'encryption_algorithm'], - 'ike_version': kwargs['ike_version'], - 'lifetime': kwargs['lifetime'], - 'pfs': kwargs['pfs'], - 'phase1_negotiation_mode': kwargs[ - 'phase1_negotiation_mode']} + body = {'ikepolicy': + {'name': kwargs['name'], + 'description': kwargs['description'], + 'auth_algorithm': kwargs['auth_algorithm'], + 'encryption_algorithm': kwargs['encryption_algorithm'], + 'ike_version': kwargs['ike_version'], + 'lifetime': kwargs['lifetime'], + 'pfs': kwargs['pfs'], + 'phase1_negotiation_mode': kwargs['phase1_negotiation_mode']} } ikepolicy = neutronclient(request).create_ikepolicy(body).get( 'ikepolicy') @@ -233,15 +231,15 @@ def ipsecpolicy_create(request, **kwargs): :param pfs: Perfect Forward Secrecy for IPSecPolicy :param transform_protocol: Transform Protocol for IPSecPolicy """ - body = {'ipsecpolicy': { - 'name': kwargs['name'], - 'description': kwargs['description'], - 'auth_algorithm': kwargs['auth_algorithm'], - 'encapsulation_mode': kwargs['encapsulation_mode'], - 'encryption_algorithm': kwargs['encryption_algorithm'], - 'lifetime': kwargs['lifetime'], - 'pfs': kwargs['pfs'], - 'transform_protocol': kwargs['transform_protocol']} + body = {'ipsecpolicy': + {'name': kwargs['name'], + 'description': kwargs['description'], + 'auth_algorithm': kwargs['auth_algorithm'], + 'encapsulation_mode': kwargs['encapsulation_mode'], + 'encryption_algorithm': kwargs['encryption_algorithm'], + 'lifetime': kwargs['lifetime'], + 'pfs': kwargs['pfs'], + 'transform_protocol': kwargs['transform_protocol']} } ipsecpolicy = neutronclient(request).create_ipsecpolicy(body).get( 'ipsecpolicy') @@ -288,20 +286,20 @@ def ipsecsiteconnection_create(request, **kwargs): :param vpnservice_id: VPNService associated with this connection :param admin_state_up: admin state (default on) """ - body = {'ipsec_site_connection': { - 'name': kwargs['name'], - 'description': kwargs['description'], - 'dpd': kwargs['dpd'], - 'ikepolicy_id': kwargs['ikepolicy_id'], - 'initiator': kwargs['initiator'], - 'ipsecpolicy_id': kwargs['ipsecpolicy_id'], - 'mtu': kwargs['mtu'], - 'peer_address': kwargs['peer_address'], - 'peer_cidrs': kwargs['peer_cidrs'], - 'peer_id': kwargs['peer_id'], - 'psk': kwargs['psk'], - 'vpnservice_id': kwargs['vpnservice_id'], - 'admin_state_up': kwargs['admin_state_up']} + body = {'ipsec_site_connection': + {'name': kwargs['name'], + 'description': kwargs['description'], + 'dpd': kwargs['dpd'], + 'ikepolicy_id': kwargs['ikepolicy_id'], + 'initiator': kwargs['initiator'], + 'ipsecpolicy_id': kwargs['ipsecpolicy_id'], + 'mtu': kwargs['mtu'], + 'peer_address': kwargs['peer_address'], + 'peer_cidrs': kwargs['peer_cidrs'], + 'peer_id': kwargs['peer_id'], + 'psk': kwargs['psk'], + 'vpnservice_id': kwargs['vpnservice_id'], + 'admin_state_up': kwargs['admin_state_up']} } ipsecsiteconnection = neutronclient(request).create_ipsec_site_connection( body).get('ipsec_site_connection') diff --git a/openstack_dashboard/dashboards/admin/defaults/views.py b/openstack_dashboard/dashboards/admin/defaults/views.py index 99455812f6f..26b9125706b 100644 --- a/openstack_dashboard/dashboards/admin/defaults/views.py +++ b/openstack_dashboard/dashboards/admin/defaults/views.py @@ -23,7 +23,7 @@ from openstack_dashboard.dashboards.admin.defaults import tabs as project_tabs from openstack_dashboard.dashboards.admin.defaults import workflows as \ - project_workflows + project_workflows from openstack_dashboard.usage import quotas diff --git a/openstack_dashboard/dashboards/admin/flavors/workflows.py b/openstack_dashboard/dashboards/admin/flavors/workflows.py index 2bc8f6b44fc..8780f20c8e7 100644 --- a/openstack_dashboard/dashboards/admin/flavors/workflows.py +++ b/openstack_dashboard/dashboards/admin/flavors/workflows.py @@ -238,8 +238,8 @@ def clean(self): for flavor in flavors: if flavor.name == name and flavor.id != flavor_id: raise forms.ValidationError( - _('The name "%s" is already used by another ' - 'flavor.') % name) + _('The name "%s" is already used by another ' + 'flavor.') % name) return self.cleaned_data diff --git a/openstack_dashboard/dashboards/admin/images/forms.py b/openstack_dashboard/dashboards/admin/images/forms.py index 944813d8a13..f962af64d6a 100644 --- a/openstack_dashboard/dashboards/admin/images/forms.py +++ b/openstack_dashboard/dashboards/admin/images/forms.py @@ -19,7 +19,7 @@ # under the License. from openstack_dashboard.dashboards.project.images_and_snapshots \ - .images import forms + .images import forms class AdminCreateImageForm(forms.CreateImageForm): diff --git a/openstack_dashboard/dashboards/admin/images/tests.py b/openstack_dashboard/dashboards/admin/images/tests.py index 39f92c65cfd..1c37ac78b33 100644 --- a/openstack_dashboard/dashboards/admin/images/tests.py +++ b/openstack_dashboard/dashboards/admin/images/tests.py @@ -40,12 +40,12 @@ def test_images_list(self): api.glance.image_list_detailed(IsA(http.HttpRequest), marker=None, paginate=True) \ - .AndReturn([self.images.list(), - False]) + .AndReturn([self.images.list(), + False]) self.mox.ReplayAll() res = self.client.get( - reverse('horizon:admin:images:index')) + reverse('horizon:admin:images:index')) self.assertTemplateUsed(res, 'admin/images/index.html') self.assertEqual(len(res.context['images_table'].data), len(self.images.list())) diff --git a/openstack_dashboard/dashboards/admin/images/views.py b/openstack_dashboard/dashboards/admin/images/views.py index 0ccc9d9e4d3..3b16b45c3bb 100644 --- a/openstack_dashboard/dashboards/admin/images/views.py +++ b/openstack_dashboard/dashboards/admin/images/views.py @@ -28,7 +28,7 @@ from openstack_dashboard import api from openstack_dashboard.dashboards.project \ - .images_and_snapshots.images import views + .images_and_snapshots.images import views from openstack_dashboard.dashboards.admin.images import forms from openstack_dashboard.dashboards.admin.images \ diff --git a/openstack_dashboard/dashboards/admin/instances/tests.py b/openstack_dashboard/dashboards/admin/instances/tests.py index 45277af2afc..6beb8fad722 100644 --- a/openstack_dashboard/dashboards/admin/instances/tests.py +++ b/openstack_dashboard/dashboards/admin/instances/tests.py @@ -71,7 +71,7 @@ def test_index_flavor_list_exception(self): AndReturn([tenants, False]) for server in servers: api.nova.flavor_get(IsA(http.HttpRequest), server.flavor["id"]). \ - AndReturn(full_flavors[server.flavor["id"]]) + AndReturn(full_flavors[server.flavor["id"]]) self.mox.ReplayAll() @@ -104,7 +104,7 @@ def test_index_flavor_get_exception(self): AndReturn([tenants, False]) for server in servers: api.nova.flavor_get(IsA(http.HttpRequest), server.flavor["id"]). \ - AndRaise(self.exceptions.nova) + AndRaise(self.exceptions.nova) self.mox.ReplayAll() res = self.client.get(reverse('horizon:admin:instances:index')) diff --git a/openstack_dashboard/dashboards/admin/instances/views.py b/openstack_dashboard/dashboards/admin/instances/views.py index 3bec0ce48ce..85a9e559db8 100644 --- a/openstack_dashboard/dashboards/admin/instances/views.py +++ b/openstack_dashboard/dashboards/admin/instances/views.py @@ -69,10 +69,10 @@ def get_data(self): project_tables.AdminInstancesTable._meta.pagination_param, None) try: instances, self._more = api.nova.server_list( - self.request, - search_opts={'marker': marker, - 'paginate': True}, - all_tenants=True) + self.request, + search_opts={'marker': marker, + 'paginate': True}, + all_tenants=True) except Exception: self._more = False exceptions.handle(self.request, @@ -105,7 +105,7 @@ def get_data(self): # If the flavor_id is not in full_flavors list, # gets it via nova api. inst.full_flavor = api.nova.flavor_get( - self.request, flavor_id) + self.request, flavor_id) except Exception: msg = _('Unable to retrieve instance size information.') exceptions.handle(self.request, msg) diff --git a/openstack_dashboard/dashboards/admin/metering/tabs.py b/openstack_dashboard/dashboards/admin/metering/tabs.py index 6539a62e2d2..0a9ebe6c78a 100644 --- a/openstack_dashboard/dashboards/admin/metering/tabs.py +++ b/openstack_dashboard/dashboards/admin/metering/tabs.py @@ -28,10 +28,10 @@ def make_tenant_queries(request, days_before=30): try: tenants, more = api.keystone.tenant_list( - request, - domain=None, - paginate=True, - marker="tenant_marker") + request, + domain=None, + paginate=True, + marker="tenant_marker") except Exception: tenants = [] exceptions.handle(request, @@ -39,9 +39,9 @@ def make_tenant_queries(request, days_before=30): queries = {} for tenant in tenants: tenant_query = [{ - "field": "project_id", - "op": "eq", - "value": tenant.id}] + "field": "project_id", + "op": "eq", + "value": tenant.id}] queries[tenant.name] = tenant_query diff --git a/openstack_dashboard/dashboards/admin/metering/views.py b/openstack_dashboard/dashboards/admin/metering/views.py index 08fa3e24596..0488701a05b 100644 --- a/openstack_dashboard/dashboards/admin/metering/views.py +++ b/openstack_dashboard/dashboards/admin/metering/views.py @@ -93,9 +93,9 @@ def get(self, request, *args, **kwargs): queries = {} for tenant in tenants: tenant_query = [{ - "field": "project_id", - "op": "eq", - "value": tenant.id}] + "field": "project_id", + "op": "eq", + "value": tenant.id}] queries[tenant.name] = tenant_query diff --git a/openstack_dashboard/dashboards/admin/networks/tests.py b/openstack_dashboard/dashboards/admin/networks/tests.py index 359783b09e4..91754dbbd72 100644 --- a/openstack_dashboard/dashboards/admin/networks/tests.py +++ b/openstack_dashboard/dashboards/admin/networks/tests.py @@ -154,7 +154,7 @@ def test_network_detail_port_exception(self): def test_network_create_get(self): tenants = self.tenants.list() api.keystone.tenant_list(IsA( - http.HttpRequest)).AndReturn([tenants, False]) + http.HttpRequest)).AndReturn([tenants, False]) # TODO(absubram): Remove if clause and create separate # test stubs for when profile_support is being used. # Additionally ensure those are always run even in default setting diff --git a/openstack_dashboard/dashboards/admin/projects/views.py b/openstack_dashboard/dashboards/admin/projects/views.py index 13eebcd992d..dfa2cafdd97 100644 --- a/openstack_dashboard/dashboards/admin/projects/views.py +++ b/openstack_dashboard/dashboards/admin/projects/views.py @@ -78,7 +78,7 @@ def has_more_data(self, table): def get_data(self): tenants = [] marker = self.request.GET.get( - project_tables.TenantsTable._meta.pagination_param, None) + project_tables.TenantsTable._meta.pagination_param, None) domain_context = self.request.session.get('domain_context', None) try: tenants, self._more = api.keystone.tenant_list( diff --git a/openstack_dashboard/dashboards/admin/projects/workflows.py b/openstack_dashboard/dashboards/admin/projects/workflows.py index 05997099cbd..296337b1e0c 100644 --- a/openstack_dashboard/dashboards/admin/projects/workflows.py +++ b/openstack_dashboard/dashboards/admin/projects/workflows.py @@ -522,11 +522,11 @@ def handle(self, request, data): # update project info try: project = api.keystone.tenant_update( - request, - project_id, - name=data['name'], - description=data['description'], - enabled=data['enabled']) + request, + project_id, + name=data['name'], + description=data['description'], + enabled=data['enabled']) # Use the domain_id from the project if available domain_id = getattr(project, "domain_id", None) except Exception: diff --git a/openstack_dashboard/dashboards/admin/users/tests.py b/openstack_dashboard/dashboards/admin/users/tests.py index c7dfca7062f..f60272eb11a 100644 --- a/openstack_dashboard/dashboards/admin/users/tests.py +++ b/openstack_dashboard/dashboards/admin/users/tests.py @@ -329,8 +329,8 @@ def test_update_validation_for_password_too_short(self): res = self.client.post(USER_UPDATE_URL, formData) self.assertFormError( - res, "form", 'password', - ['Password must be between 8 and 18 characters.']) + res, "form", 'password', + ['Password must be between 8 and 18 characters.']) @test.create_stubs({api.keystone: ('domain_get', 'user_get', @@ -360,8 +360,8 @@ def test_update_validation_for_password_too_long(self): res = self.client.post(USER_UPDATE_URL, formData) self.assertFormError( - res, "form", 'password', - ['Password must be between 8 and 18 characters.']) + res, "form", 'password', + ['Password must be between 8 and 18 characters.']) @test.create_stubs({api.keystone: ('user_update_enabled', 'user_list')}) def test_enable_user(self): diff --git a/openstack_dashboard/dashboards/project/access_and_security/keypairs/tests.py b/openstack_dashboard/dashboards/project/access_and_security/keypairs/tests.py index 58a2d5eab50..f825da04edd 100644 --- a/openstack_dashboard/dashboards/project/access_and_security/keypairs/tests.py +++ b/openstack_dashboard/dashboards/project/access_and_security/keypairs/tests.py @@ -63,7 +63,7 @@ def test_delete_keypair_exception(self): def test_create_keypair_get(self): res = self.client.get( - reverse('horizon:project:access_and_security:keypairs:create')) + reverse('horizon:project:access_and_security:keypairs:create')) self.assertTemplateUsed(res, 'project/access_and_security/keypairs/create.html') @@ -74,7 +74,7 @@ def test_download_keypair_get(self): kwargs={'keypair_name': keypair_name}) res = self.client.get(url, context) self.assertTemplateUsed( - res, 'project/access_and_security/keypairs/download.html') + res, 'project/access_and_security/keypairs/download.html') def test_generate_keypair_get(self): keypair = self.keypairs.first() @@ -141,4 +141,4 @@ def test_generate_keypair_exception(self): res = self.client.get(url, context) self.assertRedirectsNoFollow( - res, reverse('horizon:project:access_and_security:index')) + res, reverse('horizon:project:access_and_security:index')) diff --git a/openstack_dashboard/dashboards/project/access_and_security/security_groups/forms.py b/openstack_dashboard/dashboards/project/access_and_security/security_groups/forms.py index b4179dd85b5..ee9c43295e8 100644 --- a/openstack_dashboard/dashboards/project/access_and_security/security_groups/forms.py +++ b/openstack_dashboard/dashboards/project/access_and_security/security_groups/forms.py @@ -97,8 +97,8 @@ class AddRule(forms.SelfHandlingForm): id = forms.CharField(widget=forms.HiddenInput()) rule_menu = forms.ChoiceField(label=_('Rule'), widget=forms.Select(attrs={ - 'class': 'switchable', - 'data-slug': 'rule_menu'})) + 'class': 'switchable', + 'data-slug': 'rule_menu'})) # "direction" field is enabled only when custom mode. # It is because most common rules in local_settings.py is meaningful @@ -365,15 +365,15 @@ def clean(self): def handle(self, request, data): try: rule = api.network.security_group_rule_create( - request, - filters.get_int_or_uuid(data['id']), - data['direction'], - data['ethertype'], - data['ip_protocol'], - data['from_port'], - data['to_port'], - data['cidr'], - data['security_group']) + request, + filters.get_int_or_uuid(data['id']), + data['direction'], + data['ethertype'], + data['ip_protocol'], + data['from_port'], + data['to_port'], + data['cidr'], + data['security_group']) messages.success(request, _('Successfully added rule: %s') % unicode(rule)) return rule diff --git a/openstack_dashboard/dashboards/project/access_and_security/security_groups/tests.py b/openstack_dashboard/dashboards/project/access_and_security/security_groups/tests.py index a6ed5657028..1ba2056c53f 100644 --- a/openstack_dashboard/dashboards/project/access_and_security/security_groups/tests.py +++ b/openstack_dashboard/dashboards/project/access_and_security/security_groups/tests.py @@ -187,7 +187,7 @@ def test_detail_add_rule_cidr(self): rule.ip_range['cidr'], None).AndReturn(rule) api.network.security_group_list( - IsA(http.HttpRequest)).AndReturn(sec_group_list) + IsA(http.HttpRequest)).AndReturn(sec_group_list) self.mox.ReplayAll() formData = {'method': 'AddRule', @@ -219,7 +219,7 @@ def test_detail_add_rule_cidr_with_template(self): rule.ip_range['cidr'], None).AndReturn(rule) api.network.security_group_list( - IsA(http.HttpRequest)).AndReturn(sec_group_list) + IsA(http.HttpRequest)).AndReturn(sec_group_list) self.mox.ReplayAll() formData = {'method': 'AddRule', @@ -620,7 +620,7 @@ def test_detail_add_rule_custom_protocol(self): 37, None, None, 'fe80::/48', None).AndReturn(rule) api.network.security_group_list( - IsA(http.HttpRequest)).AndReturn(sec_group_list) + IsA(http.HttpRequest)).AndReturn(sec_group_list) self.mox.ReplayAll() formData = {'method': 'AddRule', @@ -649,7 +649,7 @@ def test_detail_add_rule_egress(self): 'udp', 80, 80, '10.1.1.0/24', None).AndReturn(rule) api.network.security_group_list( - IsA(http.HttpRequest)).AndReturn(sec_group_list) + IsA(http.HttpRequest)).AndReturn(sec_group_list) self.mox.ReplayAll() formData = {'method': 'AddRule', diff --git a/openstack_dashboard/dashboards/project/access_and_security/security_groups/views.py b/openstack_dashboard/dashboards/project/access_and_security/security_groups/views.py index 739b9df3926..12fb6140740 100644 --- a/openstack_dashboard/dashboards/project/access_and_security/security_groups/views.py +++ b/openstack_dashboard/dashboards/project/access_and_security/security_groups/views.py @@ -127,7 +127,7 @@ def get_form_kwargs(self): security_groups = [] for group in groups: if group.id == filters.get_int_or_uuid( - self.kwargs['security_group_id']): + self.kwargs['security_group_id']): security_groups.append((group.id, _("%s (current)") % group.name)) else: diff --git a/openstack_dashboard/dashboards/project/images_and_snapshots/images/forms.py b/openstack_dashboard/dashboards/project/images_and_snapshots/images/forms.py index dc6c2c77fe0..9960543f6b6 100644 --- a/openstack_dashboard/dashboards/project/images_and_snapshots/images/forms.py +++ b/openstack_dashboard/dashboards/project/images_and_snapshots/images/forms.py @@ -143,7 +143,7 @@ def handle(self, request, data): image = api.glance.image_create(request, **meta) messages.success(request, _('Your image %s has been queued for creation.') % - data['name']) + data['name']) return image except Exception: exceptions.handle(request, _('Unable to create new image.')) diff --git a/openstack_dashboard/dashboards/project/images_and_snapshots/images/tests.py b/openstack_dashboard/dashboards/project/images_and_snapshots/images/tests.py index f5024e86e85..1f79b5d41b5 100644 --- a/openstack_dashboard/dashboards/project/images_and_snapshots/images/tests.py +++ b/openstack_dashboard/dashboards/project/images_and_snapshots/images/tests.py @@ -85,8 +85,8 @@ def test_image_create_post_copy_from(self): 'description': u'Login with admin/admin', 'source_type': u'url', 'copy_from': u'http://cloud-images.ubuntu.com/releases/' - u'oneiric/release/ubuntu-11.10-server-cloudimg' - u'-amd64-disk1.img', + u'oneiric/release/ubuntu-11.10-server-cloudimg' + u'-amd64-disk1.img', 'disk_format': u'qcow2', 'minimum_disk': 15, 'minimum_ram': 512, @@ -161,8 +161,8 @@ def test_image_detail_get(self): self.mox.ReplayAll() res = self.client.get( - reverse('horizon:project:images_and_snapshots:images:detail', - args=[image.id])) + reverse('horizon:project:images_and_snapshots:images:detail', + args=[image.id])) self.assertTemplateUsed(res, 'project/images_and_snapshots/images/detail.html') self.assertEqual(res.context['image'].name, image.name) @@ -177,8 +177,8 @@ def test_protected_image_detail_get(self): self.mox.ReplayAll() res = self.client.get( - reverse('horizon:project:images_and_snapshots:images:detail', - args=[image.id])) + reverse('horizon:project:images_and_snapshots:images:detail', + args=[image.id])) self.assertTemplateUsed(res, 'project/images_and_snapshots/images/detail.html') self.assertEqual(res.context['image'].protected, image.protected) diff --git a/openstack_dashboard/dashboards/project/instances/tests.py b/openstack_dashboard/dashboards/project/instances/tests.py index 088f50466fa..5ca61fd1d77 100644 --- a/openstack_dashboard/dashboards/project/instances/tests.py +++ b/openstack_dashboard/dashboards/project/instances/tests.py @@ -108,7 +108,7 @@ def test_index_flavor_list_exception(self): .AndRaise(self.exceptions.nova) for server in servers: api.nova.flavor_get(IsA(http.HttpRequest), server.flavor["id"]). \ - AndReturn(full_flavors[server.flavor["id"]]) + AndReturn(full_flavors[server.flavor["id"]]) api.nova.tenant_absolute_limits(IsA(http.HttpRequest), reserved=True) \ .MultipleTimes().AndReturn(self.limits['absolute']) @@ -143,7 +143,7 @@ def test_index_flavor_get_exception(self): api.nova.flavor_list(IsA(http.HttpRequest)).AndReturn(flavors) for server in servers: api.nova.flavor_get(IsA(http.HttpRequest), server.flavor["id"]). \ - AndRaise(self.exceptions.nova) + AndRaise(self.exceptions.nova) api.nova.tenant_absolute_limits(IsA(http.HttpRequest), reserved=True) \ .MultipleTimes().AndReturn(self.limits['absolute']) @@ -1328,9 +1328,9 @@ def test_launch_instance_post_no_images_available(self): 'availability_zone_list',)}) def test_launch_flavorlist_error(self): cinder.volume_list(IsA(http.HttpRequest)) \ - .AndReturn(self.volumes.list()) + .AndReturn(self.volumes.list()) cinder.volume_snapshot_list(IsA(http.HttpRequest)) \ - .AndReturn(self.volumes.list()) + .AndReturn(self.volumes.list()) api.glance.image_list_detailed(IsA(http.HttpRequest), filters={'is_public': True, 'status': 'active'}) \ diff --git a/openstack_dashboard/dashboards/project/instances/views.py b/openstack_dashboard/dashboards/project/instances/views.py index 50807d74043..02c465edab7 100644 --- a/openstack_dashboard/dashboards/project/instances/views.py +++ b/openstack_dashboard/dashboards/project/instances/views.py @@ -63,9 +63,9 @@ def get_data(self): # Gather our instances try: instances, self._more = api.nova.server_list( - self.request, - search_opts={'marker': marker, - 'paginate': True}) + self.request, + search_opts={'marker': marker, + 'paginate': True}) except Exception: self._more = False instances = [] diff --git a/openstack_dashboard/dashboards/project/instances/workflows/create_instance.py b/openstack_dashboard/dashboards/project/instances/workflows/create_instance.py index 52eb234a82f..368696ea4d4 100644 --- a/openstack_dashboard/dashboards/project/instances/workflows/create_instance.py +++ b/openstack_dashboard/dashboards/project/instances/workflows/create_instance.py @@ -382,15 +382,15 @@ class SetAccessControlsAction(workflows.Action): "authentication."), add_item_link=KEYPAIR_IMPORT_URL) admin_pass = forms.RegexField( - label=_("Admin Pass"), - required=False, - widget=forms.PasswordInput(render_value=False), - regex=validators.password_validator(), - error_messages={'invalid': validators.password_validator_msg()}) + label=_("Admin Pass"), + required=False, + widget=forms.PasswordInput(render_value=False), + regex=validators.password_validator(), + error_messages={'invalid': validators.password_validator_msg()}) confirm_admin_pass = forms.CharField( - label=_("Confirm Admin Pass"), - required=False, - widget=forms.PasswordInput(render_value=False)) + label=_("Confirm Admin Pass"), + required=False, + widget=forms.PasswordInput(render_value=False)) groups = forms.MultipleChoiceField(label=_("Security Groups"), required=True, initial=["default"], diff --git a/openstack_dashboard/dashboards/project/loadbalancers/tests.py b/openstack_dashboard/dashboards/project/loadbalancers/tests.py index 9cb68f4145c..6509fe96d14 100644 --- a/openstack_dashboard/dashboards/project/loadbalancers/tests.py +++ b/openstack_dashboard/dashboards/project/loadbalancers/tests.py @@ -777,5 +777,5 @@ def test_delete_pool_monitor_association_get(self): self.assertEqual(workflow.name, workflows.DeletePMAssociation.name) expected_objs = [ - '', ] + '', ] self.assertQuerysetEqual(workflow.steps, expected_objs) diff --git a/openstack_dashboard/dashboards/project/loadbalancers/views.py b/openstack_dashboard/dashboards/project/loadbalancers/views.py index a13c0555162..36c1f5bbb21 100644 --- a/openstack_dashboard/dashboards/project/loadbalancers/views.py +++ b/openstack_dashboard/dashboards/project/loadbalancers/views.py @@ -272,7 +272,7 @@ def _get_object(self, *args, **kwargs): monitor_id = self.kwargs['monitor_id'] try: self._object = api.lbaas.pool_health_monitor_get( - self.request, monitor_id) + self.request, monitor_id) except Exception as e: redirect = self.success_url msg = _('Unable to retrieve health monitor details. %s') % e diff --git a/openstack_dashboard/dashboards/project/loadbalancers/workflows.py b/openstack_dashboard/dashboards/project/loadbalancers/workflows.py index 49062beaaa3..ecf56624411 100644 --- a/openstack_dashboard/dashboards/project/loadbalancers/workflows.py +++ b/openstack_dashboard/dashboards/project/loadbalancers/workflows.py @@ -555,7 +555,7 @@ class DeletePMAssociationAction(workflows.Action): def __init__(self, request, *args, **kwargs): super(DeletePMAssociationAction, self).__init__( - request, *args, **kwargs) + request, *args, **kwargs) def populate_monitor_id_choices(self, request, context): self.fields['monitor_id'].label = (_("Select a health monitor of %s") % @@ -585,7 +585,7 @@ class DeletePMAssociationStep(workflows.Step): def contribute(self, data, context): context = super(DeletePMAssociationStep, self).contribute( - data, context) + data, context) if data: return context diff --git a/openstack_dashboard/dashboards/project/networks/subnets/workflows.py b/openstack_dashboard/dashboards/project/networks/subnets/workflows.py index b491a356bfe..9a537341efd 100644 --- a/openstack_dashboard/dashboards/project/networks/subnets/workflows.py +++ b/openstack_dashboard/dashboards/project/networks/subnets/workflows.py @@ -104,16 +104,16 @@ class UpdateSubnetInfoAction(CreateSubnetInfoAction): label=_("IP Version")) gateway_ip = fields.IPField( - label=_("Gateway IP (optional)"), - required=False, - initial="", - help_text=_("IP address of Gateway (e.g. 192.168.0.254). " - "You need to specify an explicit address " - "to set the gateway. " - "If you want to use no gateway, " - "check 'Disable Gateway' below."), - version=fields.IPv4 | fields.IPv6, - mask=False) + label=_("Gateway IP (optional)"), + required=False, + initial="", + help_text=_("IP address of Gateway (e.g. 192.168.0.254). " + "You need to specify an explicit address " + "to set the gateway. " + "If you want to use no gateway, " + "check 'Disable Gateway' below."), + version=fields.IPv4 | fields.IPv6, + mask=False) no_gateway = forms.BooleanField(label=_("Disable Gateway"), initial=False, required=False) diff --git a/openstack_dashboard/dashboards/project/networks/workflows.py b/openstack_dashboard/dashboards/project/networks/workflows.py index d183f589957..e8e3b087b89 100644 --- a/openstack_dashboard/dashboards/project/networks/workflows.py +++ b/openstack_dashboard/dashboards/project/networks/workflows.py @@ -97,18 +97,18 @@ class CreateSubnetInfoAction(workflows.Action): ip_version = forms.ChoiceField(choices=[(4, 'IPv4'), (6, 'IPv6')], label=_("IP Version")) gateway_ip = fields.IPField( - label=_("Gateway IP"), - required=False, - initial="", - help_text=_("IP address of Gateway (e.g. 192.168.0.254) " - "The default value is the first IP of the " - "network address (e.g. 192.168.0.1 for " - "192.168.0.0/24). " - "If you use the default, leave blank. " - "If you want to use no gateway, " - "check 'Disable Gateway' below."), - version=fields.IPv4 | fields.IPv6, - mask=False) + label=_("Gateway IP"), + required=False, + initial="", + help_text=_("IP address of Gateway (e.g. 192.168.0.254) " + "The default value is the first IP of the " + "network address (e.g. 192.168.0.1 for " + "192.168.0.0/24). " + "If you use the default, leave blank. " + "If you want to use no gateway, " + "check 'Disable Gateway' below."), + version=fields.IPv4 | fields.IPv6, + mask=False) no_gateway = forms.BooleanField(label=_("Disable Gateway"), initial=False, required=False) diff --git a/openstack_dashboard/dashboards/project/routers/views.py b/openstack_dashboard/dashboards/project/routers/views.py index 77052ddafe6..4ccd8dc0237 100644 --- a/openstack_dashboard/dashboards/project/routers/views.py +++ b/openstack_dashboard/dashboards/project/routers/views.py @@ -104,7 +104,7 @@ def _get_data(self): router.set_id_as_name_if_empty(length=0) except Exception: msg = _('Unable to retrieve details for router "%s".') \ - % (router_id) + % (router_id) exceptions.handle(self.request, msg, redirect=self.failure_url) if router.external_gateway_info: diff --git a/openstack_dashboard/dashboards/project/stacks/api.py b/openstack_dashboard/dashboards/project/stacks/api.py index e4bbc4004f5..bec494cd2b4 100644 --- a/openstack_dashboard/dashboards/project/stacks/api.py +++ b/openstack_dashboard/dashboards/project/stacks/api.py @@ -52,10 +52,10 @@ def d3_data(request, stack_id=''): if resources: for resource in resources: resource_image = mappings.get_resource_image( - resource.resource_status, - resource.resource_type) + resource.resource_status, + resource.resource_type) resource_status = mappings.get_resource_status( - resource.resource_status) + resource.resource_status) if resource_status in ('IN_PROGRESS', 'INIT'): in_progress = True else: diff --git a/openstack_dashboard/dashboards/project/volumes/forms.py b/openstack_dashboard/dashboards/project/volumes/forms.py index d4ff2fcd39a..04152436938 100644 --- a/openstack_dashboard/dashboards/project/volumes/forms.py +++ b/openstack_dashboard/dashboards/project/volumes/forms.py @@ -41,19 +41,14 @@ class CreateForm(forms.SelfHandlingForm): widget=fields.SelectWidget( attrs={'class': 'snapshot-selector'}, data_attrs=('size', 'display_name'), - transform=lambda x: - ("%s (%sGB)" % (x.display_name, - x.size))), + transform=lambda x: "%s (%sGB)" % (x.display_name, x.size)), required=False) image_source = forms.ChoiceField( label=_("Use image as a source"), widget=fields.SelectWidget( attrs={'class': 'image-selector'}, data_attrs=('size', 'name'), - transform=lambda x: - ("%s (%s)" % - (x.name, - filesizeformat(x.bytes)))), + transform=lambda x: "%s (%s)" % (x.name, filesizeformat(x.bytes))), required=False) def __init__(self, request, *args, **kwargs): @@ -258,8 +253,8 @@ def __init__(self, *args, **kwargs): instances = [] for instance in instance_list: if instance.status in tables.ACTIVE_STATES and \ - not any(instance.id == att["server_id"] - for att in volume.attachments): + not any(instance.id == att["server_id"] + for att in volume.attachments): instances.append((instance.id, '%s (%s)' % (instance.name, instance.id))) if instances: diff --git a/openstack_dashboard/dashboards/project/vpn/tables.py b/openstack_dashboard/dashboards/project/vpn/tables.py index cbd208e07f9..798cf385e2c 100644 --- a/openstack_dashboard/dashboards/project/vpn/tables.py +++ b/openstack_dashboard/dashboards/project/vpn/tables.py @@ -150,8 +150,8 @@ class IKEPoliciesTable(tables.DataTable): auth_algorithm = tables.Column('auth_algorithm', verbose_name=_('Authorization algorithm')) encryption_algorithm = tables.Column( - 'encryption_algorithm', - verbose_name=_('Encryption algorithm')) + 'encryption_algorithm', + verbose_name=_('Encryption algorithm')) pfs = tables.Column("pfs", verbose_name=_('PFS')) class Meta: @@ -168,8 +168,8 @@ class IPSecPoliciesTable(tables.DataTable): auth_algorithm = tables.Column('auth_algorithm', verbose_name=_('Authorization algorithm')) encryption_algorithm = tables.Column( - 'encryption_algorithm', - verbose_name=_('Encryption algorithm')) + 'encryption_algorithm', + verbose_name=_('Encryption algorithm')) pfs = tables.Column("pfs", verbose_name=_('PFS')) class Meta: diff --git a/openstack_dashboard/dashboards/project/vpn/tests.py b/openstack_dashboard/dashboards/project/vpn/tests.py index d13effede7d..0e5a3ed893e 100644 --- a/openstack_dashboard/dashboards/project/vpn/tests.py +++ b/openstack_dashboard/dashboards/project/vpn/tests.py @@ -293,12 +293,11 @@ def test_add_vpnservice_post(self): self.mox.ReplayAll() - form_data = { - 'name': vpnservice['name'], - 'description': vpnservice['description'], - 'subnet_id': vpnservice['subnet_id'], - 'router_id': vpnservice['router_id'], - 'admin_state_up': vpnservice['admin_state_up']} + form_data = {'name': vpnservice['name'], + 'description': vpnservice['description'], + 'subnet_id': vpnservice['subnet_id'], + 'router_id': vpnservice['router_id'], + 'admin_state_up': vpnservice['admin_state_up']} res = self.client.post(reverse(self.ADDVPNSERVICE_PATH), form_data) @@ -323,12 +322,11 @@ def test_add_vpnservice_post_error(self): self.mox.ReplayAll() - form_data = { - 'name': vpnservice['name'], - 'description': vpnservice['description'], - 'subnet_id': '', - 'router_id': '', - 'admin_state_up': vpnservice['admin_state_up']} + form_data = {'name': vpnservice['name'], + 'description': vpnservice['description'], + 'subnet_id': '', + 'router_id': '', + 'admin_state_up': vpnservice['admin_state_up']} res = self.client.post(reverse(self.ADDVPNSERVICE_PATH), form_data) @@ -362,18 +360,17 @@ def test_add_ikepolicy_post(self): self.mox.ReplayAll() - form_data = { - 'name': ikepolicy['name'], - 'description': ikepolicy['description'], - 'auth_algorithm': ikepolicy['auth_algorithm'], - 'encryption_algorithm': ikepolicy[ - 'encryption_algorithm'], - 'ike_version': ikepolicy['ike_version'], - 'lifetime_units': ikepolicy['lifetime']['units'], - 'lifetime_value': ikepolicy['lifetime']['value'], - 'phase1_negotiation_mode': ikepolicy[ - 'phase1_negotiation_mode'], - 'pfs': ikepolicy['pfs']} + form_data = {'name': ikepolicy['name'], + 'description': ikepolicy['description'], + 'auth_algorithm': ikepolicy['auth_algorithm'], + 'encryption_algorithm': ikepolicy[ + 'encryption_algorithm'], + 'ike_version': ikepolicy['ike_version'], + 'lifetime_units': ikepolicy['lifetime']['units'], + 'lifetime_value': ikepolicy['lifetime']['value'], + 'phase1_negotiation_mode': ikepolicy[ + 'phase1_negotiation_mode'], + 'pfs': ikepolicy['pfs']} res = self.client.post(reverse(self.ADDIKEPOLICY_PATH), form_data) @@ -383,18 +380,17 @@ def test_add_ikepolicy_post(self): def test_add_ikepolicy_post_error(self): ikepolicy = self.ikepolicies.first() - form_data = { - 'name': ikepolicy['name'], - 'description': ikepolicy['description'], - 'auth_algorithm': ikepolicy['auth_algorithm'], - 'encryption_algorithm': ikepolicy[ - 'encryption_algorithm'], - 'ike_version': ikepolicy['ike_version'], - 'lifetime_units': ikepolicy['lifetime']['units'], - 'lifetime_value': 10, - 'phase1_negotiation_mode': ikepolicy[ - 'phase1_negotiation_mode'], - 'pfs': ikepolicy['pfs']} + form_data = {'name': ikepolicy['name'], + 'description': ikepolicy['description'], + 'auth_algorithm': ikepolicy['auth_algorithm'], + 'encryption_algorithm': ikepolicy[ + 'encryption_algorithm'], + 'ike_version': ikepolicy['ike_version'], + 'lifetime_units': ikepolicy['lifetime']['units'], + 'lifetime_value': 10, + 'phase1_negotiation_mode': ikepolicy[ + 'phase1_negotiation_mode'], + 'pfs': ikepolicy['pfs']} res = self.client.post(reverse(self.ADDIKEPOLICY_PATH), form_data) @@ -428,19 +424,18 @@ def test_add_ipsecpolicy_post(self): self.mox.ReplayAll() - form_data = { - 'name': ipsecpolicy['name'], - 'description': ipsecpolicy['description'], - 'auth_algorithm': ipsecpolicy['auth_algorithm'], - 'encryption_algorithm': ipsecpolicy[ - 'encryption_algorithm'], - 'encapsulation_mode': ipsecpolicy[ - 'encapsulation_mode'], - 'lifetime_units': ipsecpolicy['lifetime']['units'], - 'lifetime_value': ipsecpolicy['lifetime']['value'], - 'pfs': ipsecpolicy['pfs'], - 'transform_protocol': ipsecpolicy[ - 'transform_protocol']} + form_data = {'name': ipsecpolicy['name'], + 'description': ipsecpolicy['description'], + 'auth_algorithm': ipsecpolicy['auth_algorithm'], + 'encryption_algorithm': ipsecpolicy[ + 'encryption_algorithm'], + 'encapsulation_mode': ipsecpolicy[ + 'encapsulation_mode'], + 'lifetime_units': ipsecpolicy['lifetime']['units'], + 'lifetime_value': ipsecpolicy['lifetime']['value'], + 'pfs': ipsecpolicy['pfs'], + 'transform_protocol': ipsecpolicy[ + 'transform_protocol']} res = self.client.post(reverse(self.ADDIPSECPOLICY_PATH), form_data) @@ -450,19 +445,18 @@ def test_add_ipsecpolicy_post(self): def test_add_ipsecpolicy_post_error(self): ipsecpolicy = self.ipsecpolicies.first() - form_data = { - 'name': ipsecpolicy['name'], - 'description': ipsecpolicy['description'], - 'auth_algorithm': ipsecpolicy['auth_algorithm'], - 'encryption_algorithm': ipsecpolicy[ - 'encryption_algorithm'], - 'encapsulation_mode': ipsecpolicy[ - 'encapsulation_mode'], - 'lifetime_units': ipsecpolicy['lifetime']['units'], - 'lifetime_value': 10, - 'pfs': ipsecpolicy['pfs'], - 'transform_protocol': ipsecpolicy[ - 'transform_protocol']} + form_data = {'name': ipsecpolicy['name'], + 'description': ipsecpolicy['description'], + 'auth_algorithm': ipsecpolicy['auth_algorithm'], + 'encryption_algorithm': ipsecpolicy[ + 'encryption_algorithm'], + 'encapsulation_mode': ipsecpolicy[ + 'encapsulation_mode'], + 'lifetime_units': ipsecpolicy['lifetime']['units'], + 'lifetime_value': 10, + 'pfs': ipsecpolicy['pfs'], + 'transform_protocol': ipsecpolicy[ + 'transform_protocol']} res = self.client.post(reverse(self.ADDIPSECPOLICY_PATH), form_data) @@ -540,24 +534,23 @@ def test_add_ipsecsiteconnection_post(self): self.mox.ReplayAll() - form_data = { - 'name': ipsecsiteconnection['name'], - 'description': ipsecsiteconnection['description'], - 'dpd_action': ipsecsiteconnection['dpd']['action'], - 'dpd_interval': ipsecsiteconnection['dpd']['interval'], - 'dpd_timeout': ipsecsiteconnection['dpd']['timeout'], - 'ikepolicy_id': ipsecsiteconnection['ikepolicy_id'], - 'initiator': ipsecsiteconnection['initiator'], - 'ipsecpolicy_id': ipsecsiteconnection[ - 'ipsecpolicy_id'], - 'mtu': ipsecsiteconnection['mtu'], - 'peer_address': ipsecsiteconnection['peer_address'], - 'peer_cidrs': ipsecsiteconnection['peer_cidrs'], - 'peer_id': ipsecsiteconnection['peer_id'], - 'psk': ipsecsiteconnection['psk'], - 'vpnservice_id': ipsecsiteconnection['vpnservice_id'], - 'admin_state_up': ipsecsiteconnection[ - 'admin_state_up']} + form_data = {'name': ipsecsiteconnection['name'], + 'description': ipsecsiteconnection['description'], + 'dpd_action': ipsecsiteconnection['dpd']['action'], + 'dpd_interval': ipsecsiteconnection['dpd']['interval'], + 'dpd_timeout': ipsecsiteconnection['dpd']['timeout'], + 'ikepolicy_id': ipsecsiteconnection['ikepolicy_id'], + 'initiator': ipsecsiteconnection['initiator'], + 'ipsecpolicy_id': ipsecsiteconnection[ + 'ipsecpolicy_id'], + 'mtu': ipsecsiteconnection['mtu'], + 'peer_address': ipsecsiteconnection['peer_address'], + 'peer_cidrs': ipsecsiteconnection['peer_cidrs'], + 'peer_id': ipsecsiteconnection['peer_id'], + 'psk': ipsecsiteconnection['psk'], + 'vpnservice_id': ipsecsiteconnection['vpnservice_id'], + 'admin_state_up': ipsecsiteconnection[ + 'admin_state_up']} res = self.client.post(reverse(self.ADDVPNCONNECTION_PATH), form_data) @@ -587,23 +580,22 @@ def test_add_ipsecsiteconnection_post_error(self): self.mox.ReplayAll() - form_data = { - 'name': ipsecsiteconnection['name'], - 'description': ipsecsiteconnection['description'], - 'dpd_action': ipsecsiteconnection['dpd']['action'], - 'dpd_interval': ipsecsiteconnection['dpd']['interval'], - 'dpd_timeout': ipsecsiteconnection['dpd']['timeout'], - 'ikepolicy_id': '', - 'initiator': ipsecsiteconnection['initiator'], - 'ipsecpolicy_id': '', - 'mtu': ipsecsiteconnection['mtu'], - 'peer_address': ipsecsiteconnection['peer_address'], - 'peer_cidrs': ipsecsiteconnection['peer_cidrs'], - 'peer_id': ipsecsiteconnection['peer_id'], - 'psk': ipsecsiteconnection['psk'], - 'vpnservice_id': '', - 'admin_state_up': ipsecsiteconnection[ - 'admin_state_up']} + form_data = {'name': ipsecsiteconnection['name'], + 'description': ipsecsiteconnection['description'], + 'dpd_action': ipsecsiteconnection['dpd']['action'], + 'dpd_interval': ipsecsiteconnection['dpd']['interval'], + 'dpd_timeout': ipsecsiteconnection['dpd']['timeout'], + 'ikepolicy_id': '', + 'initiator': ipsecsiteconnection['initiator'], + 'ipsecpolicy_id': '', + 'mtu': ipsecsiteconnection['mtu'], + 'peer_address': ipsecsiteconnection['peer_address'], + 'peer_cidrs': ipsecsiteconnection['peer_cidrs'], + 'peer_id': ipsecsiteconnection['peer_id'], + 'psk': ipsecsiteconnection['psk'], + 'vpnservice_id': '', + 'admin_state_up': ipsecsiteconnection[ + 'admin_state_up']} res = self.client.post(reverse(self.ADDVPNCONNECTION_PATH), form_data) diff --git a/openstack_dashboard/dashboards/settings/user/views.py b/openstack_dashboard/dashboards/settings/user/views.py index dd4bd827956..a93504b5526 100644 --- a/openstack_dashboard/dashboards/settings/user/views.py +++ b/openstack_dashboard/dashboards/settings/user/views.py @@ -25,19 +25,20 @@ class UserSettingsView(forms.ModalFormView): template_name = 'settings/user/settings.html' def get_initial(self): - return {'language': self.request.session.get( - settings.LANGUAGE_COOKIE_NAME, - self.request.COOKIES.get(settings.LANGUAGE_COOKIE_NAME, - self.request.LANGUAGE_CODE)), - 'timezone': self.request.session.get( - 'django_timezone', - self.request.COOKIES.get('django_timezone', 'UTC')), - 'pagesize': self.request.session.get( - 'horizon_pagesize', - self.request.COOKIES.get( - 'horizon_pagesize', - getattr(settings, - 'API_RESULT_PAGE_SIZE', 20)))} + return { + 'language': self.request.session.get( + settings.LANGUAGE_COOKIE_NAME, + self.request.COOKIES.get(settings.LANGUAGE_COOKIE_NAME, + self.request.LANGUAGE_CODE)), + 'timezone': self.request.session.get( + 'django_timezone', + self.request.COOKIES.get('django_timezone', 'UTC')), + 'pagesize': self.request.session.get( + 'horizon_pagesize', + self.request.COOKIES.get( + 'horizon_pagesize', + getattr(settings, + 'API_RESULT_PAGE_SIZE', 20)))} def form_valid(self, form): return form.handle(self.request, form.cleaned_data) diff --git a/openstack_dashboard/settings.py b/openstack_dashboard/settings.py index e2317e5b6e9..1fbeef1341b 100644 --- a/openstack_dashboard/settings.py +++ b/openstack_dashboard/settings.py @@ -28,7 +28,7 @@ from openstack_dashboard import exceptions warnings.formatwarning = lambda message, category, *args, **kwargs: \ - '%s: %s' % (category.__name__, message) + '%s: %s' % (category.__name__, message) ROOT_PATH = os.path.dirname(os.path.abspath(__file__)) BIN_DIR = os.path.abspath(os.path.join(ROOT_PATH, '..', 'bin')) diff --git a/openstack_dashboard/test/api_tests/lbaas_tests.py b/openstack_dashboard/test/api_tests/lbaas_tests.py index 9581791abb3..ccf0064de57 100644 --- a/openstack_dashboard/test/api_tests/lbaas_tests.py +++ b/openstack_dashboard/test/api_tests/lbaas_tests.py @@ -142,13 +142,13 @@ def test_pool_create(self): @test.create_stubs({neutronclient: ('list_pools',)}) def test_pools_get(self): pools = {'pools': [{ - 'id': 'abcdef-c3eb-4fee-9763-12de3338041e', - 'name': 'pool1name', - 'description': 'pool1description', - 'subnet_id': '12381d38-c3eb-4fee-9763-12de3338041e', - 'protocol': 'HTTP', - 'lb_method': 'ROUND_ROBIN', - 'admin_state_up': True}, ]} + 'id': 'abcdef-c3eb-4fee-9763-12de3338041e', + 'name': 'pool1name', + 'description': 'pool1description', + 'subnet_id': '12381d38-c3eb-4fee-9763-12de3338041e', + 'protocol': 'HTTP', + 'lb_method': 'ROUND_ROBIN', + 'admin_state_up': True}, ]} neutronclient.list_pools().AndReturn(pools) self.mox.ReplayAll() @@ -207,14 +207,14 @@ def test_pool_health_monitor_create(self): 'admin_state_up': True } monitor = {'health_monitor': { - 'id': 'abcdef-c3eb-4fee-9763-12de3338041e', - 'type': 'PING', - 'delay': '10', - 'timeout': '10', - 'max_retries': '10', - 'admin_state_up': True}} + 'id': 'abcdef-c3eb-4fee-9763-12de3338041e', + 'type': 'PING', + 'delay': '10', + 'timeout': '10', + 'max_retries': '10', + 'admin_state_up': True}} neutronclient.create_health_monitor({ - 'health_monitor': form_data}).AndReturn(monitor) + 'health_monitor': form_data}).AndReturn(monitor) self.mox.ReplayAll() ret_val = api.lbaas.pool_health_monitor_create( @@ -224,15 +224,15 @@ def test_pool_health_monitor_create(self): @test.create_stubs({neutronclient: ('list_health_monitors',)}) def test_pool_health_monitors_get(self): monitors = {'health_monitors': [ - {'id': 'abcdef-c3eb-4fee-9763-12de3338041e', - 'type': 'PING', - 'delay': '10', - 'timeout': '10', - 'max_retries': '10', - 'http_method': 'GET', - 'url_path': '/monitor', - 'expected_codes': '200', - 'admin_state_up': True}, ]} + {'id': 'abcdef-c3eb-4fee-9763-12de3338041e', + 'type': 'PING', + 'delay': '10', + 'timeout': '10', + 'max_retries': '10', + 'http_method': 'GET', + 'url_path': '/monitor', + 'expected_codes': '200', + 'admin_state_up': True}, ]} neutronclient.list_health_monitors().AndReturn(monitors) self.mox.ReplayAll() @@ -287,13 +287,13 @@ def test_member_create(self): @test.create_stubs({neutronclient: ('list_members',)}) def test_members_get(self): members = {'members': [ - {'id': 'abcdef-c3eb-4fee-9763-12de3338041e', - 'pool_id': 'abcdef-c3eb-4fee-9763-12de3338041e', - 'address': '10.0.1.2', - 'protocol_port': '80', - 'weight': '10', - 'admin_state_up': True - }, ]} + {'id': 'abcdef-c3eb-4fee-9763-12de3338041e', + 'pool_id': 'abcdef-c3eb-4fee-9763-12de3338041e', + 'address': '10.0.1.2', + 'protocol_port': '80', + 'weight': '10', + 'admin_state_up': True + }, ]} neutronclient.list_members().AndReturn(members) self.mox.ReplayAll() diff --git a/openstack_dashboard/test/api_tests/vpnaas_tests.py b/openstack_dashboard/test/api_tests/vpnaas_tests.py index ff8ad105a6a..7d12c233f3d 100644 --- a/openstack_dashboard/test/api_tests/vpnaas_tests.py +++ b/openstack_dashboard/test/api_tests/vpnaas_tests.py @@ -29,11 +29,12 @@ class VPNaasApiTests(test.APITestCase): def test_vpnservice_create(self): vpnservice1 = self.api_vpnservices.first() form_data = { - 'name': vpnservice1['name'], - 'description': vpnservice1['description'], - 'subnet_id': vpnservice1['subnet_id'], - 'router_id': vpnservice1['router_id'], - 'admin_state_up': vpnservice1['admin_state_up']} + 'name': vpnservice1['name'], + 'description': vpnservice1['description'], + 'subnet_id': vpnservice1['subnet_id'], + 'router_id': vpnservice1['router_id'], + 'admin_state_up': vpnservice1['admin_state_up'] + } vpnservice = {'vpnservice': self.api_vpnservices.first()} neutronclient.create_vpnservice( @@ -76,16 +77,15 @@ def test_vpnservice_get(self): def test_ikepolicy_create(self): ikepolicy1 = self.api_ikepolicies.first() form_data = { - 'name': ikepolicy1['name'], - 'description': ikepolicy1['description'], - 'auth_algorithm': ikepolicy1['auth_algorithm'], - 'encryption_algorithm': ikepolicy1[ - 'encryption_algorithm'], - 'ike_version': ikepolicy1['ike_version'], - 'lifetime': ikepolicy1['lifetime'], - 'phase1_negotiation_mode': ikepolicy1[ - 'phase1_negotiation_mode'], - 'pfs': ikepolicy1['pfs']} + 'name': ikepolicy1['name'], + 'description': ikepolicy1['description'], + 'auth_algorithm': ikepolicy1['auth_algorithm'], + 'encryption_algorithm': ikepolicy1['encryption_algorithm'], + 'ike_version': ikepolicy1['ike_version'], + 'lifetime': ikepolicy1['lifetime'], + 'phase1_negotiation_mode': ikepolicy1['phase1_negotiation_mode'], + 'pfs': ikepolicy1['pfs'] + } ikepolicy = {'ikepolicy': self.api_ikepolicies.first()} neutronclient.create_ikepolicy( @@ -128,17 +128,15 @@ def test_ikepolicy_get(self): def test_ipsecpolicy_create(self): ipsecpolicy1 = self.api_ipsecpolicies.first() form_data = { - 'name': ipsecpolicy1['name'], - 'description': ipsecpolicy1['description'], - 'auth_algorithm': ipsecpolicy1['auth_algorithm'], - 'encryption_algorithm': ipsecpolicy1[ - 'encryption_algorithm'], - 'encapsulation_mode': ipsecpolicy1[ - 'encapsulation_mode'], - 'lifetime': ipsecpolicy1['lifetime'], - 'pfs': ipsecpolicy1['pfs'], - 'transform_protocol': ipsecpolicy1[ - 'transform_protocol']} + 'name': ipsecpolicy1['name'], + 'description': ipsecpolicy1['description'], + 'auth_algorithm': ipsecpolicy1['auth_algorithm'], + 'encryption_algorithm': ipsecpolicy1['encryption_algorithm'], + 'encapsulation_mode': ipsecpolicy1['encapsulation_mode'], + 'lifetime': ipsecpolicy1['lifetime'], + 'pfs': ipsecpolicy1['pfs'], + 'transform_protocol': ipsecpolicy1['transform_protocol'] + } ipsecpolicy = {'ipsecpolicy': self.api_ipsecpolicies.first()} neutronclient.create_ipsecpolicy( @@ -181,21 +179,20 @@ def test_ipsecpolicy_get(self): def test_ipsecsiteconnection_create(self): ipsecsiteconnection1 = self.api_ipsecsiteconnections.first() form_data = { - 'name': ipsecsiteconnection1['name'], - 'description': ipsecsiteconnection1['description'], - 'dpd': ipsecsiteconnection1['dpd'], - 'ikepolicy_id': ipsecsiteconnection1['ikepolicy_id'], - 'initiator': ipsecsiteconnection1['initiator'], - 'ipsecpolicy_id': ipsecsiteconnection1[ - 'ipsecpolicy_id'], - 'mtu': ipsecsiteconnection1['mtu'], - 'peer_address': ipsecsiteconnection1['peer_address'], - 'peer_cidrs': ipsecsiteconnection1['peer_cidrs'], - 'peer_id': ipsecsiteconnection1['peer_id'], - 'psk': ipsecsiteconnection1['psk'], - 'vpnservice_id': ipsecsiteconnection1['vpnservice_id'], - 'admin_state_up': ipsecsiteconnection1[ - 'admin_state_up']} + 'name': ipsecsiteconnection1['name'], + 'description': ipsecsiteconnection1['description'], + 'dpd': ipsecsiteconnection1['dpd'], + 'ikepolicy_id': ipsecsiteconnection1['ikepolicy_id'], + 'initiator': ipsecsiteconnection1['initiator'], + 'ipsecpolicy_id': ipsecsiteconnection1['ipsecpolicy_id'], + 'mtu': ipsecsiteconnection1['mtu'], + 'peer_address': ipsecsiteconnection1['peer_address'], + 'peer_cidrs': ipsecsiteconnection1['peer_cidrs'], + 'peer_id': ipsecsiteconnection1['peer_id'], + 'psk': ipsecsiteconnection1['psk'], + 'vpnservice_id': ipsecsiteconnection1['vpnservice_id'], + 'admin_state_up': ipsecsiteconnection1['admin_state_up'] + } ipsecsiteconnection = {'ipsec_site_connection': self.api_ipsecsiteconnections.first()} diff --git a/openstack_dashboard/test/test_data/neutron_data.py b/openstack_dashboard/test/test_data/neutron_data.py index 93b6d7f3430..7f787035f8b 100644 --- a/openstack_dashboard/test/test_data/neutron_data.py +++ b/openstack_dashboard/test/test_data/neutron_data.py @@ -136,7 +136,7 @@ def data(TEST): TEST.api_network_profile_binding.add(network_profile_binding_dict) TEST.network_profile_binding.add(neutron.Profile( - network_profile_binding_dict)) + network_profile_binding_dict)) # policy profile binding policy_profile_binding_dict = {'profile_id': @@ -145,7 +145,7 @@ def data(TEST): TEST.api_policy_profile_binding.add(policy_profile_binding_dict) TEST.policy_profile_binding.add(neutron.Profile( - policy_profile_binding_dict)) + policy_profile_binding_dict)) # ports on 1st network port_dict = {'admin_state_up': True, diff --git a/openstack_dashboard/test/tests/quotas.py b/openstack_dashboard/test/tests/quotas.py index 141364b2ae5..c511248ae55 100644 --- a/openstack_dashboard/test/tests/quotas.py +++ b/openstack_dashboard/test/tests/quotas.py @@ -143,10 +143,10 @@ def test_tenant_quota_usages_no_instances_running(self): expected_output = self.get_usages(with_volume=False) expected_output.update({ - 'ram': {'available': 10000, 'used': 0, 'quota': 10000}, - 'floating_ips': {'available': 1, 'used': 0, 'quota': 1}, - 'instances': {'available': 10, 'used': 0, 'quota': 10}, - 'cores': {'available': 10, 'used': 0, 'quota': 10}}) + 'ram': {'available': 10000, 'used': 0, 'quota': 10000}, + 'floating_ips': {'available': 1, 'used': 0, 'quota': 1}, + 'instances': {'available': 10, 'used': 0, 'quota': 10}, + 'cores': {'available': 10, 'used': 0, 'quota': 10}}) # Compare internal structure of usages to expected. self.assertEqual(quota_usages.usages, expected_output) diff --git a/openstack_dashboard/test/tests/templates.py b/openstack_dashboard/test/tests/templates.py index 11942809e10..c664619decc 100644 --- a/openstack_dashboard/test/tests/templates.py +++ b/openstack_dashboard/test/tests/templates.py @@ -34,9 +34,9 @@ def test_openrc_html_escape(self): "auth_url": "http://tests.com", "tenant_name": "ENG Perf R&D"} out = loader.render_to_string( - 'project/access_and_security/api_access/openrc.sh.template', - context, - template.Context(context)) + 'project/access_and_security/api_access/openrc.sh.template', + context, + template.Context(context)) self.assertFalse("&" in out) self.assertTrue("ENG Perf R&D" in out) @@ -48,9 +48,9 @@ def test_openrc_html_evil_shell_escape(self): "auth_url": "http://tests.com", "tenant_name": 'o"; sudo rm -rf /'} out = loader.render_to_string( - 'project/access_and_security/api_access/openrc.sh.template', - context, - template.Context(context)) + 'project/access_and_security/api_access/openrc.sh.template', + context, + template.Context(context)) self.assertFalse('o"' in out) self.assertTrue('\"' in out) @@ -62,9 +62,9 @@ def test_openrc_html_evil_shell_backslash_escape(self): "auth_url": "http://tests.com", "tenant_name": 'o\"; sudo rm -rf /'} out = loader.render_to_string( - 'project/access_and_security/api_access/openrc.sh.template', - context, - template.Context(context)) + 'project/access_and_security/api_access/openrc.sh.template', + context, + template.Context(context)) self.assertFalse('o\"' in out) self.assertFalse('o"' in out) diff --git a/tox.ini b/tox.ini index d34312ced65..45dd51149f6 100644 --- a/tox.ini +++ b/tox.ini @@ -32,11 +32,10 @@ downloadcache = ~/cache/pip [flake8] builtins = _ exclude = .venv,.git,.tox,dist,doc,*openstack/common*,*lib/python*,*egg,build,panel_template,dash_template,local_settings.py -# E126 continuation line over-indented for hanging indent # E127 continuation line over-indented for visual indent # E128 continuation line under-indented for visual indent # H102 Apache 2.0 license header not found # H4xx docstrings # H701 empty localization string # H702 Formatting operation should be outside of localization method call -ignore = E126,E127,E128,H102,H4,H701,H702 +ignore = E127,E128,H102,H4,H701,H702