diff options
Diffstat (limited to 'bitbake/lib/toaster/toastergui/api.py')
-rw-r--r-- | bitbake/lib/toaster/toastergui/api.py | 26 |
1 files changed, 15 insertions, 11 deletions
diff --git a/bitbake/lib/toaster/toastergui/api.py b/bitbake/lib/toaster/toastergui/api.py index b4cdc335ef..e367bd910e 100644 --- a/bitbake/lib/toaster/toastergui/api.py +++ b/bitbake/lib/toaster/toastergui/api.py | |||
@@ -11,7 +11,7 @@ import os | |||
11 | import re | 11 | import re |
12 | import logging | 12 | import logging |
13 | import json | 13 | import json |
14 | import subprocess | 14 | import glob |
15 | from collections import Counter | 15 | from collections import Counter |
16 | 16 | ||
17 | from orm.models import Project, ProjectTarget, Build, Layer_Version | 17 | from orm.models import Project, ProjectTarget, Build, Layer_Version |
@@ -227,20 +227,18 @@ class XhrSetDefaultImageUrl(View): | |||
227 | # same logical name | 227 | # same logical name |
228 | # * Each project that uses a layer will have its own | 228 | # * Each project that uses a layer will have its own |
229 | # LayerVersion and Project Layer for it | 229 | # LayerVersion and Project Layer for it |
230 | # * During the Paroject delete process, when the last | 230 | # * During the Project delete process, when the last |
231 | # LayerVersion for a 'local_source_dir' layer is deleted | 231 | # LayerVersion for a 'local_source_dir' layer is deleted |
232 | # then the Layer record is deleted to remove orphans | 232 | # then the Layer record is deleted to remove orphans |
233 | # | 233 | # |
234 | 234 | ||
235 | def scan_layer_content(layer,layer_version): | 235 | def scan_layer_content(layer,layer_version): |
236 | # if this is a local layer directory, we can immediately scan its content | 236 | # if this is a local layer directory, we can immediately scan its content |
237 | if layer.local_source_dir: | 237 | if os.path.isdir(layer.local_source_dir): |
238 | try: | 238 | try: |
239 | # recipes-*/*/*.bb | 239 | # recipes-*/*/*.bb |
240 | cmd = '%s %s' % ('ls', os.path.join(layer.local_source_dir,'recipes-*/*/*.bb')) | 240 | recipes_list = glob.glob(os.path.join(layer.local_source_dir, 'recipes-*/*/*.bb')) |
241 | recipes_list = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE,stderr=subprocess.STDOUT).stdout.read() | 241 | for recipe in recipes_list: |
242 | recipes_list = recipes_list.decode("utf-8").strip() | ||
243 | if recipes_list and 'No such' not in recipes_list: | ||
244 | for recipe in recipes_list.split('\n'): | 242 | for recipe in recipes_list.split('\n'): |
245 | recipe_path = recipe[recipe.rfind('recipes-'):] | 243 | recipe_path = recipe[recipe.rfind('recipes-'):] |
246 | recipe_name = recipe[recipe.rfind('/')+1:].replace('.bb','') | 244 | recipe_name = recipe[recipe.rfind('/')+1:].replace('.bb','') |
@@ -260,6 +258,9 @@ def scan_layer_content(layer,layer_version): | |||
260 | 258 | ||
261 | except Exception as e: | 259 | except Exception as e: |
262 | logger.warning("ERROR:scan_layer_content: %s" % e) | 260 | logger.warning("ERROR:scan_layer_content: %s" % e) |
261 | else: | ||
262 | logger.warning("ERROR: wrong path given") | ||
263 | raise KeyError("local_source_dir") | ||
263 | 264 | ||
264 | class XhrLayer(View): | 265 | class XhrLayer(View): |
265 | """ Delete, Get, Add and Update Layer information | 266 | """ Delete, Get, Add and Update Layer information |
@@ -456,15 +457,18 @@ class XhrLayer(View): | |||
456 | 'layerdetailurl': | 457 | 'layerdetailurl': |
457 | layer_dep.get_detailspage_url(project.pk)}) | 458 | layer_dep.get_detailspage_url(project.pk)}) |
458 | 459 | ||
459 | # Scan the layer's content and update components | 460 | # Only scan_layer_content if layer is local |
460 | scan_layer_content(layer,layer_version) | 461 | if layer_data.get('local_source_dir', None): |
462 | # Scan the layer's content and update components | ||
463 | scan_layer_content(layer,layer_version) | ||
461 | 464 | ||
462 | except Layer_Version.DoesNotExist: | 465 | except Layer_Version.DoesNotExist: |
463 | return error_response("layer-dep-not-found") | 466 | return error_response("layer-dep-not-found") |
464 | except Project.DoesNotExist: | 467 | except Project.DoesNotExist: |
465 | return error_response("project-not-found") | 468 | return error_response("project-not-found") |
466 | except KeyError: | 469 | except KeyError as e: |
467 | return error_response("incorrect-parameters") | 470 | _log("KeyError: %s" % e) |
471 | return error_response(f"incorrect-parameters") | ||
468 | 472 | ||
469 | return JsonResponse({'error': "ok", | 473 | return JsonResponse({'error': "ok", |
470 | 'imported_layer': { | 474 | 'imported_layer': { |