Example #1
0
 def OnInit(self):
     # Needed for SetToolTipString to work
     wx.HelpProvider.Set(wx.SimpleHelpProvider())  # TODO adjust to wx versions 
     self.settings = RideSettings()
     librarydatabase.initialize_database()
     self.preferences = Preferences(self.settings)
     self.namespace = Namespace(self.settings)
     self._controller = Project(self.namespace, self.settings)
     self.frame = RideFrame(self, self._controller)
     self._editor_provider = EditorProvider()
     self._plugin_loader = PluginLoader(self, self._get_plugin_dirs(),
                                        coreplugins.get_core_plugins())
     self._plugin_loader.enable_plugins()
     self.frame.Show()
     self.editor = self._get_editor()
     self._load_data()
     self.frame.tree.populate(self.model)
     self.frame.tree.set_editor(self.editor)
     self._find_robot_installation()
     self._publish_system_info()
     if self._updatecheck:
         UpdateNotifierController(
             self.settings).notify_update_if_needed(UpdateDialog)
     wx.CallLater(200, ReleaseNotes(self).bring_to_front)
     return True
Example #2
0
 def OnInit(self):
     # DEBUG To test RTL
     # self._initial_locale = wx.Locale(wx.LANGUAGE_ARABIC)
     self._initial_locale = wx.Locale(wx.LANGUAGE_ENGLISH)
     # Needed for SetToolTipString to work
     wx.HelpProvider.Set(
         wx.SimpleHelpProvider())  # TODO adjust to wx versions
     self.settings = RideSettings()
     librarydatabase.initialize_database()
     self.preferences = Preferences(self.settings)
     self.namespace = Namespace(self.settings)
     self._controller = Project(self.namespace, self.settings)
     self.frame = RideFrame(self, self._controller)
     self._editor_provider = EditorProvider()
     self._plugin_loader = PluginLoader(self, self._get_plugin_dirs(),
                                        coreplugins.get_core_plugins())
     self._plugin_loader.enable_plugins()
     self.treeplugin = TreePlugin(self)
     self.treeplugin.register_frame(self.frame)
     self.fileexplorerplugin = FileExplorerPlugin(self, self._controller)
     self.fileexplorerplugin.register_frame(self.frame)
     self.frame.Show()
     if not self.treeplugin.opened:
         self.treeplugin.close_tree()
     if not self.fileexplorerplugin.opened:
         self.fileexplorerplugin.close_tree()
     self.editor = self._get_editor()
     self._load_data()
     self.treeplugin.populate(self.model)
     self.treeplugin.set_editor(self.editor)
     self._find_robot_installation()
     self._publish_system_info()
     perspective = self.settings.get('AUI Perspective', None)
     if perspective:
         self.frame._mgr.LoadPerspective(perspective, True)
     if self._updatecheck:
         UpdateNotifierController(
             self.settings).notify_update_if_needed(UpdateDialog)
     wx.CallLater(200, ReleaseNotes(self).bring_to_front)
     wx.CallLater(200, self.fileexplorerplugin._update_tree)
     return True
Example #3
0
 def OnInit(self):
     self.settings = RideSettings()
     librarydatabase.initialize_database()
     self.preferences = Preferences(self.settings)
     self.namespace = Namespace(self.settings)
     self._controller = Project(self.namespace, self.settings)
     self.frame = RideFrame(self, self._controller)
     self._editor_provider = EditorProvider()
     self._plugin_loader = PluginLoader(self, self._get_plugin_dirs(),
                                        context.get_core_plugins())
     self._plugin_loader.enable_plugins()
     self.editor = self._get_editor()
     self.editor.show()
     self._load_data()
     self.frame.tree.populate(self.model)
     self.frame.tree.set_editor(self.editor)
     self._publish_system_info()
     if self._updatecheck:
         UpdateNotifierController(self.settings).notify_update_if_needed(UpdateDialog)
     wx.CallLater(200, ReleaseNotes(self).bring_to_front)
     return True
