3 new commits in galaxy-central: https://bitbucket.org/galaxy/galaxy-central/commits/402e63010f17/ Changeset: 402e63010f17 Branch: tool-extract User: kell...@gmail.com Date: 2014-09-25 23:48:14+00:00 Summary: Adding the tool package download function to the API. Also fixing a few issues in the packaging code. Affected #: 3 files diff -r 82f8d68414f5c9a0e5aeaaabca85cf7044e06183 -r 402e63010f17e58b1b33e488fa98db36bd56ef98 lib/galaxy/tools/__init__.py --- a/lib/galaxy/tools/__init__.py +++ b/lib/galaxy/tools/__init__.py @@ -742,32 +742,33 @@ tool_xml = file( os.path.abspath( tool.config_file ), 'r' ).read() # Retrieve tool help images and rewrite the tool's xml into a temporary file with the path # modified to be relative to the repository root. - tool_help = tool.help._source - image_found = False - # Check each line of the rendered tool help for an image tag that points to a location under static/ - for help_line in tool_help.split( '\n' ): - image_regex = re.compile( 'img alt="[^"]+" src="\${static_path}/([^"]+)"' ) - matches = re.search( image_regex, help_line ) - if matches is not None: - tool_help_image = matches.group(1) - tarball_path = tool_help_image - filesystem_path = os.path.abspath( os.path.join( trans.app.config.root, 'static', tool_help_image ) ) - if os.path.exists( filesystem_path ): - tarball_files.append( ( filesystem_path, tarball_path ) ) - image_found = True - tool_xml = tool_xml.replace( '${static_path}/%s' % tarball_path, tarball_path ) - # If one or more tool help images were found, add the modified tool XML to the tarball instead of the original. - if image_found: - fd, new_tool_config = tempfile.mkstemp( suffix='.xml' ) - os.close( fd ) - file( new_tool_config, 'w' ).write( tool_xml ) - tool_tup = ( os.path.abspath( new_tool_config ), os.path.split( tool.config_file )[-1] ) - temp_files.append( os.path.abspath( new_tool_config ) ) - else: - tool_tup = ( os.path.abspath( tool.config_file ), os.path.split( tool.config_file )[-1] ) - tarball_files.append( tool_tup ) + if tool.help is not None: + tool_help = tool.help._source + image_found = False + # Check each line of the rendered tool help for an image tag that points to a location under static/ + for help_line in tool_help.split( '\n' ): + image_regex = re.compile( 'img alt="[^"]+" src="\${static_path}/([^"]+)"' ) + matches = re.search( image_regex, help_line ) + if matches is not None: + tool_help_image = matches.group(1) + tarball_path = tool_help_image + filesystem_path = os.path.abspath( os.path.join( trans.app.config.root, 'static', tool_help_image ) ) + if os.path.exists( filesystem_path ): + tarball_files.append( ( filesystem_path, tarball_path ) ) + image_found = True + tool_xml = tool_xml.replace( '${static_path}/%s' % tarball_path, tarball_path ) + # If one or more tool help images were found, add the modified tool XML to the tarball instead of the original. + if image_found: + fd, new_tool_config = tempfile.mkstemp( suffix='.xml' ) + os.close( fd ) + file( new_tool_config, 'w' ).write( tool_xml ) + tool_tup = ( os.path.abspath( new_tool_config ), os.path.split( tool.config_file )[-1] ) + temp_files.append( os.path.abspath( new_tool_config ) ) + else: + tool_tup = ( os.path.abspath( tool.config_file ), os.path.split( tool.config_file )[-1] ) + tarball_files.append( tool_tup ) # TODO: This feels hacky. - tool_command = tool.command.split( ' ' )[0] + tool_command = tool.command.rstrip().split( ' ' )[0] tool_path = os.path.dirname( os.path.abspath( tool.config_file ) ) # Add the tool XML to the tuple that will be used to populate the tarball. if os.path.exists( os.path.join( tool_path, tool_command ) ): @@ -776,6 +777,8 @@ for external_file in tool.get_externally_referenced_paths( os.path.abspath( tool.config_file ) ): external_file_abspath = os.path.abspath( os.path.join( tool_path, external_file ) ) tarball_files.append( ( external_file_abspath, external_file ) ) + if os.path.exists( os.path.join( tool_path, "Dockerfile" ) ): + tarball_files.append( ( os.path.join( tool_path, "Dockerfile" ), "Dockerfile" ) ) # Find tests, and check them for test data. tests = tool.tests if tests is not None: @@ -816,7 +819,7 @@ if len( data_table_definitions ) > 0: # Put the data table definition XML in a temporary file. table_definition = '<?xml version="1.0" encoding="utf-8"?>\n<tables>\n %s</tables>' - table_definition = table_definition % '\n'.join( data_table_definitions ) + table_definition = table_definition % '\n'.join( data_table_definitions ) fd, table_conf = tempfile.mkstemp() os.close( fd ) file( table_conf, 'w' ).write( table_definition ) diff -r 82f8d68414f5c9a0e5aeaaabca85cf7044e06183 -r 402e63010f17e58b1b33e488fa98db36bd56ef98 lib/galaxy/webapps/galaxy/api/tools.py --- a/lib/galaxy/webapps/galaxy/api/tools.py +++ b/lib/galaxy/webapps/galaxy/api/tools.py @@ -66,6 +66,18 @@ rval.append( citation.to_dict( 'bibtex' ) ) return rval + @web.expose_api_raw + @web.require_admin + def download( self, trans, id, **kwds ): + tool_tarball, success, message = trans.app.toolbox.package_tool( trans, id ) + if success: + trans.response.set_content_type( 'application/x-gzip' ) + download_file = open( tool_tarball ) + os.unlink( tool_tarball ) + tarball_path, filename = os.path.split( tool_tarball ) + trans.response.headers[ "Content-Disposition" ] = 'attachment; filename="%s.tgz"' % ( id ) + return download_file + @web.expose_api_anonymous def create( self, trans, payload, **kwd ): """ diff -r 82f8d68414f5c9a0e5aeaaabca85cf7044e06183 -r 402e63010f17e58b1b33e488fa98db36bd56ef98 lib/galaxy/webapps/galaxy/buildapp.py --- a/lib/galaxy/webapps/galaxy/buildapp.py +++ b/lib/galaxy/webapps/galaxy/buildapp.py @@ -180,6 +180,7 @@ webapp.mapper.resource( 'group', 'groups', path_prefix='/api' ) webapp.mapper.resource_with_deleted( 'quota', 'quotas', path_prefix='/api' ) webapp.mapper.connect( '/api/tools/{id:.+?}/citations', action='citations', controller="tools" ) + webapp.mapper.connect( '/api/tools/{id:.+?}/download', action='download', controller="tools" ) webapp.mapper.connect( '/api/tools/{id:.+?}', action='show', controller="tools" ) webapp.mapper.resource( 'tool', 'tools', path_prefix='/api' ) webapp.mapper.resource_with_deleted( 'user', 'users', path_prefix='/api' ) https://bitbucket.org/galaxy/galaxy-central/commits/fb942723853e/ Changeset: fb942723853e Branch: tool-extract User: kell...@gmail.com Date: 2014-09-26 00:06:08+00:00 Summary: Fixing small bug Affected #: 1 file diff -r 402e63010f17e58b1b33e488fa98db36bd56ef98 -r fb942723853e34ea58fefa3792a58f5184dba5c6 lib/galaxy/tools/__init__.py --- a/lib/galaxy/tools/__init__.py +++ b/lib/galaxy/tools/__init__.py @@ -768,7 +768,7 @@ tool_tup = ( os.path.abspath( tool.config_file ), os.path.split( tool.config_file )[-1] ) tarball_files.append( tool_tup ) # TODO: This feels hacky. - tool_command = tool.command.rstrip().split( ' ' )[0] + tool_command = tool.command.strip().split( ' ' )[0] tool_path = os.path.dirname( os.path.abspath( tool.config_file ) ) # Add the tool XML to the tuple that will be used to populate the tarball. if os.path.exists( os.path.join( tool_path, tool_command ) ): https://bitbucket.org/galaxy/galaxy-central/commits/1daa729f4e72/ Changeset: 1daa729f4e72 User: jmchilton Date: 2014-10-06 01:05:59+00:00 Summary: Merged in kellrott/galaxy-farm/tool-extract (pull request #508) Adding the tool package download function to the API. Also fixing a few issues in the packaging code. Affected #: 3 files diff -r e7708503e1aacf07dfbbd3fa116de5bd54353b17 -r 1daa729f4e72be6e6b3670b78bc652f857bbe933 lib/galaxy/tools/__init__.py --- a/lib/galaxy/tools/__init__.py +++ b/lib/galaxy/tools/__init__.py @@ -789,32 +789,33 @@ tool_xml = file( os.path.abspath( tool.config_file ), 'r' ).read() # Retrieve tool help images and rewrite the tool's xml into a temporary file with the path # modified to be relative to the repository root. - tool_help = tool.help._source - image_found = False - # Check each line of the rendered tool help for an image tag that points to a location under static/ - for help_line in tool_help.split( '\n' ): - image_regex = re.compile( 'img alt="[^"]+" src="\${static_path}/([^"]+)"' ) - matches = re.search( image_regex, help_line ) - if matches is not None: - tool_help_image = matches.group(1) - tarball_path = tool_help_image - filesystem_path = os.path.abspath( os.path.join( trans.app.config.root, 'static', tool_help_image ) ) - if os.path.exists( filesystem_path ): - tarball_files.append( ( filesystem_path, tarball_path ) ) - image_found = True - tool_xml = tool_xml.replace( '${static_path}/%s' % tarball_path, tarball_path ) - # If one or more tool help images were found, add the modified tool XML to the tarball instead of the original. - if image_found: - fd, new_tool_config = tempfile.mkstemp( suffix='.xml' ) - os.close( fd ) - file( new_tool_config, 'w' ).write( tool_xml ) - tool_tup = ( os.path.abspath( new_tool_config ), os.path.split( tool.config_file )[-1] ) - temp_files.append( os.path.abspath( new_tool_config ) ) - else: - tool_tup = ( os.path.abspath( tool.config_file ), os.path.split( tool.config_file )[-1] ) - tarball_files.append( tool_tup ) + if tool.help is not None: + tool_help = tool.help._source + image_found = False + # Check each line of the rendered tool help for an image tag that points to a location under static/ + for help_line in tool_help.split( '\n' ): + image_regex = re.compile( 'img alt="[^"]+" src="\${static_path}/([^"]+)"' ) + matches = re.search( image_regex, help_line ) + if matches is not None: + tool_help_image = matches.group(1) + tarball_path = tool_help_image + filesystem_path = os.path.abspath( os.path.join( trans.app.config.root, 'static', tool_help_image ) ) + if os.path.exists( filesystem_path ): + tarball_files.append( ( filesystem_path, tarball_path ) ) + image_found = True + tool_xml = tool_xml.replace( '${static_path}/%s' % tarball_path, tarball_path ) + # If one or more tool help images were found, add the modified tool XML to the tarball instead of the original. + if image_found: + fd, new_tool_config = tempfile.mkstemp( suffix='.xml' ) + os.close( fd ) + file( new_tool_config, 'w' ).write( tool_xml ) + tool_tup = ( os.path.abspath( new_tool_config ), os.path.split( tool.config_file )[-1] ) + temp_files.append( os.path.abspath( new_tool_config ) ) + else: + tool_tup = ( os.path.abspath( tool.config_file ), os.path.split( tool.config_file )[-1] ) + tarball_files.append( tool_tup ) # TODO: This feels hacky. - tool_command = tool.command.split( ' ' )[0] + tool_command = tool.command.strip().split( ' ' )[0] tool_path = os.path.dirname( os.path.abspath( tool.config_file ) ) # Add the tool XML to the tuple that will be used to populate the tarball. if os.path.exists( os.path.join( tool_path, tool_command ) ): @@ -823,6 +824,8 @@ for external_file in tool.get_externally_referenced_paths( os.path.abspath( tool.config_file ) ): external_file_abspath = os.path.abspath( os.path.join( tool_path, external_file ) ) tarball_files.append( ( external_file_abspath, external_file ) ) + if os.path.exists( os.path.join( tool_path, "Dockerfile" ) ): + tarball_files.append( ( os.path.join( tool_path, "Dockerfile" ), "Dockerfile" ) ) # Find tests, and check them for test data. tests = tool.tests if tests is not None: @@ -863,7 +866,7 @@ if len( data_table_definitions ) > 0: # Put the data table definition XML in a temporary file. table_definition = '<?xml version="1.0" encoding="utf-8"?>\n<tables>\n %s</tables>' - table_definition = table_definition % '\n'.join( data_table_definitions ) + table_definition = table_definition % '\n'.join( data_table_definitions ) fd, table_conf = tempfile.mkstemp() os.close( fd ) file( table_conf, 'w' ).write( table_definition ) diff -r e7708503e1aacf07dfbbd3fa116de5bd54353b17 -r 1daa729f4e72be6e6b3670b78bc652f857bbe933 lib/galaxy/webapps/galaxy/api/tools.py --- a/lib/galaxy/webapps/galaxy/api/tools.py +++ b/lib/galaxy/webapps/galaxy/api/tools.py @@ -66,6 +66,18 @@ rval.append( citation.to_dict( 'bibtex' ) ) return rval + @web.expose_api_raw + @web.require_admin + def download( self, trans, id, **kwds ): + tool_tarball, success, message = trans.app.toolbox.package_tool( trans, id ) + if success: + trans.response.set_content_type( 'application/x-gzip' ) + download_file = open( tool_tarball ) + os.unlink( tool_tarball ) + tarball_path, filename = os.path.split( tool_tarball ) + trans.response.headers[ "Content-Disposition" ] = 'attachment; filename="%s.tgz"' % ( id ) + return download_file + @web.expose_api_anonymous def create( self, trans, payload, **kwd ): """ diff -r e7708503e1aacf07dfbbd3fa116de5bd54353b17 -r 1daa729f4e72be6e6b3670b78bc652f857bbe933 lib/galaxy/webapps/galaxy/buildapp.py --- a/lib/galaxy/webapps/galaxy/buildapp.py +++ b/lib/galaxy/webapps/galaxy/buildapp.py @@ -180,6 +180,7 @@ webapp.mapper.resource( 'group', 'groups', path_prefix='/api' ) webapp.mapper.resource_with_deleted( 'quota', 'quotas', path_prefix='/api' ) webapp.mapper.connect( '/api/tools/{id:.+?}/citations', action='citations', controller="tools" ) + webapp.mapper.connect( '/api/tools/{id:.+?}/download', action='download', controller="tools" ) webapp.mapper.connect( '/api/tools/{id:.+?}', action='show', controller="tools" ) webapp.mapper.resource( 'tool', 'tools', path_prefix='/api' ) webapp.mapper.resource_with_deleted( 'user', 'users', path_prefix='/api' ) Repository URL: https://bitbucket.org/galaxy/galaxy-central/ -- This is a commit notification from bitbucket.org. You are receiving this because you have the service enabled, addressing the recipient of this email.