Пример #1
0
    def _initUI(self):
        # Widgets
        self._brw_pendbase = DirBrowseWidget()

        self._brw_exe = FileBrowseWidget()
        if os.name == 'nt':
            self._brw_exe.setNameFilter('Application files (*.exe)')
        else:
            self._brw_exe.setNameFilter('Application files (*)')

        self._spn_dumpp = QSpinBox()
        self._spn_dumpp.setMinimum(30)
        self._spn_dumpp.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed)

        # Layouts
        layout = _ConfigurePanelWidget._initUI(self)
        layout.addRow("Path to pendbase directory", self._brw_pendbase)
        layout.addRow('Path to PENEPMA executable', self._brw_exe)
        layout.addRow('Interval between dump (s)', self._spn_dumpp)

        # Signals
        self._brw_pendbase.pathChanged.connect(self._onPathChanged)
        self._brw_exe.pathChanged.connect(self._onPathChanged)

        return layout
class _PenshowerConfigurePanelWidget(_ConfigurePanelWidget):

    def _initUI(self):
        # Widgets
        self._brw_pendbase = DirBrowseWidget()

        self._brw_exe = FileBrowseWidget()
        if os.name == 'nt':
            self._brw_exe.setNameFilter('Application files (*.exe)')
        else:
            self._brw_exe.setNameFilter('Application files (*)')

        # Layouts
        layout = _ConfigurePanelWidget._initUI(self)
        layout.addRow("Path to pendbase directory", self._brw_pendbase)
        layout.addRow('Path to PENSHOWER executable', self._brw_exe)

        # Signals
        self._brw_pendbase.pathChanged.connect(self._onPathChanged)
        self._brw_exe.pathChanged.connect(self._onPathChanged)

        return layout

    def _onPathChanged(self, path):
        if not path:
            return
        if not self._brw_pendbase.baseDir():
            self._brw_pendbase.setBaseDir(path)
        if not self._brw_exe.baseDir():
            self._brw_exe.setBaseDir(path)

    def hasAcceptableInput(self):
        if not self._brw_pendbase.path():
            return False
        if not self._brw_exe.path():
            return False
        if not os.access(self._brw_exe.path(), os.X_OK):
            return False
        return True

    def setSettings(self, settings):
        if 'penshower' in settings:
            path = getattr(settings.penshower, 'pendbase', None)
            try:
                self._brw_pendbase.setPath(path)
            except ValueError:
                pass

            path = getattr(settings.penshower, 'exe', None)
            try:
                self._brw_exe.setPath(path)
            except ValueError:
                pass

    def updateSettings(self, settings):
        section = _ConfigurePanelWidget.updateSettings(self, settings)
        section.pendbase = self._brw_pendbase.path()
        section.exe = self._brw_exe.path()
        return section
Пример #3
0
class _PenshowerConfigurePanelWidget(_ConfigurePanelWidget):
    def _initUI(self):
        # Widgets
        self._brw_pendbase = DirBrowseWidget()

        self._brw_exe = FileBrowseWidget()
        if os.name == 'nt':
            self._brw_exe.setNameFilter('Application files (*.exe)')
        else:
            self._brw_exe.setNameFilter('Application files (*)')

        # Layouts
        layout = _ConfigurePanelWidget._initUI(self)
        layout.addRow("Path to pendbase directory", self._brw_pendbase)
        layout.addRow('Path to PENSHOWER executable', self._brw_exe)

        # Signals
        self._brw_pendbase.pathChanged.connect(self._onPathChanged)
        self._brw_exe.pathChanged.connect(self._onPathChanged)

        return layout

    def _onPathChanged(self, path):
        if not path:
            return
        if not self._brw_pendbase.baseDir():
            self._brw_pendbase.setBaseDir(path)
        if not self._brw_exe.baseDir():
            self._brw_exe.setBaseDir(path)

    def hasAcceptableInput(self):
        if not self._brw_pendbase.path():
            return False
        if not self._brw_exe.path():
            return False
        if not os.access(self._brw_exe.path(), os.X_OK):
            return False
        return True

    def setSettings(self, settings):
        if 'penshower' in settings:
            path = getattr(settings.penshower, 'pendbase', None)
            try:
                self._brw_pendbase.setPath(path)
            except ValueError:
                pass

            path = getattr(settings.penshower, 'exe', None)
            try:
                self._brw_exe.setPath(path)
            except ValueError:
                pass

    def updateSettings(self, settings):
        section = _ConfigurePanelWidget.updateSettings(self, settings)
        section.pendbase = self._brw_pendbase.path()
        section.exe = self._brw_exe.path()
        return section
Пример #4
0
    def _initUI(self):
        # Widgets
        self._brw_basedir = DirBrowseWidget()

        self._brw_exe = FileBrowseWidget()
        if os.name == 'nt':
            self._brw_exe.setNameFilter('Application files (*.exe)')
        else:
            self._brw_exe.setNameFilter('Application files (*)')

        # Layouts
        layout = _ConfigurePanelWidget._initUI(self)
        layout.addRow('Full path to base directory', self._brw_basedir)
        layout.addRow('Full path to Mccli32.exe (optional)', self._brw_exe)

        # Signals
        self._brw_basedir.pathChanged.connect(self._onPathChanged)
        self._brw_exe.pathChanged.connect(self._onPathChanged)

        return layout
Пример #5
0
    def _initUI(self):
        # Widgets
        self._brw_pendbase = DirBrowseWidget()

        self._brw_exe = FileBrowseWidget()
        if os.name == 'nt':
            self._brw_exe.setNameFilter('Application files (*.exe)')
        else:
            self._brw_exe.setNameFilter('Application files (*)')

        # Layouts
        layout = _ConfigurePanelWidget._initUI(self)
        layout.addRow("Path to pendbase directory", self._brw_pendbase)
        layout.addRow('Path to PENSHOWER executable', self._brw_exe)

        # Signals
        self._brw_pendbase.pathChanged.connect(self._onPathChanged)
        self._brw_exe.pathChanged.connect(self._onPathChanged)

        return layout
    def _initUI(self):
        # Widgets
        self._brw_pendbase = DirBrowseWidget()

        self._brw_exe = FileBrowseWidget()
        if os.name == 'nt':
            self._brw_exe.setNameFilter('Application files (*.exe)')
        else:
            self._brw_exe.setNameFilter('Application files (*)')

        # Layouts
        layout = _ConfigurePanelWidget._initUI(self)
        layout.addRow("Path to pendbase directory", self._brw_pendbase)
        layout.addRow('Path to PENSHOWER executable', self._brw_exe)

        # Signals
        self._brw_pendbase.pathChanged.connect(self._onPathChanged)
        self._brw_exe.pathChanged.connect(self._onPathChanged)

        return layout
    def _initUI(self):
        # Widgets
        self._brw_basedir = DirBrowseWidget()

        self._brw_exe = FileBrowseWidget()
        if os.name == 'nt':
            self._brw_exe.setNameFilter('Application files (*.exe)')
        else:
            self._brw_exe.setNameFilter('Application files (*)')

        # Layouts
        layout = _ConfigurePanelWidget._initUI(self)
        layout.addRow('Full path to base directory', self._brw_basedir)
        layout.addRow('Full path to Mccli32.exe (optional)', self._brw_exe)

        # Signals
        self._brw_basedir.pathChanged.connect(self._onPathChanged)
        self._brw_exe.pathChanged.connect(self._onPathChanged)

        return layout