Example #4
0
 def __init__(self, random, path):
     print 'librarydatabase.initialize_database()'
     print librarydatabase.initialize_database()
     print 'settings = RideSettings()'
     print 'project = Project(Namespace(settings=settings), settings=settings)'
     settings = RideSettings()
     self._project = Project(Namespace(settings=settings),
                             settings=settings)
     self._path = path
     self._suite = None
     self._test = None
     self._keyword = None
     self._random = random
     self._skip = False
Example #5
0
 def OnInit(self):
     self.settings = RideSettings()
     self.preferences = Preferences(self.settings)
     self.namespace = Namespace(self.settings)
     self._controller = ChiefController(self.namespace, self.settings)
     self.frame = RideFrame(self, self._controller)
     self._editor_provider = EditorProvider()
     self._plugin_loader = PluginLoader(self, self._get_plugin_dirs(),
                                        context.get_core_plugins())
     self._plugin_loader.enable_plugins()
     self.editor = self._get_editor()
     self.editor.show()
     self._load_data()
     self.frame.tree.populate(self.model)
     self.frame.tree.set_editor(self.editor)
     self._publish_system_info()
     if self._updatecheck:
         UpdateNotifierController(self.settings).notify_update_if_needed(UpdateDialog)
     wx.CallLater(200, ReleaseNotes(self).bring_to_front)
     return True
Example #6
0
class RIDE(wx.App):

    def __init__(self, path=None, updatecheck=True):
        self._initial_path = path
        self._updatecheck = updatecheck
        context.APP = self
        wx.App.__init__(self, redirect=False)

    def OnInit(self):
        # Needed for SetToolTipString to work
        wx.HelpProvider_Set(wx.SimpleHelpProvider())
        self.settings = RideSettings()
        librarydatabase.initialize_database()
        self.preferences = Preferences(self.settings)
        self.namespace = Namespace(self.settings)
        self._controller = Project(self.namespace, self.settings)
        self.frame = RideFrame(self, self._controller)
        self._editor_provider = EditorProvider()
        self._plugin_loader = PluginLoader(self, self._get_plugin_dirs(),
                                           coreplugins.get_core_plugins())
        self._plugin_loader.enable_plugins()
        self.editor = self._get_editor()
        self.editor.show()
        self._load_data()
        self.frame.tree.populate(self.model)
        self.frame.tree.set_editor(self.editor)
        self._publish_system_info()
        if self._updatecheck:
            UpdateNotifierController(self.settings).notify_update_if_needed(UpdateDialog)
        wx.CallLater(200, ReleaseNotes(self).bring_to_front)
        return True

    def _publish_system_info(self):
        RideLogMessage(context.SYSTEM_INFO).publish()

    @property
    def model(self):
        return self._controller

    def _get_plugin_dirs(self):
        return [self.settings.get_path('plugins'),
                os.path.join(self.settings['install root'], 'site-plugins'),
                contrib.CONTRIB_PATH]

    def _get_editor(self):
        from robotide.editor import EditorPlugin
        for pl in self._plugin_loader.plugins:
            if isinstance(pl._plugin, EditorPlugin):
                return pl._plugin

    def _load_data(self):
        path = self._initial_path or self._get_latest_path()
        if path:
            with self.active_event_loop():
                observer = LoadProgressObserver(self.frame)
                self._controller.load_data(path, observer)

    def _get_latest_path(self):
        recent = self._get_recentfiles_plugin()
        if not recent or not recent.recent_files:
            return None
        return recent.recent_files[0]

    def _get_recentfiles_plugin(self):
        from robotide.recentfiles import RecentFilesPlugin
        for pl in self.get_plugins():
            if isinstance(pl._plugin, RecentFilesPlugin):
                return pl._plugin

    def get_plugins(self):
        return self._plugin_loader.plugins

    def register_preference_panel(self, panel_class):
        '''Add the given panel class to the list of known preference panels'''
        self.preferences.add(panel_class)

    def unregister_preference_panel(self, panel_class):
        '''Remove the given panel class from the list of known preference panels'''
        self.preferences.remove(panel_class)

    def register_editor(self, object_class, editor_class, activate):
        self._editor_provider.register_editor(object_class, editor_class,
                                              activate)

    def unregister_editor(self, object_class, editor_class):
        self._editor_provider.unregister_editor(object_class, editor_class)

    def activate_editor(self, object_class, editor_class):
        self._editor_provider.set_active_editor(object_class, editor_class)

    def get_editors(self, object_class):
        return self._editor_provider.get_editors(object_class)

    def get_editor(self, object_class):
        return self._editor_provider.get_editor(object_class)

    @contextmanager
    def active_event_loop(self):
        # With wxPython 2.9.1, ProgressBar.Pulse breaks if there's no active
        # event loop.
        # See http://code.google.com/p/robotframework-ride/issues/detail?id=798
        loop = wx.EventLoop()
        wx.EventLoop.SetActive(loop)
        yield
        del loop
Example #7
0
class RIDE(wx.App):

    def __init__(self, path=None, updatecheck=True):
        self._initial_path = path
        self._updatecheck = updatecheck
        context.APP = self
        wx.App.__init__(self, redirect=False)

    def OnInit(self):
        # Needed for SetToolTipString to work
        wx.HelpProvider.Set(wx.SimpleHelpProvider())  # TODO adjust to wx versions 
        self.settings = RideSettings()
        librarydatabase.initialize_database()
        self.preferences = Preferences(self.settings)
        self.namespace = Namespace(self.settings)
        self._controller = Project(self.namespace, self.settings)
        self.frame = RideFrame(self, self._controller)
        self._editor_provider = EditorProvider()
        self._plugin_loader = PluginLoader(self, self._get_plugin_dirs(),
                                           coreplugins.get_core_plugins())
        self._plugin_loader.enable_plugins()
        self.frame.Show()
        self.editor = self._get_editor()
        self._load_data()
        self.frame.tree.populate(self.model)
        self.frame.tree.set_editor(self.editor)
        self._find_robot_installation()
        self._publish_system_info()
        if self._updatecheck:
            UpdateNotifierController(
                self.settings).notify_update_if_needed(UpdateDialog)
        wx.CallLater(200, ReleaseNotes(self).bring_to_front)
        return True

    def _publish_system_info(self):
        publish.RideLogMessage(context.SYSTEM_INFO).publish()

    @property
    def model(self):
        return self._controller

    def _get_plugin_dirs(self):
        return [self.settings.get_path('plugins'),
                os.path.join(self.settings['install root'], 'site-plugins'),
                contrib.CONTRIB_PATH]

    def _get_editor(self):
        from robotide.editor import EditorPlugin
        for pl in self._plugin_loader.plugins:
            maybe_editor = pl._plugin
            if isinstance(maybe_editor, EditorPlugin):
                maybe_editor.show()
                return maybe_editor

    def _load_data(self):
        path = self._initial_path or self._get_latest_path()
        if path:
            observer = LoadProgressObserver(self.frame)
            self._controller.load_data(path, observer)
        """
        if path:
            with self.active_event_loop():
                # observer = LoadProgressObserver(self.frame)
                observer = None  # Avoid crash in Windows with wxPython 3
                self._controller.load_data(path, observer)
        """

    def _find_robot_installation(self):
        output = utils.run_python_command(
            ['import robot; print(robot.__file__ + \", \" + robot.__version__)'])
        if utils.PY2:
            robot_found = "ImportError" not in output and output
        else:
            robot_found = b"ModuleNotFoundError" not in output and output
        if robot_found:
            # print("DEBUG: output: %s  strip: %s" % (output, output.strip().split(b", ")))
            rf_file, rf_version = output.strip().split(b", ")
            if utils.PY2:
                publish.RideLogMessage(
                    "Found Robot Framework version %s from %s." % (
                        rf_version, os.path.dirname(rf_file))).publish()
            else:
                publish.RideLogMessage(
                    "Found Robot Framework version %s from %s." % (
                        str(rf_version, 'utf-8'),
                        str(os.path.dirname(rf_file), 'utf-8'))).publish()
            return rf_version
        else:
            publish.RideLogMessage(
                publish.get_html_message('no_robot'), notify_user=True
            ).publish()

    def _get_latest_path(self):
        recent = self._get_recentfiles_plugin()
        if not recent or not recent.recent_files:
            return None
        return recent.recent_files[0]

    def _get_recentfiles_plugin(self):
        from robotide.recentfiles import RecentFilesPlugin
        for pl in self.get_plugins():
            if isinstance(pl._plugin, RecentFilesPlugin):
                return pl._plugin

    def get_plugins(self):
        return self._plugin_loader.plugins

    def register_preference_panel(self, panel_class):
        '''Add the given panel class to the list of known preference panels'''
        self.preferences.add(panel_class)

    def unregister_preference_panel(self, panel_class):
        '''Remove the given panel class from the known preference panels'''
        self.preferences.remove(panel_class)

    def register_editor(self, object_class, editor_class, activate):
        self._editor_provider.register_editor(object_class, editor_class,
                                              activate)

    def unregister_editor(self, object_class, editor_class):
        self._editor_provider.unregister_editor(object_class, editor_class)

    def activate_editor(self, object_class, editor_class):
        self._editor_provider.set_active_editor(object_class, editor_class)

    def get_editors(self, object_class):
        return self._editor_provider.get_editors(object_class)

    def get_editor(self, object_class):
        return self._editor_provider.get_editor(object_class)

    @contextmanager
    def active_event_loop(self):
        # With wxPython 2.9.1, ProgressBar.Pulse breaks if there's no active
        # event loop.
        # See http://code.google.com/p/robotframework-ride/issues/detail?id=798
        loop = wx.EventLoop()
        wx.EventLoop.SetActive(loop)
        yield
        del loop
