Skip to content

Commit

Permalink
PEP8 E126 has been resolved
Browse files Browse the repository at this point in the history
Change-Id: Ic5d3b96b6061b7a34e7620d8d09418bd6976fbb1
Partial-Bug: #1085346
  • Loading branch information
simon authored and amotoki committed Sep 17, 2013
1 parent 08a757b commit afaa721
Show file tree
Hide file tree
Showing 48 changed files with 367 additions and 384 deletions.
2 changes: 1 addition & 1 deletion horizon/browsers/breadcrumb.py
Expand Up @@ -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))
Expand Down
2 changes: 1 addition & 1 deletion horizon/middleware.py
Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions horizon/templatetags/sizeformat.py
Expand Up @@ -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))

Expand Down
8 changes: 4 additions & 4 deletions horizon/utils/fields.py
Expand Up @@ -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'<option value="%s"%s>%s</option>' % (
escape(option_value), other_html,
conditional_escape(force_unicode(option_label)))
escape(option_value), other_html,
conditional_escape(force_unicode(option_label)))
4 changes: 2 additions & 2 deletions horizon/workflows/base.py
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion openstack_dashboard/api/cinder.py
Expand Up @@ -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):
Expand Down
25 changes: 13 additions & 12 deletions openstack_dashboard/api/nova.py
Expand Up @@ -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]
Expand Down Expand Up @@ -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',
Expand Down Expand Up @@ -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):
Expand Down Expand Up @@ -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):
Expand Down
78 changes: 38 additions & 40 deletions openstack_dashboard/api/vpn.py
Expand Up @@ -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')
Expand Down Expand Up @@ -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')
Expand Down Expand Up @@ -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')
Expand Down Expand Up @@ -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')
Expand Down
2 changes: 1 addition & 1 deletion openstack_dashboard/dashboards/admin/defaults/views.py
Expand Up @@ -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


Expand Down
4 changes: 2 additions & 2 deletions openstack_dashboard/dashboards/admin/flavors/workflows.py
Expand Up @@ -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


Expand Down
2 changes: 1 addition & 1 deletion openstack_dashboard/dashboards/admin/images/forms.py
Expand Up @@ -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):
Expand Down
6 changes: 3 additions & 3 deletions openstack_dashboard/dashboards/admin/images/tests.py
Expand Up @@ -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()))
Expand Down
2 changes: 1 addition & 1 deletion openstack_dashboard/dashboards/admin/images/views.py
Expand Up @@ -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 \
Expand Down
4 changes: 2 additions & 2 deletions openstack_dashboard/dashboards/admin/instances/tests.py
Expand Up @@ -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()

Expand Down Expand Up @@ -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'))
Expand Down
10 changes: 5 additions & 5 deletions openstack_dashboard/dashboards/admin/instances/views.py
Expand Up @@ -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,
Expand Down Expand Up @@ -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)
Expand Down
14 changes: 7 additions & 7 deletions openstack_dashboard/dashboards/admin/metering/tabs.py
Expand Up @@ -28,20 +28,20 @@
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,
_('Unable to retrieve tenant list.'))
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

Expand Down
6 changes: 3 additions & 3 deletions openstack_dashboard/dashboards/admin/metering/views.py
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion openstack_dashboard/dashboards/admin/networks/tests.py
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion openstack_dashboard/dashboards/admin/projects/views.py
Expand Up @@ -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(
Expand Down

0 comments on commit afaa721

Please sign in to comment.