Пример #1
0
    def _searchClicked(self):
        # Set pmrlib to go
        self._ui.searchResultsListWidget.clear()

        # fix up known terms to be full blown uri
        search_text = self._ui.searchLineEdit.text()
        search_terms = search_text.split()
        for term in search_terms:
            rdfterm = self._annotationTool.rdfFormOfTerm(term)
            if rdfterm:
                search_text = search_text + ' ' + rdfterm[1:-1]

        try:
            results = self._pmrTool.search(search_text)

            for r in results:
                if 'title' in r and r['title']:
                    item = QtGui.QListWidgetItem(
                        r['title'], self._ui.searchResultsListWidget)
                else:
                    item = QtGui.QListWidgetItem(
                        r['target'], self._ui.searchResultsListWidget)
                item.setData(QtCore.Qt.UserRole, r)
        except PMRToolError as e:
            message = convertExceptionToMessage(e)
            logger.warn('PMR Tool exception raised')
            logger.warn('Reason: {0}'.format(message))
Пример #2
0
    def execute(self):
        self._current += 1
        if self._current >= len(self._topological_order):
            self._current = -1
            if callable(self._finished_callback):
                self._finished_callback()
        else:
            # Form input requirements
            current_node = self._topological_order[self._current]
            if current_node in self._reverse_dependency_graph:
                connections = []
                for node in self._reverse_dependency_graph[current_node]:
                    # Find connection information and extract outputs from steps
                    new_connections = self._connections_for_nodes(
                        node, current_node)
                    connections.extend(
                        [c for c in new_connections if c not in connections])
                    if len(new_connections) == 0:
                        logger.critical(
                            'Connection in workflow not found, something has gone horribly wrong'
                        )
                        raise WorkflowError(
                            'Connection in workflow not found, something has gone horribly wrong'
                        )

                for connection in connections:
                    # Alternative indexing based on index of port based on type.
                    # But don't use this as it is not what is documented.
                    # source_step = connection.source()._step
                    # destination_step = current_node._step
                    # source_ports = [port for port in source_step._ports if port.hasProvides()]
                    # destination_ports = [port for port in destination_step._ports if port.hasUses()]
                    # source_data_index = source_ports.index(source_step._ports[connection.sourceIndex()])
                    # destination_data_index = destination_ports.index(destination_step._ports[connection.destinationIndex()])

                    # dataIn = source_step.getPortData(source_data_index)
                    # destination_step.setPortData(destination_data_index, dataIn)

                    dataIn = connection.source().getStep().getPortData(
                        connection.sourceIndex())
                    current_node.getStep().setPortData(
                        connection.destinationIndex(), dataIn)

            try:
                current_node.getStep().execute()
            except Exception as e:
                self._current = -1
                log_message = 'Exception caught while executing the workflow: ' + convertExceptionToMessage(
                    e)
                exc_type, exc_value, exc_traceback = sys.exc_info()
                redirect_output = FileTypeObject()
                traceback.print_exception(exc_type,
                                          exc_value,
                                          exc_traceback,
                                          file=redirect_output)
                raise WorkflowError(log_message + '\n\n' +
                                    ''.join(redirect_output.messages))
Пример #3
0
    def run(self):
        python_dir = self._virt_env_dir + '\Scripts\python.exe'
        pip_dir = self._virt_env_dir + '\Scripts\pip.exe'
        logs_dir = self._virt_env_dir[:-13] + '\logs'

        self._ui.label.setText('Searching for packages in pip index...')
        self._ui.progressBar.setMaximum(len(self._packages_to_install))
        found_packages = []
        not_found_packages = []
        for package in self._packages_to_install:
            self._ui.label.setText('Searching for "' + package +
                                   '" package...')
            try:
                output = subprocess.check_output(
                    [python_dir, pip_dir, 'search', package], shell=True)
                found_packages += [package]
            except Exception as e:
                not_found_packages += [package]
            self._ui.progressBar.setValue(self._ui.progressBar.value() + 1)

        self._ui.progressBar.reset()
        self._ui.progressBar.setMaximum(20 * len(found_packages))
        unsuccessful_installs = {}
        for package in found_packages:
            self.count += 1
            self._ui.label.setText('Installing "' + package + '" package...')
            for i in range(0, 10):
                time.sleep((random.randrange(0, 100) / 1000))
                self._ui.progressBar.setValue(self._ui.progressBar.value() +
                                              1.5)
            try:
                with open(
                        logs_dir + 'package_install_report_' + package +
                        '.log', 'w') as file_out:
                    subprocess.check_call(
                        [python_dir, pip_dir, 'install', package],
                        shell=True,
                        stdout=file_out,
                        stderr=file_out)
            except Exception as e:
                unsuccessful_installs[package] = convertExceptionToMessage(e)
                logger.warning('"' + package +
                               '" dependency could not be installed.')
                logger.warning('Reason: ' + unsuccessful_installs[package])
            for i in range(0, 5):
                time.sleep(0.004)
                self._ui.progressBar.setValue(self._ui.progressBar.value() + 1)

        while self._ui.progressBar.value() < self._ui.progressBar.maximum():
            time.sleep(0.004)
            self._ui.progressBar.setValue(self._ui.progressBar.value() + 1)

        return unsuccessful_installs
Пример #4
0
 def cancelInstallation(self):
     for i in range(0, self.count - 1):
         try:
             subprocess.check_call([
                 self._virt_env_dir + '\Scripts\python.exe',
                 self._virt_env_dir + '\Scripts\pip.exe', 'uninstall',
                 self._packages_to_install
             ],
                                   shell=True)
         except Exception as e:
             message = convertExceptionToMessage(e)
             logger.info('Could not uninstall "' +
                         self._packages_to_install[i] + '" package.')
             logger.info('Reason: ' + message)