diff options
author | Aníbal Limón <anibal.limon@linux.intel.com> | 2017-01-05 15:37:15 -0600 |
---|---|---|
committer | Paul Eggleton <paul.eggleton@linux.intel.com> | 2018-05-04 23:57:52 +1200 |
commit | 8ed223e13c1980e2f47202685db11fd407d05905 (patch) | |
tree | 7a4bdde3dba384585a89e6e45ef4a64a4a041230 /rrs/tools/rrs_distros.py | |
parent | 1c5b79a312c7711ce18406d7be316b91ae8637d9 (diff) | |
download | openembedded-core-contrib-8ed223e13c1980e2f47202685db11fd407d05905.tar.gz |
rrs/tools: Upgrade to use transaction.atomic() in Django 1.6
Django 1.6 provides a context manager for atomic transactions so
update the way for make db transactions.
Signed-off-by: Aníbal Limón <anibal.limon@linux.intel.com>
Diffstat (limited to 'rrs/tools/rrs_distros.py')
-rwxr-xr-x | rrs/tools/rrs_distros.py | 67 |
1 files changed, 31 insertions, 36 deletions
diff --git a/rrs/tools/rrs_distros.py b/rrs/tools/rrs_distros.py index e0c2defaf8..b28f38df86 100755 --- a/rrs/tools/rrs_distros.py +++ b/rrs/tools/rrs_distros.py @@ -94,42 +94,37 @@ if __name__=="__main__": logger.debug("Starting recipe distros update ...") - transaction.enter_transaction_management() - transaction.managed(True) + with transaction.atomic(): + for layerbranch in LayerBranch.objects.all(): + (tinfoil, d, recipes) = load_recipes(layerbranch, bitbakepath, + fetchdir, settings, logger) - for layerbranch in LayerBranch.objects.all(): - (tinfoil, d, recipes) = load_recipes(layerbranch, bitbakepath, - fetchdir, settings, logger) - - if not recipes: - continue - - from oe import distro_check - logger.debug("Downloading distro's package information ...") - distro_check.create_distro_packages_list(fetchdir, d) - pkglst_dir = os.path.join(fetchdir, "package_lists") - - RecipeDistro.objects.filter(recipe__layerbranch = layerbranch).delete() - - for recipe_data in recipes: - pn = recipe_data.getVar('PN', True) - - try: - recipe = Recipe.objects.get(pn = pn, layerbranch = layerbranch) - except: - logger.warn('%s: layer branch %s, NOT found' % (pn, - str(layerbranch))) + if not recipes: continue - distro_info = search_package_in_distros(pkglst_dir, recipe, recipe_data) - for distro, alias in distro_info.items(): - recipedistro = RecipeDistro() - recipedistro.recipe = recipe - recipedistro.distro = distro - recipedistro.alias = alias - recipedistro.save() - logger.debug('%s: layer branch %s, add distro %s alias %s' % (pn, - str(layerbranch), distro, alias)) - - transaction.commit() - transaction.leave_transaction_management() + from oe import distro_check + logger.debug("Downloading distro's package information ...") + distro_check.create_distro_packages_list(fetchdir, d) + pkglst_dir = os.path.join(fetchdir, "package_lists") + + RecipeDistro.objects.filter(recipe__layerbranch = layerbranch).delete() + + for recipe_data in recipes: + pn = recipe_data.getVar('PN', True) + + try: + recipe = Recipe.objects.get(pn = pn, layerbranch = layerbranch) + except: + logger.warn('%s: layer branch %s, NOT found' % (pn, + str(layerbranch))) + continue + + distro_info = search_package_in_distros(pkglst_dir, recipe, recipe_data) + for distro, alias in distro_info.items(): + recipedistro = RecipeDistro() + recipedistro.recipe = recipe + recipedistro.distro = distro + recipedistro.alias = alias + recipedistro.save() + logger.debug('%s: layer branch %s, add distro %s alias %s' % (pn, + str(layerbranch), distro, alias)) |