Example #8
0
 def test_get_path_with_three_parts(self):
     path = RideSettings().get_path('foo', 'bar', 'hello')
     expected_end = 'ride/foo/bar/hello'.replace('/', os.sep)
     self.assertTrue(path.endswith(expected_end))
Example #9
0
 def test_get_path_with_one_part(self):
     settings = RideSettings()
     self.assertTrue(
         settings.get_path('foo').endswith('ride%sfoo' % os.sep))
Example #10
0
 def test_get_path_without_parts(self):
     settings = RideSettings()
     self.assertTrue(settings.get_path().endswith('ride'))
Example #11
0
 def test_get_path_with_three_parts(self):
     path = RideSettings().get_path('foo', 'bar', 'hello')
     expected_end = 'ride/foo/bar/hello'.replace('/', os.sep)
     self.assertTrue(path.endswith(expected_end))
Example #12
0
 def test_get_path_with_one_part(self):
     settings = RideSettings()
     self.assertTrue(settings.get_path('foo').endswith('ride%sfoo' % os.sep))
Example #13
0
 def test_get_path_without_parts(self):
     settings = RideSettings()
     self.assertTrue(settings.get_path().endswith('ride'))
Example #14
0
 def test_loading_settings(self):
     settings = RideSettings()
     self.assertTrue(settings._config_obj["mainframe size"])
Example #15
0
 def test_loading_settings(self):
     settings = RideSettings()
     # print("DEBUG: RideSettings, %s", settings._config_obj.__repr__())
     # print("DEBUG: settings path %s", settings._config_obj['install root'])
     self.assertTrue(settings._config_obj['mainframe size'])