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 <paul.eggleton@linux.intel.com>
This commit is contained in:
Paul Eggleton 2018-03-24 01:10:39 +13:00
parent fdec9d1d63
commit c607ba6945

View File

@ -62,12 +62,12 @@ def _create_upgrade(recipe_data, layerbranch, ct, title, info, logger, initial=F
pn = recipe_data.getVar('PN', True) pn = recipe_data.getVar('PN', True)
pv = recipe_data.getVar('PV', True) pv = recipe_data.getVar('PV', True)
try: recipes = Recipe.objects.filter(pn=pn, layerbranch=layerbranch).order_by('id')
recipe = Recipe.objects.get(pn=pn, layerbranch=layerbranch) if not recipes:
except Exception as e:
logger.warn("%s: Not found in Layer branch %s." % logger.warn("%s: Not found in Layer branch %s." %
(pn, str(layerbranch))) (pn, str(layerbranch)))
return return
recipe = recipes[0]
try: try:
latest_upgrade = RecipeUpgrade.objects.filter( latest_upgrade = RecipeUpgrade.objects.filter(