commit/galaxy-central: greg: Various tool shed fixes and enhancements:
1 new changeset in galaxy-central: http://bitbucket.org/galaxy/galaxy-central/changeset/98ef4f135243/ changeset: 98ef4f135243 user: greg date: 2011-07-19 17:27:16 summary: Various tool shed fixes and enhancements: 1) Fix for uploading empty files to a repository 2) Better error messages when setting repository metadata fails 3) Automatically copy uploaded xxx.loc.sample files to ~/tool-data/xxx.loc 4) Fix for setting the value of the upload_point when uploading files to a repository affected #: 4 files (3.3 KB) --- a/lib/galaxy/webapps/community/controllers/common.py Mon Jul 18 21:56:23 2011 -0400 +++ b/lib/galaxy/webapps/community/controllers/common.py Tue Jul 19 11:27:16 2011 -0400 @@ -214,7 +214,23 @@ if invalid_files: message = "Metadata cannot be defined for change set revision '%s'. Correct the following problems and reset metadata.<br/>" % str( change_set_revision ) for itc_tup in invalid_files: - message += "<b>%s</b> - %s<br/>" % ( itc_tup[0], itc_tup[1] ) + # Handle the special case where a tool depends on a missing xxx.loc file by telliing + # the user to upload xxx.loc.sample to the repository so that it can be copied to + # ~/tool-data/xxx.loc. In this case, itc_tup[1] will be a message looking something like: + # [Errno 2] No such file or directory: '/Users/gvk/central/tool-data/blast2go.loc' + tool_file = itc_tup[0] + exception_msg = itc_tup[1] + if exception_msg.find( 'No such file or directory' ) >= 0: + exception_items = exception_msg.split() + missing_file_items = exception_items[7].split( '/' ) + missing_file = missing_file_items[-1].rstrip( '\'' ) + correction_msg = "This file refers to a missing file <b>%s</b>. " % str( missing_file ) + if exception_msg.find( '.loc' ) >= 0: + sample_loc_file = '%s.sample' % str( missing_file ) + correction_msg += "Upload a file named <b>%s</b> to the repository to correct this error." % sample_loc_file + else: + correction_msg += "Upload a file named <b>%s</b> to the repository to correct this error." % missing_file + message += "<b>%s</b> - %s<br/>" % ( tool_file, correction_msg ) status = 'error' elif flush_needed: # We only flush if there are no tool config errors, so change sets will only have metadata @@ -231,6 +247,14 @@ if str( ctx ) == change_set_revision: return ctx return None +def copy_sample_loc_file( trans, filename ): + """Copy xxx.loc.sample to ~/tool-data/xxx.loc""" + sample_loc_file = os.path.split( filename )[1] + loc_file = os.path.split( filename )[1].rstrip( '.sample' ) + tool_data_path = os.path.abspath( trans.app.config.tool_data_path ) + if not ( os.path.exists( os.path.join( tool_data_path, loc_file ) ) or os.path.exists( os.path.join( tool_data_path, sample_loc_file ) ) ): + shutil.copy( os.path.abspath( filename ), os.path.join( tool_data_path, sample_loc_file ) ) + shutil.copy( os.path.abspath( filename ), os.path.join( tool_data_path, loc_file ) ) def get_user( trans, id ): """Get a user from the database""" return trans.sa_session.query( trans.model.User ).get( trans.security.decode_id( id ) ) --- a/lib/galaxy/webapps/community/controllers/upload.py Mon Jul 18 21:56:23 2011 -0400 +++ b/lib/galaxy/webapps/community/controllers/upload.py Tue Jul 19 11:27:16 2011 -0400 @@ -45,6 +45,7 @@ uploaded_file = file_data.file uploaded_file_name = uploaded_file.name uploaded_file_filename = file_data.filename + isempty = os.path.getsize( os.path.abspath( uploaded_file_name ) ) == 0 if uploaded_file: isgzip = False isbz2 = False @@ -53,17 +54,21 @@ if not isgzip: isbz2 = is_bz2( uploaded_file_name ) ok = True - # Determine what we have - a single file or an archive - try: - if ( isgzip or isbz2 ) and uncompress_file: - # Open for reading with transparent compression. - tar = tarfile.open( uploaded_file_name, 'r:*' ) - else: - tar = tarfile.open( uploaded_file_name ) - istar = True - except tarfile.ReadError, e: + if isempty: tar = None istar = False + else: + # Determine what we have - a single file or an archive + try: + if ( isgzip or isbz2 ) and uncompress_file: + # Open for reading with transparent compression. + tar = tarfile.open( uploaded_file_name, 'r:*' ) + else: + tar = tarfile.open( uploaded_file_name ) + istar = True + except tarfile.ReadError, e: + tar = None + istar = False if istar: ok, message, files_to_remove = self.upload_tar( trans, repository, @@ -83,6 +88,10 @@ shutil.move( uploaded_file_name, full_path ) commands.add( repo.ui, repo, full_path ) commands.commit( repo.ui, repo, full_path, user=trans.user.username, message=commit_message ) + if full_path.endswith( '.loc.sample' ): + # Handle the special case where a xxx.loc.sample file is + # being uploaded by copying it to ~/tool-data/xxx.loc. + copy_sample_loc_file( trans, full_path ) handle_email_alerts( trans, repository ) if ok: # Update the repository files for browsing, a by-product of doing this @@ -170,6 +179,10 @@ commands.remove( repo.ui, repo, repo_file ) for filename_in_archive in filenames_in_archive: commands.add( repo.ui, repo, filename_in_archive ) + if filename_in_archive.endswith( '.loc.sample' ): + # Handle the special case where a xxx.loc.sample file is + # being uploaded by copying it to ~/tool-data/xxx.loc. + copy_sample_loc_file( trans, filename_in_archive ) # Commit the changes. commands.commit( repo.ui, repo, full_path, user=trans.user.username, message=commit_message ) handle_email_alerts( trans, repository ) --- a/templates/webapps/community/repository/common.mako Mon Jul 18 21:56:23 2011 -0400 +++ b/templates/webapps/community/repository/common.mako Tue Jul 19 11:27:16 2011 -0400 @@ -44,7 +44,7 @@ } // The following is used only in ~/templates/webapps/community/repository/upload.mako. if (document.forms["upload_form"]) { - document.upload_form.upload_point.value = selKeys[0]; + document.upload_form.upload_point.value = selKeys.slice(-1); } }, onActivate: function(dtnode) { --- a/templates/webapps/community/repository/upload.mako Mon Jul 18 21:56:23 2011 -0400 +++ b/templates/webapps/community/repository/upload.mako Tue Jul 19 11:27:16 2011 -0400 @@ -64,96 +64,96 @@ <div class="toolForm"><div class="toolFormTitle">Upload a single file or a tarball</div><div class="toolFormBody"> - ## TODO: nginx - <form id="upload_form" name="upload_form" action="${h.url_for( controller='upload', action='upload', repository_id=trans.security.encode_id( repository.id ) )}" enctype="multipart/form-data" method="post"> - <div class="form-row"> - <label>File:</label> - <div class="form-row-input"> - <input type="file" name="file_data"/> - </div> - <div style="clear: both"></div> - </div> - - <div class="form-row"> - <% - if uncompress_file: - yes_selected = 'selected' - no_selected = '' - else: - yes_selected = '' - no_selected = 'selected' - %> - <label>Uncompress files?</label> - <div class="form-row-input"> - <select name="uncompress_file"> - <option value="true" ${yes_selected}>Yes - <option value="false" ${no_selected}>No - </select> - </div> - <div class="toolParamHelp" style="clear: both;"> - Supported compression types are gz and bz2. If <b>Yes</b> is selected, the uploaded file will be uncompressed. However, - if the uploaded file is an archive that contains compressed files, the contained files will not be uncompressed. For - example, if the uploaded compressed file is some_file.tar.gz, some_file.tar will be uncompressed and extracted, but if - some_file.tar contains some_contained_file.gz, the contained file will not be uncompressed. - </div> - </div> - %if not is_new: - <div class="form-row"> - <% - if remove_repo_files_not_in_tar: - yes_selected = 'selected' - no_selected = '' - else: - yes_selected = '' - no_selected = 'selected' - %> - <label>Remove files in the repository (relative to the root or selected upload point) that are not in the uploaded archive?</label> - <div class="form-row-input"> - <select name="remove_repo_files_not_in_tar"> - <option value="true" ${yes_selected}>Yes - <option value="false" ${no_selected}>No - </select> + ## TODO: nginx + <form id="upload_form" name="upload_form" action="${h.url_for( controller='upload', action='upload', repository_id=trans.security.encode_id( repository.id ) )}" enctype="multipart/form-data" method="post"> + <div class="form-row"> + <label>File:</label> + <div class="form-row-input"> + <input type="file" name="file_data"/> + </div> + <div style="clear: both"></div></div> - <div class="toolParamHelp" style="clear: both;"> - This selection pertains only to uploaded tar archives, not to single file uploads. If <b>Yes</b> is selected, files - that exist in the repository (relative to the root or selected upload point) but that are not in the uploaded archive - will be removed from the repository. Otherwise, all existing repository files will remain and the uploaded archive - files will be added to the repository. + + <div class="form-row"> + <% + if uncompress_file: + yes_selected = 'selected' + no_selected = '' + else: + yes_selected = '' + no_selected = 'selected' + %> + <label>Uncompress files?</label> + <div class="form-row-input"> + <select name="uncompress_file"> + <option value="true" ${yes_selected}>Yes + <option value="false" ${no_selected}>No + </select> + </div> + <div class="toolParamHelp" style="clear: both;"> + Supported compression types are gz and bz2. If <b>Yes</b> is selected, the uploaded file will be uncompressed. However, + if the uploaded file is an archive that contains compressed files, the contained files will not be uncompressed. For + example, if the uploaded compressed file is some_file.tar.gz, some_file.tar will be uncompressed and extracted, but if + some_file.tar contains some_contained_file.gz, the contained file will not be uncompressed. + </div></div> - </div> - %endif - <div class="form-row"> - <label>Change set commit message:</label> - <div class="form-row-input"> - %if commit_message: - <pre><textarea name="commit_message" rows="3" cols="35">${commit_message}</textarea></pre> - %else: - <textarea name="commit_message" rows="3" cols="35"></textarea> + %if not is_new: + <div class="form-row"> + <% + if remove_repo_files_not_in_tar: + yes_selected = 'selected' + no_selected = '' + else: + yes_selected = '' + no_selected = 'selected' + %> + <label>Remove files in the repository (relative to the root or selected upload point) that are not in the uploaded archive?</label> + <div class="form-row-input"> + <select name="remove_repo_files_not_in_tar"> + <option value="true" ${yes_selected}>Yes + <option value="false" ${no_selected}>No + </select> + </div> + <div class="toolParamHelp" style="clear: both;"> + This selection pertains only to uploaded tar archives, not to single file uploads. If <b>Yes</b> is selected, files + that exist in the repository (relative to the root or selected upload point) but that are not in the uploaded archive + will be removed from the repository. Otherwise, all existing repository files will remain and the uploaded archive + files will be added to the repository. + </div> + </div> %endif - </div> - <div class="toolParamHelp" style="clear: both;"> - This is the commit message for the mercurial change set that will be created by this upload. - </div> - <div style="clear: both"></div> - </div> - %if not repository.is_new: - <div class="form-row" > - <label>Contents:</label> - <div id="tree" > - Loading... + <div class="form-row"> + <label>Change set commit message:</label> + <div class="form-row-input"> + %if commit_message: + <pre><textarea name="commit_message" rows="3" cols="35">${commit_message}</textarea></pre> + %else: + <textarea name="commit_message" rows="3" cols="35"></textarea> + %endif + </div> + <div class="toolParamHelp" style="clear: both;"> + This is the commit message for the mercurial change set that will be created by this upload. + </div> + <div style="clear: both"></div></div> - <input type="hidden" id="upload_point" name="upload_point" value=""/> - <div class="toolParamHelp" style="clear: both;"> - Select a location within the repository to upload your files by clicking a check box next to the location. The - selected location is considered the upload point. If a location is not selected, the upload point will be the - repository root. + %if not repository.is_new: + <div class="form-row" > + <label>Contents:</label> + <div id="tree" > + Loading... + </div> + <input type="hidden" id="upload_point" name="upload_point" value=""/> + <div class="toolParamHelp" style="clear: both;"> + Select a location within the repository to upload your files by clicking a check box next to the location. The + selected location is considered the upload point. If a location is not selected, the upload point will be the + repository root. + </div> + <div style="clear: both"></div> + </div> + %endif + <div class="form-row"> + <input type="submit" class="primary-button" name="upload_button" value="Upload"></div> - <div style="clear: both"></div> - </div> - %endif - <div class="form-row"> - <input type="submit" class="primary-button" name="upload_button" value="Upload"> - </div> - </form> + </form></div></div> 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.
participants (1)
-
Bitbucket