1
0
Fork 0
mirror of https://github.com/retspen/webvirtcloud synced 2025-07-31 12:41:08 +00:00

Migrate source code to python 3.7 and refine code style

This commit is contained in:
Gao Jiangmiao 2019-08-16 12:59:37 +08:00
parent 0e231a930d
commit a4d74a09a6
55 changed files with 192 additions and 306 deletions

View file

@ -16,7 +16,7 @@ class AddNetPool(forms.Form):
def clean_name(self):
name = self.cleaned_data['name']
have_symbol = re.match('^[a-zA-Z0-9\.\_\-]+$', name)
have_symbol = re.match('^[a-zA-Z0-9._-]+$', name)
if not have_symbol:
raise forms.ValidationError(_('The pool name must not contain any special characters'))
elif len(name) > 20:
@ -35,7 +35,7 @@ class AddNetPool(forms.Form):
def clean_bridge_name(self):
bridge_name = self.cleaned_data['bridge_name']
if self.cleaned_data['forward'] == 'bridge':
have_symbol = re.match('^[a-zA-Z0-9\.\_\:\-]+$', bridge_name)
have_symbol = re.match('^[a-zA-Z0-9._:-]+$', bridge_name)
if not have_symbol:
raise forms.ValidationError(_('The pool bridge name must not contain any special characters'))
elif len(bridge_name) > 20:

View file

@ -153,13 +153,11 @@ def network(request, compute_id, pool):
edit_xml = request.POST.get('edit_xml', '')
if edit_xml:
try:
new_conn = wvmNetworks(compute.hostname,
compute.login,
compute.password,
compute.type)
new_conn = wvmNetworks(compute.hostname, compute.login, compute.password, compute.type)
conn.define_network(edit_xml)
if conn.is_active():
messages.success(request, _("Network XML is changed. Stop and start network to activate new config."))
messages.success(request,
_("Network XML is changed. Stop and start network to activate new config."))
else:
messages.success(request, _("Network XML is changed."))
return HttpResponseRedirect(request.get_full_path())