1
0
Fork 0
mirror of https://github.com/retspen/webvirtcloud synced 2024-12-25 07:35:22 +00:00

Fixed pep8

This commit is contained in:
Retspen 2015-03-27 17:12:15 +02:00
parent b9bf14fdb5
commit 56f840c893
13 changed files with 37 additions and 18 deletions

12
.travis.yml Normal file
View file

@ -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

View file

@ -6,8 +6,8 @@ from django.contrib.auth.models import User
class UserAddForm(forms.Form): class UserAddForm(forms.Form):
name = forms.CharField(label="Name", name = forms.CharField(label="Name",
error_messages={'required': _('No User name has been entered')}, error_messages={'required': _('No User name has been entered')},
max_length=20) max_length=20)
password = forms.CharField(required=True, error_messages={'required': _('No password has been entered')},) password = forms.CharField(required=True, error_messages={'required': _('No password has been entered')},)
def clean_name(self): def clean_name(self):

View file

@ -1,9 +1,10 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
from __future__ import unicode_literals from __future__ import unicode_literals
from django.db import models, migrations from django.db import migrations
from django.contrib.auth.models import User from django.contrib.auth.models import User
def add_admin(apps, schema_editor): def add_admin(apps, schema_editor):
add_user = User.objects.create_user("admin", None, "admin") add_user = User.objects.create_user("admin", None, "admin")
add_user.is_active = True add_user.is_active = True
@ -11,6 +12,7 @@ def add_admin(apps, schema_editor):
add_user.is_staff = True add_user.is_staff = True
add_user.save() add_user.save()
class Migration(migrations.Migration): class Migration(migrations.Migration):
dependencies = [ dependencies = [
@ -19,4 +21,4 @@ class Migration(migrations.Migration):
operations = [ operations = [
migrations.RunPython(add_admin), migrations.RunPython(add_admin),
] ]

View file

@ -10,4 +10,4 @@ class UserInstance(models.Model):
is_delete = models.BooleanField(default=False) is_delete = models.BooleanField(default=False)
def __unicode__(self): def __unicode__(self):
return self.instance.name return self.instance.name

View file

@ -122,7 +122,7 @@ def account(request, user_id):
instances = Instance.objects.all() instances = Instance.objects.all()
if user.username == request.user.username: if user.username == request.user.username:
return HttpResponseRedirect(reverse('profile')) return HttpResponseRedirect(reverse('profile'))
if request.method == 'POST': if request.method == 'POST':
if 'delete' in request.POST: if 'delete' in request.POST:
@ -150,4 +150,4 @@ def account(request, user_id):
add_user_inst.save() add_user_inst.save()
return HttpResponseRedirect(request.get_full_path()) return HttpResponseRedirect(request.get_full_path())
return render(request, 'account.html', locals()) return render(request, 'account.html', locals())

View file

@ -9,4 +9,4 @@ class Compute(models.Model):
type = models.IntegerField() type = models.IntegerField()
def __unicode__(self): def __unicode__(self):
return self.hostname return self.hostname

View file

@ -37,7 +37,7 @@ def computes(request):
'type': compute.type, 'type': compute.type,
'login': compute.login, 'login': compute.login,
'password': compute.password 'password': compute.password
}) })
return compute_data return compute_data
error_messages = [] error_messages = []
@ -222,4 +222,4 @@ def compute_graph(request, compute_id):
response.cookies['timer'] = datasets['timer'] response.cookies['timer'] = datasets['timer']
response.cookies['mem'] = datasets['mem'] response.cookies['mem'] = datasets['mem']
response.write(data) response.write(data)
return response return response

View file

@ -1,7 +1,8 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
from __future__ import unicode_literals from __future__ import unicode_literals
from django.db import models, migrations from django.db import migrations
def add_favors(apps, schema_editor): def add_favors(apps, schema_editor):
Flavor = apps.get_model("create", "Flavor") 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 = Flavor(label="xlarge", vcpu="8", memory="16384", disk="160")
add_flavor.save() add_flavor.save()
class Migration(migrations.Migration): class Migration(migrations.Migration):
dependencies = [ dependencies = [
@ -26,4 +28,4 @@ class Migration(migrations.Migration):
operations = [ operations = [
migrations.RunPython(add_favors), migrations.RunPython(add_favors),
] ]

View file

@ -1,2 +1,5 @@
Django==1.7.7 Django==1.7.7
websockify==0.6.0 websockify==0.6.0
pep8==1.6.2
pyflakes==0.8.1
pylint==1.4.3

View file

@ -8,4 +8,4 @@ class Instance(models.Model):
uuid = models.CharField(max_length=36) uuid = models.CharField(max_length=36)
def __unicode__(self): def __unicode__(self):
return self.name return self.name

View file

@ -8,4 +8,4 @@ register = template.Library()
def class_active(request, pattern): def class_active(request, pattern):
if re.search(pattern, request.path): if re.search(pattern, request.path):
return 'class="active"' return 'class="active"'
return '' return ''

View file

@ -234,7 +234,7 @@ def instance(request, compute_id, vname):
conn.force_shutdown() conn.force_shutdown()
msg = _("Force Off") msg = _("Force Off")
addlogmsg(request.user.id, instance.id, msg) 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 'delete' in request.POST:
if conn.get_status() == 1: 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]}) json_net.append({'dev': net['dev'], 'data': [datasets_rx, datasets_tx]})
datasets_net[net['dev']] = [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['cpu'] = datasets['cpu']
response.cookies['timer'] = datasets['timer'] response.cookies['timer'] = datasets['timer']

View file

@ -132,7 +132,7 @@ def storage(request, compute_id, pool):
if 'delete' in request.POST: if 'delete' in request.POST:
try: try:
conn.delete() conn.delete()
return HttpResponseRedirect(reverse('storages', args=[host_id])) return HttpResponseRedirect(reverse('storages', args=[compute_id]))
except libvirtError as lib_err: except libvirtError as lib_err:
error_messages.append(lib_err.message) error_messages.append(lib_err.message)
if 'set_autostart' in request.POST: if 'set_autostart' in request.POST: