[hg] galaxy 3514: Fixes for downloading library archives - corre...
details: http://www.bx.psu.edu/hg/galaxy/rev/06dcf56688ea changeset: 3514:06dcf56688ea user: fubar: ross Lazarus at gmail period com date: Wed Mar 10 23:58:35 2010 -0500 description: Fixes for downloading library archives - correct extensions help a lot and removing spaces from ldda.name helps too. diffstat: lib/galaxy/web/controllers/library_common.py | 15 +++++++++------ 1 files changed, 9 insertions(+), 6 deletions(-) diffs (63 lines): diff -r 87da8cd1f091 -r 06dcf56688ea lib/galaxy/web/controllers/library_common.py --- a/lib/galaxy/web/controllers/library_common.py Wed Mar 10 20:59:11 2010 -0500 +++ b/lib/galaxy/web/controllers/library_common.py Wed Mar 10 23:58:35 2010 -0500 @@ -1,4 +1,4 @@ -import os, os.path, shutil, urllib, StringIO, re, gzip, tempfile, shutil, zipfile, copy, glob +import os, os.path, shutil, urllib, StringIO, re, gzip, tempfile, shutil, zipfile, copy, glob, string from galaxy.web.base.controller import * from galaxy import util, jobs from galaxy.datatypes import sniff @@ -1258,7 +1258,6 @@ messagetype = 'error' else: ldda_ids = util.listify( ldda_ids ) - log.debug('## act on multiple got %s' % ldda_ids) if action == 'import_to_history': history = trans.get_history() if history is None: @@ -1312,6 +1311,8 @@ msg = "The selected datasets have been removed from this data library" else: error = False + killme = string.punctuation + string.whitespace + trantab = string.maketrans(killme,'_'*len(killme)) try: outext = 'zip' if action == 'zip': @@ -1325,10 +1326,10 @@ archive.add = lambda x, y: archive.write( x, y.encode('CP437') ) elif action == 'tgz': archive = util.streamball.StreamBall( 'w|gz' ) - outext = 'gz' + outext = 'tgz' elif action == 'tbz': archive = util.streamball.StreamBall( 'w|bz2' ) - outext = 'bz2' + outext = 'tbz2' except (OSError, zipfile.BadZipFile): error = True log.exception( "Unable to create archive for download" ) @@ -1356,12 +1357,13 @@ path = os.path.join( parent_folder.name, path ) parent_folder = parent_folder.parent path += ldda.name + path = path.translate(trantab) while path in seen: path += '_' seen.append( path ) + zpath = os.path.split(path)[-1] # comes as base_name/fname + outfname,zpathext = os.path.splitext(zpath) if is_composite: # need to add all the components from the extra_files_path to the zip - zpath = os.path.split(path)[-1] # comes as base_name/fname - outfname,zpathext = os.path.splitext(zpath) if zpathext == '': zpath = '%s.html' % zpath # fake the real nature of the html file try: @@ -1375,6 +1377,7 @@ flist = glob.glob(os.path.join(ldda.dataset.extra_files_path,'*.*')) # glob returns full paths for fpath in flist: efp,fname = os.path.split(fpath) + fname = fname.translate(trantab) try: archive.add( fpath,fname ) except IOError:
participants (1)
-
Greg Von Kuster