Exemple #1
0
def main():
    cmdLine = _parseCommandLine()

    profiler = _StartProfiler(cmdLine["profiling"])

    try:
        _checkDependencies(profiler)
    except ImportError:
        sys.exit(-1)

    # Imports only here. Hack for ability to get help and version info even on system without PyQt.
    import PyQt5.QtGui
    import qutepart

    logging.basicConfig(level=logging.ERROR)
    logging.getLogger('qutepart').removeHandler(qutepart.consoleHandler)

    sys.excepthook = excepthook

    app = PyQt5.QtWidgets.QApplication(sys.argv)
    app.setApplicationName(enki.core.defines.PACKAGE_NAME)
    app.setOrganizationName(enki.core.defines.PACKAGE_ORGANISATION)
    app.setOrganizationDomain(enki.core.defines.PACKAGE_URL)
    app.lastWindowClosed.connect(app.quit)

    profiler.stepDone('Construct application')

    # init the core
    from enki.core.core import core
    core.init(profiler, cmdLine)

    _openFiles(core, cmdLine, profiler)

    profiler.stepDone('Open files')

    if core.workspace().currentDocument():
        core.workspace().currentDocument().setFocus()

    core.mainWindow().loadState()
    profiler.stepDone('Load state')

    core.mainWindow().show()

    profiler.stepDone('Show main window')

    # execute application
    if profiler.enabled:
        core.workspace().forceCloseAllDocuments()
        result = 0
    else:
        result = app.exec_()

    core.term()

    profiler.printInfo()

    profiler.stepDone('Terminate core')

    return result
Exemple #2
0
def main():
    cmdLine = _parseCommandLine()

    profiler = _StartProfiler(cmdLine["profiling"])

    try:
        _checkDependencies(profiler)
    except ImportError:
        sys.exit(-1)

    # Imports only here. Hack for ability to get help and version info even on system without PyQt.
    import PyQt5.QtGui
    import qutepart

    logging.basicConfig(level=logging.ERROR)
    logging.getLogger('qutepart').removeHandler(qutepart.consoleHandler)

    sys.excepthook = excepthook

    app = PyQt5.QtWidgets.QApplication(sys.argv)
    app.setApplicationName(enki.core.defines.PACKAGE_NAME)
    app.setOrganizationName(enki.core.defines.PACKAGE_ORGANISATION)
    app.setOrganizationDomain(enki.core.defines.PACKAGE_URL)
    app.lastWindowClosed.connect(app.quit)

    profiler.stepDone('Construct application')

    # init the core
    from enki.core.core import core
    core.init(profiler, cmdLine)

    _openFiles(core, cmdLine, profiler)

    profiler.stepDone('Open files')

    if core.workspace().currentDocument():
        core.workspace().currentDocument().setFocus()

    core.mainWindow().loadState()
    profiler.stepDone('Load state')

    core.mainWindow().show()

    profiler.stepDone('Show main window')

    # execute application
    if profiler.enabled:
        core.workspace().forceCloseAllDocuments()
        result = 0
    else:
        result = app.exec_()

    core.term()

    profiler.printInfo()

    profiler.stepDone('Terminate core')

    return result
Exemple #3
0
 def blockingFunc():
     try:
         core.workspace().forceCloseAllDocuments()
         core.term()
     finally:
         try:
             QApplication.instance().processEvents()
         except:
             pass
         QApplication.instance().quit()
Exemple #4
0
 def blockingFunc():
     try:
         core.workspace().forceCloseAllDocuments()
         core.term()
     finally:
         try:
             QApplication.instance().processEvents()
         except:
             pass
         QApplication.instance().quit()
Exemple #5
0
    def tearDown(self):
        self._finished = True

        for document in core.workspace().documents():
            document.qutepart.text = ''  # clear modified flag, avoid Save Files dialog

        core.workspace().closeAllDocuments()
        core.term()
        _processPendingEvents()
        self._cleanUpFs()
Exemple #6
0
    def test_1(self):
        """ Init with current document path
        """
        path = os.path.abspath("../..")

        dock = self.findDock("&File Browser")
        dock._onVisibilityChanged(True)
        dock.setCurrentPath(path)

        core.term()
        core.init(base.DummyProfiler(), {"session_name": ""})
        dock = self.findDock("&File Browser")
        dock._onVisibilityChanged(True)

        # We can't simply do ``dock.currentPath() == path`` because of
        # Windows fun: ``u'C:/Users/bjones/AppData/Local' != 'c:\\users\\bjones\\appdata\\local'``.
        # We can't use ``os.path.samefile()`` because that's available only on
        # Unix for Python 2.7. So, use normpath and normcase per
        # http://stackoverflow.com/questions/21158667/comparing-two-paths-in-python.
        self.assertEqual(normpathcase(dock.currentPath()), normpathcase(self.TEST_FILE_DIR))
Exemple #7
0
    def test_1(self):
        """ Init with current document path
        """
        path = os.path.abspath('../..')

        dock = self.findDock('&File Browser')
        dock._onVisibilityChanged(True)
        dock.setCurrentPath(path)

        core.term()
        core.init(base.DummyProfiler(), {'session_name': '',
                                         'auto-session-name': ''})
        dock = self.findDock('&File Browser')
        dock._onVisibilityChanged(True)

        # We can't simply do ``dock.currentPath() == path`` because of
        # Windows fun: ``u'C:/Users/bjones/AppData/Local' != 'c:\\users\\bjones\\appdata\\local'``.
        # We can't use ``os.path.samefile()`` because that's available only on
        # Unix for Python 2.7. So, use normpath and normcase per
        # http://stackoverflow.com/questions/21158667/comparing-two-paths-in-python.
        self.assertEqual(normpathcase(dock.currentPath()), normpathcase(self.TEST_FILE_DIR))
Exemple #8
0
    def tearDown(self):
        self._finished = True

        for document in core.workspace().documents():
            document.qutepart.text = ''  # clear modified flag, avoid Save Files dialog

        core.workspace().closeAllDocuments()
        core.term()

        # | **Find orphaned objects**
        # | Look for any objects that are still generating signals after
        # core.term().
        #
        # \1. Process all termination-related events.
        _processPendingEvents()
        # \2. Now, print a diagnostic on any events that are still occurring.
        self.app.assertOnEvents = True
        _processPendingEvents()
        self.app.assertOnEvents = False

        self._cleanUpFs()
Exemple #9
0
 def setUp(self):
     base.TestCase.setUp(self)
     core.term()
Exemple #10
0
 def setUp(self):
     base.TestCase.setUp(self)
     core.term()
Exemple #11
0
 def tearDown(self):
     core.term()
Exemple #12
0
 def tearDown(self):
     core.term()