From 56f840c89309c0c341edfcfb02ecbf030b48007a Mon Sep 17 00:00:00 2001 From: Retspen Date: Fri, 27 Mar 2015 17:12:15 +0200 Subject: [PATCH] Fixed pep8 --- .travis.yml | 12 ++++++++++++ accounts/forms.py | 4 ++-- accounts/migrations/0002_auto_20150325_0846.py | 6 ++++-- accounts/models.py | 2 +- accounts/views.py | 4 ++-- computes/models.py | 2 +- computes/views.py | 4 ++-- create/migrations/0002_auto_20150325_0921.py | 6 ++++-- dev/requirements.txt | 5 ++++- instances/models.py | 2 +- instances/templatetags/tags_active.py | 2 +- instances/views.py | 4 ++-- storages/views.py | 2 +- 13 files changed, 37 insertions(+), 18 deletions(-) create mode 100644 .travis.yml diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..d79e109 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,12 @@ +language: python +python: + - "2.7" +env: + - DJANGO=1.7.7 +install: + - pip install -r dev/requirements.txt --use-mirrors +script: + - pep8 --exclude=IPy.py --ignore=E501 vrtManager accounts computes console create instances interfaces networks secrets storages + - pyflakes vrtManager accounts computes console create instances interfaces networks secrets storages + - python manage.py migrate + - python manage.py test --settings=webvirtcloud.settings-dev diff --git a/accounts/forms.py b/accounts/forms.py index 749dbd9..55d5c29 100644 --- a/accounts/forms.py +++ b/accounts/forms.py @@ -6,8 +6,8 @@ from django.contrib.auth.models import User class UserAddForm(forms.Form): name = forms.CharField(label="Name", - error_messages={'required': _('No User name has been entered')}, - max_length=20) + error_messages={'required': _('No User name has been entered')}, + max_length=20) password = forms.CharField(required=True, error_messages={'required': _('No password has been entered')},) def clean_name(self): diff --git a/accounts/migrations/0002_auto_20150325_0846.py b/accounts/migrations/0002_auto_20150325_0846.py index 734eae1..eac6d60 100644 --- a/accounts/migrations/0002_auto_20150325_0846.py +++ b/accounts/migrations/0002_auto_20150325_0846.py @@ -1,9 +1,10 @@ # -*- coding: utf-8 -*- from __future__ import unicode_literals -from django.db import models, migrations +from django.db import migrations from django.contrib.auth.models import User + def add_admin(apps, schema_editor): add_user = User.objects.create_user("admin", None, "admin") add_user.is_active = True @@ -11,6 +12,7 @@ def add_admin(apps, schema_editor): add_user.is_staff = True add_user.save() + class Migration(migrations.Migration): dependencies = [ @@ -19,4 +21,4 @@ class Migration(migrations.Migration): operations = [ migrations.RunPython(add_admin), - ] \ No newline at end of file + ] diff --git a/accounts/models.py b/accounts/models.py index 2334901..5151861 100644 --- a/accounts/models.py +++ b/accounts/models.py @@ -10,4 +10,4 @@ class UserInstance(models.Model): is_delete = models.BooleanField(default=False) def __unicode__(self): - return self.instance.name \ No newline at end of file + return self.instance.name diff --git a/accounts/views.py b/accounts/views.py index b50c97d..c237350 100644 --- a/accounts/views.py +++ b/accounts/views.py @@ -122,7 +122,7 @@ def account(request, user_id): instances = Instance.objects.all() if user.username == request.user.username: - return HttpResponseRedirect(reverse('profile')) + return HttpResponseRedirect(reverse('profile')) if request.method == 'POST': if 'delete' in request.POST: @@ -150,4 +150,4 @@ def account(request, user_id): add_user_inst.save() return HttpResponseRedirect(request.get_full_path()) - return render(request, 'account.html', locals()) \ No newline at end of file + return render(request, 'account.html', locals()) diff --git a/computes/models.py b/computes/models.py index a76355a..6ee7de8 100644 --- a/computes/models.py +++ b/computes/models.py @@ -9,4 +9,4 @@ class Compute(models.Model): type = models.IntegerField() def __unicode__(self): - return self.hostname \ No newline at end of file + return self.hostname diff --git a/computes/views.py b/computes/views.py index 19feeb3..d7f14e9 100644 --- a/computes/views.py +++ b/computes/views.py @@ -37,7 +37,7 @@ def computes(request): 'type': compute.type, 'login': compute.login, 'password': compute.password - }) + }) return compute_data error_messages = [] @@ -222,4 +222,4 @@ def compute_graph(request, compute_id): response.cookies['timer'] = datasets['timer'] response.cookies['mem'] = datasets['mem'] response.write(data) - return response \ No newline at end of file + return response diff --git a/create/migrations/0002_auto_20150325_0921.py b/create/migrations/0002_auto_20150325_0921.py index e30f1f9..5594060 100644 --- a/create/migrations/0002_auto_20150325_0921.py +++ b/create/migrations/0002_auto_20150325_0921.py @@ -1,7 +1,8 @@ # -*- coding: utf-8 -*- from __future__ import unicode_literals -from django.db import models, migrations +from django.db import migrations + def add_favors(apps, schema_editor): Flavor = apps.get_model("create", "Flavor") @@ -18,6 +19,7 @@ def add_favors(apps, schema_editor): add_flavor = Flavor(label="xlarge", vcpu="8", memory="16384", disk="160") add_flavor.save() + class Migration(migrations.Migration): dependencies = [ @@ -26,4 +28,4 @@ class Migration(migrations.Migration): operations = [ migrations.RunPython(add_favors), - ] \ No newline at end of file + ] diff --git a/dev/requirements.txt b/dev/requirements.txt index fad841d..0a40713 100644 --- a/dev/requirements.txt +++ b/dev/requirements.txt @@ -1,2 +1,5 @@ Django==1.7.7 -websockify==0.6.0 \ No newline at end of file +websockify==0.6.0 +pep8==1.6.2 +pyflakes==0.8.1 +pylint==1.4.3 \ No newline at end of file diff --git a/instances/models.py b/instances/models.py index b182399..4345cc1 100644 --- a/instances/models.py +++ b/instances/models.py @@ -8,4 +8,4 @@ class Instance(models.Model): uuid = models.CharField(max_length=36) def __unicode__(self): - return self.name \ No newline at end of file + return self.name diff --git a/instances/templatetags/tags_active.py b/instances/templatetags/tags_active.py index 78dfb49..8d8ce62 100644 --- a/instances/templatetags/tags_active.py +++ b/instances/templatetags/tags_active.py @@ -8,4 +8,4 @@ register = template.Library() def class_active(request, pattern): if re.search(pattern, request.path): return 'class="active"' - return '' \ No newline at end of file + return '' diff --git a/instances/views.py b/instances/views.py index 4e55bfb..7323bf3 100644 --- a/instances/views.py +++ b/instances/views.py @@ -234,7 +234,7 @@ def instance(request, compute_id, vname): conn.force_shutdown() msg = _("Force Off") addlogmsg(request.user.id, instance.id, msg) - return HttpResponseRedirect(request.get_full_path() + '#powerforce') + return HttpResponseRedirect(request.get_full_path() + '#powerforce') if 'delete' in request.POST: if conn.get_status() == 1: @@ -547,7 +547,7 @@ def inst_graph(request, compute_id, vname): json_net.append({'dev': net['dev'], 'data': [datasets_rx, datasets_tx]}) datasets_net[net['dev']] = [datasets_rx, datasets_tx] - data = json.dumps({'cpudata': datasets['cpu'], 'blkdata': json_blk, 'netdata': json_net, 'timeline': datasets['timer']}) + data = json.dumps({'cpudata': datasets['cpu'], 'blkdata': json_blk, 'netdata': json_net, 'timeline': datasets['timer']}) response.cookies['cpu'] = datasets['cpu'] response.cookies['timer'] = datasets['timer'] diff --git a/storages/views.py b/storages/views.py index 565f060..66f5e26 100644 --- a/storages/views.py +++ b/storages/views.py @@ -132,7 +132,7 @@ def storage(request, compute_id, pool): if 'delete' in request.POST: try: conn.delete() - return HttpResponseRedirect(reverse('storages', args=[host_id])) + return HttpResponseRedirect(reverse('storages', args=[compute_id])) except libvirtError as lib_err: error_messages.append(lib_err.message) if 'set_autostart' in request.POST: