Beispiel #1
0
def test_exporter_is_not_valid():
    config_file = "snake_oil.ert"
    rc = ResConfig(user_config_file=config_file)
    rc.convertToCReference(None)
    ert = EnKFMain(rc)
    ex = Exporter(ert)
    assert not ex.is_valid()
Beispiel #2
0
def test_exporter_is_valid():
    with ErtPluginContext():
        config_file = "snake_oil.ert"
        rc = ResConfig(user_config_file=config_file)
        rc.convertToCReference(None)
        ert = EnKFMain(rc)
        ex = Exporter(ert)
        assert ex.is_valid(), "Missing CSV_EXPORT2 or EXPORT_RUNPATH jobs"
Beispiel #3
0
def test_exporter_is_not_valid():
    config_file = "snake_oil.ert"
    rc = ResConfig(user_config_file=config_file)
    rc.convertToCReference(None)
    ert = EnKFMain(rc)
    notifier = ErtCliNotifier(ert, config_file)
    with ERT.adapt(notifier):
        ex = Exporter()
        assert not ex.is_valid()
Beispiel #4
0
class ExportTool(Tool):
    def __init__(self):
        super(ExportTool, self).__init__("Export Data", "tools/export",
                                         resourceIcon("ide/table_export"))
        self.__export_widget = None
        self.__dialog = None
        self.__exporter = Exporter()
        self.setEnabled(self.__exporter.is_valid())

    def trigger(self):
        if self.__export_widget is None:
            self.__export_widget = ref(ExportPanel(self.parent()))
            self.__export_widget().runExport.connect(self._run_export)

        self.__dialog = ref(
            ClosableDialog("Export", self.__export_widget(), self.parent()))
        self.__export_widget().updateExportButton.connect(
            self.__dialog().toggleButton)
        self.__dialog().addButton("Export", self.export)
        self.__dialog().show()

    def _run_export(self, params):
        try:
            self.__exporter.run_export(params)
            QMessageBox.information(None, "Success", """Export completed!""",
                                    QMessageBox.Ok)
        except UserWarning as usrwarning:
            logging.error(str(usrwarning))
            QMessageBox.warning(
                None,
                "Failure",
                """Export failed with the follwing message:\n{}""".format(
                    str(usrwarning)),
                QMessageBox.Ok,
            )

    def export(self):
        self.__export_widget().export()
        self.__dialog().accept()