예제 #1
0
 def init(self, project):
     """
     Create a new instance of Eddy loading the given project from the '@resources' directory.
     :type project: str
     """
     # COPY TEST PROJECT OVER
     cpdir('@tests/%s/' % project, '@tests/.tests/%s' % project)
     # CREATE AN INSTANCE OF EDDY
     arguments = [
         '--nosplash', '--tests', '--open',
         '@tests/.tests/%s' % project
     ]
     parser = ArgumentParser()
     parser.add_argument('--nosplash', dest='nosplash', action='store_true')
     parser.add_argument('--tests', dest='tests', action='store_true')
     parser.add_argument('--open', dest='open', default=None)
     options, _ = parser.parse_known_args(args=arguments)
     with LoggingDisabled():
         self.eddy = Eddy(options, arguments)
         self.eddy.configure(options)
         self.eddy.start(options)
         # WAIT FOR THE SESSION TO BE COMPLETELY INITIALIZED
         QtTest.QTest.qWaitForWindowActive(self.eddy.sessions[0])
         # SET SHORTCUTS
         self.project = self.eddy.sessions[0].project
         self.session = self.eddy.sessions[0]
예제 #2
0
def main():
    """
    Application entry point.
    """
    parser = ArgumentParser()
    parser.add_argument('--nosplash', dest='nosplash', action='store_true')
    parser.add_argument('--tests', dest='tests', action='store_true')
    parser.add_argument('--open', dest='open', default=None)

    sys.excepthook = base_except_hook

    options, _ = parser.parse_known_args(args=sys.argv)

    global app
    app = Eddy(options, sys.argv)
    if app.isRunning():
        sys.exit(0)

    LOGGER.separator(separator='-')
    LOGGER.frame('%s v%s', APPNAME, VERSION, separator='|')
    LOGGER.frame(COPYRIGHT, separator='|')
    LOGGER.separator(separator='-')
    LOGGER.frame('OS: %s %s', platform.system(), platform.release(), separator='|')
    LOGGER.frame('Python version: %s', platform.python_version(), separator='|')
    LOGGER.frame('Qt version: %s', QtCore.QT_VERSION_STR, separator='|')
    LOGGER.frame('PyQt version: %s', Qt.PYQT_VERSION_STR, separator='|')
    LOGGER.frame('SIP version: %s', SIP_VERSION_STR, separator='|')
    LOGGER.separator(separator='-')

    app.configure(options)
    app.start(options)
    sys.exit(app.exec_())
예제 #3
0
 def setUp(self):
     """
     Initialize test case environment.
     """
     self.app = Eddy(['--nosplash', '--tests'])
     self.mainwindow = self.app.mainwindow
     self.mainwindow.snapToGrid = False
     self.mainwindow.activateWindow()
     QTest.qWaitForWindowActive(self.mainwindow)
예제 #4
0
def qapp(qapp_args, tmpdir_factory):
    """
    Overrides pytest-qt default qapp fixture to provide
    an instance of Eddy.

    You can use the ``qapp`` fixture in tests which require a ``QApplication``
    to run, but where you don't need full ``qtbot`` functionality.
    """
    app = QtWidgets.QApplication.instance()
    if app is None:
        global _qapp_instance
        os.environ['JAVA_HOME'] = findJavaHome() or ''

        if sys.platform.startswith('win'):
            path = os.getenv('PATH', '')
            path = path.split(os.pathsep)
            path.insert(0, os.path.join(os.environ['JAVA_HOME'], 'jre', 'bin'))
            if platform.architecture()[0] == '32bit':
                path.insert(
                    0,
                    os.path.join(os.environ['JAVA_HOME'], 'jre', 'bin',
                                 'client'))
            else:
                path.insert(
                    0,
                    os.path.join(os.environ['JAVA_HOME'], 'jre', 'bin',
                                 'server'))
            os.environ['PATH'] = os.pathsep.join(path)

        for path in pkg_resources.resource_listdir(eddy.core.jvm.__name__,
                                                   'lib'):
            if File.forPath(path) is File.Jar:
                addJVMClasspath(
                    pkg_resources.resource_filename(eddy.core.jvm.__name__,
                                                    os.path.join('lib', path)))
        # noinspection PyTypeChecker
        addJVMOptions('-ea', '-Xmx512m')

        workspace_tmpdir = tmpdir_factory.mktemp('settings')
        QtCore.QSettings.setPath(QtCore.QSettings.NativeFormat,
                                 QtCore.QSettings.UserScope,
                                 str(workspace_tmpdir))
        settings = QtCore.QSettings(ORGANIZATION, APPNAME)
        settings.setValue('workspace/home', str(workspace_tmpdir))
        settings.setValue('update/check_on_startup', False)

        argparser = getArgumentParser()
        options, args = argparser.parse_known_args(qapp_args)
        _qapp_instance = Eddy(options, args)
        _qapp_instance.configure(options)
        yield _qapp_instance
    else:
        yield app
예제 #5
0
def main():
    """
    Application entry point.
    """
    global app
    sys.excepthook = base_except_hook
    app = Eddy(sys.argv)

    if app.isRunning:
        # If the application is already running in another process send a message to the
        # process containing all the sys.argv elements joined into a string. This will
        # cause the other process to activate itself and handle the received message.
        app.sendMessage(' '.join(sys.argv))
        sys.exit(0)

    sys.exit(app.exec_())