def _GetSolutionFile(self, filepath): if not filepath in self._solution_for_file: # NOTE: detection could throw an exception if an extra_conf_store needs # to be confirmed path_to_solutionfile = solutiondetection.FindSolutionPath(filepath) if not path_to_solutionfile: raise RuntimeError('Autodetection of solution file failed. \n') self._solution_for_file[filepath] = path_to_solutionfile return self._solution_for_file[filepath]
def _StartServer(self, request_data): """ Start the OmniSharp server """ self._logger.info('startup') # NOTE: detection could throw an exception if an extra_conf_store needs to # be confirmed path_to_solutionfile = solutiondetection.FindSolutionPath( request_data['filepath']) if not path_to_solutionfile: raise RuntimeError('Autodetection of solution file failed.\n') self._logger.info( u'Loading solution file {0}'.format(path_to_solutionfile)) self._ChooseOmnisharpPort() # we need to pass the command to Popen as a string since we're passing # shell=True (as recommended by Python's doc) command = ' '.join([ PATH_TO_OMNISHARP_BINARY, '-p', str(self._omnisharp_port), '-s', u'"{0}"'.format(path_to_solutionfile) ]) if not utils.OnWindows() and not utils.OnCygwin(): command = u'mono ' + command if utils.OnCygwin(): command = command + ' --client-path-mode Cygwin' filename_format = os.path.join(utils.PathToTempDir(), u'omnisharp_{port}_{sln}_{std}.log') solutionfile = os.path.basename(path_to_solutionfile) self._filename_stdout = filename_format.format( port=self._omnisharp_port, sln=solutionfile, std='stdout') self._filename_stderr = filename_format.format( port=self._omnisharp_port, sln=solutionfile, std='stderr') with open(self._filename_stderr, 'w') as fstderr: with open(self._filename_stdout, 'w') as fstdout: # shell=True is needed for Windows so OmniSharp does not spawn # in a new visible window self._omnisharp_phandle = utils.SafePopen(command, stdout=fstdout, stderr=fstderr, shell=True) self._solution_path = path_to_solutionfile self._logger.info('Starting OmniSharp server')