parameters: ( self, request_data )
docstring: Start the OmniSharp server
docstring_summary: Start the OmniSharp server
docstring_tokens: Start the OmniSharp server
function: def _StartServer( self, request_data ):
      """ Start the OmniSharp server """
      self._logger.info( 'startup' )
  
      self._omnisharp_port = utils.GetUnusedLocalhostPort()
      solution_files, folder = _FindSolutionFiles( request_data[ 'filepath' ] )
  
      if len( solution_files ) == 0:
        raise RuntimeError(
          'Error starting OmniSharp server: no solutionfile found' )
      elif len( solution_files ) == 1:
        solutionfile = solution_files[ 0 ]
      else:
        # multiple solutions found : if there is one whose name is the same
        # as the folder containing the file we edit, use this one
        # (e.g. if we have bla/Project.sln and we are editing
        # bla/Project/Folder/File.cs, use bla/Project.sln)
        filepath_components = _PathComponents( request_data[ 'filepath' ] )
        solutionpath = _PathComponents( folder )
        foldername = ''
        if len( filepath_components ) > len( solutionpath ):
            foldername = filepath_components[ len( solutionpath ) ]
        solution_file_candidates = [ solutionfile for solutionfile in solution_files
          if _GetFilenameWithoutExtension( solutionfile ) == foldername ]
        if len( solution_file_candidates ) == 1:
          solutionfile = solution_file_candidates[ 0 ]
        else:
          raise RuntimeError(
            'Found multiple solution files instead of one!\n{0}'.format(
              solution_files ) )
  
      omnisharp = os.path.join(
        os.path.abspath( os.path.dirname( __file__ ) ),
        'OmniSharpServer/OmniSharp/bin/Debug/OmniSharp.exe' )
  
      if not os.path.isfile( omnisharp ):
        raise RuntimeError( SERVER_NOT_FOUND_MSG.format( omnisharp ) )
  
      path_to_solutionfile = os.path.join( folder, solutionfile )
      # we need to pass the command to Popen as a string since we're passing
      # shell=True (as recommended by Python's doc)
      command = ( omnisharp + ' -p ' + str( self._omnisharp_port ) + ' -s ' +
                  path_to_solutionfile )
  
      if not utils.OnWindows():
        command = 'mono ' + command
  
      filename_format = os.path.join( utils.PathToTempDir(),
                                     'omnisharp_{port}_{sln}_{std}.log' )
  
      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
          utils.SafePopen( command, stdout=fstdout, stderr=fstderr, shell=True )
  
      self._logger.info( 'Starting OmniSharp server' )
function_tokens: def _StartServer ( self , request_data ) : self . _logger . info ( 'startup' ) self . _omnisharp_port = utils . GetUnusedLocalhostPort ( ) solution_files , folder = _FindSolutionFiles ( request_data [ 'filepath' ] ) if len ( solution_files ) == 0 : raise RuntimeError ( 'Error starting OmniSharp server: no solutionfile found' ) elif len ( solution_files ) == 1 : solutionfile = solution_files [ 0 ] else : # multiple solutions found : if there is one whose name is the same # as the folder containing the file we edit, use this one # (e.g. if we have bla/Project.sln and we are editing # bla/Project/Folder/File.cs, use bla/Project.sln) filepath_components = _PathComponents ( request_data [ 'filepath' ] ) solutionpath = _PathComponents ( folder ) foldername = '' if len ( filepath_components ) > len ( solutionpath ) : foldername = filepath_components [ len ( solutionpath ) ] solution_file_candidates = [ solutionfile for solutionfile in solution_files if _GetFilenameWithoutExtension ( solutionfile ) == foldername ] if len ( solution_file_candidates ) == 1 : solutionfile = solution_file_candidates [ 0 ] else : raise RuntimeError ( 'Found multiple solution files instead of one!\n{0}' . format ( solution_files ) ) omnisharp = os . path . join ( os . path . abspath ( os . path . dirname ( __file__ ) ) , 'OmniSharpServer/OmniSharp/bin/Debug/OmniSharp.exe' ) if not os . path . isfile ( omnisharp ) : raise RuntimeError ( SERVER_NOT_FOUND_MSG . format ( omnisharp ) ) path_to_solutionfile = os . path . join ( folder , solutionfile ) # we need to pass the command to Popen as a string since we're passing # shell=True (as recommended by Python's doc) command = ( omnisharp + ' -p ' + str ( self . _omnisharp_port ) + ' -s ' + path_to_solutionfile ) if not utils . OnWindows ( ) : command = 'mono ' + command filename_format = os . path . join ( utils . PathToTempDir ( ) , 'omnisharp_{port}_{sln}_{std}.log' ) 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 utils . SafePopen ( command , stdout = fstdout , stderr = fstderr , shell = True ) self . _logger . info ( 'Starting OmniSharp server' )