From 84eecd7a54d73cd380b4a390a98e270855beaa62 Mon Sep 17 00:00:00 2001 From: Paul Eggleton Date: Wed, 18 Sep 2013 21:19:43 +0100 Subject: update.py: add --fullreload option Recently the -r/--reload option was changed to preserve existing recipe data, so that it could be used to load values into newly added fields; however we still need an option to load recipe data from scratch for testing purposes (e.g. in combination with --nocheckout) so add a --fullreload option to do this. Signed-off-by: Paul Eggleton --- layerindex/update.py | 41 +++++++++++++++++++++++++---------------- 1 file changed, 25 insertions(+), 16 deletions(-) (limited to 'layerindex/update.py') diff --git a/layerindex/update.py b/layerindex/update.py index f43b260bb2..f62e62a8ce 100755 --- a/layerindex/update.py +++ b/layerindex/update.py @@ -119,8 +119,11 @@ def main(): help = "Specify layers to update (use commas to separate multiple). Default is all published layers.", action="store", dest="layers") parser.add_option("-r", "--reload", - help = "Discard existing recipe data and fetch it from scratch", + help = "Reload recipe data instead of updating since last update", action="store_true", dest="reload") + parser.add_option("", "--fullreload", + help = "Discard existing recipe data and fetch it from scratch", + action="store_true", dest="fullreload") parser.add_option("-n", "--dry-run", help = "Don't write any data back to the database", action="store_true", dest="dryrun") @@ -143,6 +146,9 @@ def main(): parser.print_help() sys.exit(1) + if options.fullreload: + options.reload = True + utils.setup_django() import settings from layerindex.models import LayerItem, LayerBranch, Recipe, RecipeFileDependency, Machine, BBAppend, BBClass @@ -430,21 +436,24 @@ def main(): else: # Collect recipe data from scratch - # First, check which recipes still exist - layerrecipe_values = layerrecipes.values('id', 'filepath', 'filename', 'pn') - layerrecipe_fns = [] - for v in layerrecipe_values: - root = os.path.join(layerdir, v['filepath']) - fullpath = os.path.join(root, v['filename']) - if os.path.exists(fullpath): - # Recipe still exists, update it - results = layerrecipes.filter(id=v['id'])[:1] - recipe = results[0] - update_recipe_file(config_data_copy, root, recipe, layerdir_start, repodir) - else: - # Recipe no longer exists, mark it for later on - layerrecipes_delete.append(v) - layerrecipe_fns.append(fullpath) + if options.fullreload: + layerrecipes.delete() + else: + # First, check which recipes still exist + layerrecipe_values = layerrecipes.values('id', 'filepath', 'filename', 'pn') + layerrecipe_fns = [] + for v in layerrecipe_values: + root = os.path.join(layerdir, v['filepath']) + fullpath = os.path.join(root, v['filename']) + if os.path.exists(fullpath): + # Recipe still exists, update it + results = layerrecipes.filter(id=v['id'])[:1] + recipe = results[0] + update_recipe_file(config_data_copy, root, recipe, layerdir_start, repodir) + else: + # Recipe no longer exists, mark it for later on + layerrecipes_delete.append(v) + layerrecipe_fns.append(fullpath) layermachines.delete() layerappends.delete() -- cgit 1.2.3-korg