From 6344724afd28a8dbd9d3025f12c610aab8e47a09 Mon Sep 17 00:00:00 2001 From: Paul Eggleton Date: Wed, 14 Aug 2019 11:23:55 +1200 Subject: [PATCH] RRS: use more robust method of getting last upgrade record Silently catching all exceptions like this is evil. Use .first() and check the return instead. Signed-off-by: Paul Eggleton --- rrs/tools/upgrade_history_internal.py | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/rrs/tools/upgrade_history_internal.py b/rrs/tools/upgrade_history_internal.py index 7798321..1f6bf20 100644 --- a/rrs/tools/upgrade_history_internal.py +++ b/rrs/tools/upgrade_history_internal.py @@ -160,13 +160,10 @@ def _create_upgrade(recipe_data, layerbranch, ct, title, info, filepath, logger, summary = recipe_data.getVar('SUMMARY', True) or recipe_data.getVar('DESCRIPTION', True) recipesymbol = RecipeSymbol.symbol(recipe_data.getVar('PN', True), layerbranch, summary=summary) - try: - latest_upgrade = RecipeUpgrade.objects.filter( - recipesymbol=recipesymbol).order_by('-commit_date')[0] + latest_upgrade = RecipeUpgrade.objects.filter(recipesymbol=recipesymbol).order_by('-commit_date').first() + if latest_upgrade: prev_pv = latest_upgrade.version - except KeyboardInterrupt: - raise - except: + else: prev_pv = None if prev_pv is None: