def _SetUpServer(self): self._available_completers = {} self._user_notified_about_crash = False self._filetypes_with_keywords_loaded = set() self._server_is_ready_with_cache = False self._message_poll_request = None base.LoadJsonDefaultsIntoVim() user_options_store.SetAll(base.BuildServerConf()) self._user_options = user_options_store.GetAll() self._omnicomp = OmniCompleter(self._user_options) self._buffers = BufferDict(self._user_options) self._SetLogLevel() hmac_secret = os.urandom(HMAC_SECRET_LENGTH) options_dict = dict(self._user_options) options_dict['hmac_secret'] = utils.ToUnicode( base64.b64encode(hmac_secret)) options_dict['server_keep_logfiles'] = self._user_options[ 'keep_logfiles'] # The temp options file is deleted by ycmd during startup. with NamedTemporaryFile(delete=False, mode='w+') as options_file: json.dump(options_dict, options_file) server_port = utils.GetUnusedLocalhostPort() BaseRequest.server_location = 'http://127.0.0.1:' + str(server_port) BaseRequest.hmac_secret = hmac_secret this_file_path = os.path.dirname(os.path.realpath(__file__)) tabnine_binary_path = os.path.join(this_file_path, '../../binaries/') args = [ '--client=vim', '--port={0}'.format(server_port), '--options_file={0}'.format(options_file.name), '--log={0}'.format(self._user_options['log_level']), '--idle_suicide_seconds={0}'.format(SERVER_IDLE_SUICIDE_SECONDS) ] self._server_stdout = utils.CreateLogfile( SERVER_LOGFILE_FORMAT.format(port=server_port, std='stdout')) self._server_stderr = utils.CreateLogfile( SERVER_LOGFILE_FORMAT.format(port=server_port, std='stderr')) args.append('--stdout={0}'.format(self._server_stdout)) args.append('--stderr={0}'.format(self._server_stderr)) if self._user_options['keep_logfiles']: args.append('--keep_logfiles') try: self._server_popen = start_tabnine_proc( cmd_args=args, binary_dir=tabnine_binary_path) except RuntimeError as error: error_message = str(error) self._logger.exception(error_message) vimsupport.PostVimMessage(error_message) return
def SetUpYCM(): from ycm import base from ycmd import user_options_store from ycm.youcompleteme import YouCompleteMe base.LoadJsonDefaultsIntoVim() user_options_store.SetAll(base.BuildServerConf()) return YouCompleteMe(user_options_store.GetAll())
def SetUpYCM(): from ycm import base, paths from ycmd import user_options_store, utils from ycm.youcompleteme import YouCompleteMe base.LoadJsonDefaultsIntoVim() user_options_store.SetAll(base.BuildServerConf()) popen_args = [ paths.PathToPythonInterpreter(), paths.PathToCheckCoreVersion() ] if utils.SafePopen(popen_args).wait() == 2: raise RuntimeError('YCM support libs too old, PLEASE RECOMPILE.') return YouCompleteMe(user_options_store.GetAll())
def _SetUpServer(self): self._available_completers = {} self._user_notified_about_crash = False self._filetypes_with_keywords_loaded = set() self._server_is_ready_with_cache = False self._message_poll_request = None base.LoadJsonDefaultsIntoVim() user_options_store.SetAll(base.BuildServerConf()) self._user_options = user_options_store.GetAll() self._omnicomp = OmniCompleter(self._user_options) self._buffers = BufferDict(self._user_options) self._SetLogLevel() hmac_secret = os.urandom(HMAC_SECRET_LENGTH) options_dict = dict(self._user_options) options_dict['hmac_secret'] = utils.ToUnicode( base64.b64encode(hmac_secret)) options_dict['server_keep_logfiles'] = self._user_options[ 'keep_logfiles'] # The temp options file is deleted by ycmd during startup. with NamedTemporaryFile(delete=False, mode='w+') as options_file: json.dump(options_dict, options_file) server_port = utils.GetUnusedLocalhostPort() BaseRequest.server_location = 'http://127.0.0.1:' + str(server_port) BaseRequest.hmac_secret = hmac_secret try: python_interpreter = paths.PathToPythonInterpreter() except RuntimeError as error: error_message = ("Unable to start the ycmd server. {0}. " "Correct the error then restart the server " "with ':YcmRestartServer'.".format( str(error).rstrip('.'))) self._logger.exception(error_message) vimsupport.PostVimMessage(error_message) return args = [ python_interpreter, paths.PathToServerScript(), '--port={0}'.format(server_port), '--options_file={0}'.format(options_file.name), '--log={0}'.format(self._user_options['log_level']), '--idle_suicide_seconds={0}'.format(SERVER_IDLE_SUICIDE_SECONDS) ] self._server_stdout = utils.CreateLogfile( SERVER_LOGFILE_FORMAT.format(port=server_port, std='stdout')) self._server_stderr = utils.CreateLogfile( SERVER_LOGFILE_FORMAT.format(port=server_port, std='stderr')) args.append('--stdout={0}'.format(self._server_stdout)) args.append('--stderr={0}'.format(self._server_stderr)) if self._user_options['keep_logfiles']: args.append('--keep_logfiles') self._server_popen = utils.SafePopen(args, stdin_windows=PIPE, stdout=PIPE, stderr=PIPE)