summaryrefslogtreecommitdiffstats
path: root/bitbake/lib/toaster/bldviewer
diff options
context:
space:
mode:
Diffstat (limited to 'bitbake/lib/toaster/bldviewer')
-rw-r--r--bitbake/lib/toaster/bldviewer/__init__.py0
-rw-r--r--bitbake/lib/toaster/bldviewer/api.py37
-rw-r--r--bitbake/lib/toaster/bldviewer/templates/base.html30
-rw-r--r--bitbake/lib/toaster/bldviewer/templates/basebuildpage.html17
-rw-r--r--bitbake/lib/toaster/bldviewer/templates/basetable.html46
-rw-r--r--bitbake/lib/toaster/bldviewer/templates/bfile.html24
-rw-r--r--bitbake/lib/toaster/bldviewer/templates/bpackage.html44
-rw-r--r--bitbake/lib/toaster/bldviewer/templates/build.html43
-rw-r--r--bitbake/lib/toaster/bldviewer/templates/configuration.html20
-rw-r--r--bitbake/lib/toaster/bldviewer/templates/layer.html34
-rw-r--r--bitbake/lib/toaster/bldviewer/templates/package.html36
-rw-r--r--bitbake/lib/toaster/bldviewer/templates/recipe.html54
-rw-r--r--bitbake/lib/toaster/bldviewer/templates/task.html63
-rw-r--r--bitbake/lib/toaster/bldviewer/templatetags/__init__.py0
-rw-r--r--bitbake/lib/toaster/bldviewer/templatetags/projecttags.py26
-rw-r--r--bitbake/lib/toaster/bldviewer/urls.py32
-rw-r--r--bitbake/lib/toaster/bldviewer/views.py260
17 files changed, 766 insertions, 0 deletions
diff --git a/bitbake/lib/toaster/bldviewer/__init__.py b/bitbake/lib/toaster/bldviewer/__init__.py
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/bitbake/lib/toaster/bldviewer/__init__.py
diff --git a/bitbake/lib/toaster/bldviewer/api.py b/bitbake/lib/toaster/bldviewer/api.py
new file mode 100644
index 0000000000..f761ba65a9
--- /dev/null
+++ b/bitbake/lib/toaster/bldviewer/api.py
@@ -0,0 +1,37 @@
1#
2# BitBake Toaster Implementation
3#
4# Copyright (C) 2013 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.conf.urls import patterns, include, url
20
21
22urlpatterns = patterns('bldviewer.views',
23 url(r'^builds$', 'model_explorer', {'model_name':'build'}, name='builds'),
24 url(r'^targets$', 'model_explorer', {'model_name':'target'}, name='targets'),
25 url(r'^tasks$', 'model_explorer', {'model_name':'task'}, name='task'),
26 url(r'^task_dependencies$', 'model_explorer', {'model_name':'task_dependency'}, name='task_dependencies'),
27 url(r'^packages$', 'model_explorer', {'model_name':'build_package'}, name='build_packages'),
28 url(r'^package_dependencies$', 'model_explorer', {'model_name':'build_package_dependency'}, name='build_package_dependencies'),
29 url(r'^target_packages$', 'model_explorer', {'model_name':'target_package'}, name='target_packages'),
30 url(r'^package_files$', 'model_explorer', {'model_name':'build_file'}, name='build_files'),
31 url(r'^layers$', 'model_explorer', {'model_name':'layer'}, name='layer'),
32 url(r'^layerversions$', 'model_explorer', {'model_name':'layerversion'}, name='layerversion'),
33 url(r'^recipes$', 'model_explorer', {'model_name':'recipe'}, name='recipe'),
34 url(r'^recipe_dependencies$', 'model_explorer', {'model_name':'recipe_dependency'}, name='recipe_dependencies'),
35 url(r'^variables$', 'model_explorer', {'model_name':'variable'}, name='variables'),
36 url(r'^logmessages$', 'model_explorer', {'model_name':'logmessage'}, name='logmessages'),
37)
diff --git a/bitbake/lib/toaster/bldviewer/templates/base.html b/bitbake/lib/toaster/bldviewer/templates/base.html
new file mode 100644
index 0000000000..101880d3ea
--- /dev/null
+++ b/bitbake/lib/toaster/bldviewer/templates/base.html
@@ -0,0 +1,30 @@
1<!DOCTYPE html>
2{% load static %}
3<html>
4 <head>
5 <title>Toaster Simple Explorer</title>
6<script src="{% static 'js/jquery-2.0.3.js' %}">
7</script>
8<script src="{% static 'js/bootstrap.js' %}">
9</script>
10<link href="{% static 'css/bootstrap.css' %}" rel="stylesheet" type="text/css">
11 </head>
12
13<body style="height: 100%">
14<div style="width:100%; height: 100%; position:absolute">
15<div style="width: 100%; height: 3em" class="nav">
16 <ul class="nav nav-tabs">
17 <li><a href="{% url all-builds %}">All Builds</a></li>
18 <li><a href="{% url all-layers %}">All Layers</a></li>
19 </ul>
20</div>
21
22<div style="overflow-y:scroll; width: 100%; position: absolute; top: 3em; bottom:70px ">
23{% block pagecontent %}
24{% endblock %}
25</div>
26<div class="navbar" style="position: absolute; bottom: 0; width:100%"><br/>About Toaster | Yocto Project </div>
27</div>
28</body>
29</html>
30
diff --git a/bitbake/lib/toaster/bldviewer/templates/basebuildpage.html b/bitbake/lib/toaster/bldviewer/templates/basebuildpage.html
new file mode 100644
index 0000000000..873f271bab
--- /dev/null
+++ b/bitbake/lib/toaster/bldviewer/templates/basebuildpage.html
@@ -0,0 +1,17 @@
1{% extends "basetable.html" %}
2
3{% block pagename %}
4<ul class="nav nav-tabs" style="display: inline-block">
5 <li><a>Build {{build.target_set.all|join:"&nbsp;"}} at {{build.started_on}} : </a></li>
6 <li><a href="{% url task build.id %}"> Tasks </a></li>
7 <li><a href="{% url bpackage build.id %}"> Build Packages </a></li>
8 {% for t in build.target_set.all %}
9 {% if t.is_image %}
10 <li><a href="{% url tpackage build.id t.pk %}"> Packages for {{t.target}} </a> </li>
11 {% endif %}
12 {% endfor %}
13 <li><a href="{% url configuration build.id %}"> Configuration </a> </li>
14</ul>
15 <h1>Toaster - Build {% block pagetitle %} {% endblock %}</h1>
16{% endblock %}
17
diff --git a/bitbake/lib/toaster/bldviewer/templates/basetable.html b/bitbake/lib/toaster/bldviewer/templates/basetable.html
new file mode 100644
index 0000000000..083bcb82e9
--- /dev/null
+++ b/bitbake/lib/toaster/bldviewer/templates/basetable.html
@@ -0,0 +1,46 @@
1{% extends "base.html" %}
2
3{% block pagecontent %}
4<script>
5function showhideTableColumn(i, sh) {
6 if (sh)
7 $('td:nth-child('+i+'),th:nth-child('+i+')').show();
8 else
9 $('td:nth-child('+i+'),th:nth-child('+i+')').hide();
10}
11
12
13function filterTableRows(test) {
14 if (test.length > 0) {
15 var r = test.split(/[ ,]+/).map(function (e) { return new RegExp(e, 'i') });
16 $('tr.data').map( function (i, el) {
17 (! r.map(function (j) { return j.test($(el).html())}).reduce(function (c, p) { return c && p;} )) ? $(el).hide() : $(el).show();
18 });
19 } else
20 {
21 $('tr.data').show();
22 }
23}
24</script>
25<div style="margin-bottom: 0.5em">
26
27 {% block pagename %}
28 {% endblock %}
29 <div align="left" style="display:inline-block; width: 40%; margin-left: 2em"> Search: <input type="search" id="filterstring" style="width: 80%" onkeyup="filterTableRows($('#filterstring').val())" autocomplete="off">
30 </div>
31 {% if hideshowcols %}
32 <div align="right" style="display: inline-block; width: 40%">Show/Hide columns:
33 {% for i in hideshowcols %}
34 <span>{{i.name}} <input type="checkbox" id="ct{{i.name}}" onchange="showhideTableColumn({{i.order}}, $('#ct{{i.name}}').is(':checked'))" checked autocomplete="off"></span> |
35 {% endfor %}
36 </div>
37 {% endif %}
38</div>
39<div>
40 <table class="table table-striped table-condensed" style="width:95%">
41{% block pagetable %}
42{% endblock %}
43 </table>
44</div>
45
46{% endblock %}
diff --git a/bitbake/lib/toaster/bldviewer/templates/bfile.html b/bitbake/lib/toaster/bldviewer/templates/bfile.html
new file mode 100644
index 0000000000..d90f4fbddb
--- /dev/null
+++ b/bitbake/lib/toaster/bldviewer/templates/bfile.html
@@ -0,0 +1,24 @@
1{% extends "basebuildpage.html" %}
2
3{% block pagetitle %}Files for package {{files.0.bpackage.name}} {% endblock %}
4{% block pagetable %}
5 {% if not files %}
6 <p>No files were recorded for this package!</p>
7 {% else %}
8
9 <tr>
10 <th>Name</th>
11 <th>Size (Bytes)</th>
12 </tr>
13
14 {% for file in files %}
15
16 <tr class="data">
17 <td>{{file.path}}</td>
18 <td>{{file.size}}</td>
19
20 {% endfor %}
21
22 {% endif %}
23
24{% endblock %}
diff --git a/bitbake/lib/toaster/bldviewer/templates/bpackage.html b/bitbake/lib/toaster/bldviewer/templates/bpackage.html
new file mode 100644
index 0000000000..2e254dbad6
--- /dev/null
+++ b/bitbake/lib/toaster/bldviewer/templates/bpackage.html
@@ -0,0 +1,44 @@
1{% extends "basebuildpage.html" %}
2
3{% block pagetitle %}Packages{% endblock %}
4{% block pagetable %}
5 {% if not packages %}
6 <p>No packages were recorded for this target!</p>
7 {% else %}
8
9 <tr>
10 <th>Name</th>
11 <th>Version</th>
12 <th>Recipe</th>
13 <th>Summary</th>
14 <th>Section</th>
15 <th>Description</th>
16 <th>Size on host disk (KBytes)</th>
17 <th>License</th>
18 <th>Dependencies List (all)</th>
19 </tr>
20
21 {% for package in packages %}
22
23 <tr class="data">
24 <td><a name="#{{package.name}}" href="{% url bfile build.pk package.pk %}">{{package.name}} ({{package.filelist_bpackage.count}} files)</a></td>
25 <td>{{package.version}}-{{package.revision}}</td>
26 <td><a href="{% url layer_versions_recipes package.recipe.layer_version_id %}#{{package.recipe.name}}">{{package.recipe.name}}</a>{{package.package_name}}</a></td>
27
28 <td>{{package.summary}}</td>
29 <td>{{package.section}}</td>
30 <td>{{package.description}}</td>
31 <td>{{package.size}}</td>
32 <td>{{package.license}}</td>
33 <td>
34 <div style="height: 3em; overflow:auto">
35 {% for bpd in package.bpackage_dependencies_package.all %}
36 {{bpd.dep_type}}: {{bpd.depends_on}} <br/>
37 {% endfor %}
38 </div>
39 </td>
40 {% endfor %}
41
42 {% endif %}
43
44{% endblock %}
diff --git a/bitbake/lib/toaster/bldviewer/templates/build.html b/bitbake/lib/toaster/bldviewer/templates/build.html
new file mode 100644
index 0000000000..ab6e19643b
--- /dev/null
+++ b/bitbake/lib/toaster/bldviewer/templates/build.html
@@ -0,0 +1,43 @@
1{% extends "basetable.html" %}
2
3{% block pagename %}
4 <h1>Toaster - Builds</h1>
5{% endblock %}
6
7{% block pagetable %}
8
9 {% load projecttags %}
10 <tr>
11 <th>Outcome</th>
12 <th>Started On</th>
13 <th>Completed On</th>
14 <th>Target</th>
15 <th>Machine</th>
16 <th>Time</th>
17 <th>Errors</th>
18 <th>Warnings</th>
19 <th>Output</th>
20 <th>Log</th>
21 <th>Bitbake Version</th>
22 <th>Build Name</th>
23 </tr>
24 {% for build in builds %}
25 <tr class="data">
26 <td><a href="{% url configuration build.id %}">{{build.get_outcome_display}}</a></td>
27 <td>{{build.started_on}}</td>
28 <td>{{build.completed_on}}</td>
29 <td>{% for t in build.target_set.all %}<a href="{% url tpackage build.id t.id %}">{{t.target}}</a>{% if t.is_image %} (Img){% endif %}<br/>{% endfor %}</td>
30 <td>{{build.machine}}</td>
31 <td>{% time_difference build.started_on build.completed_on %}</td>
32 <td>{{build.errors_no}}:{% if build.errors_no %}{% for error in logs %}{% if error.build == build %}{% if error.level == 2 %}<p>{{error.message}}</p>{% endif %}{% endif %}{% endfor %}{% else %}None{% endif %}</td>
33 <td>{{build.warnings_no}}:{% if build.warnings_no %}{% for warning in logs %}{% if warning.build == build %}{% if warning.level == 1 %}<p>{{warning.message}}</p>{% endif %}{% endif %}{% endfor %}{% else %}None{% endif %}</td>
34 <td>{% if build.outcome == 0 %}{% for t in build.target_set.all %}{% if t.is_image %}{{build.image_fstypes}}{% endif %}{% endfor %}{% endif %}</td>
35 <td>{{build.cooker_log_path}}</td>
36 <td>{{build.bitbake_version}}</td>
37 <td>{{build.build_name}}</td>
38 </tr>
39
40 {% endfor %}
41{% endblock %}
42
43
diff --git a/bitbake/lib/toaster/bldviewer/templates/configuration.html b/bitbake/lib/toaster/bldviewer/templates/configuration.html
new file mode 100644
index 0000000000..052c37c4e8
--- /dev/null
+++ b/bitbake/lib/toaster/bldviewer/templates/configuration.html
@@ -0,0 +1,20 @@
1{% extends "basebuildpage.html" %}
2
3{% block pagetitle %}Configuration{% endblock %}
4{% block pagetable %}
5
6 <tr>
7 <th>Name</th>
8 <th>Value</th>
9 <th>Description</th>
10 </tr>
11
12 {% for variable in configuration %}
13
14 <tr class="data">
15 <td>{{variable.variable_name}}</td>
16 <td>{{variable.variable_value}}</td>
17 <td>{% if variable.description %}{{variable.description}}{% endif %}</td>
18 {% endfor %}
19
20{% endblock %}
diff --git a/bitbake/lib/toaster/bldviewer/templates/layer.html b/bitbake/lib/toaster/bldviewer/templates/layer.html
new file mode 100644
index 0000000000..fa4fd9bde8
--- /dev/null
+++ b/bitbake/lib/toaster/bldviewer/templates/layer.html
@@ -0,0 +1,34 @@
1{% extends "basetable.html" %}
2
3{% block pagename %}
4 <h1>Toaster - Layers</h1>
5{% endblock %}
6
7{% block pagetable %}
8 {% load projecttags %}
9
10 <tr>
11 <th>Name</th>
12 <th>Local Path</th>
13 <th>Layer Index URL</th>
14 <th>Known Versions</th>
15 </tr>
16
17 {% for layer in layers %}
18
19 <tr class="data">
20 <td>{{layer.name}}</td>
21 <td>{{layer.local_path}}</td>
22 <td><a href='{{layer.layer_index_url}}'>{{layer.layer_index_url}}</a></td>
23 <td><table>
24 {% for lv in layer.versions %}
25 <tr><td>
26 <a href="{% url layer_versions_recipes lv.id %}">({{lv.priority}}){{lv.branch}}:{{lv.commit}} ({{lv.count}} recipes)</a>
27 </td></tr>
28 {% endfor %}
29 </table></td>
30 </tr>
31
32 {% endfor %}
33
34{% endblock %}
diff --git a/bitbake/lib/toaster/bldviewer/templates/package.html b/bitbake/lib/toaster/bldviewer/templates/package.html
new file mode 100644
index 0000000000..642fcab9a1
--- /dev/null
+++ b/bitbake/lib/toaster/bldviewer/templates/package.html
@@ -0,0 +1,36 @@
1{% extends "basebuildpage.html" %}
2
3{% block pagetable %}
4 {% if not packages %}
5 <p>No packages were recorded for this target!</p>
6 {% else %}
7
8 <tr>
9 <th>Name</th>
10 <th>Version</th>
11 <th>Size (Bytes)</th>
12 <th>Recipe</th>
13 <th>Depends on</th>
14 </tr>
15
16 {% for package in packages %}
17
18 <tr class="data">
19 <td><a name="#{{package.name}}">{{package.name}}</a></td>
20 <td>{{package.version}}</td>
21 <td>{{package.size}}</td>
22 <td><a name="{{package.recipe.name}}.{{package.package_name}}">
23 <a href="{% url layer_versions_recipes package.recipe.layer_version_id %}#{{package.recipe.name}}">{{package.recipe.name}}</a>{{package.package_name}}</a></td>
24 <td>
25 <div style="height: 3em; overflow:auto">
26 {% for d in package.depends_on %}
27 <a href="#{{d.name}}">{{d.name}}</a><br/>
28 {% endfor %}
29 </div>
30 </td>
31
32 {% endfor %}
33
34 {% endif %}
35
36{% endblock %}
diff --git a/bitbake/lib/toaster/bldviewer/templates/recipe.html b/bitbake/lib/toaster/bldviewer/templates/recipe.html
new file mode 100644
index 0000000000..a62437066d
--- /dev/null
+++ b/bitbake/lib/toaster/bldviewer/templates/recipe.html
@@ -0,0 +1,54 @@
1{% extends "basetable.html" %}
2
3{% block pagename %}
4<ul class="nav nav-tabs" style="display: inline-block">
5 <li><a>Layer {{layer_version.layer.name}}&nbsp;:&nbsp;{{layer_version.branch}}&nbsp;:&nbsp;{{layer_version.commit}}&nbsp;:&nbsp;{{layer_version.priority}}</a></li>
6</ul>
7 <h1>Toaster - Recipes for a Layer</h1>
8{% endblock %}
9
10{% block pagetable %}
11 {% load projecttags %}
12
13 <tr>
14 </tr>
15 <th>Name</th>
16 <th>Version</th>
17 <th>Summary</th>
18 <th>Description</th>
19 <th>Section</th>
20 <th>License</th>
21 <th>License file</th>
22 <th>Homepage</th>
23 <th>Bugtracker</th>
24 <th>Author</th>
25 <th>File_path</th>
26 <th style="width: 30em">Recipe Dependency</th>
27
28
29 {% for recipe in recipes %}
30
31 <tr class="data">
32 <td><a name="{{recipe.name}}">{{recipe.name}}</a></td>
33 <td>{{recipe.version}}</td>
34 <td>{{recipe.summary}}</td>
35 <td>{{recipe.description}}</td>
36 <td>{{recipe.section}}</td>
37 <td>{{recipe.license}}</td>
38 <td>{{recipe.licensing_info}}</td>
39 <td>{{recipe.homepage}}</td>
40 <td>{{recipe.bugtracker}}</td>
41 <td>{{recipe.author}}</td>
42 <td>{{recipe.file_path}}</td>
43 <td>
44 <div style="height: 5em; overflow:auto">
45 {% for rr in recipe.r_dependencies_recipe.all %}
46 <a href="#{{rr.depends_on.name}}">{{rr.depends_on.name}}</a><br/>
47 {% endfor %}
48 </div>
49 </td>
50 </tr>
51
52 {% endfor %}
53
54{% endblock %}
diff --git a/bitbake/lib/toaster/bldviewer/templates/task.html b/bitbake/lib/toaster/bldviewer/templates/task.html
new file mode 100644
index 0000000000..e7253698cd
--- /dev/null
+++ b/bitbake/lib/toaster/bldviewer/templates/task.html
@@ -0,0 +1,63 @@
1{% extends "basebuildpage.html" %}
2
3{% block pagetitle %}Tasks{% endblock %}
4{% block pagetable %}
5 {% if not tasks %}
6 <p>No tasks were executed in this build!</p>
7 {% else %}
8
9 <tr>
10 <th>Order</th>
11 <th>Task</th>
12 <th>Recipe Version</th>
13 <th>Task Type</th>
14 <th>Checksum</th>
15 <th>Outcome</th>
16 <th>Message</th>
17 <th>Logfile</th>
18 <th>Time</th>
19 <th>CPU usage</th>
20 <th>Disk I/O</th>
21 <th>Script type</th>
22 <th>File path</th>
23 <th>Depends</th>
24 </tr>
25
26 {% for task in tasks %}
27
28 <tr class="data">
29 <td>{{task.order}}</td>
30 <td><a name="{{task.recipe.name}}.{{task.task_name}}">
31 <a href="{% url layer_versions_recipes task.recipe.layer_version_id %}#{{task.recipe.name}}">{{task.recipe.name}}</a>.{{task.task_name}}</a></td>
32 <td>{{task.recipe.version}}</td>
33
34 {% if task.task_executed %}
35 <td>Executed</td>
36 {% else %}
37 <td>Prebuilt</td>
38 {% endif %}
39
40 <td>{{task.sstate_checksum}}</td>
41 <td>{{task.get_outcome_display}}{% if task.provider %}</br>(by <a href="#{{task.provider.recipe.name}}.{{task.provider.task_name}}">{{task.provider.recipe.name}}.{{task.provider.task_name}}</a>){% endif %}</td>
42 <td><p>{{task.message}}</td>
43 <td><a target="_fileview" href="file:///{{task.logfile}}">{{task.logfile}}</a></td>
44 <td>{{task.elapsed_time}}</td>
45 <td>{{task.cpu_usage}}</td>
46 <td>{{task.disk_io}}</td>
47 <td>{{task.get_script_type_display}}</td>
48 <td><a target="_fileview" href="file:///{{task.recipe.file_path}}">{{task.recipe.file_path}}</a></td>
49 <td>
50 <div style="height: 3em; overflow:auto">
51 {% for tt in task.task_dependencies_task.all %}
52 <a href="#{{tt.depends_on.recipe.name}}.{{tt.depends_on.task_name}}">
53 {{tt.depends_on.recipe.name}}.{{tt.depends_on.task_name}}</a><br/>
54 {% endfor %}
55 </div>
56 </td>
57 </tr>
58
59 {% endfor %}
60
61 {% endif %}
62
63{% endblock %}
diff --git a/bitbake/lib/toaster/bldviewer/templatetags/__init__.py b/bitbake/lib/toaster/bldviewer/templatetags/__init__.py
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/bitbake/lib/toaster/bldviewer/templatetags/__init__.py
diff --git a/bitbake/lib/toaster/bldviewer/templatetags/projecttags.py b/bitbake/lib/toaster/bldviewer/templatetags/projecttags.py
new file mode 100644
index 0000000000..0c0d804c0c
--- /dev/null
+++ b/bitbake/lib/toaster/bldviewer/templatetags/projecttags.py
@@ -0,0 +1,26 @@
1#
2# BitBake Toaster Implementation
3#
4# Copyright (C) 2013 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 datetime import datetime
20from django import template
21
22register = template.Library()
23
24@register.simple_tag
25def time_difference(start_time, end_time):
26 return end_time - start_time
diff --git a/bitbake/lib/toaster/bldviewer/urls.py b/bitbake/lib/toaster/bldviewer/urls.py
new file mode 100644
index 0000000000..becc679203
--- /dev/null
+++ b/bitbake/lib/toaster/bldviewer/urls.py
@@ -0,0 +1,32 @@
1#
2# BitBake Toaster Implementation
3#
4# Copyright (C) 2013 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.conf.urls import patterns, include, url
20from django.views.generic.simple import redirect_to
21
22urlpatterns = patterns('bldviewer.views',
23 url(r'^builds/$', 'build', name='all-builds'),
24 url(r'^build/(?P<build_id>\d+)/task/$', 'task', name='task'),
25 url(r'^build/(?P<build_id>\d+)/packages/$', 'bpackage', name='bpackage'),
26 url(r'^build/(?P<build_id>\d+)/package/(?P<package_id>\d+)/files/$', 'bfile', name='bfile'),
27 url(r'^build/(?P<build_id>\d+)/target/(?P<target_id>\d+)/packages/$', 'tpackage', name='tpackage'),
28 url(r'^build/(?P<build_id>\d+)/configuration/$', 'configuration', name='configuration'),
29 url(r'^layers/$', 'layer', name='all-layers'),
30 url(r'^layerversions/(?P<layerversion_id>\d+)/recipes/.*$', 'layer_versions_recipes', name='layer_versions_recipes'),
31 url(r'^$', redirect_to, {'url': 'builds/'}),
32)
diff --git a/bitbake/lib/toaster/bldviewer/views.py b/bitbake/lib/toaster/bldviewer/views.py
new file mode 100644
index 0000000000..7be4d4b899
--- /dev/null
+++ b/bitbake/lib/toaster/bldviewer/views.py
@@ -0,0 +1,260 @@
1#
2# BitBake Toaster Implementation
3#
4# Copyright (C) 2013 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
19import operator
20
21from django.db.models import Q
22from django.shortcuts import render
23from orm.models import Build, Target, Task, Layer, Layer_Version, Recipe, Target_Package, LogMessage, Variable
24from orm.models import Task_Dependency, Recipe_Dependency, Build_Package, Build_File, Build_Package_Dependency
25from django.views.decorators.cache import cache_control
26
27@cache_control(no_store=True)
28def build(request):
29 template = 'build.html'
30 build_info = Build.objects.all()
31
32 logs = LogMessage.objects.all()
33
34 context = {'builds': build_info, 'logs': logs ,
35 'hideshowcols' : [
36 {'name': 'Output', 'order':10},
37 {'name': 'Log', 'order':11},
38 ]}
39
40 return render(request, template, context)
41
42
43def _find_task_revdep(task):
44 tp = []
45 for p in Task_Dependency.objects.filter(depends_on=task):
46 tp.append(p.task);
47 return tp
48
49def _find_task_provider(task):
50 task_revdeps = _find_task_revdep(task)
51 for tr in task_revdeps:
52 if tr.outcome != Task.OUTCOME_COVERED:
53 return tr
54 for tr in task_revdeps:
55 trc = _find_task_provider(tr)
56 if trc is not None:
57 return trc
58 return None
59
60def task(request, build_id):
61 template = 'task.html'
62
63 tasks = Task.objects.filter(build=build_id)
64
65 for t in tasks:
66 if t.outcome == Task.OUTCOME_COVERED:
67 t.provider = _find_task_provider(t)
68
69 context = {'build': Build.objects.filter(pk=build_id)[0], 'tasks': tasks}
70
71 return render(request, template, context)
72
73def configuration(request, build_id):
74 template = 'configuration.html'
75 variables = Variable.objects.filter(build=build_id)
76 context = {'build': Build.objects.filter(pk=build_id)[0], 'configuration' : variables}
77 return render(request, template, context)
78
79def bpackage(request, build_id):
80 template = 'bpackage.html'
81 packages = Build_Package.objects.filter(build = build_id)
82 context = {'build': Build.objects.filter(pk=build_id)[0], 'packages' : packages}
83 return render(request, template, context)
84
85def bfile(request, build_id, package_id):
86 template = 'bfile.html'
87 files = Build_File.objects.filter(bpackage = package_id)
88 context = {'build': Build.objects.filter(pk=build_id)[0], 'files' : files}
89 return render(request, template, context)
90
91def tpackage(request, build_id, target_id):
92 template = 'package.html'
93
94 packages = Target_Package.objects.filter(target=target_id)
95
96 context = {'build' : Build.objects.filter(pk=build_id)[0],'packages': packages}
97
98 return render(request, template, context)
99
100def layer(request):
101 template = 'layer.html'
102 layer_info = Layer.objects.all()
103
104 for li in layer_info:
105 li.versions = Layer_Version.objects.filter(layer = li)
106 for liv in li.versions:
107 liv.count = Recipe.objects.filter(layer_version__id = liv.id).count()
108
109 context = {'layers': layer_info}
110
111 return render(request, template, context)
112
113
114def layer_versions_recipes(request, layerversion_id):
115 template = 'recipe.html'
116 recipes = Recipe.objects.filter(layer_version__id = layerversion_id)
117
118 context = {'recipes': recipes,
119 'layer_version' : Layer_Version.objects.filter( id = layerversion_id )[0]
120 }
121
122 return render(request, template, context)
123
124#### API
125
126import json
127from django.core import serializers
128from django.http import HttpResponse, HttpResponseBadRequest
129
130
131def model_explorer(request, model_name):
132
133 DESCENDING = 'desc'
134 response_data = {}
135 model_mapping = {
136 'build': Build,
137 'target': Target,
138 'target_package': Target_Package,
139 'task': Task,
140 'task_dependency': Task_Dependency,
141 'package': Build_Package,
142 'layer': Layer,
143 'layerversion': Layer_Version,
144 'recipe': Recipe,
145 'recipe_dependency': Recipe_Dependency,
146 'build_package': Build_Package,
147 'build_package_dependency': Build_Package_Dependency,
148 'build_file': Build_File,
149 'variable': Variable,
150 'logmessage': LogMessage,
151 }
152
153 if model_name not in model_mapping.keys():
154 return HttpResponseBadRequest()
155
156 model = model_mapping[model_name]
157
158 try:
159 limit = int(request.GET.get('limit', 0))
160 except ValueError:
161 limit = 0
162
163 try:
164 offset = int(request.GET.get('offset', 0))
165 except ValueError:
166 offset = 0
167
168 ordering_string, invalid = _validate_input(request.GET.get('orderby', ''),
169 model)
170 if invalid:
171 return HttpResponseBadRequest()
172
173 filter_string, invalid = _validate_input(request.GET.get('filter', ''),
174 model)
175 if invalid:
176 return HttpResponseBadRequest()
177
178 search_term = request.GET.get('search', '')
179
180 if filter_string:
181 filter_terms = _get_filtering_terms(filter_string)
182 try:
183 queryset = model.objects.filter(**filter_terms)
184 except ValueError:
185 queryset = []
186 else:
187 queryset = model.objects.all()
188
189 if search_term:
190 queryset = _get_search_results(search_term, queryset, model)
191
192 if ordering_string and queryset:
193 column, order = ordering_string.split(':')
194 if order.lower() == DESCENDING:
195 queryset = queryset.order_by('-' + column)
196 else:
197 queryset = queryset.order_by(column)
198
199 if offset and limit:
200 queryset = queryset[offset:(offset+limit)]
201 elif offset:
202 queryset = queryset[offset:]
203 elif limit:
204 queryset = queryset[:limit]
205
206 if queryset:
207 response_data['count'] = queryset.count()
208 else:
209 response_data['count'] = 0
210
211 response_data['list'] = serializers.serialize('json', queryset)
212
213 return HttpResponse(json.dumps(response_data),
214 content_type='application/json')
215
216def _get_filtering_terms(filter_string):
217
218 search_terms = filter_string.split(":")
219 keys = search_terms[0].split(',')
220 values = search_terms[1].split(',')
221
222 return dict(zip(keys, values))
223
224def _validate_input(input, model):
225
226 invalid = 0
227
228 if input:
229 input_list = input.split(":")
230
231 # Check we have only one colon
232 if len(input_list) != 2:
233 invalid = 1
234 return None, invalid
235
236 # Check we have an equal number of terms both sides of the colon
237 if len(input_list[0].split(',')) != len(input_list[1].split(',')):
238 invalid = 1
239 return None, invalid
240
241 # Check we are looking for a valid field
242 valid_fields = model._meta.get_all_field_names()
243 for field in input_list[0].split(','):
244 if field not in valid_fields:
245 invalid = 1
246 return None, invalid
247
248 return input, invalid
249
250def _get_search_results(search_term, queryset, model):
251 search_objects = []
252 for st in search_term.split(" "):
253 q_map = map(lambda x: Q(**{x+'__icontains': st}),
254 model.search_allowed_fields)
255
256 search_objects.append(reduce(operator.or_, q_map))
257 search_object = reduce(operator.and_, search_objects)
258 queryset = queryset.filter(search_object)
259
260 return queryset