diff options
| -rwxr-xr-x | bitbake/lib/toaster/toastergui/views.py | 4 | ||||
| -rw-r--r-- | bitbake/lib/toaster/toastermain/management/commands/builddelete.py | 56 |
2 files changed, 38 insertions, 22 deletions
diff --git a/bitbake/lib/toaster/toastergui/views.py b/bitbake/lib/toaster/toastergui/views.py index 1a504b8455..ec65903080 100755 --- a/bitbake/lib/toaster/toastergui/views.py +++ b/bitbake/lib/toaster/toastergui/views.py | |||
| @@ -64,9 +64,9 @@ def _get_latest_builds(prj=None): | |||
| 64 | if prj is not None: | 64 | if prj is not None: |
| 65 | queryset = queryset.filter(project = prj) | 65 | queryset = queryset.filter(project = prj) |
| 66 | 66 | ||
| 67 | return itertools.chain( | 67 | return list(itertools.chain( |
| 68 | queryset.filter(outcome=Build.IN_PROGRESS).order_by("-pk"), | 68 | queryset.filter(outcome=Build.IN_PROGRESS).order_by("-pk"), |
| 69 | queryset.filter(outcome__lt=Build.IN_PROGRESS).order_by("-pk")[:3] ) | 69 | queryset.filter(outcome__lt=Build.IN_PROGRESS).order_by("-pk")[:3] )) |
| 70 | 70 | ||
| 71 | 71 | ||
| 72 | # a JSON-able dict of recent builds; for use in the Project page, xhr_ updates, and other places, as needed | 72 | # a JSON-able dict of recent builds; for use in the Project page, xhr_ updates, and other places, as needed |
diff --git a/bitbake/lib/toaster/toastermain/management/commands/builddelete.py b/bitbake/lib/toaster/toastermain/management/commands/builddelete.py index 5cec436714..343d3114c0 100644 --- a/bitbake/lib/toaster/toastermain/management/commands/builddelete.py +++ b/bitbake/lib/toaster/toastermain/management/commands/builddelete.py | |||
| @@ -1,33 +1,49 @@ | |||
| 1 | from django.core.management.base import BaseCommand, CommandError | 1 | from django.core.management.base import BaseCommand, CommandError |
| 2 | from orm.models import Build | 2 | from orm.models import Build |
| 3 | from django.db import OperationalError | ||
| 3 | import os | 4 | import os |
| 4 | 5 | ||
| 5 | 6 | ||
| 6 | 7 | ||
| 7 | class Command(BaseCommand): | 8 | class Command(BaseCommand): |
| 8 | args = "buildId" | 9 | args = "buildId" |
| 9 | help = "Deletes selected build" | 10 | help = "Deletes selected build(s)" |
| 10 | 11 | ||
| 11 | def handle(self, buildId, *args, **options): | 12 | def handle(self, buildId, *args, **options): |
| 12 | b = Build.objects.get(pk = buildId) | 13 | for bid in buildId.split(","): |
| 13 | # theoretically, just b.delete() would suffice | 14 | b = Build.objects.get(pk = bid) |
| 14 | # however SQLite runs into problems when you try to | 15 | # theoretically, just b.delete() would suffice |
| 15 | # delete too many rows at once, so we delete some direct | 16 | # however SQLite runs into problems when you try to |
| 16 | # relationships from Build manually. | 17 | # delete too many rows at once, so we delete some direct |
| 18 | # relationships from Build manually. | ||
| 19 | for t in b.target_set.all(): | ||
| 20 | t.delete() | ||
| 21 | for t in b.task_build.all(): | ||
| 22 | t.delete() | ||
| 23 | for p in b.package_set.all(): | ||
| 24 | p.delete() | ||
| 25 | for lv in b.layer_version_build.all(): | ||
| 26 | lv.delete() | ||
| 27 | for v in b.variable_build.all(): | ||
| 28 | v.delete() | ||
| 29 | for l in b.logmessage_set.all(): | ||
| 30 | l.delete() | ||
| 17 | 31 | ||
| 18 | for t in b.target_set.all(): | 32 | # delete the build; some databases might have had problem with migration of the bldcontrol app |
| 19 | t.delete() | 33 | retry_count = 0 |
| 20 | for t in b.task_build.all(): | 34 | need_bldcontrol_migration = False |
| 21 | t.delete() | 35 | while True: |
| 22 | for p in b.package_set.all(): | 36 | if retry_count >= 5: |
| 23 | p.delete() | 37 | break |
| 24 | for lv in b.layer_version_build.all(): | 38 | retry_count += 1 |
| 25 | lv.delete() | 39 | if need_bldcontrol_migration: |
| 26 | for v in b.variable_build.all(): | 40 | from django.core import management |
| 27 | v.delete() | 41 | management.call_command('migrate', 'bldcontrol', interactive=False) |
| 28 | for l in b.logmessage_set.all(): | ||
| 29 | l.delete() | ||
| 30 | 42 | ||
| 31 | # this should take care of the rest | 43 | try: |
| 32 | b.delete() | 44 | b.delete() |
| 45 | break | ||
| 46 | except OperationalError as e: | ||
| 47 | # execute migrations | ||
| 48 | need_bldcontrol_migration = True | ||
| 33 | 49 | ||
