summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoe Heck <heckj@mac.com>2011-10-31 11:33:54 -0700
committerJoe Heck <heckj@mac.com>2011-10-31 11:33:54 -0700
commitf5156e7d737fdb9de970ba499f6a6502e7016f3c (patch)
tree3ad9a846ce7e5f63fe1798826d65f4ca92524c62
parent5bb04304935492c5a6d4d08a737b01ee4c290988 (diff)
downloadtuskar-ui-f5156e7d737fdb9de970ba499f6a6502e7016f3c.tar.gz
more pep8 cleanup to reduce to 0 pep8 issues
Change-Id: I7183f9c4a337657d0a5badfb07535b2b34f677b8
-rw-r--r--django-openstack/django_openstack/api.py20
-rw-r--r--django-openstack/django_openstack/context_processors.py3
-rw-r--r--django-openstack/django_openstack/dash/views/ports.py4
-rw-r--r--django-openstack/django_openstack/exceptions.py1
-rw-r--r--django-openstack/django_openstack/syspanel/views/images.py9
-rw-r--r--django-openstack/django_openstack/tests/api_tests.py13
-rw-r--r--django-openstack/django_openstack/tests/templatetag_tests.py19
-rw-r--r--django-openstack/django_openstack/tests/view_tests/auth_tests.py9
-rw-r--r--django-openstack/django_openstack/tests/view_tests/dash/floating_ip_tests.py7
9 files changed, 54 insertions, 31 deletions
diff --git a/django-openstack/django_openstack/api.py b/django-openstack/django_openstack/api.py
index c4fb35b8..7b096178 100644
--- a/django-openstack/django_openstack/api.py
+++ b/django-openstack/django_openstack/api.py
@@ -225,7 +225,7 @@ class Tenant(APIResourceWrapper):
class Token(APIResourceWrapper):
"""Simple wrapper around keystoneclient.tokens.Tenant"""
- _attrs = ['id', 'user', 'serviceCatalog', 'tenant',]
+ _attrs = ['id', 'user', 'serviceCatalog', 'tenant']
class Usage(APIResourceWrapper):
@@ -406,7 +406,8 @@ def keystoneclient(request, username=None, password=None, tenant_id=None,
"""
# Take care of client connection caching/fetching a new client
user = request.user
- if hasattr(request, '_keystone') and request._keystone.auth_token == user.token:
+ if (hasattr(request, '_keystone') and
+ request._keystone.auth_token == user.token):
conn = request._keystone
else:
conn = keystone_client.Client(username=username or user.username,
@@ -671,11 +672,12 @@ def token_create(request, tenant, username, password):
c = keystoneclient(request, username=username, password=password,
tenant_id=tenant,
endpoint=settings.OPENSTACK_KEYSTONE_URL)
- token = c.tokens.authenticate(username=username, password=password, tenant=tenant)
+ token = c.tokens.authenticate(username=username,
+ password=password,
+ tenant=tenant)
return Token(token)
-
def token_create_scoped(request, tenant, token):
'''
Creates a scoped token using the tenant id and unscoped token; retrieves
@@ -689,7 +691,6 @@ def token_create_scoped(request, tenant, token):
return Token(scoped_token)
-
def tenant_quota_get(request, tenant):
return novaclient(request).quotas.get(tenant)
@@ -740,7 +741,8 @@ def security_group_rule_delete(request, security_group_rule_id):
def user_list(request, tenant_id=None):
- return [User(u) for u in keystoneclient(request).users.list(tenant_id=tenant_id)]
+ return [User(u) for u in
+ keystoneclient(request).users.list(tenant_id=tenant_id)]
def user_create(request, user_id, email, password, tenant_id, enabled):
@@ -765,11 +767,13 @@ def user_update_enabled(request, user_id, enabled):
def user_update_password(request, user_id, password):
- return User(keystoneclient(request).users.update_password(user_id, password))
+ return User(keystoneclient(request).users.update_password(user_id,
+ password))
def user_update_tenant(request, user_id, tenant_id):
- return User(keystoneclient(request).users.update_tenant(user_id, tenant_id))
+ return User(keystoneclient(request).users.update_tenant(user_id,
+ tenant_id))
def _get_role(request, name):
diff --git a/django-openstack/django_openstack/context_processors.py b/django-openstack/django_openstack/context_processors.py
index 8df39dc3..1d1b0a5b 100644
--- a/django-openstack/django_openstack/context_processors.py
+++ b/django-openstack/django_openstack/context_processors.py
@@ -29,7 +29,8 @@ def tenants(request):
return {}
try:
- return {'tenants': api.tenant_list_for_token(request, request.user.token)}
+ return {'tenants': api.tenant_list_for_token(request,
+ request.user.token)}
except api_exceptions.BadRequest, e:
messages.error(request, _("Unable to retrieve tenant list from\
keystone: %s") % e.message)
diff --git a/django-openstack/django_openstack/dash/views/ports.py b/django-openstack/django_openstack/dash/views/ports.py
index 840ed351..ad690cfe 100644
--- a/django-openstack/django_openstack/dash/views/ports.py
+++ b/django-openstack/django_openstack/dash/views/ports.py
@@ -98,7 +98,9 @@ class AttachPort(forms.SelfHandlingForm):
except Exception, e:
messages.error(request,
_('Unable to attach port %(port)s to VIF %(vif)s: %(msg)s') %
- {"port": data['port'], "vif": data['vif_id'], "msg": e.message})
+ {"port": data['port'],
+ "vif": data['vif_id'],
+ "msg": e.message})
else:
msg = _('Port %(port)s connected to VIF %(vif)s.') % \
{"port": data['port'], "vif": data['vif_id']}
diff --git a/django-openstack/django_openstack/exceptions.py b/django-openstack/django_openstack/exceptions.py
index e1642f8b..09856350 100644
--- a/django-openstack/django_openstack/exceptions.py
+++ b/django-openstack/django_openstack/exceptions.py
@@ -2,6 +2,7 @@
from novaclient import exceptions as nova_exceptions
+
class Unauthorized(nova_exceptions.Unauthorized):
""" A wrapper around novaclient's Unauthorized exception. """
pass
diff --git a/django-openstack/django_openstack/syspanel/views/images.py b/django-openstack/django_openstack/syspanel/views/images.py
index 8dd8d7aa..887581a4 100644
--- a/django-openstack/django_openstack/syspanel/views/images.py
+++ b/django-openstack/django_openstack/syspanel/views/images.py
@@ -82,7 +82,8 @@ class UpdateImageForm(forms.Form):
container_format = forms.CharField(label=_("Container Format"),
required=False)
disk_format = forms.CharField(label=_("Disk Format"))
- #is_public = forms.BooleanField(label=_("Publicly Available"), required=False)
+ #is_public = forms.BooleanField(label=_("Publicly Available"),
+ # required=False)
@login_required
@@ -175,7 +176,8 @@ def update(request, image_id):
messages.error(request,
_("Image could not be uploaded, please try agian."))
form = UpdateImageForm(request.POST)
- return render_to_response('django_openstack/syspanel/images/update.html', {
+ return render_to_response('django_openstack/syspanel/images/'
+ 'update.html', {
'image': image,
'form': form,
}, context_instance=template.RequestContext(request))
@@ -193,7 +195,8 @@ def update(request, image_id):
'disk_format': image.get('disk_format', ''),
})
- return render_to_response('django_openstack/syspanel/images/update.html', {
+ return render_to_response('django_openstack/syspanel/images/'
+ 'update.html', {
'image': image,
'form': form,
}, context_instance=template.RequestContext(request))
diff --git a/django-openstack/django_openstack/tests/api_tests.py b/django-openstack/django_openstack/tests/api_tests.py
index cdc65bc4..43b0cae8 100644
--- a/django-openstack/django_openstack/tests/api_tests.py
+++ b/django-openstack/django_openstack/tests/api_tests.py
@@ -99,7 +99,8 @@ class Tenant(object):
class Token(object):
""" More or less fakes what the api is looking for """
- def __init__(self, id, username, tenant_id, tenant_name, serviceCatalog=None):
+ def __init__(self, id, username, tenant_id, tenant_name,
+ serviceCatalog=None):
self.id = id
self.user = {'name': username}
self.tenant = {'id': tenant_id, 'name': tenant_name}
@@ -679,7 +680,9 @@ class AdminApiTests(APITestCase):
class TokenApiTests(APITestCase):
def setUp(self):
super(TokenApiTests, self).setUp()
- self._prev_OPENSTACK_KEYSTONE_URL = getattr(settings, 'OPENSTACK_KEYSTONE_URL', None)
+ self._prev_OPENSTACK_KEYSTONE_URL = getattr(settings,
+ 'OPENSTACK_KEYSTONE_URL',
+ None)
settings.OPENSTACK_KEYSTONE_URL = TEST_URL
def tearDown(self):
@@ -703,8 +706,10 @@ class TokenApiTests(APITestCase):
keystoneclient = self.stub_keystoneclient()
keystoneclient.tokens = self.mox.CreateMockAnything()
- keystoneclient.tokens.authenticate(username=TEST_USERNAME, password=TEST_PASSWORD,
- tenant=TEST_TENANT_ID).AndReturn(test_token)
+ keystoneclient.tokens.authenticate(username=TEST_USERNAME,
+ password=TEST_PASSWORD,
+ tenant=TEST_TENANT_ID
+ ).AndReturn(test_token)
self.mox.ReplayAll()
diff --git a/django-openstack/django_openstack/tests/templatetag_tests.py b/django-openstack/django_openstack/tests/templatetag_tests.py
index c49f9052..7ca198e2 100644
--- a/django-openstack/django_openstack/tests/templatetag_tests.py
+++ b/django-openstack/django_openstack/tests/templatetag_tests.py
@@ -5,9 +5,12 @@ from django.utils.text import normalize_newlines
from django_openstack import signals, test
+
def single_line(text):
''' Quick utility to make comparing template output easier. '''
- return re.sub(' +', ' ', normalize_newlines(text).replace('\n', '')).strip()
+ return re.sub(' +',
+ ' ',
+ normalize_newlines(text).replace('\n', '')).strip()
class TemplateTagTests(test.TestCase):
@@ -29,7 +32,7 @@ class TemplateTagTests(test.TestCase):
})
'''
self.mox.StubOutWithMock(signals, 'dash_modules_detect')
- signals_call= (
+ signals_call = (
(self._signal, {
'title': 'Nixon',
'links': [{'url':'/dash/nixon/google',
@@ -52,11 +55,17 @@ class TemplateTagTests(test.TestCase):
# Dash module is rendered correctly, and only in dash sidebar
ttext = '{% load sidebar_modules %}{% dash_sidebar_modules request %}'
t = template.Template(ttext)
- self.assertEqual(single_line(t.render(context)) , '<h3>Nixon</h3> <ul class="sub_nav"> <li><a href="/dash/nixon/google">Google</a></li> </ul>')
+ self.assertEqual(single_line(t.render(context)),
+ '<h3>Nixon</h3> <ul class="sub_nav"> <li>'
+ '<a href="/dash/nixon/google">Google</a></li> </ul>')
# Syspanel module is rendered correctly and only in syspanel sidebar
- ttext = '{% load sidebar_modules %}{% syspanel_sidebar_modules request %}'
+ ttext = ('{% load sidebar_modules %}'
+ '{% syspanel_sidebar_modules request %}')
t = template.Template(ttext)
- self.assertEqual(single_line(t.render(context)) , '<h3>Nixon</h3> <ul class="sub_nav"> <li><a href="/syspanel/nixon/google">Google</a></li> </ul>')
+ self.assertEqual(single_line(t.render(context)),
+ '<h3>Nixon</h3> <ul class="sub_nav"> <li>'
+ '<a href="/syspanel/nixon/google">Google</a></li>'
+ ' </ul>')
self.mox.VerifyAll()
diff --git a/django-openstack/django_openstack/tests/view_tests/auth_tests.py b/django-openstack/django_openstack/tests/view_tests/auth_tests.py
index 788c367b..1c637f27 100644
--- a/django-openstack/django_openstack/tests/view_tests/auth_tests.py
+++ b/django-openstack/django_openstack/tests/view_tests/auth_tests.py
@@ -63,9 +63,9 @@ class AuthViewTests(base.BaseViewTests):
self.mox.StubOutWithMock(api, 'token_create')
class FakeToken(object):
- id=TOKEN_ID,
- user={'roles': [{'name': 'fake'}]},
- serviceCatalog={}
+ id = TOKEN_ID,
+ user = {'roles': [{'name': 'fake'}]},
+ serviceCatalog = {}
aToken = api.Token(FakeToken())
api.token_create(IsA(http.HttpRequest), "", self.TEST_USER,
@@ -104,7 +104,7 @@ class AuthViewTests(base.BaseViewTests):
class FakeToken(object):
id = TOKEN_ID,
user = {"id": "1",
- "roles": [{"id": "1", "name": "fake"},], "name": "user"}
+ "roles": [{"id": "1", "name": "fake"}], "name": "user"}
serviceCatalog = {}
tenant = None
aToken = api.Token(FakeToken())
@@ -208,7 +208,6 @@ class AuthViewTests(base.BaseViewTests):
api.tenant_list_for_token(IsA(http.HttpRequest), aToken.id).\
AndReturn([aTenant])
-
self.mox.ReplayAll()
res = self.client.post(reverse('auth_switch', args=[NEW_TENANT_ID]),
diff --git a/django-openstack/django_openstack/tests/view_tests/dash/floating_ip_tests.py b/django-openstack/django_openstack/tests/view_tests/dash/floating_ip_tests.py
index cd926ca1..6a7c05f0 100644
--- a/django-openstack/django_openstack/tests/view_tests/dash/floating_ip_tests.py
+++ b/django-openstack/django_openstack/tests/view_tests/dash/floating_ip_tests.py
@@ -200,9 +200,9 @@ class FloatingIpViewTests(base.BaseViewTests):
self.mox.StubOutWithMock(api, 'server_remove_floating_ip')
exception = novaclient_exceptions.ClientException('ClientException',
message='clientException')
- api.server_remove_floating_ip(IsA(http.HttpRequest), IsA(int),
- IsA(int)).\
- AndRaise(exception)
+ api.server_remove_floating_ip(IsA(http.HttpRequest),
+ IsA(int),
+ IsA(int)).AndRaise(exception)
self.mox.StubOutWithMock(messages, 'error')
messages.error(IsA(http.HttpRequest), IsA(basestring))
@@ -219,4 +219,3 @@ class FloatingIpViewTests(base.BaseViewTests):
self.assertRedirects(res, reverse('dash_floating_ips',
args=[self.TEST_TENANT]))
self.mox.VerifyAll()
-