Esempio n. 1
0
 def __stream_dataset_collection(self, trans, dataset_collection_instance):
     archive_type_string = 'w|gz'
     archive_ext = 'tgz'
     if self.app.config.upstream_gzip:
         archive_type_string = 'w|'
         archive_ext = 'tar'
     archive = StreamBall(mode=archive_type_string)
     names, hdas = get_hda_and_element_identifiers(
         dataset_collection_instance)
     for name, hda in zip(names, hdas):
         if hda.state != hda.states.OK:
             continue
         for file_path, relpath in hda.datatype.to_archive(trans=trans,
                                                           dataset=hda,
                                                           name=name):
             archive.add(file=file_path, relpath=relpath)
     archive_name = "%s: %s.%s" % (dataset_collection_instance.hid,
                                   dataset_collection_instance.name,
                                   archive_ext)
     trans.response.set_content_type("application/x-tar")
     trans.response.headers[
         "Content-Disposition"] = 'attachment; filename="{}"'.format(
             archive_name)
     archive.wsgi_status = trans.response.wsgi_status()
     archive.wsgi_headeritems = trans.response.wsgi_headeritems()
     return archive.stream
Esempio n. 2
0
def stream_dataset_collection(dataset_collection_instance, upstream_mod_zip=False, upstream_gzip=False):
    archive_name = f"{dataset_collection_instance.hid}: {dataset_collection_instance.name}"
    archive = ZipstreamWrapper(
        archive_name=archive_name,
        upstream_mod_zip=upstream_mod_zip,
        upstream_gzip=upstream_gzip,
    )
    names, hdas = get_hda_and_element_identifiers(dataset_collection_instance)
    for name, hda in zip(names, hdas):
        if hda.state != hda.states.OK:
            continue
        for file_path, relpath in hda.datatype.to_archive(dataset=hda, name=name):
            archive.write(file_path, relpath)
    return archive
 def __stream_dataset_collection(self, trans, dataset_collection_instance):
     archive_type_string = 'w|gz'
     archive_ext = 'tgz'
     if self.app.config.upstream_gzip:
         archive_type_string = 'w|'
         archive_ext = 'tar'
     archive = StreamBall(mode=archive_type_string)
     names, hdas = get_hda_and_element_identifiers(dataset_collection_instance)
     for name, hda in zip(names, hdas):
         if hda.state != hda.states.OK:
             continue
         for file_path, relpath in hda.datatype.to_archive(trans=trans, dataset=hda, name=name):
             archive.add(file=file_path, relpath=relpath)
     archive_name = "%s: %s.%s" % (dataset_collection_instance.hid, dataset_collection_instance.name, archive_ext)
     trans.response.set_content_type("application/x-tar")
     trans.response.headers["Content-Disposition"] = 'attachment; filename="{}"'.format(archive_name)
     archive.wsgi_status = trans.response.wsgi_status()
     archive.wsgi_headeritems = trans.response.wsgi_headeritems()
     return archive.stream