diff options
Diffstat (limited to 'bitbake')
-rw-r--r-- | bitbake/lib/toaster/orm/models.py | 34 |
1 files changed, 23 insertions, 11 deletions
diff --git a/bitbake/lib/toaster/orm/models.py b/bitbake/lib/toaster/orm/models.py index 90e11d2383..4d1dcbc9f3 100644 --- a/bitbake/lib/toaster/orm/models.py +++ b/bitbake/lib/toaster/orm/models.py | |||
@@ -724,7 +724,7 @@ class LayerIndexLayerSource(LayerSource): | |||
724 | """ | 724 | """ |
725 | assert self.apiurl is not None | 725 | assert self.apiurl is not None |
726 | from django.db import IntegrityError | 726 | from django.db import IntegrityError |
727 | from django.db import transaction | 727 | from django.db import transaction, connection |
728 | 728 | ||
729 | import httplib, urlparse, json | 729 | import httplib, urlparse, json |
730 | import os | 730 | import os |
@@ -789,7 +789,8 @@ class LayerIndexLayerSource(LayerSource): | |||
789 | 789 | ||
790 | # update layers | 790 | # update layers |
791 | layers_info = _get_json_response(apilinks['layerItems']) | 791 | layers_info = _get_json_response(apilinks['layerItems']) |
792 | transaction.set_autocommit(False) | 792 | if not connection.features.autocommits_when_autocommit_is_off: |
793 | transaction.set_autocommit(False) | ||
793 | for li in layers_info: | 794 | for li in layers_info: |
794 | l, created = Layer.objects.get_or_create(layer_source = self, name = li['name']) | 795 | l, created = Layer.objects.get_or_create(layer_source = self, name = li['name']) |
795 | l.up_id = li['id'] | 796 | l.up_id = li['id'] |
@@ -801,7 +802,8 @@ class LayerIndexLayerSource(LayerSource): | |||
801 | l.summary = li['summary'] | 802 | l.summary = li['summary'] |
802 | l.description = li['description'] | 803 | l.description = li['description'] |
803 | l.save() | 804 | l.save() |
804 | transaction.set_autocommit(True) | 805 | if not connection.features.autocommits_when_autocommit_is_off: |
806 | transaction.set_autocommit(True) | ||
805 | 807 | ||
806 | # update layerbranches/layer_versions | 808 | # update layerbranches/layer_versions |
807 | print "Fetching layer information" | 809 | print "Fetching layer information" |
@@ -809,7 +811,8 @@ class LayerIndexLayerSource(LayerSource): | |||
809 | + "?filter=branch:%s" % "OR".join(map(lambda x: str(x.up_id), [i for i in Branch.objects.filter(layer_source = self) if i.up_id is not None] )) | 811 | + "?filter=branch:%s" % "OR".join(map(lambda x: str(x.up_id), [i for i in Branch.objects.filter(layer_source = self) if i.up_id is not None] )) |
810 | ) | 812 | ) |
811 | 813 | ||
812 | transaction.set_autocommit(False) | 814 | if not connection.features.autocommits_when_autocommit_is_off: |
815 | transaction.set_autocommit(False) | ||
813 | for lbi in layerbranches_info: | 816 | for lbi in layerbranches_info: |
814 | lv, created = Layer_Version.objects.get_or_create(layer_source = self, | 817 | lv, created = Layer_Version.objects.get_or_create(layer_source = self, |
815 | up_id = lbi['id'], | 818 | up_id = lbi['id'], |
@@ -822,12 +825,14 @@ class LayerIndexLayerSource(LayerSource): | |||
822 | lv.commit = lbi['actual_branch'] | 825 | lv.commit = lbi['actual_branch'] |
823 | lv.dirpath = lbi['vcs_subdir'] | 826 | lv.dirpath = lbi['vcs_subdir'] |
824 | lv.save() | 827 | lv.save() |
825 | transaction.set_autocommit(True) | 828 | if not connection.features.autocommits_when_autocommit_is_off: |
829 | transaction.set_autocommit(True) | ||
826 | 830 | ||
827 | # update layer dependencies | 831 | # update layer dependencies |
828 | layerdependencies_info = _get_json_response(apilinks['layerDependencies']) | 832 | layerdependencies_info = _get_json_response(apilinks['layerDependencies']) |
829 | dependlist = {} | 833 | dependlist = {} |
830 | transaction.set_autocommit(False) | 834 | if not connection.features.autocommits_when_autocommit_is_off: |
835 | transaction.set_autocommit(False) | ||
831 | for ldi in layerdependencies_info: | 836 | for ldi in layerdependencies_info: |
832 | try: | 837 | try: |
833 | lv = Layer_Version.objects.get(layer_source = self, up_id = ldi['layerbranch']) | 838 | lv = Layer_Version.objects.get(layer_source = self, up_id = ldi['layerbranch']) |
@@ -846,7 +851,8 @@ class LayerIndexLayerSource(LayerSource): | |||
846 | LayerVersionDependency.objects.filter(layer_version = lv).delete() | 851 | LayerVersionDependency.objects.filter(layer_version = lv).delete() |
847 | for lvd in dependlist[lv]: | 852 | for lvd in dependlist[lv]: |
848 | LayerVersionDependency.objects.get_or_create(layer_version = lv, depends_on = lvd) | 853 | LayerVersionDependency.objects.get_or_create(layer_version = lv, depends_on = lvd) |
849 | transaction.set_autocommit(True) | 854 | if not connection.features.autocommits_when_autocommit_is_off: |
855 | transaction.set_autocommit(True) | ||
850 | 856 | ||
851 | 857 | ||
852 | # update machines | 858 | # update machines |
@@ -854,21 +860,26 @@ class LayerIndexLayerSource(LayerSource): | |||
854 | machines_info = _get_json_response(apilinks['machines'] | 860 | machines_info = _get_json_response(apilinks['machines'] |
855 | + "?filter=layerbranch:%s" % "OR".join(map(lambda x: str(x.up_id), Layer_Version.objects.filter(layer_source = self))) | 861 | + "?filter=layerbranch:%s" % "OR".join(map(lambda x: str(x.up_id), Layer_Version.objects.filter(layer_source = self))) |
856 | ) | 862 | ) |
857 | transaction.set_autocommit(False) | 863 | |
864 | if not connection.features.autocommits_when_autocommit_is_off: | ||
865 | transaction.set_autocommit(False) | ||
858 | for mi in machines_info: | 866 | for mi in machines_info: |
859 | mo, created = Machine.objects.get_or_create(layer_source = self, up_id = mi['id'], layer_version = Layer_Version.objects.get(layer_source = self, up_id = mi['layerbranch'])) | 867 | mo, created = Machine.objects.get_or_create(layer_source = self, up_id = mi['id'], layer_version = Layer_Version.objects.get(layer_source = self, up_id = mi['layerbranch'])) |
860 | mo.up_date = mi['updated'] | 868 | mo.up_date = mi['updated'] |
861 | mo.name = mi['name'] | 869 | mo.name = mi['name'] |
862 | mo.description = mi['description'] | 870 | mo.description = mi['description'] |
863 | mo.save() | 871 | mo.save() |
864 | transaction.set_autocommit(True) | 872 | |
873 | if not connection.features.autocommits_when_autocommit_is_off: | ||
874 | transaction.set_autocommit(True) | ||
865 | 875 | ||
866 | # update recipes; paginate by layer version / layer branch | 876 | # update recipes; paginate by layer version / layer branch |
867 | print "Fetching target information" | 877 | print "Fetching target information" |
868 | recipes_info = _get_json_response(apilinks['recipes'] | 878 | recipes_info = _get_json_response(apilinks['recipes'] |
869 | + "?filter=layerbranch:%s" % "OR".join(map(lambda x: str(x.up_id), Layer_Version.objects.filter(layer_source = self))) | 879 | + "?filter=layerbranch:%s" % "OR".join(map(lambda x: str(x.up_id), Layer_Version.objects.filter(layer_source = self))) |
870 | ) | 880 | ) |
871 | transaction.set_autocommit(False) | 881 | if not connection.features.autocommits_when_autocommit_is_off: |
882 | transaction.set_autocommit(False) | ||
872 | for ri in recipes_info: | 883 | for ri in recipes_info: |
873 | try: | 884 | try: |
874 | ro, created = Recipe.objects.get_or_create(layer_source = self, up_id = ri['id'], layer_version = Layer_Version.objects.get(layer_source = self, up_id = ri['layerbranch'])) | 885 | ro, created = Recipe.objects.get_or_create(layer_source = self, up_id = ri['id'], layer_version = Layer_Version.objects.get(layer_source = self, up_id = ri['layerbranch'])) |
@@ -886,7 +897,8 @@ class LayerIndexLayerSource(LayerSource): | |||
886 | except: | 897 | except: |
887 | #print "Duplicate Recipe, ignoring: ", vars(ro) | 898 | #print "Duplicate Recipe, ignoring: ", vars(ro) |
888 | pass | 899 | pass |
889 | transaction.set_autocommit(True) | 900 | if not connection.features.autocommits_when_autocommit_is_off: |
901 | transaction.set_autocommit(True) | ||
890 | pass | 902 | pass |
891 | 903 | ||
892 | class BitbakeVersion(models.Model): | 904 | class BitbakeVersion(models.Model): |