Пример #8
0
    def __init__(self, parent=None):
        QDialog.__init__(self, parent)
        self.setWindowTitle('Runner')
        self.setMinimumWidth(750)

        # Runner
        self._runner = None

        self._running_timer = QTimer()
        self._running_timer.setInterval(500)

        # Widgets
        self._dlg_progress = QProgressDialog()
        self._dlg_progress.setRange(0, 100)
        self._dlg_progress.setModal(True)
        self._dlg_progress.hide()

        lbl_outputdir = QLabel("Output directory")
        self._txt_outputdir = DirBrowseWidget()

        max_workers = cpu_count() #@UndefinedVariable
        lbl_workers = QLabel('Number of workers')
        self._spn_workers = QSpinBox()
        self._spn_workers.setRange(1, max_workers)
        self._spn_workers.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed)
        lbl_max_workers = QLabel('(max: %i)' % max_workers)

        self._chk_overwrite = QCheckBox("Overwrite existing results in output directory")
        self._chk_overwrite.setChecked(True)

        self._lbl_available = QLabel('Available')
        self._lst_available = QListView()
        self._lst_available.setModel(_AvailableOptionsListModel())
        self._lst_available.setSelectionMode(QListView.SelectionMode.MultiSelection)

        tlb_available = QToolBar()
        spacer = QWidget()
        spacer.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
        tlb_available.addWidget(spacer)
        act_open = tlb_available.addAction(getIcon("document-open"), "Open")
        act_open.setShortcut(QKeySequence.Open)
        tlb_available.addSeparator()
        act_remove = tlb_available.addAction(getIcon("list-remove"), "Remove")
        act_clear = tlb_available.addAction(getIcon("edit-clear"), "Clear")

        self._btn_addtoqueue = QPushButton(getIcon("go-next"), "")
        self._btn_addtoqueue.setToolTip("Add to queue")
        self._btn_addtoqueue.setEnabled(False)

        self._btn_addalltoqueue = QPushButton(getIcon("go-last"), "")
        self._btn_addalltoqueue.setToolTip("Add all to queue")
        self._btn_addalltoqueue.setEnabled(False)

        self._lbl_options = QLabel('Queued/Running/Completed')
        self._tbl_options = QTableView()
        self._tbl_options.setModel(_StateOptionsTableModel())
        self._tbl_options.setItemDelegate(_StateOptionsItemDelegate())
        self._tbl_options.setSelectionMode(QListView.SelectionMode.NoSelection)
        self._tbl_options.setColumnWidth(1, 60)
        self._tbl_options.setColumnWidth(2, 80)
        header = self._tbl_options.horizontalHeader()
        header.setResizeMode(0, QHeaderView.Interactive)
        header.setResizeMode(1, QHeaderView.Fixed)
        header.setResizeMode(2, QHeaderView.Fixed)
        header.setResizeMode(3, QHeaderView.Stretch)

        self._btn_start = QPushButton(getIcon("media-playback-start"), "Start")

        self._btn_cancel = QPushButton("Cancel")
        self._btn_cancel.setEnabled(False)

        self._btn_close = QPushButton("Close")

        self._btn_import = QPushButton("Import")
        self._btn_import.setEnabled(False)

        # Layouts
        layout = QVBoxLayout()

        sublayout = QGridLayout()
        sublayout.addWidget(lbl_outputdir, 0, 0)
        sublayout.addWidget(self._txt_outputdir, 0, 1)
        sublayout.addWidget(lbl_workers, 1, 0)

        subsublayout = QHBoxLayout()
        subsublayout.addWidget(self._spn_workers)
        subsublayout.addWidget(lbl_max_workers)
        sublayout.addLayout(subsublayout, 1, 1)
        layout.addLayout(sublayout)

        sublayout.addWidget(self._chk_overwrite, 2, 0, 1, 3)

        sublayout = QGridLayout()
        sublayout.setColumnStretch(0, 1)
        sublayout.setColumnStretch(2, 3)
        sublayout.addWidget(self._lbl_available, 0, 0)
        sublayout.addWidget(self._lst_available, 1, 0)
        sublayout.addWidget(tlb_available, 2, 0)

        subsublayout = QVBoxLayout()
        subsublayout.addStretch()
        subsublayout.addWidget(self._btn_addtoqueue)
        subsublayout.addWidget(self._btn_addalltoqueue)
        subsublayout.addStretch()
        sublayout.addLayout(subsublayout, 1, 1)

        sublayout.addWidget(self._lbl_options, 0, 2)
        sublayout.addWidget(self._tbl_options, 1, 2)
        layout.addLayout(sublayout)

        sublayout = QHBoxLayout()
        sublayout.addStretch()
        sublayout.addWidget(self._btn_import)
        sublayout.addWidget(self._btn_start)
        sublayout.addWidget(self._btn_cancel)
        sublayout.addWidget(self._btn_close)
        layout.addLayout(sublayout)

        self.setLayout(layout)

        # Signal
        self._running_timer.timeout.connect(self._onRunningTimer)

        act_open.triggered.connect(self._onOpen)
        act_remove.triggered.connect(self._onRemove)
        act_clear.triggered.connect(self._onClear)

        self._btn_addtoqueue.released.connect(self._onAddToQueue)
        self._btn_addalltoqueue.released.connect(self._onAddAllToQueue)
        self._btn_start.released.connect(self._onStart)
        self._btn_cancel.released.connect(self._onCancel)
        self._btn_close.released.connect(self._onClose)
        self._btn_import.released.connect(self._onImport)

        self.options_added.connect(self._onOptionsAdded)
        self.options_running.connect(self._onOptionsRunning)
        self.options_simulated.connect(self._onOptionsSimulated)
        self.options_error.connect(self._onOptionsError)
        self.results_error.connect(self._onResultsError)

        # Defaults
        settings = get_settings()
        section = settings.add_section('gui')
        if hasattr(section, 'outputdir'):
            self._txt_outputdir.setPath(section.outputdir)
        if hasattr(section, 'maxworkers'):
            self._spn_workers.setValue(int(section.maxworkers))
        if hasattr(section, 'overwrite'):
            state = True if section.overwrite.lower() == 'true' else False
            self._chk_overwrite.setChecked(state)
