diff --git a/bitbake/lib/bb/ui/buildinfohelper.py b/bitbake/lib/bb/ui/buildinfohelper.py index a0da2e1..2da38e2 100644 --- a/bitbake/lib/bb/ui/buildinfohelper.py +++ b/bitbake/lib/bb/ui/buildinfohelper.py @@ -336,6 +336,49 @@ class ORMWrapper(object): return layer_info + def _get_layer_dict(self, layer_path): + + layer_info = {} + layer_name = layer_path.split('/')[-1] + layer_url = 'http://layers.openembedded.org/layerindex/layer/{layer}/' + layer_url_name = self._get_url_map_name(layer_name) + + layer_info['name'] = layer_name + layer_info['local_path'] = layer_path + layer_info['layer_index_url'] = layer_url.format(layer=layer_url_name) + + return layer_info + + def _get_url_map_name(self, layer_name): + """ Some layers have a different name on openembedded.org site, + this method returns the correct name to use in the URL + """ + + url_name = layer_name + url_mapping = {'meta': 'openembedded-core'} + + for key in url_mapping.keys(): + if key == layer_name: + url_name = url_mapping[key] + + return url_name + + def _save_layer_object(self, layer_path): + + layer_information = self._get_layer_dict(layer_path) + + layer_object = Layer.objects.get_or_create( + name=layer_information['name'], + local_path=layer_information['local_path'], + layer_index_url=layer_information['layer_index_url']) + + layer_object[0].save() + + def store_layer_info(self): + layers = self.server.runCommand(["getVariable", "BBLAYERS"])[0].strip().split(" ") + for layer_path in layers: + self._save_layer_object(layer_path) + class BuildInfoHelper(object): """ This class gathers the build information from the server and sends it @@ -352,6 +395,8 @@ class BuildInfoHelper(object): def store_started_build(self, event): + self.orm_wrapper.store_layer_info() + machine_information = self.orm_wrapper.get_machine_information() machine_obj = self.orm_wrapper.create_machine_object(machine_information) diff --git a/bitbake/lib/webhob/bldviewer/templates/layer.html b/bitbake/lib/webhob/bldviewer/templates/layer.html new file mode 100644 index 0000000..905a781 --- /dev/null +++ b/bitbake/lib/webhob/bldviewer/templates/layer.html @@ -0,0 +1,34 @@ + + + + WebHob Layer page + + + +

WebHob Layers

+ + + + {% load projecttags %} + + + + + + + + {% for layer in layers %} + + + + + + + + {% endfor %} + +
NameLocal PathLayer Index URL
{{layer.name}}{{layer.local_path}}{{layer.layer_index_url}}
+ + + + diff --git a/bitbake/lib/webhob/bldviewer/urls.py b/bitbake/lib/webhob/bldviewer/urls.py index 335885c..8d5dc6e 100644 --- a/bitbake/lib/webhob/bldviewer/urls.py +++ b/bitbake/lib/webhob/bldviewer/urls.py @@ -3,5 +3,6 @@ from django.conf.urls import patterns, include, url urlpatterns = patterns('bldviewer.views', url(r'^$', 'build', name='build'), + url(r'^layers/$', 'layer', name='layer'), url(r'^(?P\d+)/$', 'task', name='task'), ) diff --git a/bitbake/lib/webhob/bldviewer/views.py b/bitbake/lib/webhob/bldviewer/views.py index 292a638..f40d396 100644 --- a/bitbake/lib/webhob/bldviewer/views.py +++ b/bitbake/lib/webhob/bldviewer/views.py @@ -1,5 +1,5 @@ from django.shortcuts import render -from orm.models import Build, Task +from orm.models import Build, Task, Layer def build(request): @@ -18,3 +18,11 @@ def task(request, build_id): context = {'tasks': tasks} return render(request, template, context) + +def layer(request): + template = 'layer.html' + layer_info = Layer.objects.all() + + context = {'layers': layer_info} + + return render(request, template, context)