From 0b486a7a1ba811746e7b06c8918ef5796441e450 Mon Sep 17 00:00:00 2001 From: Martin Cech Date: Wed, 5 Aug 2015 13:51:59 -0400 Subject: [PATCH 1/3] do not encode id when returning TS tool search results --- lib/galaxy/webapps/tool_shed/search/tool_search.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/galaxy/webapps/tool_shed/search/tool_search.py b/lib/galaxy/webapps/tool_shed/search/tool_search.py index 19d324166e0..19d11056ca6 100644 --- a/lib/galaxy/webapps/tool_shed/search/tool_search.py +++ b/lib/galaxy/webapps/tool_shed/search/tool_search.py @@ -77,7 +77,7 @@ class ToolSearch( object ): results[ 'hits' ] = [] for hit in hits: hit_dict = {} - hit_dict[ 'id' ] = trans.security.encode_id( hit.get( 'id' ) ) + hit_dict[ 'id' ] = hit.get( 'id' ) hit_dict[ 'repo_owner_username' ] = hit.get( 'repo_owner_username' ) hit_dict[ 'repo_name' ] = hit.get( 'repo_name' ) hit_dict[ 'name' ] = hit.get( 'name' ) From 0ad5c8a1a82cc64c2c17133eb8dc3c70f4017994 Mon Sep 17 00:00:00 2001 From: Martin Cech Date: Wed, 5 Aug 2015 13:55:01 -0400 Subject: [PATCH 2/3] fix TS search index building script to properly visit subdirectories --- scripts/tool_shed/build_ts_whoosh_index.py | 39 +++++++++++++--------- 1 file changed, 24 insertions(+), 15 deletions(-) diff --git a/scripts/tool_shed/build_ts_whoosh_index.py b/scripts/tool_shed/build_ts_whoosh_index.py index 78954de35e5..43ea20f62fd 100644 --- a/scripts/tool_shed/build_ts_whoosh_index.py +++ b/scripts/tool_shed/build_ts_whoosh_index.py @@ -161,21 +161,13 @@ def get_repos( sa_session, path_to_repositories ): path = os.path.join( path_to_repositories, *model.directory_hash_id( repo.id )) path = os.path.join( path, "repo_%d" % repo.id ) if os.path.exists(path): - tool_elems = load_tool_elements_from_path(path) - if tool_elems: - for elem in tool_elems: - root = elem[1].getroot() - if root.tag == 'tool': - tool = {} - if root.find('help') is not None: - tool.update( dict( help=root.find( 'help' ).text ) ) - if root.find('description') is not None: - tool.update( dict( description=root.find( 'description' ).text ) ) - tool.update( dict( id=root.attrib.get('id'), - name=root.attrib.get('name'), - version=root.attrib.get('version') ) ) - - tools_list.append( tool ) + tools_list.extend( load_one_dir( path ) ) + for root, dirs, files in os.walk( path ): + if '.hg' in dirs: + dirs.remove('.hg') + for name in dirs: + tools_in_dir = load_one_dir( os.path.join( root, name ) ) + tools_list.extend( tools_in_dir ) results.append(dict( id=repo_id, name=name, @@ -191,6 +183,23 @@ def get_repos( sa_session, path_to_repositories ): tools_list=tools_list ) ) return results +def load_one_dir( path ): + tools_in_dir = [] + tool_elems = load_tool_elements_from_path( path ) + if tool_elems: + for elem in tool_elems: + root = elem[1].getroot() + if root.tag == 'tool': + tool = {} + if root.find( 'help' ) is not None: + tool.update( dict( help=root.find( 'help' ).text ) ) + if root.find( 'description' ) is not None: + tool.update( dict( description=root.find( 'description' ).text ) ) + tool.update( dict( id=root.attrib.get( 'id' ), + name=root.attrib.get( 'name' ), + version=root.attrib.get( 'version' ) ) ) + tools_in_dir.append( tool ) + return tools_in_dir def get_sa_session_and_needed_config_settings( path_to_tool_shed_config ): conf_parser = ConfigParser.ConfigParser( { 'here' : os.getcwd() } ) From d583c376a57cf2acb870a1b48ebdbb5db4ba2892 Mon Sep 17 00:00:00 2001 From: Martin Cech Date: Wed, 5 Aug 2015 14:27:25 -0400 Subject: [PATCH 3/3] flake8 spotted by @nsoranzo --- scripts/tool_shed/build_ts_whoosh_index.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/scripts/tool_shed/build_ts_whoosh_index.py b/scripts/tool_shed/build_ts_whoosh_index.py index 43ea20f62fd..d9b335c4510 100644 --- a/scripts/tool_shed/build_ts_whoosh_index.py +++ b/scripts/tool_shed/build_ts_whoosh_index.py @@ -183,6 +183,7 @@ def get_repos( sa_session, path_to_repositories ): tools_list=tools_list ) ) return results + def load_one_dir( path ): tools_in_dir = [] tool_elems = load_tool_elements_from_path( path ) @@ -201,6 +202,7 @@ def load_one_dir( path ): tools_in_dir.append( tool ) return tools_in_dir + def get_sa_session_and_needed_config_settings( path_to_tool_shed_config ): conf_parser = ConfigParser.ConfigParser( { 'here' : os.getcwd() } ) conf_parser.read( path_to_tool_shed_config )