def apply_config(request): "Apply configuration" if request.method == "POST": confirm = False form = ApplyForm(request.POST) if form.is_valid(): vcmd = getattr(settings, "BARUWA_WEB_VERIFY_CMD") acmd = getattr(settings, "BARUWA_WEB_APPLY_CMD") if not os.path.exists(vcmd): msg = _("The verify command does not exist") messages.info(request, msg) return HttpResponseRedirect(reverse("acl-rules")) if not os.path.exists(acmd): msg = _("The apply command does not exist") messages.info(request, msg) return HttpResponseRedirect(reverse("acl-rules")) try: lock_tables() pipe = Popen([vcmd], stdout=PIPE, stderr=PIPE) stdout, stderr = pipe.communicate() if pipe.returncode != 0: raise ValueError(stdout) pipe = Popen([acmd], stdout=PIPE, stderr=PIPE) stdout, stderr = pipe.communicate() if pipe.returncode == 0: success = True else: success = False except (OSError, ValueError), exception: stdout += str(exception) success = False finally:
def apply_config(request): "Apply configuration" if request.method == 'POST': confirm = False form = ApplyForm(request.POST) if form.is_valid(): vcmd = getattr(settings, 'BARUWA_WEB_VERIFY_CMD') acmd = getattr(settings, 'BARUWA_WEB_APPLY_CMD') if not os.path.exists(vcmd): msg = _('The verify command does not exist') messages.info(request, msg) return HttpResponseRedirect(reverse('acl-rules')) if not os.path.exists(acmd): msg = _('The apply command does not exist') messages.info(request, msg) return HttpResponseRedirect(reverse('acl-rules')) try: lock_tables() pipe = Popen([vcmd], stdout=PIPE, stderr=PIPE) stdout, stderr = pipe.communicate() if pipe.returncode != 0: raise ValueError(stdout) pipe = Popen([acmd], stdout=PIPE, stderr=PIPE) stdout, stderr = pipe.communicate() if pipe.returncode == 0: success = True else: success = False except (OSError, ValueError), exception: stdout += str(exception) success = False finally:
def verify_config(request): "Verify configuration" cmd = getattr(settings, "BARUWA_WEB_VERIFY_CMD") if not os.path.exists(cmd): msg = _("The verify command does not exist") messages.info(request, msg) return HttpResponseRedirect(reverse("acl-rules")) try: lock_tables() pipe = Popen([cmd], stdout=PIPE, stderr=PIPE) stdout, stderr = pipe.communicate() if pipe.returncode == 0: success = True else: success = False except OSError, exception: stdout += str(exception) success = False
def verify_config(request): "Verify configuration" cmd = getattr(settings, 'BARUWA_WEB_VERIFY_CMD') if not os.path.exists(cmd): msg = _('The verify command does not exist') messages.info(request, msg) return HttpResponseRedirect(reverse('acl-rules')) try: lock_tables() pipe = Popen([cmd], stdout=PIPE, stderr=PIPE) stdout, stderr = pipe.communicate() if pipe.returncode == 0: success = True else: success = False except OSError, exception: stdout += str(exception) success = False