def get(cls, package_name: str, storage_path: str, minimum_version: SemanticVersion) -> Optional['NodeRuntime']: if cls._node_runtime_resolved: if cls._node_runtime: cls._check_node_version(cls._node_runtime, minimum_version) return cls._node_runtime cls._node_runtime_resolved = True cls._node_runtime = cls._resolve_node_runtime(package_name, storage_path, minimum_version) debug('Resolved Node Runtime for client {}: {}'.format(package_name, cls._node_runtime)) return cls._node_runtime
def on_start(self, window) -> bool: if not self.__server.ready: cmd = self.configuration.get('command')[0] debug(__package__, 'command', cmd, 'is not ready') sublime.status_message( "{}: Please install {} for the server to work.".format( __package__, cmd)) return False return True
def config(self) -> ClientConfig: settings = {} loaded_settings = sublime.load_settings(self.settings_filename) if loaded_settings: for key, default in self.DEFAULT_SETTINGS.items(): settings[key] = loaded_settings.get(key, default) self.configuration.update(settings) executable = self.__server.config(self.configuration.get('command')[0]) self.configuration.update({'command': [executable]}) debug(__package__, 'read config:', self.configuration) return read_client_config(self.name, self.configuration)
def _download() -> None: debug('Downloading server from', url) target = sublime.active_window() label = 'Downloading PromQL language server' with ActivityIndicator(target, label): try: opener = FancyURLopener() tmp_file, _ = opener.retrieve(url) if not checksum_verified(checksum, tmp_file): debug('Checksum error.') sublime.status_message('Server binary', os.path.basename(tmp_file), 'checkusm error.') return # extract and copy the cache with tarfile.open(tmp_file) as tf: tf.extractall(self._cache_path) os.unlink(tmp_file) self._ready = True except Exception as ex: debug('Failed downloading server:', ex) finally: opener.close()
def log_debug(msg): logging.debug("lsp-elixir: {}".format(msg))