aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorAlexandru DAMIAN <alexandru.damian@intel.com>2014-03-06 16:34:50 +0000
committerAlexandru DAMIAN <alexandru.damian@intel.com>2014-03-11 14:12:30 +0000
commite9a8c32512bb270cda3dee4a3ed5fd22204c24bc (patch)
treed975861f70f74d9cd7c0f0a6aa16d1edcdba37ea /lib
parentf3a69ef7cc536a4b879d60936199a1002584c4f4 (diff)
downloadbitbake-e9a8c32512bb270cda3dee4a3ed5fd22204c24bc.tar.gz
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 Signed-off-by: Alexandru DAMIAN <alexandru.damian@intel.com>
Diffstat (limited to 'lib')
-rw-r--r--lib/toaster/toastermain/management/__init__.py0
-rw-r--r--lib/toaster/toastermain/management/commands/__init__.py0
-rw-r--r--lib/toaster/toastermain/management/commands/builddelete.py33
-rw-r--r--lib/toaster/toastermain/management/commands/buildslist.py13
4 files changed, 46 insertions, 0 deletions
diff --git a/lib/toaster/toastermain/management/__init__.py b/lib/toaster/toastermain/management/__init__.py
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/lib/toaster/toastermain/management/__init__.py
diff --git a/lib/toaster/toastermain/management/commands/__init__.py b/lib/toaster/toastermain/management/commands/__init__.py
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/lib/toaster/toastermain/management/commands/__init__.py
diff --git a/lib/toaster/toastermain/management/commands/builddelete.py b/lib/toaster/toastermain/management/commands/builddelete.py
new file mode 100644
index 000000000..5cec43671
--- /dev/null
+++ b/lib/toaster/toastermain/management/commands/builddelete.py
@@ -0,0 +1,33 @@
+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()
+
diff --git a/lib/toaster/toastermain/management/commands/buildslist.py b/lib/toaster/toastermain/management/commands/buildslist.py
new file mode 100644
index 000000000..cad987fd9
--- /dev/null
+++ b/lib/toaster/toastermain/management/commands/buildslist.py
@@ -0,0 +1,13 @@
+from django.core.management.base import NoArgsCommand, CommandError
+from orm.models import Build
+import os
+
+
+
+class Command(NoArgsCommand):
+ args = ""
+ help = "Lists current builds"
+
+ def handle_noargs(self,**options):
+ for b in Build.objects.all():
+ print "%d: %s %s %s" % (b.pk, b.machine, b.distro, ",".join([x.target for x in b.target_set.all()]))