[bitbake-devel] [PATCH] toaster: delete multiple builds cleanup

Elliot Smith elliot.smith at intel.com
Mon Sep 14 15:45:40 UTC 2015


From: brian avery <avery.brian at gmail.com>

This patch cleans up the multiple delete. It:

1) skips build id's that don't exist rather than giving a traceback.
2) let you pass in the ids as a space separated list
3) fixes the usage to match the space separated list format

[YOCTO #7726]

Signed-off-by: brian avery <avery.brian at gmail.com>
Signed-off-by: Elliot Smith <elliot.smith at intel.com>
---
 .../toaster/toastermain/management/commands/builddelete.py  | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/bitbake/lib/toaster/toastermain/management/commands/builddelete.py b/bitbake/lib/toaster/toastermain/management/commands/builddelete.py
index 343d311..ff93e54 100644
--- a/bitbake/lib/toaster/toastermain/management/commands/builddelete.py
+++ b/bitbake/lib/toaster/toastermain/management/commands/builddelete.py
@@ -1,4 +1,5 @@
 from django.core.management.base import BaseCommand, CommandError
+from django.core.exceptions import ObjectDoesNotExist
 from orm.models import Build
 from django.db import OperationalError
 import os
@@ -6,12 +7,16 @@ import os
 
 
 class Command(BaseCommand):
-    args    = "buildId"
+    args    = '<buildID1 buildID2 .....>'
     help    = "Deletes selected build(s)"
 
-    def handle(self, buildId, *args, **options):
-        for bid in buildId.split(","):
-            b = Build.objects.get(pk = bid)
+    def handle(self, *args, **options):
+        for bid in args:
+            try:
+                b = Build.objects.get(pk = bid)
+            except ObjectDoesNotExist:
+                print 'build %s does not exist, skipping...' %(bid)
+                continue
             # 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
-- 
1.9.3

---------------------------------------------------------------------
Intel Corporation (UK) Limited
Registered No. 1134945 (England)
Registered Office: Pipers Way, Swindon SN3 1RJ
VAT No: 860 2173 47

This e-mail and any attachments may contain confidential material for
the sole use of the intended recipient(s). Any review or distribution
by others is strictly prohibited. If you are not the intended
recipient, please contact the sender and delete all copies.




More information about the bitbake-devel mailing list