def _show_installation_dialog(self): """Show installation dialog.""" kite_installation_enabled = self.get_option('show_installation_dialog') installed, path = check_if_kite_installed() if (not installed and kite_installation_enabled and not running_under_pytest()): self.kite_installer.show() self.kite_installer.center()
def start(self): installed, path = check_if_kite_installed() if installed: logger.debug('Kite was found on the system: {0}'.format(path)) running = check_if_kite_running() if not running: logger.debug('Starting Kite service...') self.kite_process = run_program(path) self.client.start()
def start(self): try: if not self.enabled: return 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_option('show_installation_error_message'): box = MessageCheckBox(icon=QMessageBox.Critical, parent=self.main) box.setWindowTitle(_("Kite installation error")) box.set_checkbox_text(_("Don't show again.")) box.setStandardButtons(QMessageBox.Ok) box.setDefaultButton(QMessageBox.Ok) box.set_checked(False) box.set_check_visible(True) box.setText( _("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))) box.exec_() # Update checkbox based on user interaction self.set_option('show_installation_error_message', not box.is_checked()) finally: # Always start client to support possibly undetected Kite builds self.client.start()
def __init__(self, parent, statusbar, plugin): self.plugin = plugin self.tooltip = self.BASE_TOOLTIP super(KiteStatusWidget, self).__init__(parent, statusbar, icon=ima.get_icon('kite', adjust_for_interface=True)) is_installed, _ = check_if_kite_installed() self.setVisible(is_installed)
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: #32414B; " " border-radius: 4px;} " "#kite-call-to-action:hover " "{ border:1px solid #148CD2; }")) # 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('kite', 'call_to_action') self._escaped = False self.hide() is_kite_installed, __ = check_if_kite_installed() if is_kite_installed: self._dismiss_forever()
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=self.FINISHED) else: try: path, http_response = self._download_installer_or_script() self._execute_installer_or_script(path) except Exception as error: self._change_installation_status(status=self.ERRORED) self.sig_error_msg.emit(to_text_string(error)) return
def start(self): # Always start client to support possibly undetected Kite builds self.client.start() if not self.enabled: return 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)
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)
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('lsp-server', 'code_snippets', False) lsp.update_configuration() 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 runnning") 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')
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('lsp-server', 'code_snippets', False) lsp.update_configuration() 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')
def __init__(self, parent, plugin): self.plugin = plugin self.tooltip = self.BASE_TOOLTIP super().__init__(parent) is_installed, _ = check_if_kite_installed() self.setVisible(is_installed)