diff --git a/lib/galaxy/util/streamball.py b/lib/galaxy/util/streamball.py index ad9fa80c882..7a89be5e818 100644 --- a/lib/galaxy/util/streamball.py +++ b/lib/galaxy/util/streamball.py @@ -1,7 +1,7 @@ """ A simple wrapper for writing tarballs as a stream. """ - +import os import logging, tarfile log = logging.getLogger( __name__ ) @@ -26,3 +26,19 @@ class StreamBall( object ): tf.add( file, arcname=rel ) tf.close() return [] + +class ZipBall(object): + def __init__(self, tmpf, tmpd): + self._tmpf = tmpf + self._tmpd = tmpd + def stream(self, environ, start_response): + response_write = start_response( self.wsgi_status, self.wsgi_headeritems ) + tmpfh = open( self._tmpf ) + response_write(tmpfh.read()) + tmpfh.close() + try: + os.unlink( self._tmpf ) + os.rmdir( self._tmpd ) + except OSError: + log.exception( "Unable to remove temporary library download archive and directory" ) + return [] diff --git a/lib/galaxy/web/controllers/library.py b/lib/galaxy/web/controllers/library.py index 93a9ef9a320..ece87c7df90 100644 --- a/lib/galaxy/web/controllers/library.py +++ b/lib/galaxy/web/controllers/library.py @@ -35,7 +35,7 @@ class LibraryListGrid( grids.Grid ): attach_popup=False, filterable="advanced" ), ] - columns.append( grids.MulticolFilterColumn( "search library dataset name, info, message, dbkey", + columns.append( grids.MulticolFilterColumn( "search dataset name, info, message, dbkey", cols_to_filter=[ columns[0], columns[1] ], key="free-text-search", visible=False, diff --git a/lib/galaxy/web/controllers/library_admin.py b/lib/galaxy/web/controllers/library_admin.py index 8012c12e796..00aa8890e32 100644 --- a/lib/galaxy/web/controllers/library_admin.py +++ b/lib/galaxy/web/controllers/library_admin.py @@ -50,7 +50,7 @@ class LibraryListGrid( grids.Grid ): # Columns that are valid for filtering but are not visible. grids.DeletedColumn( "Deleted", key="deleted", visible=False, filterable="advanced" ) ] - columns.append( grids.MulticolFilterColumn( "search library dataset name, info, message, dbkey", + columns.append( grids.MulticolFilterColumn( "search dataset name, info, message, dbkey", cols_to_filter=[ columns[0], columns[1] ], key="free-text-search", visible=False, diff --git a/lib/galaxy/web/controllers/library_common.py b/lib/galaxy/web/controllers/library_common.py index 211241a5900..dcde9bf59b8 100644 --- a/lib/galaxy/web/controllers/library_common.py +++ b/lib/galaxy/web/controllers/library_common.py @@ -1706,20 +1706,12 @@ class LibraryCommon( BaseController, UsesFormDefinitions ): fname = lname.replace( ' ', '_' ) + '_files' if action == 'zip': archive.close() - tmpfh = open( tmpf ) - # clean up now - try: - os.unlink( tmpf ) - os.rmdir( tmpd ) - except OSError: - error = True - log.exception( "Unable to remove temporary library download archive and directory" ) - message = "Unable to create archive for download, please report this error" - status = 'error' - if not error: - trans.response.set_content_type( "application/x-zip-compressed" ) - trans.response.headers[ "Content-Disposition" ] = "attachment; filename=%s.%s" % (fname,outext) - return tmpfh + trans.response.set_content_type( "application/x-zip-compressed" ) + trans.response.headers[ "Content-Disposition" ] = "attachment; filename=%s.%s" % (fname,outext) + archive = util.streamball.ZipBall(tmpf, tmpd) + archive.wsgi_status = trans.response.wsgi_status() + archive.wsgi_headeritems = trans.response.wsgi_headeritems() + return archive.stream elif action == 'ngxzip': trans.response.set_content_type( "application/zip" ) trans.response.headers[ "Content-Disposition" ] = "attachment; filename=%s.%s" % (fname,outext) @@ -1831,11 +1823,11 @@ class LibraryCommon( BaseController, UsesFormDefinitions ): hist_names_str = ", ".join( [ target_history.name for target_history in target_histories ] ) num_source = len( ldda_ids ) - invalid_datasets num_target = len( target_histories ) - message = "%i %s have been imported into %i %s: %s" % ( num_source, - inflector.cond_plural( num_source, "dataset" ), - num_target, - inflector.cond_plural( num_target, "history" ), - hist_names_str ) + message = "%i %s imported into %i %s: %s" % ( num_source, + inflector.cond_plural( num_source, "dataset" ), + num_target, + inflector.cond_plural( num_target, "history" ), + hist_names_str ) trans.sa_session.refresh( current_history ) current_user_roles = trans.get_current_user_roles() source_lddas = [] @@ -2240,7 +2232,7 @@ def whoosh_search( trans, cntrller, search_term, **kwd ): # Perform search parser = MultifieldParser( [ 'name', 'info', 'dbkey', 'message' ], schema=schema ) # Search term with wildcards may be slow... - results = searcher.search( parser.parse( '*' + search_term + '*' ), minscore=0.1 ) + results = searcher.search( parser.parse( '*' + search_term + '*' ), minscore=0.5 ) ldda_ids = [ result[ 'id' ] for result in results ] lddas = [] for ldda_id in ldda_ids: diff --git a/scripts/data_libraries/build_whoosh_index.py b/scripts/data_libraries/build_whoosh_index.py index 32f54e62678..eb564f83983 100644 --- a/scripts/data_libraries/build_whoosh_index.py +++ b/scripts/data_libraries/build_whoosh_index.py @@ -63,7 +63,10 @@ def get_lddas( sa_session ): else: info = '' dbkey = ldda.metadata.dbkey - message = ldda.message + if ldda.message: + message = ldda.message + else: + message = '' yield id, name, info, dbkey, message def get_sa_session_and_needed_config_settings( ini_file ): diff --git a/templates/library/common/browse_library.mako b/templates/library/common/browse_library.mako index f72fc831ad6..384e932a3b4 100644 --- a/templates/library/common/browse_library.mako +++ b/templates/library/common/browse_library.mako @@ -1,6 +1,7 @@ <%namespace file="/message.mako" import="render_msg" /> <%namespace file="/library/common/library_item_info.mako" import="render_library_item_info" /> <%namespace file="/library/common/common.mako" import="render_actions_on_multiple_items" /> +<%namespace file="/library/common/common.mako" import="render_compression_types_help" /> <%namespace file="/library/common/common.mako" import="common_javascripts" /> <%! @@ -564,34 +565,6 @@ %endif - - ## Help about compression types - -
-

- TIP: You can download individual library files by selecting "Download this dataset" from the context menu (triangle) next to the dataset's name. -

-
- %if len( comptypes ) > 1: -
-

- TIP: Multiple compression options are available for downloading library datasets: -

- -
- %endif + + ${render_compression_types_help( comptypes )} diff --git a/templates/library/common/common.mako b/templates/library/common/common.mako index 29c3abb70e0..9bbdc7eaddb 100644 --- a/templates/library/common/common.mako +++ b/templates/library/common/common.mako @@ -43,6 +43,36 @@ +<%def name="render_compression_types_help( comptypes )"> +
+

+ TIP: You can download individual library datasets by selecting "Download this dataset" from the context menu (triangle) next to each dataset's name. +

+
+ %if len( comptypes ) > 1: +
+

+ TIP: Several compression options are available for downloading multiple library datasets simultaneously: +

+ +
+ %endif + + <%def name="render_upload_form( cntrller, upload_option, action, library_id, folder_id, replace_dataset, file_formats, dbkeys, space_to_tab, link_data_only, widgets, roles_select_list, history, show_deleted )"> <% import os, os.path diff --git a/templates/library/common/import_datasets_to_histories.mako b/templates/library/common/import_datasets_to_histories.mako index ad7522b7bf8..71370c07f6c 100644 --- a/templates/library/common/import_datasets_to_histories.mako +++ b/templates/library/common/import_datasets_to_histories.mako @@ -58,8 +58,14 @@ ${h.js( "jquery", "galaxy.base" )}

@@ -68,12 +74,15 @@ ${h.js( "jquery", "galaxy.base" )} diff --git a/templates/library/common/library_dataset_search_results.mako b/templates/library/common/library_dataset_search_results.mako index b0ac151a5b7..8d41600c71f 100644 --- a/templates/library/common/library_dataset_search_results.mako +++ b/templates/library/common/library_dataset_search_results.mako @@ -1,6 +1,7 @@ <%namespace file="/message.mako" import="render_msg" /> <%namespace file="/library/common/browse_library.mako" import="render_dataset" /> <%namespace file="/library/common/common.mako" import="render_actions_on_multiple_items" /> +<%namespace file="/library/common/common.mako" import="render_compression_types_help" /> <%namespace file="/library/common/common.mako" import="common_javascripts" /> <%! @@ -127,35 +128,7 @@ ${render_actions_on_multiple_items( actions_to_exclude=[ 'manage_permissions' ] )} - ## Help about compression types - -
-

- TIP: You can download individual library files by selecting "Download this dataset" from the context menu (triangle) next to the dataset's name. -

-
- %if len( comptypes ) > 1: -
-

- TIP: Multiple compression options are available for downloading library datasets: -

- -
- %endif + ${render_compression_types_help( comptypes )} %elif status != 'error':

The string "${search_term}" was not found in any of the following information components for any library datasets that you can access.

${render_searched_components()} diff --git a/test/functional/test_library_security.py b/test/functional/test_library_security.py index 09ad5b37c3b..a946f40ae51 100644 --- a/test/functional/test_library_security.py +++ b/test/functional/test_library_security.py @@ -300,7 +300,7 @@ class TestLibrarySecurity( TwillTestCase ): library_id=self.security.encode_id( library1.id ), ldda_ids=self.security.encode_id( ldda2.id ), new_history_name='goodbye', - strings_displayed=[ '1 dataset have been imported into 1 history' ] ) + strings_displayed=[ '1 dataset imported into 1 history' ] ) self.logout() # regular_user2 should not be able to see ldda2 self.login( email=regular_user2.email )