Beispiel #1
0
 def install_repository( self, repository_info_dict, install_tool_dependencies=True, install_repository_dependencies=True, 
                         strings_displayed=[], strings_not_displayed=[], preview_strings_displayed=[], 
                         post_submit_strings_displayed=[], new_tool_panel_section=None, **kwd ):
     name = repository_info_dict[ 'name' ]
     owner = repository_info_dict[ 'owner' ]
     changeset_revision = repository_info_dict[ 'changeset_revision' ]
     encoded_repository_id = repository_info_dict[ 'repository_id' ]
     tool_shed_url = repository_info_dict[ 'tool_shed_url' ]
     preview_params = urllib.urlencode( dict( repository_id=encoded_repository_id, changeset_revision=changeset_revision ) )
     self.visit_url( '%s/repository/preview_tools_in_changeset?%s' % ( tool_shed_url, preview_params ) )
     install_params = urllib.urlencode( dict( repository_ids=encoded_repository_id, 
                                              changeset_revisions=changeset_revision,
                                              galaxy_url=self.url ) )
     # If the tool shed does not have the same hostname as the Galaxy server being used for these tests, 
     # twill will not carry over previously set cookies for the Galaxy server when following the 
     # install_repositories_by_revision redirect, so we have to include 403 in the allowed HTTP 
     # status codes and log in again.
     url = '%s/repository/install_repositories_by_revision?%s' % ( tool_shed_url, install_params )
     self.visit_url( url, allowed_codes=[ 200, 403 ] )
     self.logout()
     self.login( email='*****@*****.**', username='******' )
     install_params = urllib.urlencode( dict( repository_ids=encoded_repository_id, 
                                              changeset_revisions=changeset_revision,
                                              tool_shed_url=tool_shed_url ) )
     url = '/admin_toolshed/prepare_for_install?%s' % install_params
     self.visit_url( url )
     # This section is tricky, due to the way twill handles form submission. The tool dependency checkbox needs to 
     # be hacked in through tc.browser, putting the form field in kwd doesn't work.
     if 'install_tool_dependencies' in self.last_page():
         form = tc.browser.get_form( 'select_tool_panel_section' )
         checkbox = form.find_control( id="install_tool_dependencies" )
         checkbox.disabled = False
         if install_tool_dependencies:
             checkbox.selected = True
             kwd[ 'install_tool_dependencies' ] = 'True'
         else:
             checkbox.selected = False
             kwd[ 'install_tool_dependencies' ] = 'False'
     if 'install_repository_dependencies' in self.last_page():
         form = tc.browser.get_form( 'select_tool_panel_section' )
         checkbox = form.find_control( id="install_repository_dependencies" )
         checkbox.disabled = False
         if install_repository_dependencies:
             checkbox.selected = True
             kwd[ 'install_repository_dependencies' ] = 'True'
         else:
             checkbox.selected = False
             kwd[ 'install_repository_dependencies' ] = 'False'
     if 'shed_tool_conf' not in kwd:
         kwd[ 'shed_tool_conf' ] = self.shed_tool_conf
     if new_tool_panel_section:
         kwd[ 'new_tool_panel_section' ] =  new_tool_panel_section
     self.submit_form( 1, 'select_tool_panel_section_button', **kwd )
     self.check_for_strings( post_submit_strings_displayed, strings_not_displayed )
     repository_ids = self.initiate_installation_process( new_tool_panel_section=new_tool_panel_section )
     self.wait_for_repository_installation( repository_ids )
 def install_repository( self, repository_info_dict, install_tool_dependencies=True, install_repository_dependencies=True,
                         strings_displayed=[], strings_not_displayed=[], preview_strings_displayed=[],
                         post_submit_strings_displayed=[], new_tool_panel_section_label=None, **kwd ):
     name = repository_info_dict[ 'name' ]
     owner = repository_info_dict[ 'owner' ]
     changeset_revision = repository_info_dict[ 'changeset_revision' ]
     encoded_repository_id = repository_info_dict[ 'repository_id' ]
     tool_shed_url = repository_info_dict[ 'tool_shed_url' ]
     # Pass galaxy_url to the tool shed in order to set cookies and redirects correctly.
     install_params = urllib.urlencode( dict( repository_ids=encoded_repository_id,
                                              changeset_revisions=changeset_revision,
                                              galaxy_url=self.url ) )
     # If the tool shed does not have the same hostname as the Galaxy server being used for these tests,
     # twill will not carry over previously set cookies for the Galaxy server when following the
     # install_repositories_by_revision redirect, so we have to include 403 in the allowed HTTP
     # status codes and log in again.
     url = '%s/repository/install_repositories_by_revision?%s' % ( tool_shed_url, install_params )
     self.visit_url( url, allowed_codes=[ 200, 403 ] )
     self.logout()
     self.login( email='*****@*****.**', username='******' )
     install_params = urllib.urlencode( dict( repository_ids=encoded_repository_id,
                                              changeset_revisions=changeset_revision,
                                              tool_shed_url=tool_shed_url ) )
     url = '/admin_toolshed/prepare_for_install?%s' % install_params
     self.visit_url( url )
     # This section is tricky, due to the way twill handles form submission. The tool dependency checkbox needs to
     # be hacked in through tc.browser, putting the form field in kwd doesn't work.
     form = tc.browser.get_form( 'select_tool_panel_section' )
     if form is None:
         form = tc.browser.get_form( 'select_shed_tool_panel_config' )
     assert form is not None, 'Could not find form select_shed_tool_panel_config or select_tool_panel_section.'
     kwd = self.set_form_value( form, kwd, 'install_tool_dependencies', install_tool_dependencies )
     kwd = self.set_form_value( form, kwd, 'install_repository_dependencies', install_repository_dependencies )
     kwd = self.set_form_value( form, kwd, 'shed_tool_conf', self.shed_tool_conf )
     if new_tool_panel_section_label is not None:
         kwd = self.set_form_value( form, kwd, 'new_tool_panel_section_label', new_tool_panel_section_label )
     submit_button_control = form.find_control( type='submit' )
     assert submit_button_control is not None, 'No submit button found for form %s.' % form.attrs.get( 'id' )
     self.submit_form( form.attrs.get( 'id' ), str( submit_button_control.name ), **kwd )
     self.check_for_strings( post_submit_strings_displayed, strings_not_displayed )
     repository_ids = self.initiate_installation_process( new_tool_panel_section_label=new_tool_panel_section_label )
     log.debug( 'Waiting for the installation of repository IDs: %s' % str( repository_ids ) )
     self.wait_for_repository_installation( repository_ids )