diff options
author | Alexandru DAMIAN <alexandru.damian@intel.com> | 2015-08-18 17:28:50 +0100 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2015-08-19 18:05:52 +0100 |
commit | 504396f6a35e1a18d852f2387098ba7f8f298d3d (patch) | |
tree | d7a1a6624ffd18c407317e53bcf64e7ae3019380 /bitbake/lib | |
parent | 99730d64d4b83ce37d4b3f5a7f992512fd12cbf7 (diff) | |
download | poky-504396f6a35e1a18d852f2387098ba7f8f298d3d.tar.gz |
bitbake: toaster: improve exception handling
This patch improves exception handling, fixing issues
as prompted by pylint, including exception renaming.
(Bitbake rev: 652fad64864703cb1bbeede8d5bfc4208974be68)
Signed-off-by: Alexandru DAMIAN <alexandru.damian@intel.com>
Signed-off-by: Michael Wood <michael.g.wood@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake/lib')
-rw-r--r-- | bitbake/lib/toaster/orm/models.py | 15 | ||||
-rwxr-xr-x | bitbake/lib/toaster/toastergui/views.py | 13 |
2 files changed, 10 insertions, 18 deletions
diff --git a/bitbake/lib/toaster/orm/models.py b/bitbake/lib/toaster/orm/models.py index b3f8db9750..6b485d2ac4 100644 --- a/bitbake/lib/toaster/orm/models.py +++ b/bitbake/lib/toaster/orm/models.py | |||
@@ -269,11 +269,10 @@ class Project(models.Model): | |||
269 | except ProjectVariable.DoesNotExist: | 269 | except ProjectVariable.DoesNotExist: |
270 | pass | 270 | pass |
271 | br.save() | 271 | br.save() |
272 | except Exception as e: | 272 | except Exception: |
273 | # revert the build request creation since we're not done cleanly | ||
273 | br.delete() | 274 | br.delete() |
274 | import sys | 275 | raise |
275 | et, ei, tb = sys.exc_info() | ||
276 | raise type(e), e, tb | ||
277 | return br | 276 | return br |
278 | 277 | ||
279 | class Build(models.Model): | 278 | class Build(models.Model): |
@@ -364,7 +363,7 @@ class BuildArtifact(models.Model): | |||
364 | 363 | ||
365 | 364 | ||
366 | def is_available(self): | 365 | def is_available(self): |
367 | return build.buildrequest.environment.has_artifact(file_path) | 366 | return self.build.buildrequest.environment.has_artifact(self.file_name) |
368 | 367 | ||
369 | class ProjectTarget(models.Model): | 368 | class ProjectTarget(models.Model): |
370 | project = models.ForeignKey(Project) | 369 | project = models.ForeignKey(Project) |
@@ -981,12 +980,10 @@ class LayerIndexLayerSource(LayerSource): | |||
981 | if 'inherits' in ri: | 980 | if 'inherits' in ri: |
982 | ro.is_image = 'image' in ri['inherits'].split() | 981 | ro.is_image = 'image' in ri['inherits'].split() |
983 | ro.save() | 982 | ro.save() |
984 | except: | 983 | except Exception: |
985 | #print "Duplicate Recipe, ignoring: ", vars(ro) | 984 | logger.warning("Duplicate Recipe, ignoring: %s " % vars(ro)) |
986 | pass | ||
987 | if not connection.features.autocommits_when_autocommit_is_off: | 985 | if not connection.features.autocommits_when_autocommit_is_off: |
988 | transaction.set_autocommit(True) | 986 | transaction.set_autocommit(True) |
989 | pass | ||
990 | 987 | ||
991 | class BitbakeVersion(models.Model): | 988 | class BitbakeVersion(models.Model): |
992 | 989 | ||
diff --git a/bitbake/lib/toaster/toastergui/views.py b/bitbake/lib/toaster/toastergui/views.py index 03c7507762..d6bd7c94ba 100755 --- a/bitbake/lib/toaster/toastergui/views.py +++ b/bitbake/lib/toaster/toastergui/views.py | |||
@@ -1876,10 +1876,7 @@ if True: | |||
1876 | 1876 | ||
1877 | queryset = Build.objects.filter(outcome__lte = Build.IN_PROGRESS) | 1877 | queryset = Build.objects.filter(outcome__lte = Build.IN_PROGRESS) |
1878 | 1878 | ||
1879 | try: | 1879 | context, pagesize, orderby = _build_list_helper(request, queryset) |
1880 | context, pagesize, orderby = _build_list_helper(request, queryset) | ||
1881 | except InvalidRequestException as e: | ||
1882 | raise RedirectException( builds, request.GET, e.response) | ||
1883 | 1880 | ||
1884 | _set_parameters_values(pagesize, orderby, request) | 1881 | _set_parameters_values(pagesize, orderby, request) |
1885 | return context | 1882 | return context |
@@ -2422,7 +2419,8 @@ if True: | |||
2422 | # dependency already (like modified on another page) | 2419 | # dependency already (like modified on another page) |
2423 | try: | 2420 | try: |
2424 | prj_layer, prj_layer_created = ProjectLayer.objects.get_or_create(layercommit=layer_dep_obj, project=prj) | 2421 | prj_layer, prj_layer_created = ProjectLayer.objects.get_or_create(layercommit=layer_dep_obj, project=prj) |
2425 | except: | 2422 | except IntegrityError as e: |
2423 | logger.warning("Integrity error while saving Project Layers: %s (original %s)" % (e, e.__cause__)) | ||
2426 | continue | 2424 | continue |
2427 | 2425 | ||
2428 | if prj_layer_created: | 2426 | if prj_layer_created: |
@@ -2639,10 +2637,7 @@ if True: | |||
2639 | 2637 | ||
2640 | queryset = Build.objects.filter(outcome__lte = Build.IN_PROGRESS) | 2638 | queryset = Build.objects.filter(outcome__lte = Build.IN_PROGRESS) |
2641 | 2639 | ||
2642 | try: | 2640 | context, pagesize, orderby = _build_list_helper(request, queryset) |
2643 | context, pagesize, orderby = _build_list_helper(request, queryset) | ||
2644 | except InvalidRequestException as e: | ||
2645 | raise RedirectException('projectbuilds', request.GET, e.response, pid = pid) | ||
2646 | 2641 | ||
2647 | context['project'] = prj | 2642 | context['project'] = prj |
2648 | _set_parameters_values(pagesize, orderby, request) | 2643 | _set_parameters_values(pagesize, orderby, request) |