Пример #9
0
class RunnerDialog(QDialog):

    options_added = Signal(Options)
    options_running = Signal(Options)
    options_simulated = Signal(Options)
    options_error = Signal(Options, Exception)
    results_saved = Signal(Results, str)
    results_error = Signal(Results, Exception)

    def __init__(self, parent=None):
        QDialog.__init__(self, parent)
        self.setWindowTitle('Runner')
        self.setMinimumWidth(750)

        # Runner
        self._runner = None

        self._running_timer = QTimer()
        self._running_timer.setInterval(500)

        # Widgets
        self._dlg_progress = QProgressDialog()
        self._dlg_progress.setRange(0, 100)
        self._dlg_progress.setModal(True)
        self._dlg_progress.hide()

        lbl_outputdir = QLabel("Output directory")
        self._txt_outputdir = DirBrowseWidget()

        max_workers = cpu_count() #@UndefinedVariable
        lbl_workers = QLabel('Number of workers')
        self._spn_workers = QSpinBox()
        self._spn_workers.setRange(1, max_workers)
        self._spn_workers.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed)
        lbl_max_workers = QLabel('(max: %i)' % max_workers)

        self._chk_overwrite = QCheckBox("Overwrite existing results in output directory")
        self._chk_overwrite.setChecked(True)

        self._lbl_available = QLabel('Available')
        self._lst_available = QListView()
        self._lst_available.setModel(_AvailableOptionsListModel())
        self._lst_available.setSelectionMode(QListView.SelectionMode.MultiSelection)

        tlb_available = QToolBar()
        spacer = QWidget()
        spacer.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
        tlb_available.addWidget(spacer)
        act_open = tlb_available.addAction(getIcon("document-open"), "Open")
        act_open.setShortcut(QKeySequence.Open)
        tlb_available.addSeparator()
        act_remove = tlb_available.addAction(getIcon("list-remove"), "Remove")
        act_clear = tlb_available.addAction(getIcon("edit-clear"), "Clear")

        self._btn_addtoqueue = QPushButton(getIcon("go-next"), "")
        self._btn_addtoqueue.setToolTip("Add to queue")
        self._btn_addtoqueue.setEnabled(False)

        self._btn_addalltoqueue = QPushButton(getIcon("go-last"), "")
        self._btn_addalltoqueue.setToolTip("Add all to queue")
        self._btn_addalltoqueue.setEnabled(False)

        self._lbl_options = QLabel('Queued/Running/Completed')
        self._tbl_options = QTableView()
        self._tbl_options.setModel(_StateOptionsTableModel())
        self._tbl_options.setItemDelegate(_StateOptionsItemDelegate())
        self._tbl_options.setSelectionMode(QListView.SelectionMode.NoSelection)
        self._tbl_options.setColumnWidth(1, 60)
        self._tbl_options.setColumnWidth(2, 80)
        header = self._tbl_options.horizontalHeader()
        header.setResizeMode(0, QHeaderView.Interactive)
        header.setResizeMode(1, QHeaderView.Fixed)
        header.setResizeMode(2, QHeaderView.Fixed)
        header.setResizeMode(3, QHeaderView.Stretch)

        self._btn_start = QPushButton(getIcon("media-playback-start"), "Start")

        self._btn_cancel = QPushButton("Cancel")
        self._btn_cancel.setEnabled(False)

        self._btn_close = QPushButton("Close")

        self._btn_import = QPushButton("Import")
        self._btn_import.setEnabled(False)

        # Layouts
        layout = QVBoxLayout()

        sublayout = QGridLayout()
        sublayout.addWidget(lbl_outputdir, 0, 0)
        sublayout.addWidget(self._txt_outputdir, 0, 1)
        sublayout.addWidget(lbl_workers, 1, 0)

        subsublayout = QHBoxLayout()
        subsublayout.addWidget(self._spn_workers)
        subsublayout.addWidget(lbl_max_workers)
        sublayout.addLayout(subsublayout, 1, 1)
        layout.addLayout(sublayout)

        sublayout.addWidget(self._chk_overwrite, 2, 0, 1, 3)

        sublayout = QGridLayout()
        sublayout.setColumnStretch(0, 1)
        sublayout.setColumnStretch(2, 3)
        sublayout.addWidget(self._lbl_available, 0, 0)
        sublayout.addWidget(self._lst_available, 1, 0)
        sublayout.addWidget(tlb_available, 2, 0)

        subsublayout = QVBoxLayout()
        subsublayout.addStretch()
        subsublayout.addWidget(self._btn_addtoqueue)
        subsublayout.addWidget(self._btn_addalltoqueue)
        subsublayout.addStretch()
        sublayout.addLayout(subsublayout, 1, 1)

        sublayout.addWidget(self._lbl_options, 0, 2)
        sublayout.addWidget(self._tbl_options, 1, 2)
        layout.addLayout(sublayout)

        sublayout = QHBoxLayout()
        sublayout.addStretch()
        sublayout.addWidget(self._btn_import)
        sublayout.addWidget(self._btn_start)
        sublayout.addWidget(self._btn_cancel)
        sublayout.addWidget(self._btn_close)
        layout.addLayout(sublayout)

        self.setLayout(layout)

        # Signal
        self._running_timer.timeout.connect(self._onRunningTimer)

        act_open.triggered.connect(self._onOpen)
        act_remove.triggered.connect(self._onRemove)
        act_clear.triggered.connect(self._onClear)

        self._btn_addtoqueue.released.connect(self._onAddToQueue)
        self._btn_addalltoqueue.released.connect(self._onAddAllToQueue)
        self._btn_start.released.connect(self._onStart)
        self._btn_cancel.released.connect(self._onCancel)
        self._btn_close.released.connect(self._onClose)
        self._btn_import.released.connect(self._onImport)

        self.options_added.connect(self._onOptionsAdded)
        self.options_running.connect(self._onOptionsRunning)
        self.options_simulated.connect(self._onOptionsSimulated)
        self.options_error.connect(self._onOptionsError)
        self.results_error.connect(self._onResultsError)

        # Defaults
        settings = get_settings()
        section = settings.add_section('gui')
        if hasattr(section, 'outputdir'):
            self._txt_outputdir.setPath(section.outputdir)
        if hasattr(section, 'maxworkers'):
            self._spn_workers.setValue(int(section.maxworkers))
        if hasattr(section, 'overwrite'):
            state = True if section.overwrite.lower() == 'true' else False
            self._chk_overwrite.setChecked(state)

    def _onDialogProgressProgress(self, progress, status):
        self._dlg_progress.setValue(progress * 100)
        self._dlg_progress.setLabelText(status)

    def _onDialogProgressCancel(self):
        self._dlg_progress.hide()
        if self._options_reader_thread is None:
            return
        self._options_reader_thread.cancel()
        self._options_reader_thread.quit()
        self._options_reader_thread.wait()

    def _onDialogProgressException(self, ex):
        self._dlg_progress.hide()
        self._options_reader_thread.quit()
        self._options_reader_thread.wait()
        messagebox.exception(self, ex)

    def _onRunningTimer(self):
        self._tbl_options.model().reset()

    def _onOpen(self):
        settings = get_settings()
        curdir = getattr(settings.gui, 'opendir', os.getcwd())

        filepath, namefilter = \
            QFileDialog.getOpenFileName(self, "Open", curdir,
                                        'Options [*.xml] (*.xml)')

        if not filepath or not namefilter:
            return
        settings.gui.opendir = os.path.dirname(filepath)

        if not filepath.endswith('.xml'):
            filepath += '.xml'

        self._options_reader_thread = _OptionsReaderWrapperThread(filepath)
        self._dlg_progress.canceled.connect(self._onDialogProgressCancel)
        self._options_reader_thread.resultReady.connect(self._onOpened)
        self._options_reader_thread.progressUpdated.connect(self._onDialogProgressProgress)
        self._options_reader_thread.exceptionRaised.connect(self._onDialogProgressException)
        self._options_reader_thread.start()

        self._dlg_progress.reset()
        self._dlg_progress.show()

    def _onOpened(self, options):
        self._dlg_progress.hide()
        self._options_reader_thread.quit()
        self._options_reader_thread.wait()
        self._options_reader_thread = None

        try:
            self._lst_available.model().addOptions(options)
        except Exception as ex:
            messagebox.exception(self, ex)

    def _onRemove(self):
        selection = self._lst_available.selectionModel().selection().indexes()
        if len(selection) == 0:
            QMessageBox.warning(self, "Queue", "Select an options")
            return

        model = self._lst_available.model()
        for row in sorted(map(methodcaller('row'), selection), reverse=True):
            model.popOptions(row)

    def _onClear(self):
        self._lst_available.model().clearOptions()

    def _onAddToQueue(self):
        selection = self._lst_available.selectionModel().selection().indexes()
        if len(selection) == 0:
            QMessageBox.warning(self, "Queue", "Select an options")
            return

        model = self._lst_available.model()
        for row in sorted(map(methodcaller('row'), selection), reverse=True):
            options = model.options(row)
            try:
                self._runner.put(options)
            except Exception as ex:
                messagebox.exception(self, ex)
                return

    def _onAddAllToQueue(self):
        model = self._lst_available.model()
        for row in reversed(range(0, model.rowCount())):
            options = model.options(row)
            try:
                self._runner.put(options)
            except Exception as ex:
                messagebox.exception(self, ex)
                return

    def _onStart(self):
        outputdir = self._txt_outputdir.path()
        if not outputdir:
            QMessageBox.critical(self, 'Start', 'Missing output directory')
            return
        max_workers = self._spn_workers.value()
        overwrite = self._chk_overwrite.isChecked()
        self.start(outputdir, overwrite, max_workers)

    def _onCancel(self):
        self.cancel()

    def _onClose(self):
        if self._runner is not None:
            self._runner.close()
        self._running_timer.stop()
        self.close()

    def _onImport(self):
        list_options = self._lst_available.model().listOptions()
        if not list_options:
            return

        # Select options
        dialog = _OptionsSelector(list_options)
        if not dialog.exec_():
            return
        options = dialog.options()

        # Start importer
        outputdir = self._runner.outputdir
        max_workers = self._runner.max_workers
        importer = LocalImporter(outputdir, max_workers)

        importer.start()
        importer.put(options)

        self._dlg_progress.show()
        try:
            while importer.is_alive():
                if self._dlg_progress.wasCanceled():
                    importer.cancel()
                    break
                self._dlg_progress.setValue(importer.progress * 100)
        finally:
            self._dlg_progress.hide()

    def _onOptionsAdded(self, options):
        logging.debug('runner: optionsAdded')
        self._tbl_options.model().addOptions(options)

    def _onOptionsRunning(self, options):
        logging.debug('runner: optionsRunning')
        self._tbl_options.model().resetOptions(options)

    def _onOptionsSimulated(self, options):
        logging.debug('runner: optionsSimulated')
        self._tbl_options.model().resetOptions(options)

    def _onOptionsError(self, options, ex):
        logging.debug('runner: optionsError')
        self._tbl_options.model().resetOptions(options)

    def _onResultsError(self, results, ex):
        logging.debug('runner: resultsError')
        self._tbl_options.model().reset()

    def closeEvent(self, event):
        if self.is_running():
            message = 'Runner is running. Do you want to continue?'
            answer = QMessageBox.question(self, 'Runner', message,
                                          QMessageBox.Yes | QMessageBox.No)
            if answer == QMessageBox.No:
                event.ignore()
                return

        self.cancel()
        self._dlg_progress.close()

        settings = get_settings()
        section = settings.add_section('gui')

        path = self._txt_outputdir.path()
        if path:
            section.outputdir = path
        section.maxworkers = str(self._spn_workers.value())
        section.overwrite = str(self._chk_overwrite.isChecked())

        settings.write()

        event.accept()

    def addAvailableOptions(self, options):
        self._lst_available.model().addOptions(options)

    def removeAvailableOptions(self, options):
        self._lst_available.model().removeOptions(options)

    def clearAvailableOptions(self):
        self._lbl_available.model().clearOptions()

    def start(self, outputdir, overwrite, max_workers):
        self._runner = LocalRunner(outputdir=outputdir,
                                   overwrite=overwrite,
                                   max_workers=max_workers)

        self._tbl_options.setModel(_StateOptionsTableModel(self._runner))

        self._spn_workers.setEnabled(False)
        self._txt_outputdir.setEnabled(False)
        self._chk_overwrite.setEnabled(False)
        self._btn_addtoqueue.setEnabled(True)
        self._btn_addalltoqueue.setEnabled(True)
        self._btn_start.setEnabled(False)
        self._btn_cancel.setEnabled(True)
        self._btn_close.setEnabled(False)
        self._btn_import.setEnabled(True)

        self._runner.options_added.connect(self.options_added.emit)
        self._runner.options_running.connect(self.options_running.emit)
        self._runner.options_simulated.connect(self.options_simulated.emit)
        self._runner.options_error.connect(self.options_error.emit)
        self._runner.results_saved.connect(self.results_saved.emit)
        self._runner.results_error.connect(self.results_error.emit)

        self._running_timer.start()
        self._runner.start()

    def cancel(self):
        if self._runner is None:
            return
        self._runner.cancel()
        self._running_timer.stop()

        self._runner.options_added.disconnect(self.options_added.emit)
        self._runner.options_running.disconnect(self.options_running.emit)
        self._runner.options_simulated.disconnect(self.options_simulated.emit)
        self._runner.options_error.disconnect(self.options_error.emit)
        self._runner.results_saved.disconnect(self.results_saved.emit)
        self._runner.results_error.disconnect(self.results_error.emit)

        self._runner = None

        self._spn_workers.setEnabled(True)
        self._txt_outputdir.setEnabled(True)
        self._chk_overwrite.setEnabled(True)
        self._btn_addtoqueue.setEnabled(False)
        self._btn_addalltoqueue.setEnabled(False)
        self._btn_start.setEnabled(True)
        self._btn_cancel.setEnabled(False)
        self._btn_close.setEnabled(True)
        self._btn_import.setEnabled(False)

    def is_running(self):
        return self._runner is not None and self._runner.is_alive()
