mirror of
git://git.yoctoproject.org/layerindex-web.git
synced 2025-07-19 20:59:01 +02:00
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>
This commit is contained in:
parent
1c5b79a312
commit
8ed223e13c
|
@ -94,9 +94,7 @@ 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)
|
||||
|
@ -130,6 +128,3 @@ if __name__=="__main__":
|
|||
recipedistro.save()
|
||||
logger.debug('%s: layer branch %s, add distro %s alias %s' % (pn,
|
||||
str(layerbranch), distro, alias))
|
||||
|
||||
transaction.commit()
|
||||
transaction.leave_transaction_management()
|
||||
|
|
|
@ -90,8 +90,7 @@ def maintainer_history(logger):
|
|||
commits = utils.runcmd("git log --format='%H' --reverse --date=rfc " +
|
||||
MAINTAINERS_INCLUDE_PATH, pokypath, logger=logger)
|
||||
|
||||
transaction.enter_transaction_management()
|
||||
transaction.managed(True)
|
||||
with transaction.atomic():
|
||||
for commit in commits.strip().split("\n"):
|
||||
if RecipeMaintainerHistory.objects.filter(sha1=commit):
|
||||
continue
|
||||
|
@ -161,9 +160,6 @@ def maintainer_history(logger):
|
|||
logger.debug("%s: New recipe not found maintainer set to 'No maintainer'." % \
|
||||
(recipe.pn))
|
||||
|
||||
transaction.commit()
|
||||
transaction.leave_transaction_management()
|
||||
|
||||
if __name__=="__main__":
|
||||
parser = optparse.OptionParser(usage = """%prog [options]""")
|
||||
|
||||
|
|
|
@ -46,11 +46,9 @@ if __name__=="__main__":
|
|||
|
||||
logger.info('Starting unique recipes ...')
|
||||
|
||||
transaction.enter_transaction_management()
|
||||
transaction.managed(True)
|
||||
|
||||
# only keep the major version of recipe
|
||||
logger.info('Starting remove of duplicate recipes only keep major version ...')
|
||||
with transaction.atomic():
|
||||
for layerbranch in LayerBranch.objects.all():
|
||||
recipes = {}
|
||||
|
||||
|
@ -82,7 +80,3 @@ if __name__=="__main__":
|
|||
logger.debug("%s: Removed older recipe (%s), current recipe (%s)." \
|
||||
% (recipes[pn].pn, recipe.pv, recipes[pn].pv))
|
||||
recipe.delete()
|
||||
|
||||
|
||||
transaction.commit()
|
||||
transaction.leave_transaction_management()
|
||||
|
|
|
@ -157,6 +157,7 @@ def do_initial(layerbranch, ct, logger):
|
|||
(tinfoil, d, recipes) = load_recipes(layerbranch, bitbakepath,
|
||||
fetchdir, settings, logger, nocheckout=True)
|
||||
|
||||
with transaction.atomic():
|
||||
for recipe_data in recipes:
|
||||
_create_upgrade(recipe_data, layerbranch, '', title,
|
||||
info, logger, initial=True)
|
||||
|
@ -188,6 +189,7 @@ def do_loop(layerbranch, ct, logger):
|
|||
repodir, logger=logger)
|
||||
info = utils.runcmd("git log --format='%an;%ae;%ad;%cd' --date=rfc -n 1 " \
|
||||
+ ct, destdir=repodir, logger=logger)
|
||||
with transaction.atomic():
|
||||
for recipe_data in recipes:
|
||||
_create_upgrade(recipe_data, layerbranch, ct, title,
|
||||
info, logger)
|
||||
|
@ -232,8 +234,6 @@ def upgrade_history(options, logger):
|
|||
logger=logger)
|
||||
commit_list = commits.split('\n')
|
||||
|
||||
transaction.enter_transaction_management()
|
||||
transaction.managed(True)
|
||||
if options.initial:
|
||||
logger.debug("Adding initial upgrade history ....")
|
||||
|
||||
|
@ -255,9 +255,6 @@ def upgrade_history(options, logger):
|
|||
p.start()
|
||||
p.join()
|
||||
|
||||
transaction.commit()
|
||||
transaction.leave_transaction_management()
|
||||
|
||||
if __name__=="__main__":
|
||||
parser = optparse.OptionParser(usage = """%prog [options]""")
|
||||
|
||||
|
|
|
@ -146,8 +146,7 @@ if __name__=="__main__":
|
|||
|
||||
logger.debug("Starting upstream history...")
|
||||
|
||||
transaction.enter_transaction_management()
|
||||
transaction.managed(True)
|
||||
with transaction.atomic():
|
||||
for layerbranch in LayerBranch.objects.all():
|
||||
layer = layerbranch.layer
|
||||
urldir = layer.get_fetch_dir()
|
||||
|
@ -195,6 +194,3 @@ if __name__=="__main__":
|
|||
|
||||
logger.debug('%s: layer branch %s, pv %s, upstream (%s)' % (recipe.pn,
|
||||
str(layerbranch), recipe.pv, str(ru)))
|
||||
|
||||
transaction.commit()
|
||||
transaction.leave_transaction_management()
|
||||
|
|
Loading…
Reference in New Issue
Block a user