generic-poky/bitbake/lib/toaster/toastermain/management/commands/builddelete.py
Alexandru DAMIAN bff408ad63 bitbake: toaster: add commands to list and delete builds
We add Django commands for the manage.py to manage the database
content.

The two commands added are:
* buildslist - produces a list of current builds
* builddelete - deletes a build and all associated data from the database

(Bitbake rev: e9a8c32512bb270cda3dee4a3ed5fd22204c24bc)

Signed-off-by: Alexandru DAMIAN <alexandru.damian@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2014-03-11 12:24:31 -07:00

34 lines
964 B
Python

from django.core.management.base import BaseCommand, CommandError
from orm.models import Build
import os
class Command(BaseCommand):
args = "buildId"
help = "Deletes selected build"
def handle(self, buildId, *args, **options):
b = Build.objects.get(pk = buildId)
# theoretically, just b.delete() would suffice
# however SQLite runs into problems when you try to
# delete too many rows at once, so we delete some direct
# relationships from Build manually.
for t in b.target_set.all():
t.delete()
for t in b.task_build.all():
t.delete()
for p in b.package_set.all():
p.delete()
for lv in b.layer_version_build.all():
lv.delete()
for v in b.variable_build.all():
v.delete()
for l in b.logmessage_set.all():
l.delete()
# this should take care of the rest
b.delete()