Пример #10
0
class _PenepmaConfigurePanelWidget(_ConfigurePanelWidget):
    def _initUI(self):
        # Widgets
        self._brw_pendbase = DirBrowseWidget()

        self._brw_exe = FileBrowseWidget()
        if os.name == 'nt':
            self._brw_exe.setNameFilter('Application files (*.exe)')
        else:
            self._brw_exe.setNameFilter('Application files (*)')

        self._spn_dumpp = QSpinBox()
        self._spn_dumpp.setMinimum(30)
        self._spn_dumpp.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed)

        # Layouts
        layout = _ConfigurePanelWidget._initUI(self)
        layout.addRow("Path to pendbase directory", self._brw_pendbase)
        layout.addRow('Path to PENEPMA executable', self._brw_exe)
        layout.addRow('Interval between dump (s)', self._spn_dumpp)

        # Signals
        self._brw_pendbase.pathChanged.connect(self._onPathChanged)
        self._brw_exe.pathChanged.connect(self._onPathChanged)

        return layout

    def _onPathChanged(self, path):
        if not path:
            return
        if not self._brw_pendbase.baseDir():
            self._brw_pendbase.setBaseDir(path)
        if not self._brw_exe.baseDir():
            self._brw_exe.setBaseDir(path)

    def hasAcceptableInput(self):
        if not self._brw_pendbase.path():
            return False
        if not self._brw_exe.path():
            return False
        if not os.access(self._brw_exe.path(), os.X_OK):
            return False
        return True

    def setSettings(self, settings):
        if 'penepma' in settings:
            path = getattr(settings.penepma, 'pendbase', None)
            try:
                self._brw_pendbase.setPath(path)
            except ValueError:
                pass

            path = getattr(settings.penepma, 'exe', None)
            try:
                self._brw_exe.setPath(path)
            except ValueError:
                pass

            try:
                dumpp = int(getattr(settings.penepma, 'dumpp', 30))
                self._spn_dumpp.setValue(dumpp)
            except (TypeError, ValueError):
                pass

    def updateSettings(self, settings):
        section = _ConfigurePanelWidget.updateSettings(self, settings)
        section.pendbase = self._brw_pendbase.path()
        section.exe = self._brw_exe.path()
        section.dumpp = int(self._spn_dumpp.value())
        return section
