diff options
Diffstat (limited to 'bitbake/lib/toaster/toastergui/views.py')
-rwxr-xr-x | bitbake/lib/toaster/toastergui/views.py | 270 |
1 files changed, 156 insertions, 114 deletions
diff --git a/bitbake/lib/toaster/toastergui/views.py b/bitbake/lib/toaster/toastergui/views.py index b38d260d6f..6de448596a 100755 --- a/bitbake/lib/toaster/toastergui/views.py +++ b/bitbake/lib/toaster/toastergui/views.py | |||
@@ -540,132 +540,174 @@ def recipe(request, build_id, recipe_id): | |||
540 | } | 540 | } |
541 | return render(request, template, context) | 541 | return render(request, template, context) |
542 | 542 | ||
543 | def target(request, build_id, target_id): | 543 | def target_common( request, build_id, target_id, variant ): |
544 | template = "target.html" | 544 | template = "target.html" |
545 | default_orderby = 'name:+'; | ||
545 | mandatory_parameters = { 'count': 25, 'page' : 1, 'orderby':'name:+'}; | 546 | mandatory_parameters = { 'count': 25, 'page' : 1, 'orderby':'name:+'}; |
546 | retval = _verify_parameters( request.GET, mandatory_parameters ) | 547 | retval = _verify_parameters( request.GET, mandatory_parameters ) |
547 | if retval: | 548 | if retval: |
548 | return _redirect_parameters( 'target', request.GET, mandatory_parameters, build_id = build_id, target_id = target_id) | 549 | return _redirect_parameters( |
549 | (filter_string, search_term, ordering_string) = _search_tuple(request, Package) | 550 | variant, request.GET, mandatory_parameters, |
551 | build_id = build_id, target_id = target_id ) | ||
552 | ( filter_string, search_term, ordering_string ) = _search_tuple( request, Package ) | ||
550 | 553 | ||
551 | # FUTURE: get rid of nested sub-queries replacing with ManyToMany field | 554 | # FUTURE: get rid of nested sub-queries replacing with ManyToMany field |
552 | queryset = Package.objects.filter(size__gte=0, id__in=Target_Installed_Package.objects.filter(target_id=target_id).values('package_id')) | 555 | queryset = Package.objects.filter( |
553 | packages_sum = queryset.aggregate(Sum('installed_size')) | 556 | size__gte = 0, |
554 | queryset = _get_queryset(Package, queryset, filter_string, search_term, ordering_string, 'name') | 557 | id__in = Target_Installed_Package.objects.filter( |
555 | packages = _build_page_range(Paginator(queryset, request.GET.get('count', 25)),request.GET.get('page', 1)) | 558 | target_id=target_id ).values( 'package_id' )) |
559 | packages_sum = queryset.aggregate( Sum( 'installed_size' )) | ||
560 | queryset = _get_queryset( | ||
561 | Package, queryset, filter_string, search_term, ordering_string, 'name' ) | ||
562 | packages = _build_page_range( Paginator( | ||
563 | queryset, request.GET.get( 'count', 25 )),request.GET.get( 'page', 1 )) | ||
556 | 564 | ||
557 | # bring in package dependencies | 565 | # bring in package dependencies |
558 | for p in packages.object_list: | 566 | for p in packages.object_list: |
559 | p.runtime_dependencies = p.package_dependencies_source.filter(target_id = target_id, dep_type=Package_Dependency.TYPE_TRDEPENDS) | 567 | p.runtime_dependencies = p.package_dependencies_source.filter( |
560 | p.reverse_runtime_dependencies = p.package_dependencies_target.filter(target_id = target_id, dep_type=Package_Dependency.TYPE_TRDEPENDS) | 568 | target_id = target_id, dep_type=Package_Dependency.TYPE_TRDEPENDS ) |
561 | 569 | p.reverse_runtime_dependencies = p.package_dependencies_target.filter( | |
562 | context = { 'build': Build.objects.filter(pk=build_id)[0], | 570 | target_id = target_id, dep_type=Package_Dependency.TYPE_TRDEPENDS ) |
563 | 'target': Target.objects.filter(pk=target_id)[0], | 571 | tc_package = { |
564 | 'objects': packages, | 572 | 'name' : 'Package', |
565 | 'packages_sum' : packages_sum['installed_size__sum'], | 573 | 'qhelp' : 'Packaged output resulting from building a recipe included in this image', |
566 | 'object_search_display': "packages included", | 574 | 'orderfield' : _get_toggle_order( request, "name" ), |
567 | 'default_orderby' : 'name:+', | 575 | 'ordericon' : _get_toggle_order_icon( request, "name" ), |
568 | 'tablecols':[ | 576 | } |
569 | { | 577 | tc_packageVersion = { |
570 | 'name':'Package', | 578 | 'name' : 'Package version', |
571 | 'qhelp':'Packaged output resulting from building a recipe and included in this image', | 579 | 'qhelp' : 'The package version and revision', |
572 | 'orderfield': _get_toggle_order(request, "name"), | 580 | } |
573 | 'ordericon':_get_toggle_order_icon(request, "name"), | 581 | tc_size = { |
574 | }, | 582 | 'name' : 'Size', |
575 | { | 583 | 'qhelp' : 'The size of the package', |
576 | 'name':'Package version', | 584 | 'orderfield' : _get_toggle_order( request, "size", True ), |
577 | 'qhelp':'The package version and revision', | 585 | 'ordericon' : _get_toggle_order_icon( request, "size" ), |
578 | }, | 586 | 'orderkey' : 'size', |
579 | { | 587 | 'clclass' : 'size', |
580 | 'name':'Size', | 588 | 'dclass' : 'span2', |
581 | 'qhelp':'The size of the package', | 589 | } |
582 | 'orderfield': _get_toggle_order(request, "size", True), | 590 | if ( variant == 'target' ): |
583 | 'ordericon':_get_toggle_order_icon(request, "size"), | 591 | tc_size[ "hidden" ] = 0 |
584 | 'orderkey' : 'size', | 592 | else: |
585 | 'clclass': 'size', | 593 | tc_size[ "hidden" ] = 1 |
586 | 'dclass' : 'span2', | 594 | tc_sizePercentage = { |
587 | 'hidden' : 0, | 595 | 'name' : 'Size over total (%)', |
588 | }, | 596 | 'qhelp' : 'Proportion of the overall size represented by this package', |
589 | { | 597 | 'orderfield' : _get_toggle_order( request, "size" ), |
590 | 'name':'Size over total (%)', | 598 | 'ordericon' : _get_toggle_order_icon( request, "size" ), |
591 | 'qhelp':'Proportion of the overall included package size represented by this package', | 599 | 'clclass' : 'size_over_total', |
592 | 'orderkey' : 'size', | 600 | 'hidden' : 1, |
593 | 'clclass': 'size_over_total', | 601 | } |
594 | 'dclass' : 'span2', | 602 | tc_license = { |
595 | 'hidden' : 1, | 603 | 'name' : 'License', |
596 | }, | 604 | 'qhelp' : 'The license under which the package is distributed. Separate license names u\ |
597 | { | 605 | sing | (pipe) means there is a choice between licenses. Separate license names using & (ampersand) m\ |
598 | 'name':'License', | 606 | eans multiple licenses exist that cover different parts of the source', |
599 | 'qhelp':'The license under which the package is distributed. Multiple license names separated by the pipe character indicates a choice between licenses. Multiple license names separated by the ampersand character indicates multiple licenses exist that cover different parts of the source', | 607 | 'orderfield' : _get_toggle_order( request, "license" ), |
600 | 'orderfield': _get_toggle_order(request, "license"), | 608 | 'ordericon' : _get_toggle_order_icon( request, "license" ), |
601 | 'ordericon':_get_toggle_order_icon(request, "license"), | 609 | 'orderkey' : 'license', |
602 | 'orderkey' : 'license', | 610 | 'clclass' : 'license', |
603 | 'clclass': 'license', | 611 | } |
604 | 'hidden' : 1, | 612 | if ( variant == 'target' ): |
605 | }, | 613 | tc_license[ "hidden" ] = 1 |
606 | { | 614 | else: |
607 | 'name':'Dependencies', | 615 | tc_license[ "hidden" ] = 0 |
608 | 'qhelp':"Package runtime dependencies (i.e. other packages)", | 616 | tc_dependencies = { |
609 | 'clclass': 'depends', | 617 | 'name' : 'Dependencies', |
610 | 'hidden' : 0, | 618 | 'qhelp' : "Package runtime dependencies (other packages)", |
611 | }, | 619 | 'clclass' : 'depends', |
612 | { | 620 | } |
613 | 'name':'Reverse dependencies', | 621 | if ( variant == 'target' ): |
614 | 'qhelp':'Package run-time reverse dependencies (i.e. other packages that depend on this package)', | 622 | tc_dependencies[ "hidden" ] = 0 |
615 | 'clclass': 'brought_in_by', | 623 | else: |
616 | 'hidden' : 0, | 624 | tc_dependencies[ "hidden" ] = 1 |
617 | }, | 625 | tc_rdependencies = { |
618 | { | 626 | 'name' : 'Reverse dependencies', |
619 | 'name':'Recipe', | 627 | 'qhelp' : 'Package run-time reverse dependencies (i.e. which other packages depend on t\ |
620 | 'qhelp':'The name of the recipe building the package', | 628 | his package', |
621 | 'orderfield': _get_toggle_order(request, "recipe__name"), | 629 | 'clclass' : 'brought_in_by', |
622 | 'ordericon':_get_toggle_order_icon(request, "recipe__name"), | 630 | } |
623 | 'orderkey' : 'recipe__name', | 631 | if ( variant == 'target' ): |
624 | 'clclass': 'recipe_name', | 632 | tc_rdependencies[ "hidden" ] = 0 |
625 | 'hidden' : 0, | 633 | else: |
626 | }, | 634 | tc_rdependencies[ "hidden" ] = 1 |
627 | { | 635 | tc_recipe = { |
628 | 'name':'Recipe version', | 636 | 'name' : 'Recipe', |
629 | 'qhelp':'Version and revision of the recipe building the package', | 637 | 'qhelp' : 'The name of the recipe building the package', |
630 | 'clclass': 'recipe_version', | 638 | 'orderfield' : _get_toggle_order( request, "recipe__name" ), |
631 | 'hidden' : 1, | 639 | 'ordericon' : _get_toggle_order_icon( request, "recipe__name" ), |
632 | }, | 640 | 'clclass' : 'recipe_name', |
633 | { | 641 | 'hidden' : 0, |
634 | 'name':'Layer', | 642 | } |
635 | 'qhelp':'The name of the layer providing the recipe that builds the package', | 643 | tc_recipeVersion = { |
636 | 'orderfield': _get_toggle_order(request, "recipe__layer_version__layer__name"), | 644 | 'name' : 'Recipe version', |
637 | 'ordericon':_get_toggle_order_icon(request, "recipe__layer_version__layer__name"), | 645 | 'qhelp' : 'Version and revision of the recipe building the package', |
638 | 'orderkey' : 'recipe__layer_version__layer__name', | 646 | 'clclass' : 'recipe_version', |
639 | 'clclass': 'layer_name', | 647 | 'hidden' : 1, |
640 | 'hidden' : 1, | 648 | } |
641 | }, | 649 | tc_layer = { |
642 | { | 650 | 'name' : 'Layer', |
643 | 'name':'Layer branch', | 651 | 'qhelp' : 'The name of the layer providing the recipe that builds the package', |
644 | 'qhelp':'The Git branch of the layer providing the recipe that builds the package', | 652 | 'orderfield' : _get_toggle_order( request, "recipe__layer_version__layer__name" ), |
645 | 'orderfield': _get_toggle_order(request, "recipe__layer_version__branch"), | 653 | 'ordericon' : _get_toggle_order_icon( request, "recipe__layer_version__layer__name" ), |
646 | 'ordericon':_get_toggle_order_icon(request, "recipe__layer_version__branch"), | 654 | 'clclass' : 'layer_name', |
647 | 'orderkey' : 'recipe__layer_version__branch', | 655 | 'hidden' : 1, |
648 | 'clclass': 'layer_branch', | 656 | } |
649 | 'hidden' : 1, | 657 | tc_layerBranch = { |
650 | }, | 658 | 'name' : 'Layer branch', |
651 | { | 659 | 'qhelp' : 'The Git branch of the layer providing the recipe that builds the package', |
652 | 'name':'Layer commit', | 660 | 'orderfield' : _get_toggle_order( request, "recipe__layer_version__branch" ), |
653 | 'qhelp':'The Git commit of the layer providing the recipe that builds the package', | 661 | 'ordericon' : _get_toggle_order_icon( request, "recipe__layer_version__branch" ), |
654 | 'clclass': 'layer_commit', | 662 | 'clclass' : 'layer_branch', |
655 | 'hidden' : 1, | 663 | 'hidden' : 1, |
656 | }, | 664 | } |
657 | { | 665 | tc_layerCommit = { |
658 | 'name':'Layer directory', | 666 | 'name' : 'Layer commit', |
659 | 'qhelp':'Path to the layer providing the recipe that builds the package', | 667 | 'qhelp' : 'The Git commit of the layer providing the recipe that builds the package', |
660 | 'orderfield': _get_toggle_order(request, "recipe__layer_version__layer__local_path"), | 668 | 'clclass' : 'layer_commit', |
661 | 'ordericon':_get_toggle_order_icon(request, "recipe__layer_version__layer__local_path"), | 669 | 'hidden' : 1, |
662 | 'clclass': 'layer_directory', | 670 | } |
663 | 'hidden' : 1, | 671 | tc_layerDir = { |
664 | }, | 672 | 'name':'Layer directory', |
673 | 'qhelp':'Location in disk of the layer providing the recipe that builds the package', | ||
674 | 'orderfield' : _get_toggle_order( request, "recipe__layer_version__layer__local_path" ), | ||
675 | 'ordericon' : _get_toggle_order_icon( request, "recipe__layer_version__layer__local_path" )\ | ||
676 | , | ||
677 | 'clclass' : 'layer_directory', | ||
678 | 'hidden' : 1, | ||
679 | } | ||
680 | context = { | ||
681 | 'objectname': variant, | ||
682 | 'build' : Build.objects.filter( pk = build_id )[ 0 ], | ||
683 | 'target' : Target.objects.filter( pk = target_id )[ 0 ], | ||
684 | 'objects' : packages, | ||
685 | 'packages_sum' : packages_sum[ 'installed_size__sum' ], | ||
686 | 'object_search_display': "packages included", | ||
687 | 'default_orderby' : default_orderby, | ||
688 | 'tablecols' : [ | ||
689 | tc_package, | ||
690 | tc_packageVersion, | ||
691 | tc_license, | ||
692 | tc_size, | ||
693 | tc_sizePercentage, | ||
694 | tc_dependencies, | ||
695 | tc_rdependencies, | ||
696 | tc_recipe, | ||
697 | tc_recipeVersion, | ||
698 | tc_layer, | ||
699 | tc_layerBranch, | ||
700 | tc_layerCommit, | ||
701 | tc_layerDir, | ||
665 | ] | 702 | ] |
666 | } | 703 | } |
704 | return( render( request, template, context )) | ||
667 | 705 | ||
668 | return render(request, template, context) | 706 | def target( request, build_id, target_id ): |
707 | return( target_common( request, build_id, target_id, "target" )) | ||
708 | |||
709 | def targetpkg( request, build_id, target_id ): | ||
710 | return( target_common( request, build_id, target_id, "targetpkg" )) | ||
669 | 711 | ||
670 | from django.core.serializers.json import DjangoJSONEncoder | 712 | from django.core.serializers.json import DjangoJSONEncoder |
671 | from django.http import HttpResponse | 713 | from django.http import HttpResponse |