commit/galaxy-central: 2 new changesets
2 new commits in galaxy-central: https://bitbucket.org/galaxy/galaxy-central/commits/44acfec11d87/ Changeset: 44acfec11d87 User: jmchilton Date: 2013-11-27 17:12:48 Summary: Patch from Peter Cock. Allow overriding composite type main file in archives. Affected #: 1 file diff -r 372ff609235643994e50f1502fb9c73d37a3f97f -r 44acfec11d87f2efc38bccb2b3333e86b9d96667 lib/galaxy/datatypes/data.py --- a/lib/galaxy/datatypes/data.py +++ b/lib/galaxy/datatypes/data.py @@ -199,6 +199,29 @@ out = "Can't create peek %s" % str( exc ) return out + def _archive_main_file(self, archive, outfname, data_filename): + """Called from _archive_composite_dataset to add central file to archive. + + Unless subclassed, this will add the main dataset file (argument data_filename) + to the archive, as an HTML file with its filename derived from the dataset name + (argument outfname). + + Returns a tuple of boolean, string, string: (error, msg, messagetype) + """ + error, msg, messagetype = False, "", "" + htmlname = os.path.splitext(outfname)[0] + if not htmlname.endswith(ext): + htmlname = '%s_%s' % (htmlname, ext) + archname = '%s.html' % htmlname # fake the real nature of the html file + try: + archive.add(data_filename, archname) + except IOError: + error = True + log.exception("Unable to add composite parent %s to temporary library download archive" % data_filename) + msg = "Unable to create archive for download, please report this error" + messagetype = "error" + return error, msg, messagetype + def _archive_composite_dataset( self, trans, data=None, **kwd ): # save a composite object into a compressed archive for downloading params = util.Params( kwd ) @@ -233,33 +256,25 @@ messagetype = 'error' if not error: current_user_roles = trans.get_current_user_roles() - ext = data.extension path = data.file_name fname = os.path.split(path)[-1] efp = data.extra_files_path - htmlname = os.path.splitext(outfname)[0] - if not htmlname.endswith(ext): - htmlname = '%s_%s' % (htmlname,ext) - archname = '%s.html' % htmlname # fake the real nature of the html file - try: - archive.add(data.file_name,archname) - except IOError: - error = True - log.exception( "Unable to add composite parent %s to temporary library download archive" % data.file_name) - msg = "Unable to create archive for download, please report this error" - messagetype = 'error' - for root, dirs, files in os.walk(efp): - for fname in files: - fpath = os.path.join(root,fname) - rpath = os.path.relpath(fpath,efp) - try: - archive.add( fpath,rpath ) - except IOError: - error = True - log.exception( "Unable to add %s to temporary library download archive" % rpath) - msg = "Unable to create archive for download, please report this error" - messagetype = 'error' - continue + #Add any central file to the archive, + error, msg, messagetype = self._archive_main_file(archive, outfname, path) + if not error: + #Add any child files to the archive, + for root, dirs, files in os.walk(efp): + for fname in files: + fpath = os.path.join(root,fname) + rpath = os.path.relpath(fpath,efp) + try: + archive.add( fpath,rpath ) + except IOError: + error = True + log.exception( "Unable to add %s to temporary library download archive" % rpath) + msg = "Unable to create archive for download, please report this error" + messagetype = 'error' + continue if not error: if params.do_action == 'zip': archive.close() https://bitbucket.org/galaxy/galaxy-central/commits/cd94f9721265/ Changeset: cd94f9721265 User: jmchilton Date: 2013-12-02 19:40:43 Summary: Fix default behavior of composite archival broken with previous changeset. Other small tweaks this implementation. Affected #: 1 file diff -r 44acfec11d87f2efc38bccb2b3333e86b9d96667 -r cd94f9721265741d448a225df511141190049f34 lib/galaxy/datatypes/data.py --- a/lib/galaxy/datatypes/data.py +++ b/lib/galaxy/datatypes/data.py @@ -199,7 +199,7 @@ out = "Can't create peek %s" % str( exc ) return out - def _archive_main_file(self, archive, outfname, data_filename): + def _archive_main_file(self, archive, display_name, data_filename): """Called from _archive_composite_dataset to add central file to archive. Unless subclassed, this will add the main dataset file (argument data_filename) @@ -209,10 +209,7 @@ Returns a tuple of boolean, string, string: (error, msg, messagetype) """ error, msg, messagetype = False, "", "" - htmlname = os.path.splitext(outfname)[0] - if not htmlname.endswith(ext): - htmlname = '%s_%s' % (htmlname, ext) - archname = '%s.html' % htmlname # fake the real nature of the html file + archname = '%s.html' % display_name # fake the real nature of the html file try: archive.add(data_filename, archname) except IOError: @@ -256,11 +253,17 @@ messagetype = 'error' if not error: current_user_roles = trans.get_current_user_roles() + ext = data.extension path = data.file_name fname = os.path.split(path)[-1] efp = data.extra_files_path #Add any central file to the archive, - error, msg, messagetype = self._archive_main_file(archive, outfname, path) + + display_name = os.path.splitext(outfname)[0] + if not display_name.endswith(ext): + display_name = '%s_%s' % (display_name, ext) + + error, msg, messagetype = self._archive_main_file(archive, display_name, path) if not error: #Add any child files to the archive, for root, dirs, files in os.walk(efp): 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)
-
commits-noreply@bitbucket.org