Пример #11
0
class _MonacoConfigurePanelWidget(_ConfigurePanelWidget):
    def _initUI(self):
        # Widgets
        self._brw_basedir = DirBrowseWidget()

        self._brw_exe = FileBrowseWidget()
        if os.name == 'nt':
            self._brw_exe.setNameFilter('Application files (*.exe)')
        else:
            self._brw_exe.setNameFilter('Application files (*)')

        # Layouts
        layout = _ConfigurePanelWidget._initUI(self)
        layout.addRow('Full path to base directory', self._brw_basedir)
        layout.addRow('Full path to Mccli32.exe (optional)', self._brw_exe)

        # Signals
        self._brw_basedir.pathChanged.connect(self._onPathChanged)
        self._brw_exe.pathChanged.connect(self._onPathChanged)

        return layout

    def _onPathChanged(self, path):
        if not path:
            return
        if not self._brw_basedir.baseDir():
            self._brw_basedir.setBaseDir(path)
        if not self._brw_exe.baseDir():
            self._brw_exe.setBaseDir(path)

    def hasAcceptableInput(self):
        basedir = self._brw_basedir.path()
        if not basedir:
            return False

        mccli32_exe = self._brw_exe.path()
        if not mccli32_exe:
            mccli32_exe = os.path.join(basedir, 'Mccli32.exe')
        if not os.path.isfile(mccli32_exe):
            return False

        return True

    def setSettings(self, settings):
        if 'monaco' in settings:
            path = getattr(settings.monaco, 'basedir', None)
            try:
                self._brw_basedir.setPath(path)
            except ValueError:
                pass

            path = getattr(settings.monaco, 'exe', None)
            try:
                self._brw_exe.setPath(path)
            except ValueError:
                pass

    def updateSettings(self, settings):
        section = _ConfigurePanelWidget.updateSettings(self, settings)
        section.basedir = self._brw_basedir.path()
        section.exe = self._brw_exe.path() or \
            os.path.join(self._brw_basedir.path(), 'Mccli32.exe')
        return section
