summaryrefslogtreecommitdiffstats
path: root/bitbake/lib/toaster/orm
diff options
context:
space:
mode:
authorMichael Wood <michael.g.wood@intel.com>2015-06-16 16:00:26 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2015-06-26 09:27:33 +0100
commitdf48243970fac633586eb99c9baf3090123c681c (patch)
treea616118bed5fa9831a5ddbf0033cc5833d51e80a /bitbake/lib/toaster/orm
parent62288a66896416beaef1d85aeefc8dab0835f4f8 (diff)
downloadpoky-df48243970fac633586eb99c9baf3090123c681c.tar.gz
bitbake: toaster: split orm app into it's own module and app
The orm application was also the django application to collect the build information. Splitting this module up into it's functional parts. orm for the data module and bldcollector for build collection data. (Bitbake rev: 8ca10764ffd6cfec12cbfeabf240d81213a07845) Signed-off-by: Michael Wood <michael.g.wood@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake/lib/toaster/orm')
-rw-r--r--bitbake/lib/toaster/orm/admin.py34
-rw-r--r--bitbake/lib/toaster/orm/urls.py27
-rw-r--r--bitbake/lib/toaster/orm/views.py62
3 files changed, 0 insertions, 123 deletions
diff --git a/bitbake/lib/toaster/orm/admin.py b/bitbake/lib/toaster/orm/admin.py
deleted file mode 100644
index 706e517e0e..0000000000
--- a/bitbake/lib/toaster/orm/admin.py
+++ /dev/null
@@ -1,34 +0,0 @@
1from django.contrib import admin
2from django.contrib.admin.filters import RelatedFieldListFilter
3from .models import BitbakeVersion, Release, LayerSource, ToasterSetting
4from django.forms.widgets import Textarea
5from django import forms
6import django.db.models as models
7
8from django.contrib.admin import widgets, helpers
9
10class LayerSourceAdmin(admin.ModelAdmin):
11 pass
12
13class BitbakeVersionAdmin(admin.ModelAdmin):
14
15 # we override the formfield for db URLField because of broken URL validation
16
17 def formfield_for_dbfield(self, db_field, **kwargs):
18 if isinstance(db_field, models.fields.URLField):
19 return forms.fields.CharField()
20 return super(BitbakeVersionAdmin, self).formfield_for_dbfield(db_field, **kwargs)
21
22
23
24class ReleaseAdmin(admin.ModelAdmin):
25 pass
26
27class ToasterSettingAdmin(admin.ModelAdmin):
28 pass
29
30admin.site.register(LayerSource, LayerSourceAdmin)
31admin.site.register(BitbakeVersion, BitbakeVersionAdmin)
32admin.site.register(Release, ReleaseAdmin)
33admin.site.register(ToasterSetting, ToasterSettingAdmin)
34
diff --git a/bitbake/lib/toaster/orm/urls.py b/bitbake/lib/toaster/orm/urls.py
deleted file mode 100644
index 961bc19070..0000000000
--- a/bitbake/lib/toaster/orm/urls.py
+++ /dev/null
@@ -1,27 +0,0 @@
1#
2# BitBake Toaster Implementation
3#
4# Copyright (C) 2014 Intel Corporation
5#
6# This program is free software; you can redistribute it and/or modify
7# it under the terms of the GNU General Public License version 2 as
8# published by the Free Software Foundation.
9#
10# This program is distributed in the hope that it will be useful,
11# but WITHOUT ANY WARRANTY; without even the implied warranty of
12# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13# GNU General Public License for more details.
14#
15# You should have received a copy of the GNU General Public License along
16# with this program; if not, write to the Free Software Foundation, Inc.,
17# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18
19
20from django.conf.urls import patterns, include, url
21from django.views.generic import RedirectView
22
23urlpatterns = patterns('orm.views',
24 # landing point for pushing a bitbake_eventlog.json file to this toaster instace
25 url(r'^eventfile$', 'eventfile', name='eventfile'),
26 )
27
diff --git a/bitbake/lib/toaster/orm/views.py b/bitbake/lib/toaster/orm/views.py
deleted file mode 100644
index f32fa4d225..0000000000
--- a/bitbake/lib/toaster/orm/views.py
+++ /dev/null
@@ -1,62 +0,0 @@
1#
2# BitBake Toaster Implementation
3#
4# Copyright (C) 2014 Intel Corporation
5#
6# This program is free software; you can redistribute it and/or modify
7# it under the terms of the GNU General Public License version 2 as
8# published by the Free Software Foundation.
9#
10# This program is distributed in the hope that it will be useful,
11# but WITHOUT ANY WARRANTY; without even the implied warranty of
12# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13# GNU General Public License for more details.
14#
15# You should have received a copy of the GNU General Public License along
16# with this program; if not, write to the Free Software Foundation, Inc.,
17# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18
19from django.views.decorators.cache import cache_control
20from django.core.urlresolvers import reverse
21from django.core.paginator import Paginator, EmptyPage, PageNotAnInteger
22from django.http import HttpResponseBadRequest, HttpResponse
23from django.utils import timezone
24from django.utils.html import escape
25from datetime import timedelta
26from django.utils import formats
27from toastergui.templatetags.projecttags import json as jsonfilter
28import json
29import os
30import tempfile
31import subprocess
32import toastermain
33from django.views.decorators.csrf import csrf_exempt
34
35
36@csrf_exempt
37def eventfile(request):
38 """ Receives a file by POST, and runs toaster-eventreply on this file """
39 if request.method != "POST":
40 return HttpResponseBadRequest("This API only accepts POST requests. Post a file with:\n\ncurl -F eventlog=@bitbake_eventlog.json %s\n" % request.build_absolute_uri(reverse('eventfile')), content_type="text/plain;utf8")
41
42 # write temporary file
43 (handle, abstemppath) = tempfile.mkstemp(dir="/tmp/")
44 with os.fdopen(handle, "w") as tmpfile:
45 for chunk in request.FILES['eventlog'].chunks():
46 tmpfile.write(chunk)
47 tmpfile.close()
48
49 # compute the path to "bitbake/bin/toaster-eventreplay"
50 from os.path import dirname as DN
51 import_script = os.path.join(DN(DN(DN(DN(os.path.abspath(__file__))))), "bin/toaster-eventreplay")
52 if not os.path.exists(import_script):
53 raise Exception("script missing %s" % import_script)
54 scriptenv = os.environ.copy()
55 scriptenv["DATABASE_URL"] = toastermain.settings.getDATABASE_URL()
56
57 # run the data loading process and return the results
58 importer = subprocess.Popen([import_script, abstemppath], stdout=subprocess.PIPE, stderr=subprocess.PIPE, env=scriptenv)
59 (out, err) = importer.communicate()
60 if importer.returncode == 0:
61 os.remove(abstemppath)
62 return HttpResponse("== Retval %d\n== STDOUT\n%s\n\n== STDERR\n%s" % (importer.returncode, out, err), content_type="text/plain;utf8")