# HG changeset patch # User sanbi-uwc # Date 1466899385 14400 # Node ID c48ea98bd3b2cae3f840e216a68ea0ca95e6fa88 # Parent 45b969e6ff9ac86b370dcb438cbf15288d544d0d planemo upload for repository https://github.com/SANBI-SA/tools-sanbi-uwc/tree/master/datatypes/neo4j_datatypes commit 84f212526ffc0d9206dcabc86d214860c2c03db5 diff -r 45b969e6ff9a -r c48ea98bd3b2 neo4j.py --- a/neo4j.py Thu Jun 09 07:50:13 2016 -0400 +++ b/neo4j.py Sat Jun 25 20:03:05 2016 -0400 @@ -20,6 +20,8 @@ derived from html - composite datatype elements stored in extra files path """ + def __init__(self): + Html.__init__( self, **kwd ) def get_mime(self): """Returns the mime type of the datatype""" @@ -46,26 +48,38 @@ """Documented as an old display method, but still gets called via tests etc This allows us to format the data shown in the central pane via the "eye" icon. """ - trans.response.set_content_type(data.get_mime()) - trans.log_event( "Display dataset id: %s" % str( data.id ) ) + if preview == False: + trans.response.set_content_type(data.get_mime()) + trans.log_event( "Display dataset id: %s" % str( data.id ) ) + + # the target directory name + dir_name = str(os.path.dirname( trans.app.object_store.get_filename(data.dataset) )) + '/dataset_{}_files/neo4jdb'.format( data.dataset.id ) - # the target directory name - dir_name = str(os.path.dirname( trans.app.object_store.get_filename(data.dataset) )) + '/dataset_{}_files/neo4jdb'.format( data.dataset.id ) + # generate unique filename for this dataset + valid_chars = '.,^_-()[]0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ' + fname = ''.join(c in valid_chars and c or '_' for c in data.name)[0:150] - # generate unique filename for this dataset - valid_chars = '.,^_-()[]0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ' - fname = ''.join(c in valid_chars and c or '_' for c in data.name)[0:150] + # zip the target directory (dir_name) using the fname + shutil.make_archive(fname, 'zip', dir_name) + download_zip = fname + '.zip' - # zip the target directory (dir_name) using the fname - shutil.make_archive(fname, 'zip', dir_name) - download_zip = fname + '.zip' + # setup headers for the download + trans.response.headers['Content-Length'] = int( os.stat( download_zip ).st_size ) + trans.response.set_content_type( "application/octet-stream" ) # force octet-stream so Safari doesn't append mime extensions to filename + trans.response.headers["Content-Disposition"] = 'attachment; filename="Galaxy%s-[%s].%s"' % (data.hid, download_zip , "zip") - # setup headers for the download - trans.response.headers['Content-Length'] = int( os.stat( download_zip ).st_size ) - trans.response.set_content_type( "application/octet-stream" ) # force octet-stream so Safari doesn't append mime extensions to filename - trans.response.headers["Content-Disposition"] = 'attachment; filename="Galaxy%s-[%s].%s"' % (data.hid, download_zip , "zip") - - return open( download_zip ) + return open( download_zip ) + else: + rval = [ + '