Пример #12
0
class _MonacoConfigurePanelWidget(_ConfigurePanelWidget):

    def _initUI(self):
        # Widgets
        self._brw_basedir = DirBrowseWidget()

        self._brw_exe = FileBrowseWidget()
        if os.name == 'nt':
            self._brw_exe.setNameFilter('Application files (*.exe)')
        else:
            self._brw_exe.setNameFilter('Application files (*)')

        # Layouts
        layout = _ConfigurePanelWidget._initUI(self)
        layout.addRow('Full path to base directory', self._brw_basedir)
        layout.addRow('Full path to Mccli32.exe (optional)', self._brw_exe)

        # Signals
        self._brw_basedir.pathChanged.connect(self._onPathChanged)
        self._brw_exe.pathChanged.connect(self._onPathChanged)

        return layout

    def _onPathChanged(self, path):
        if not path:
            return
        if not self._brw_basedir.baseDir():
            self._brw_basedir.setBaseDir(path)
        if not self._brw_exe.baseDir():
            self._brw_exe.setBaseDir(path)

    def hasAcceptableInput(self):
        basedir = self._brw_basedir.path()
        if not basedir:
            return False

        mccli32_exe = self._brw_exe.path()
        if not mccli32_exe:
            mccli32_exe = os.path.join(basedir, 'Mccli32.exe')
        if not os.path.isfile(mccli32_exe):
            return False

        return True

    def setSettings(self, settings):
        if 'monaco' in settings:
            path = getattr(settings.monaco, 'basedir', None)
            try:
                self._brw_basedir.setPath(path)
            except ValueError:
                pass

            path = getattr(settings.monaco, 'exe', None)
            try:
                self._brw_exe.setPath(path)
            except ValueError:
                pass

    def updateSettings(self, settings):
        section = _ConfigurePanelWidget.updateSettings(self, settings)
        section.basedir = self._brw_basedir.path()
        section.exe = self._brw_exe.path() or \
            os.path.join(self._brw_basedir.path(), 'Mccli32.exe')
        return section