Commit e3776e32 authored by Duggan, John's avatar Duggan, John
Browse files

Fix collection download

parent 6ad250dd
Loading
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
[project]
name = "ips-fastran-gui"
version = "0.2.5"
version = "0.2.6"
description = "IPS Fastran GUI Project"
authors = []
readme = "README.md"
+11 −16
Original line number Diff line number Diff line
"""IPS Fastran classes."""

import logging
import os
import zipfile
from io import BytesIO
from typing import List, Tuple

from nova.galaxy import Dataset, Parameters, Tool
@@ -44,26 +44,21 @@ class IPSFastranTool(BasicTool):
    def get_output_paths(self) -> List[str]:
        outputs = self.tool.get_results()
        collection = outputs.get_collection("outputs")
        elements = collection.get_content()
        collection.download("data.zip")

        paths = []
        for element in elements:
            dataset = Dataset()
            dataset.id = element["id"]
            dataset.store = collection.store
        with zipfile.ZipFile("data.zip", "r") as zip_obj:
            zip_obj.extractall()

            path = element["element_identifier"]
        paths = []
        for path in os.listdir("IPS Fastran output"):
            if path.startswith("f"):
                dataset.download(path)
                paths.append(path)

        return paths

    def get_results(self, tool: Tool) -> bytes:
        outputs = tool.get_results()
        output = outputs.get_dataset("output").get_content()
        zip_buffer = BytesIO()
        with zipfile.ZipFile(zip_buffer, mode="w", compression=zipfile.ZIP_DEFLATED) as zf:
            zf.writestr("output.nc", output)
        zip_buffer.seek(0)
        return zip_buffer.getvalue()
        if not os.path.exists("data.zip"):
            return bytes()

        with open("data.zip", "rb") as zip_obj:
            return zip_obj.read()
+3 −3
Original line number Diff line number Diff line
@@ -24,9 +24,9 @@ class PlotFastran:
    def load_fastran(self, fn_ncfile: Path) -> None:
        self.figure.clear()

        self.filename = fn_ncfile
        self.fastran = netCDF4.Dataset(fn_ncfile, "r", format="NETCDF4")
        self.basename = os.path.basename(fn_ncfile)
        self.filename = Path("IPS Fastran output") / fn_ncfile
        self.fastran = netCDF4.Dataset(self.filename, "r", format="NETCDF4")
        self.basename = os.path.basename(self.filename)

    def set_page(self, txt: str = "") -> None:
        nrows = self.input_params["pannel"]["nrows"]