[gnome-continuous-yocto/gnomeostree-3.28-rocko: 1227/8267] bitbake: toaster: api Add util function for returning the error response
- From: Emmanuele Bassi <ebassi src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-continuous-yocto/gnomeostree-3.28-rocko: 1227/8267] bitbake: toaster: api Add util function for returning the error response
- Date: Sat, 16 Dec 2017 21:31:56 +0000 (UTC)
commit e1ba2fd331b7f937b8ddf3e83389df5caf33d9e8
Author: Michael Wood <michael g wood intel com>
Date: Wed Jul 6 18:22:37 2016 +0100
bitbake: toaster: api Add util function for returning the error response
Also clean up flake8 warnings in XhrBuildRequest
(Bitbake rev: aa0845242eda8650a97180bf6675551c26554cde)
Signed-off-by: Michael Wood <michael g wood intel com>
Signed-off-by: Elliot Smith <elliot smith intel com>
Signed-off-by: Richard Purdie <richard purdie linuxfoundation org>
bitbake/lib/toaster/toastergui/api.py | 28 ++++++++++++++++------------
1 files changed, 16 insertions(+), 12 deletions(-)
---
diff --git a/bitbake/lib/toaster/toastergui/api.py b/bitbake/lib/toaster/toastergui/api.py
index a024748..112ce58 100644
--- a/bitbake/lib/toaster/toastergui/api.py
+++ b/bitbake/lib/toaster/toastergui/api.py
@@ -29,6 +29,9 @@ from django.views.generic import View
from django.core.urlresolvers import reverse
+def error_response(error):
+ return JsonResponse({"error": error})
+
class XhrBuildRequest(View):
@@ -81,20 +84,24 @@ class XhrBuildRequest(View):
br.save()
except BuildRequest.DoesNotExist:
- return JsonResponse({'error':'No such build id %s' % i})
+ return error_response('No such build id %s' % i)
- return JsonResponse({'error': 'ok'})
+ return error_response('ok')
if 'buildDelete' in request.POST:
for i in request.POST['buildDelete'].strip().split(" "):
try:
- BuildRequest.objects.select_for_update().get(project = project, pk = i, state__lte =
BuildRequest.REQ_DELETED).delete()
+ BuildRequest.objects.select_for_update().get(
+ project=project,
+ pk=i,
+ state__lte=BuildRequest.REQ_DELETED).delete()
+
except BuildRequest.DoesNotExist:
pass
- return JsonResponse({'error': 'ok' })
+ return error_response("ok")
if 'targets' in request.POST:
- ProjectTarget.objects.filter(project = project).delete()
+ ProjectTarget.objects.filter(project=project).delete()
s = str(request.POST['targets'])
for t in re.sub(r'[;%|"]', '', s).split(" "):
if ":" in t:
@@ -102,12 +109,12 @@ class XhrBuildRequest(View):
else:
target = t
task = ""
- ProjectTarget.objects.create(project = project,
- target = target,
- task = task)
+ ProjectTarget.objects.create(project=project,
+ target=target,
+ task=task)
project.schedule_build()
- return JsonResponse({'error': 'ok' })
+ return error_response('ok')
response = HttpResponse()
response.status_code = 500
@@ -135,9 +142,6 @@ class XhrLayer(View):
{"error": <error message>}
"""
- def error_response(error):
- return JsonResponse({"error": error})
-
try:
# We currently only allow Imported layers to be edited
layer_version = Layer_Version.objects.get(
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]