1 new commit in galaxy-central: https://bitbucket.org/galaxy/galaxy-central/commits/bd469f8d2944/ Changeset: bd469f8d2944 User: greg Date: 2013-08-05 21:59:49 Summary: Enhance the generated name of the archive file created when exporting a tool shed repository. Affected #: 3 files diff -r cf08022b68927bebe340c976e6d5eb7a657de7d6 -r bd469f8d2944f2719fb4fca7078e06e6411c86a3 lib/galaxy/webapps/tool_shed/api/repository_revisions.py --- a/lib/galaxy/webapps/tool_shed/api/repository_revisions.py +++ b/lib/galaxy/webapps/tool_shed/api/repository_revisions.py @@ -54,7 +54,6 @@ try: # We'll currently support only gzip-compressed tar archives. file_type = 'gz' - file_type_str = suc.get_file_type_str( changeset_revision, file_type ) export_repository_dependencies = util.string_as_bool( export_repository_dependencies ) # Get the repository information. repository = suc.get_repository_by_name_and_owner( trans.app, name, owner ) diff -r cf08022b68927bebe340c976e6d5eb7a657de7d6 -r bd469f8d2944f2719fb4fca7078e06e6411c86a3 lib/tool_shed/scripts/api/export.py --- a/lib/tool_shed/scripts/api/export.py +++ b/lib/tool_shed/scripts/api/export.py @@ -13,6 +13,7 @@ sys.path.insert( 0, os.path.dirname( __file__ ) ) from common import display from common import submit +from tool_shed.util import export_util CHUNK_SIZE = 2**20 # 1Mb @@ -54,17 +55,20 @@ if repository_id: # We'll currently support only gzip-compressed tar archives. file_type = 'gz' - file_type_str = get_file_type_str( options.changeset_revision, file_type ) url = '%s%s' % ( base_tool_shed_url, '/api/repository_revisions/%s/export' % str( repository_id ) ) export_dict = submit( url, data, return_formatted=False ) error_messages = export_dict[ 'error_messages' ] if error_messages: print "Error attempting to export revision ", options.changeset_revision, " of repository ", options.name, " owned by ", options.owner, ":\n", error_messages else: - if string_as_bool( options.export_repository_dependencies ): - repositories_archive_filename = 'exported-with-dependencies-%s-%s' % ( name, file_type_str ) - else: - repositories_archive_filename = 'exported-%s-%s' % ( name, file_type_str ) + repositories_archive_filename = \ + export_util.generate_repository_archive_filename( base_tool_shed_url, + options.name, + options.owner, + options.changeset_revision, + file_type, + export_repository_dependencies=string_as_bool( options.export_repository_dependencies ), + use_tmp_archive_dir=False ) download_url = export_dict[ 'download_url' ] download_dir = os.path.abspath( options.download_dir ) file_path = os.path.join( download_dir, repositories_archive_filename ) diff -r cf08022b68927bebe340c976e6d5eb7a657de7d6 -r bd469f8d2944f2719fb4fca7078e06e6411c86a3 lib/tool_shed/util/export_util.py --- a/lib/tool_shed/util/export_util.py +++ b/lib/tool_shed/util/export_util.py @@ -24,6 +24,8 @@ log = logging.getLogger( __name__ ) +CAPSULE_FILENAME = 'capsule' +CAPSULE_WITH_DEPENDENCIES_FILENAME = 'capsule_with_dependencies' class ExportedRepositoryRegistry( object ): @@ -45,11 +47,22 @@ log.exception( error_message ) return return_code, error_message +def clean_tool_shed_url( base_url ): + protocol, base = base_url.split( '://' ) + base = base.replace( ':', '_colon_' ) + base = base.rstrip( '/' ) + return base + def export_repository( trans, tool_shed_url, repository_id, repository_name, changeset_revision, file_type, export_repository_dependencies, api=False ): - file_type_str = suc.get_file_type_str( changeset_revision, file_type ) - tmp_archive_dir = tempfile.mkdtemp( prefix="tmp-toolshed-arcdir" ) + repository = suc.get_repository_in_tool_shed( trans, repository_id ) + repositories_archive_filename = generate_repository_archive_filename( tool_shed_url, + str( repository.name ), + str( repository.user.username ), + changeset_revision, + file_type, + export_repository_dependencies=export_repository_dependencies, + use_tmp_archive_dir=True ) if export_repository_dependencies: - repositories_archive_filename = os.path.join( tmp_archive_dir, 'exported-with-dependencies-%s-%s' % ( repository_name, file_type_str ) ) repo_info_dicts = get_repo_info_dicts( trans, tool_shed_url, repository_id, changeset_revision ) repository_ids = get_repository_ids( trans, repo_info_dicts ) ordered_repository_ids, ordered_repositories, ordered_changeset_revisions = order_components_for_import( trans, repository_ids, repo_info_dicts ) @@ -57,8 +70,6 @@ ordered_repository_ids = [] ordered_repositories = [] ordered_changeset_revisions = [] - repositories_archive_filename = os.path.join( tmp_archive_dir, 'exported-%s-%s' % ( repository_name, file_type_str ) ) - repository = suc.get_repository_in_tool_shed( trans, repository_id ) if repository: repository_metadata = suc.get_current_repository_metadata_for_changeset_revision( trans, repository, changeset_revision ) if repository_metadata: @@ -138,6 +149,18 @@ repository_archive.close() return repository_archive, error_message +def generate_repository_archive_filename( tool_shed_url, name, owner, changeset_revision, file_type, export_repository_dependencies=False, use_tmp_archive_dir=False ): + tool_shed = clean_tool_shed_url( tool_shed_url ) + file_type_str = suc.get_file_type_str( changeset_revision, file_type ) + if export_repository_dependencies: + repositories_archive_filename = '%s_%s_%s_%s_%s' % ( CAPSULE_WITH_DEPENDENCIES_FILENAME, tool_shed, name, owner, file_type_str ) + else: + repositories_archive_filename = '%s_%s_%s_%s_%s' % ( CAPSULE_FILENAME, tool_shed, name, owner, file_type_str ) + if use_tmp_archive_dir: + tmp_archive_dir = tempfile.mkdtemp( prefix="tmp-toolshed-arcdir" ) + repositories_archive_filename = os.path.join( tmp_archive_dir, repositories_archive_filename ) + return repositories_archive_filename + def get_components_from_repo_info_dict( trans, repo_info_dict ): """ Return the repository and the associated latest installable changeset_revision (including updates) for the repository defined by the received 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.