Exemplo n.º 1
0
    def _run(self, work_manager: worker.ToolJobManager) -> None:
        window = speedwagon.gui.MainWindow1(
            work_manager=work_manager,
            debug=False)

        window.show()
        try:
            while not self._pending_tasks.empty():
                active_workflow, options = self._pending_tasks.get()
                if active_workflow.name is not None:
                    window.setWindowTitle(active_workflow.name)
                runner_strategy = \
                    runner_strategies.QtRunner(window)

                active_workflow.validate_user_options(**options)

                runner_strategy.run(
                    active_workflow,
                    options,
                    window.log_manager
                )

                self._pending_tasks.task_done()
        except runner_strategies.TaskFailed as task_error:
            raise job.JobCancelled(task_error) from task_error

        finally:
            window.log_manager.handlers.clear()
            window.close()
Exemplo n.º 2
0
    def test_run_abstract_workflow_calls_run_abs_workflow(self, qtbot):
        runner = runner_strategies.QtRunner(None)
        job = Mock()
        job.__class__ = speedwagon.job.Workflow
        runner.run_abs_workflow = Mock()
        runner.run(job=job, options={})

        assert runner.run_abs_workflow.called is True
Exemplo n.º 3
0
def tool_job_manager_spy():

    with SpyToolJobManager() as e:
        manager_strat = runner_strategies.QtRunner(parent=None)

        runner = runner_strategies.RunRunner(manager_strat)

        yield runner
Exemplo n.º 4
0
    def test_run_non_abstract_workflow_doesnt_call_run_abs_workflow(
            self, qtbot):

        runner = runner_strategies.QtRunner(None)
        job = Mock()
        # NOTE: job.__class__ != speedwagon.job.AbsWorkflow
        runner.run_abs_workflow = Mock()
        runner.run(job=job, options={})

        assert runner.run_abs_workflow.called is False
Exemplo n.º 5
0
    def test_run_abs_workflow_calls_task_runner(self):
        manager = Mock()
        runner = runner_strategies.QtRunner(manager)
        job = Mock()
        job.__class__ = speedwagon.job.AbsWorkflow

        task_runner = MagicMock()

        runner.run_abs_workflow(task_scheduler=task_runner,
                                job=job,
                                options={})
        assert task_runner.run.called is True
Exemplo n.º 6
0
    def test_run_abs_workflow_fails_with_task_failed_exception(self):
        manager = Mock()
        runner = runner_strategies.QtRunner(manager)
        job = Mock()
        job.__class__ = speedwagon.job.AbsWorkflow

        task_runner = MagicMock()

        task_runner.run = Mock(
            side_effect=runner_strategies.TaskFailed("my bad"))
        with pytest.raises(runner_strategies.TaskFailed) as error:
            runner.run_abs_workflow(
                task_scheduler=task_runner,
                job=job,
                options={},
            )

        assert "my bad" in str(error.value)
Exemplo n.º 7
0
    def _run_workflow(
            self,
            job_manager: runner_strategies.BackgroundJobManager,
            workflow,
            options
    ):
        window = \
            SingleWorkflowJSON._load_main_window(job_manager, workflow.name)

        runner_strategy = runner_strategies.QtRunner(window)
        window.logger = cast(logging.Logger, window.logger)
        window.logger.setLevel(logging.INFO)
        window.show()
        window.console.log_handler.capacity = 1
        runner_strategy.run(workflow,
                            options,
                            window.logger
                            )

        if self.on_exit is not None:
            self.on_exit(window)
Exemplo n.º 8
0
    def _run(self, work_manager: worker.ToolJobManager) -> None:
        if self._active_workflow is None:
            raise ValueError("No active workflow set")

        window = speedwagon.gui.MainWindow1(
            work_manager=work_manager,
            debug=False)

        window.show()
        if self._active_workflow.name is not None:
            window.setWindowTitle(self._active_workflow.name)
        runner_strategy = \
            runner_strategies.QtRunner(window)

        self._active_workflow.validate_user_options(**self.options)
        # runner_strategy.additional_info_callback

        runner_strategy.run(self._active_workflow,
                            self.options,
                            window.log_manager)
        window.log_manager.handlers.clear()
        window.close()