def start(self): try: installed, path = check_if_kite_installed() if not installed: return logger.debug('Kite was found on the system: {0}'.format(path)) running = check_if_kite_running() if running: return logger.debug('Starting Kite service...') self.kite_process = run_program(path) except OSError: installed, path = check_if_kite_installed() logger.debug( 'Error starting Kite service at {path}...'.format(path=path)) if self.get_conf('show_installation_error_message'): err_str = _("It seems that your Kite installation is faulty. " "If you want to use Kite, please remove the " "directory that appears bellow, " "and try a reinstallation:<br><br>" "<code>{kite_dir}</code>").format( kite_dir=osp.dirname(path)) dialog_wrapper = KiteInstallationErrorMessage.instance( err_str, self.set_conf) self.sig_show_widget.emit(dialog_wrapper) finally: # Always start client to support possibly undetected Kite builds self.client.start()
def __init__(self, textedit, ancestor): super(KiteCallToAction, self).__init__(ancestor) self.textedit = textedit self.setFrameStyle(QFrame.StyledPanel | QFrame.Plain) self.setAutoFillBackground(True) self.setWindowFlags(Qt.SubWindow | Qt.FramelessWindowHint) self.setFocusPolicy(Qt.NoFocus) if is_dark_interface(): self.setObjectName("kite-call-to-action") self.setStyleSheet(self.styleSheet() + ( "#kite-call-to-action " "{{ border: 1px solid; " " border-color: {border_color}; " " border-radius: 4px;}} " "#kite-call-to-action:hover " "{{ border:1px solid {border}; }}" ).format(border_color=QStylePalette.COLOR_BACKGROUND_4, border=QStylePalette.COLOR_ACCENT_4)) # sub-layout: horizontally aligned links actions = QFrame(self) actions_layout = QHBoxLayout() actions_layout.setContentsMargins(5, 5, 5, 5) actions_layout.setSpacing(10) actions_layout.addStretch() actions.setLayout(actions_layout) self._install_button = QPushButton(_("Install Kite")) self._learn_button = QPushButton(_("Learn More")) self._dismiss_button = QPushButton(_("Dismiss Forever")) self._install_button.clicked.connect(self._install_kite) self._learn_button.clicked.connect(self._learn_more) self._dismiss_button.clicked.connect(self._dismiss_forever) actions_layout.addWidget(self._install_button) actions_layout.addWidget(self._learn_button) actions_layout.addWidget(self._dismiss_button) # main layout: message + horizontally aligned links main_layout = QVBoxLayout() main_layout.setContentsMargins(5, 5, 5, 5) self.setLayout(main_layout) self.label = QLabel(self) self.label.setWordWrap(True) main_layout.addWidget(self.label) main_layout.addWidget(actions) main_layout.addStretch() self._enabled = CONF.get('completions', 'kite_call_to_action') self._escaped = False self.hide() is_kite_installed, __ = check_if_kite_installed() if is_kite_installed: self._dismiss_forever()
def setup_menus(self): is_kite_installed, kite_path = check_if_kite_installed() if not is_kite_installed: install_kite_action = self.create_action( KiteProviderActions.Installation, _("Install Kite completion engine"), icon=ima.get_icon('kite', adjust_for_interface=True), triggered=self.show_kite_installation) self.add_item_to_application_menu(install_kite_action, menu_id=ApplicationMenus.Tools, section=ToolsMenuSections.Tools)
def setup_menus(self): is_kite_installed, kite_path = check_if_kite_installed() if not is_kite_installed: install_kite_action = self.create_action( KiteProviderActions.Installation, _("Install Kite completion engine"), icon=ima.icon('kite'), triggered=self.show_kite_installation) self.add_item_to_application_menu( install_kite_action, menu_id=ApplicationMenus.Tools, section=ToolsMenuSections.External, before_section=ToolsMenuSections.Extras)
def __init__(self, parent, provider): self.provider = provider self.tooltip = self.BASE_TOOLTIP self.installation_thread = KiteInstallationThread(self) super().__init__(parent) is_installed, _ = check_if_kite_installed() self.setVisible(is_installed) # Installation dialog self.installer = KiteInstallerDialog(self, self.installation_thread) self.installation_thread.sig_installation_status.connect( self.set_value) self.sig_clicked.connect(self.show_installation_dialog)
def run(self): """Execute the installation task.""" is_kite_installed, installation_path = check_if_kite_installed() if is_kite_installed: self._change_installation_status(status=FINISHED) else: try: path, http_response = self._download_installer_or_script() self._execute_installer_or_script(path) except KiteInstallationCancelledException: self._change_installation_status(status=CANCELLED) except Exception as error: self._change_installation_status(status=ERRORED) logger.debug( "Installation error: {0}".format(to_text_string(error))) self.sig_error_msg.emit(to_text_string(error)) return
def test_kite_install(qtbot): """Test the correct execution of the installation process of kite.""" install_manager = KiteInstallationThread(None) installation_statuses = [] def installation_status(status): installation_statuses.append(status) def error_msg(error): # Should not enter here assert False def download_progress(progress, total): assert total != 0 def finished(): if sys.platform.startswith("linux"): expected_installation_status = [ DOWNLOADING_SCRIPT, DOWNLOADING_INSTALLER, INSTALLING, FINISHED] else: expected_installation_status = [ DOWNLOADING_INSTALLER, INSTALLING, FINISHED] # This status can be obtained the second time our tests are run if not installation_statuses == ['Installation finished']: assert installation_statuses == expected_installation_status install_manager.sig_installation_status.connect(installation_status) install_manager.sig_error_msg.connect(error_msg) install_manager.sig_download_progress.connect(download_progress) install_manager.finished.connect(finished) with qtbot.waitSignal(install_manager.finished, timeout=INSTALL_TIMEOUT): install_manager.install() # Check that kite was installed and is running qtbot.waitUntil( lambda: check_if_kite_installed() and check_if_kite_running(), timeout=5000)
def completion_plugin_all_started(request, qtbot_module, completion_plugin_all): completion_plugin = completion_plugin_all os.environ['SPY_TEST_USE_INTROSPECTION'] = 'True' completion_plugin.wait_for_ms = 20000 completion_plugin.start_all_providers() kite_installed, _ = check_if_kite_installed() total_providers = 3 + int(kite_installed) def wait_until_all_started(): all_started = True for provider in completion_plugin.providers: if provider == 'kite' and not kite_installed: continue provider_info = completion_plugin.providers[provider] all_started &= provider_info['status'] == completion_plugin.RUNNING return all_started qtbot_module.waitUntil(wait_until_all_started, timeout=30000) with qtbot_module.waitSignal( completion_plugin.sig_language_completions_available, timeout=30000) as blocker: completion_plugin.start_completion_services_for_language('python') capabilities, _ = blocker.args def teardown(): os.environ['SPY_TEST_USE_INTROSPECTION'] = 'False' completion_plugin.stop_all_providers() request.addfinalizer(teardown) return completion_plugin, capabilities
cursor = code_editor.textCursor() cursor.movePosition(QTextCursor.StartOfBlock) cursor.movePosition(QTextCursor.EndOfBlock, mode=QTextCursor.KeepAnchor) text1 = cursor.selectedText() assert text1 == 'test_func(longer, y1, some_z)' CONF.set('completions', 'enable_code_snippets', False) completion_plugin.after_configuration_update([]) code_editor.toggle_automatic_completions(True) code_editor.toggle_code_snippets(True) @pytest.mark.slow @pytest.mark.skipif((not check_if_kite_installed() or not check_if_kite_running()), reason="It's not meant to be run without kite installed " "and running") def test_kite_code_snippets(kite_codeeditor, qtbot): """ Test kite code snippets completions without initial placeholder. See spyder-ide/spyder#10971 """ code_editor, kite = kite_codeeditor completion = code_editor.completion_widget snippets = code_editor.editor_extensions.get('SnippetsExtension') CONF.set('lsp-server', 'code_snippets', True) CONF.set('kite', 'enable', True)
def show_installation_dialog(self): """Show installation dialog.""" installed, path = check_if_kite_installed() if not installed and not running_under_pytest(): self.installer.show()
cursor = code_editor.textCursor() cursor.movePosition(QTextCursor.StartOfBlock) cursor.movePosition(QTextCursor.EndOfBlock, mode=QTextCursor.KeepAnchor) text1 = cursor.selectedText() assert text1 == 'test_func(longer, y1, some_z)' CONF.set('completions', 'enable_code_snippets', False) completion_plugin.after_configuration_update([]) code_editor.toggle_automatic_completions(True) code_editor.toggle_code_snippets(True) @pytest.mark.slow @pytest.mark.skipif( (not check_if_kite_installed() or not check_if_kite_running()), reason="It's not meant to be run without kite installed " "and running") def test_kite_code_snippets(kite_codeeditor, qtbot): """ Test kite code snippets completions without initial placeholder. See spyder-ide/spyder#10971 """ code_editor, kite = kite_codeeditor completion = code_editor.completion_widget snippets = code_editor.editor_extensions.get('SnippetsExtension') CONF.set('lsp-server', 'code_snippets', True) CONF.set('kite', 'enable', True) code_editor.toggle_automatic_completions(False)
cursor = code_editor.textCursor() cursor.movePosition(QTextCursor.StartOfBlock) cursor.movePosition(QTextCursor.EndOfBlock, mode=QTextCursor.KeepAnchor) text1 = cursor.selectedText() assert text1 == 'test_func(longer, y1, some_z)' CONF.set('completions', 'enable_code_snippets', False) completion_plugin.after_configuration_update([]) code_editor.toggle_automatic_completions(True) code_editor.toggle_code_snippets(True) @pytest.mark.slow @pytest.mark.skipif((not rtree_available or not check_if_kite_installed() or not check_if_kite_running()), reason="Only works if rtree is installed." "It's not meant to be run without kite installed " "and running") def test_kite_code_snippets(kite_codeeditor, qtbot): """ Test kite code snippets completions without initial placeholder. See spyder-ide/spyder#10971 """ assert rtree_available code_editor, kite = kite_codeeditor completion = code_editor.completion_widget snippets = code_editor.editor_extensions.get('SnippetsExtension')