@@ -494,7 +494,7 @@ def __get_install_info_from_tool_shed( self, tool_shed_url, name, owner, changes
494
494
495
495
def __handle_repository_contents ( self , tool_shed_repository , tool_path , repository_clone_url , relative_install_dir ,
496
496
tool_shed = None , tool_section = None , shed_tool_conf = None , reinstalling = False ,
497
- tool_versions_response = None ):
497
+ tool_versions_response = None , tool_panel_section_mapping = {} ):
498
498
"""
499
499
Generate the metadata for the installed tool shed repository, among other things.
500
500
This method is called when an administrator is installing a new repository or
@@ -572,7 +572,8 @@ def __handle_repository_contents( self, tool_shed_repository, tool_path, reposit
572
572
owner = tool_shed_repository .owner ,
573
573
shed_tool_conf = shed_tool_conf ,
574
574
tool_panel_dict = tool_panel_dict ,
575
- new_install = True )
575
+ new_install = True ,
576
+ tool_panel_section_mapping = tool_panel_section_mapping )
576
577
if 'data_manager' in irmm_metadata_dict :
577
578
dmh = data_manager .DataManagerHandler ( self .app )
578
579
dmh .install_data_managers ( self .app .config .shed_data_manager_config_file ,
@@ -648,13 +649,20 @@ def initiate_repository_installation( self, installation_dict ):
648
649
status = installation_dict [ 'status' ]
649
650
tool_panel_section_id = installation_dict [ 'tool_panel_section_id' ]
650
651
tool_panel_section_keys = installation_dict [ 'tool_panel_section_keys' ]
652
+ tool_panel_section_mapping = installation_dict .get ( 'tool_panel_section_mapping' , {} )
651
653
tool_path = installation_dict [ 'tool_path' ]
652
654
tool_shed_url = installation_dict [ 'tool_shed_url' ]
653
655
# Handle contained tools.
654
656
if includes_tools_for_display_in_tool_panel and ( new_tool_panel_section_label or tool_panel_section_id ):
655
657
self .tpm .handle_tool_panel_section ( self .app .toolbox ,
656
658
tool_panel_section_id = tool_panel_section_id ,
657
659
new_tool_panel_section_label = new_tool_panel_section_label )
660
+ if includes_tools_for_display_in_tool_panel and ( tool_panel_section_mapping is not None ):
661
+ for tool_guid in tool_panel_section_mapping :
662
+ if tool_panel_section_mapping [ tool_guid ][ 'action' ] == 'create' :
663
+ new_tool_panel_section_name = tool_panel_section_mapping [ tool_guid ][ 'tool_panel_section' ]
664
+ log .debug ( 'Creating tool panel section "%s" for tool %s' % ( new_tool_panel_section_name , tool_guid ) )
665
+ self .tpm .handle_tool_panel_section ( self .app .toolbox , None , tool_panel_section_mapping [ tool_guid ][ 'tool_panel_section' ] )
658
666
encoded_repository_ids = [ self .app .security .encode_id ( tsr .id ) for tsr in created_or_updated_tool_shed_repositories ]
659
667
new_kwd = dict ( includes_tools = includes_tools ,
660
668
includes_tools_for_display_in_tool_panel = includes_tools_for_display_in_tool_panel ,
@@ -719,6 +727,7 @@ def __initiate_and_install_repositories( self, tool_shed_url, repository_revisio
719
727
if install_tool_dependencies :
720
728
self .__assert_can_install_dependencies ()
721
729
new_tool_panel_section_label = install_options .get ( 'new_tool_panel_section_label' , '' )
730
+ tool_panel_section_mapping = install_options .get ( 'tool_panel_section_mapping' , {} )
722
731
shed_tool_conf = install_options .get ( 'shed_tool_conf' , None )
723
732
if shed_tool_conf :
724
733
# Get the tool_path setting.
@@ -737,6 +746,7 @@ def __initiate_and_install_repositories( self, tool_shed_url, repository_revisio
737
746
# for each repository being installed.
738
747
installation_dict = dict ( install_repository_dependencies = install_repository_dependencies ,
739
748
new_tool_panel_section_label = new_tool_panel_section_label ,
749
+ tool_panel_section_mapping = tool_panel_section_mapping ,
740
750
no_changes_checked = False ,
741
751
repo_info_dicts = repo_info_dicts ,
742
752
tool_panel_section_id = tool_panel_section_id ,
@@ -761,6 +771,7 @@ def __initiate_and_install_repositories( self, tool_shed_url, repository_revisio
761
771
status = 'done' ,
762
772
tool_panel_section_id = tool_panel_section_id ,
763
773
tool_panel_section_keys = tool_panel_section_keys ,
774
+ tool_panel_section_mapping = tool_panel_section_mapping ,
764
775
tool_path = tool_path ,
765
776
tool_shed_url = tool_shed_url )
766
777
# Prepare the repositories for installation. Even though this
@@ -783,13 +794,15 @@ def __initiate_and_install_repositories( self, tool_shed_url, repository_revisio
783
794
tool_panel_section_keys = tool_panel_section_keys ,
784
795
repo_info_dicts = filtered_repo_info_dicts ,
785
796
install_tool_dependencies = install_tool_dependencies ,
797
+ tool_panel_section_mapping = tool_panel_section_mapping ,
786
798
)
787
799
return self .install_repositories (tsr_ids , decoded_kwd , reinstalling = False )
788
800
789
801
def install_repositories ( self , tsr_ids , decoded_kwd , reinstalling ):
790
802
shed_tool_conf = decoded_kwd .get ( 'shed_tool_conf' , '' )
791
803
tool_path = decoded_kwd [ 'tool_path' ]
792
804
tool_panel_section_keys = util .listify ( decoded_kwd [ 'tool_panel_section_keys' ] )
805
+ tool_panel_section_mapping = decoded_kwd .get ( 'tool_panel_section_mapping' , {} )
793
806
repo_info_dicts = util .listify ( decoded_kwd [ 'repo_info_dicts' ] )
794
807
install_tool_dependencies = decoded_kwd ['install_tool_dependencies' ]
795
808
filtered_repo_info_dicts = []
@@ -827,14 +840,15 @@ def install_repositories( self, tsr_ids, decoded_kwd, reinstalling ):
827
840
shed_tool_conf = shed_tool_conf ,
828
841
tool_path = tool_path ,
829
842
install_tool_dependencies = install_tool_dependencies ,
830
- reinstalling = reinstalling )
843
+ reinstalling = reinstalling ,
844
+ tool_panel_section_mapping = tool_panel_section_mapping )
831
845
installed_tool_shed_repositories .append ( tool_shed_repository )
832
846
else :
833
847
raise RepositoriesInstalledException ()
834
848
return installed_tool_shed_repositories
835
849
836
850
def install_tool_shed_repository ( self , tool_shed_repository , repo_info_dict , tool_panel_section_key , shed_tool_conf , tool_path ,
837
- install_tool_dependencies , reinstalling = False ):
851
+ install_tool_dependencies , reinstalling = False , tool_panel_section_mapping = {} ):
838
852
self .app .install_model .context .flush ()
839
853
if tool_panel_section_key :
840
854
_ , tool_section = self .app .toolbox .get_section ( tool_panel_section_key )
@@ -878,7 +892,8 @@ def install_tool_shed_repository( self, tool_shed_repository, repo_info_dict, to
878
892
tool_section = tool_section ,
879
893
shed_tool_conf = shed_tool_conf ,
880
894
tool_versions_response = tool_versions_response ,
881
- reinstalling = reinstalling )
895
+ reinstalling = reinstalling ,
896
+ tool_panel_section_mapping = tool_panel_section_mapping )
882
897
self .install_model .context .refresh ( tool_shed_repository )
883
898
metadata = tool_shed_repository .metadata
884
899
if 'tools' in metadata :
0 commit comments