From c607ba6945c12dc8559919aefd136e9dc43da123 Mon Sep 17 00:00:00 2001 From: Paul Eggleton Date: Sat, 24 Mar 2018 01:10:39 +1300 Subject: [PATCH] rrs_upgrade_history: handle multiple recipes with same pn per layer We should expect multiple matches for layerbranch + pn, so use filter() instead of get() and take the first id that matches. Signed-off-by: Paul Eggleton --- rrs/tools/upgrade_history_internal.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/rrs/tools/upgrade_history_internal.py b/rrs/tools/upgrade_history_internal.py index 82fbe1a..783e893 100644 --- a/rrs/tools/upgrade_history_internal.py +++ b/rrs/tools/upgrade_history_internal.py @@ -62,12 +62,12 @@ def _create_upgrade(recipe_data, layerbranch, ct, title, info, logger, initial=F pn = recipe_data.getVar('PN', True) pv = recipe_data.getVar('PV', True) - try: - recipe = Recipe.objects.get(pn=pn, layerbranch=layerbranch) - except Exception as e: + recipes = Recipe.objects.filter(pn=pn, layerbranch=layerbranch).order_by('id') + if not recipes: logger.warn("%s: Not found in Layer branch %s." % (pn, str(layerbranch))) return + recipe = recipes[0] try: latest_upgrade = RecipeUpgrade.objects.filter(