Beispiel #1
0
def session(qapp, qtbot, logging_disabled):
    """
    Provide an initialized Session instance.
    """
    with logging_disabled:
        session = Session(qapp, expandPath('@tests/test_project_3/test_project_3_1.graphol'))
        session.show()
    qtbot.addWidget(session)
    qtbot.waitExposed(session, timeout=3000)
    with qtbot.waitSignal(session.sgnDiagramFocused):
        session.sgnFocusDiagram.emit(session.project.diagram('diagram'))
    yield session
def session(qapp, qtbot, logging_disabled):
    """
    Provide an initialized Session instance.
    """
    with logging_disabled:
        # SCAN FOR PLUGIN
        PluginManager.scan(os.path.abspath(os.path.normpath(os.path.join(os.curdir, os.pardir))))
        # CREATE EDDY SESSION
        session = Session(qapp, expandPath(os.path.join(basepath, 'tests', 'test_books')))
        session.show()
    qtbot.addWidget(session)
    qtbot.waitExposed(session, timeout=3000)
    with qtbot.waitSignal(session.sgnDiagramFocused):
        session.sgnFocusDiagram.emit(session.project.diagram('books'))
    yield session
Beispiel #3
0
    def doCreateSessionFromScratch(self, projName, ontIri, ontPrefix):
        """
        Create a session for a new brand project.
        """
        for session in self.sessions:
            # Look among the active sessions and see if we already have
            # a session loaded for the given project: if so, focus it.
            if not session.project.path and session.project.name == projName and session.project.ontologyIRI == ontIri:
                session.show()
                break
        else:
            # If we do not have a session for the given project we'll create one.
            with BusyProgressDialog('Creating new project with name: {0}'.format(projName)):
                try:
                    session = Session(self, path=None, projName=projName, ontIri=ontIri, ontPrefix=ontPrefix)
                except ProjectStopLoadingError:
                    pass
                except Exception as e:
                    LOGGER.warning('Failed to create session for new project : %s',  e)
                    msgbox = QtWidgets.QMessageBox()
                    msgbox.setIconPixmap(QtGui.QIcon(':/icons/48/ic_error_outline_black').pixmap(48))
                    msgbox.setText('Failed to create session for new project')
                    msgbox.setTextFormat(QtCore.Qt.RichText)
                    msgbox.setDetailedText(format_exception(e))
                    msgbox.setStandardButtons(QtWidgets.QMessageBox.Close)
                    msgbox.setWindowIcon(QtGui.QIcon(':/icons/128/ic_eddy'))
                    msgbox.setWindowTitle('Project Error!')
                    msgbox.exec_()
                else:

                    #############################################
                    # CLOSE THE WELCOME SCREEN IF NECESSARY
                    #################################

                    try:
                        self.welcome.close()
                    except (AttributeError, RuntimeError):
                        pass

                    #############################################
                    # STARTUP THE SESSION
                    #################################

                    connect(session.sgnQuit, self.doQuit)
                    connect(session.sgnClosed, self.onSessionClosed)
                    self.sessions.append(session)
                    self.sgnSessionCreated.emit(session)
                    session.show()
Beispiel #4
0
    def doCreateSession(self, path):
        """
        Create a session using the given project path.
        :type path: str
        """
        for session in self.sessions:
            # Look among the active sessions and see if we already have
            # a session loaded for the given project: if so, focus it.
            if session.project.path == path:
                session.show()
                break
        else:
            # If we do not have a session for the given project we'll create one.
            with BusyProgressDialog('Loading project: {0}'.format(
                    os.path.basename(path))):

                try:
                    session = Session(self, path)
                except ProjectStopLoadingError:
                    pass
                except (ProjectNotFoundError, ProjectNotValidError,
                        ProjectVersionError) as e:
                    LOGGER.warning(
                        'Failed to create session for project %s: %s', path, e)
                    msgbox = QtWidgets.QMessageBox()
                    msgbox.setIconPixmap(
                        QtGui.QIcon(
                            ':/icons/48/ic_error_outline_black').pixmap(48))
                    msgbox.setText(
                        'Failed to create session for project: <b>{0}</b>!'.
                        format(os.path.basename(path)))
                    msgbox.setTextFormat(QtCore.Qt.RichText)
                    msgbox.setDetailedText(format_exception(e))
                    msgbox.setStandardButtons(QtWidgets.QMessageBox.Close)
                    msgbox.setWindowIcon(QtGui.QIcon(':/icons/128/ic_eddy'))
                    msgbox.setWindowTitle('Project Error!')
                    msgbox.exec_()
                except Exception as e:
                    raise e
                else:

                    #############################################
                    # UPDATE RECENT PROJECTS
                    #################################

                    settings = QtCore.QSettings(ORGANIZATION, APPNAME)
                    projects = settings.value('project/recent', None,
                                              str) or []

                    try:
                        projects.remove(path)
                    except ValueError:
                        pass
                    finally:
                        projects.insert(0, path)
                        projects = projects[:8]
                        settings.setValue('project/recent', projects)
                        settings.sync()

                    #############################################
                    # CLOSE THE WELCOME SCREEN IF NECESSARY
                    #################################

                    try:
                        self.welcome.close()
                    except (AttributeError, RuntimeError):
                        pass

                    #############################################
                    # STARTUP THE SESSION
                    #################################

                    connect(session.sgnQuit, self.doQuit)
                    connect(session.sgnClosed, self.onSessionClosed)
                    self.sessions.append(session)
                    session.show()
Beispiel #5
0
 def doCreateSession(self, path):
     """
     Create a session using the given project path.
     :type path: str
     """
     for session in self.sessions:
         # Look among the active sessions and see if we already have
         # a session loaded for the given project: if so, focus it.
         if session.project.path == path:
             session.show()
             break
     else:
         # If we do not have a session for the given project we'll create one.
         with BusyProgressDialog('Loading project: {0}'.format(os.path.basename(path))):
 
             try:
                 session = Session(self, path)
             except ProjectStopLoadingError:
                 pass
             except (ProjectNotFoundError, ProjectNotValidError, ProjectVersionError) as e:
                 LOGGER.warning('Failed to create session for project %s: %s', path, e)
                 msgbox = QtWidgets.QMessageBox()
                 msgbox.setIconPixmap(QtGui.QIcon(':/icons/48/ic_error_outline_black').pixmap(48))
                 msgbox.setText('Failed to create session for project: <b>{0}</b>!'.format(os.path.basename(path)))
                 msgbox.setTextFormat(QtCore.Qt.RichText)
                 msgbox.setDetailedText(format_exception(e))
                 msgbox.setStandardButtons(QtWidgets.QMessageBox.Close)
                 msgbox.setWindowIcon(QtGui.QIcon(':/icons/128/ic_eddy'))
                 msgbox.setWindowTitle('Project Error!')
                 msgbox.exec_()
             except Exception as e:
                 raise e
             else:
                 
                 #############################################
                 # UPDATE RECENT PROJECTS
                 #################################
 
                 settings = QtCore.QSettings(ORGANIZATION, APPNAME)
                 projects = settings.value('project/recent', None, str) or []
 
                 try:
                     projects.remove(path)
                 except ValueError:
                     pass
                 finally:
                     projects.insert(0, path)
                     projects = projects[:8]
                     settings.setValue('project/recent', projects)
                     settings.sync()
 
                 #############################################
                 # CLOSE THE WELCOME SCREEN IF NECESSARY
                 #################################
 
                 try:
                     self.welcome.close()
                 except (AttributeError, RuntimeError):
                     pass
 
                 #############################################
                 # STARTUP THE SESSION
                 #################################
                 
                 connect(session.sgnQuit, self.doQuit)
                 connect(session.sgnClosed, self.onSessionClosed)
                 self.sessions.append(session)
                 session.show()