diff options
Diffstat (limited to 'bitbake/lib/toaster/toastergui/buildtables.py')
-rw-r--r-- | bitbake/lib/toaster/toastergui/buildtables.py | 63 |
1 files changed, 61 insertions, 2 deletions
diff --git a/bitbake/lib/toaster/toastergui/buildtables.py b/bitbake/lib/toaster/toastergui/buildtables.py index 51c136f988..17de369305 100644 --- a/bitbake/lib/toaster/toastergui/buildtables.py +++ b/bitbake/lib/toaster/toastergui/buildtables.py | |||
@@ -19,8 +19,8 @@ | |||
19 | # with this program; if not, write to the Free Software Foundation, Inc., | 19 | # with this program; if not, write to the Free Software Foundation, Inc., |
20 | # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | 20 | # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
21 | 21 | ||
22 | from orm.models import Build, Task | 22 | from orm.models import Build, Task, Target, Package |
23 | from django.db.models import Q | 23 | from django.db.models import Q, Sum |
24 | 24 | ||
25 | import toastergui.tables as tables | 25 | import toastergui.tables as tables |
26 | from toastergui.widgets import ToasterTable | 26 | from toastergui.widgets import ToasterTable |
@@ -155,6 +155,65 @@ class BuiltPackagesTable(BuildTablesMixin, BuiltPackagesTableBase): | |||
155 | self.columns = list(remove_dep_cols(self.columns)) | 155 | self.columns = list(remove_dep_cols(self.columns)) |
156 | 156 | ||
157 | 157 | ||
158 | class InstalledPackagesTable(BuildTablesMixin, BuiltPackagesTableBase): | ||
159 | """ Show all packages installed in an image """ | ||
160 | def __init__(self, *args, **kwargs): | ||
161 | super(InstalledPackagesTable, self).__init__(*args, **kwargs) | ||
162 | self.title = "Installed Packages" | ||
163 | self.default_orderby = "name" | ||
164 | |||
165 | def make_package_list(self, target): | ||
166 | # The database design means that you get the intermediate objects and | ||
167 | # not package objects like you'd really want so we get them here | ||
168 | pkgs = target.target_installed_package_set.values_list('package', | ||
169 | flat=True) | ||
170 | return Package.objects.filter(pk__in=pkgs) | ||
171 | |||
172 | def get_context_data(self, **kwargs): | ||
173 | context = super(InstalledPackagesTable, | ||
174 | self).get_context_data(**kwargs) | ||
175 | |||
176 | target = Target.objects.get(pk=kwargs['target_id']) | ||
177 | packages = self.make_package_list(target) | ||
178 | |||
179 | context['packages_sum'] = packages.aggregate( | ||
180 | Sum('installed_size'))['installed_size__sum'] | ||
181 | |||
182 | context['target'] = target | ||
183 | return context | ||
184 | |||
185 | def setup_queryset(self, *args, **kwargs): | ||
186 | build = Build.objects.get(pk=kwargs['build_id']) | ||
187 | self.static_context_extra['build'] = build | ||
188 | |||
189 | target = Target.objects.get(pk=kwargs['target_id']) | ||
190 | self.queryset = self.make_package_list(target) | ||
191 | |||
192 | def setup_columns(self, *args, **kwargs): | ||
193 | super(InstalledPackagesTable, self).setup_columns(**kwargs) | ||
194 | self.add_column(title="Installed size", | ||
195 | static_data_name="installed_size", | ||
196 | static_data_template="{% load projecttags %}" | ||
197 | "{{data.size|filtered_filesizeformat}}", | ||
198 | orderable=True) | ||
199 | |||
200 | # Add the template to show installed name for installed packages | ||
201 | install_name_tmpl =\ | ||
202 | ('{{data.name}} ' | ||
203 | '{% if data.installed_name and data.installed_name !=' | ||
204 | ' data.name %}' | ||
205 | '<span class="muted"> as {{data.installed_name}}</span>' | ||
206 | ' <i class="icon-question-sign get-help hover-help"' | ||
207 | ' title="{{data.name}} was renamed at packaging time and' | ||
208 | ' was installed in your image as {{data.installed_name}}' | ||
209 | '"></i>{% endif %} ') | ||
210 | |||
211 | for column in self.columns: | ||
212 | if column['static_data_name'] == 'name': | ||
213 | column['static_data_template'] = install_name_tmpl | ||
214 | break | ||
215 | |||
216 | |||
158 | class BuiltRecipesTable(BuildTablesMixin): | 217 | class BuiltRecipesTable(BuildTablesMixin): |
159 | """ Table to show the recipes that have been built in this build """ | 218 | """ Table to show the recipes that have been built in this build """ |
160 | 219 | ||