Ejemplo n.º 1
0
    def _StopServer(self):
        """Stop the Gocode server."""
        with self._gocode_lock:
            _logger.info('Stopping Gocode server')

            if self._ServerIsRunning():
                self._ExecuteCommand([
                    self._gocode_binary_path, '-addr', self._gocode_address,
                    'close'
                ])
                self._gocode_handle.terminate()
                self._gocode_handle.wait()

            self._gocode_handle = None
            self._gocode_port = None
            self._gocode_address = None

            if not self._keep_logfiles:
                if self._gocode_stdout:
                    utils.RemoveIfExists(self._gocode_stdout)
                    self._gocode_stdout = None

                if self._gocode_stderr:
                    utils.RemoveIfExists(self._gocode_stderr)
                    self._gocode_stderr = None
Ejemplo n.º 2
0
 def _CleanupAfterServerStop( self ):
   self._omnisharp_port = None
   self._omnisharp_phandle = None
   if ( not self._keep_logfiles ):
     if self._filename_stdout:
       utils.RemoveIfExists( self._filename_stdout )
     if self._filename_stderr:
       utils.RemoveIfExists( self._filename_stderr )
Ejemplo n.º 3
0
 def _CleanUp(self):
     self._jedihttp_phandle = None
     self._jedihttp_port = None
     if not self._keep_logfiles:
         utils.RemoveIfExists(self._logfile_stdout)
         self._logfile_stdout = None
         utils.RemoveIfExists(self._logfile_stderr)
         self._logfile_stderr = None
Ejemplo n.º 4
0
 def _CleanUp(self):
     utils.CloseStandardStreams(self._server_handle)
     self._server_handle = None
     self._server_port = None
     if not self._server_keep_logfiles:
         utils.RemoveIfExists(self._server_stdout)
         self._server_stdout = None
         utils.RemoveIfExists(self._server_stderr)
         self._server_stderr = None
Ejemplo n.º 5
0
 def _CleanUp(self):
     self._racerd_phandle = None
     self._racerd_host = None
     if not self._keep_logfiles:
         if self._server_stdout:
             utils.RemoveIfExists(self._server_stdout)
             self._server_stdout = None
         if self._server_stderr:
             utils.RemoveIfExists(self._server_stderr)
             self._server_stderr = None
Ejemplo n.º 6
0
 def Wrapper(*args, **kwargs):
     utils.RemoveIfExists(os.path.join(dir_name, '.project'))
     utils.RemoveIfExists(os.path.join(dir_name, '.classpath'))
     utils.RemoveDirIfExists(os.path.join(dir_name, '.settings'))
     try:
         test(*args, **kwargs)
     finally:
         utils.RemoveIfExists(os.path.join(dir_name, '.project'))
         utils.RemoveIfExists(os.path.join(dir_name, '.classpath'))
         utils.RemoveDirIfExists(os.path.join(dir_name, '.settings'))
Ejemplo n.º 7
0
 def _CleanUp( self ):
   self._omnisharp_port = None
   self._omnisharp_phandle = None
   if not self._keep_logfiles:
     if self._filename_stdout:
       utils.RemoveIfExists( self._filename_stdout )
       self._filename_stdout = None
     if self._filename_stderr:
       utils.RemoveIfExists( self._filename_stderr )
       self._filename_stderr = None
Ejemplo n.º 8
0
 def _CleanUp(self):
     self._gocode_handle = None
     self._gocode_port = None
     self._gocode_host = None
     if not self._keep_logfiles:
         if self._gocode_stdout:
             utils.RemoveIfExists(self._gocode_stdout)
             self._gocode_stdout = None
         if self._gocode_stderr:
             utils.RemoveIfExists(self._gocode_stderr)
             self._gocode_stderr = None
Ejemplo n.º 9
0
    def _StopServer(self):
        with self._server_lock:
            self._logger.info('Stopping JediHTTP')
            if self._jedihttp_phandle:
                self._jedihttp_phandle.terminate()
                self._jedihttp_phandle = None
                self._jedihttp_port = None

            if not self._keep_logfiles:
                utils.RemoveIfExists(self._logfile_stdout)
                utils.RemoveIfExists(self._logfile_stderr)
Ejemplo n.º 10
0
  def _Reset( self ):
    with self._server_state_mutex:
      if not self._server_keep_logfiles:
        if self._server_stdout:
          utils.RemoveIfExists( self._server_stdout )
          self._server_stdout = None
        if self._server_stderr:
          utils.RemoveIfExists( self._server_stderr )
          self._server_stderr = None

      self._server_handle = None
      self._server_port   = 0
Ejemplo n.º 11
0
    def _Reset(self):
        """Callers must hold self._server_state_mutex"""

        if not self._server_keep_logfiles:
            if self._server_stdout:
                utils.RemoveIfExists(self._server_stdout)
            if self._server_stderr:
                utils.RemoveIfExists(self._server_stderr)

        self._server_handle = None
        self._server_port = 0
        self._server_stdout = None
        self._server_stderr = None
Ejemplo n.º 12
0
 def _CleanUp(self):
     utils.CloseStandardStreams(self._tsserver_handle)
     self._tsserver_handle = None
     self._latest_diagnostics_for_file = defaultdict(list)
     if not self.user_options['server_keep_logfiles'] and self._logfile:
         utils.RemoveIfExists(self._logfile)
         self._logfile = None
Ejemplo n.º 13
0
    def _CleanUp(self):
        if not self._server_keep_logfiles:
            if self._server_stderr:
                utils.RemoveIfExists(self._server_stderr)
                self._server_stderr = None

        if self._workspace_path and self._use_clean_workspace:
            try:
                shutil.rmtree(self._workspace_path)
            except OSError:
                LOGGER.exception('Failed to clean up workspace dir %s',
                                 self._workspace_path)

        self._launcher_path = _PathToLauncherJar()
        self._launcher_config = _LauncherConfiguration()
        self._workspace_path = None
        self._java_project_dir = None
        self._received_ready_message = threading.Event()
        self._server_init_status = 'Not started'
        self._server_started = False

        self._server_handle = None
        self._connection = None
        self._started_message_sent = False

        self.ServerReset()
Ejemplo n.º 14
0
def SetupOptions(options_file):
    options = (json.load(open(options_file, 'r'))
               if options_file else user_options_store.DefaultOptions())
    utils.RemoveIfExists(options_file)
    options['hmac_secret'] = base64.b64decode(options['hmac_secret'])
    user_options_store.SetAll(options)
    return options
Ejemplo n.º 15
0
def CleanUpLogfiles(stdout, stderr, keep_logfiles):
    # We reset stderr & stdout, just in case something tries to use them
    if stderr:
        tmp = sys.stderr
        sys.stderr = sys.__stderr__
        tmp.close()
    if stdout:
        tmp = sys.stdout
        sys.stdout = sys.__stdout__
        tmp.close()

    if not keep_logfiles:
        if stderr:
            utils.RemoveIfExists(stderr)
        if stdout:
            utils.RemoveIfExists(stdout)
Ejemplo n.º 16
0
def SetupOptions(options_file):
    options = user_options_store.DefaultOptions()
    if options_file is not None:
        user_options = json.loads(ReadFile(options_file))
        options.update(user_options)
        utils.RemoveIfExists(options_file)
    user_options_store.SetAll(options)
    return options
Ejemplo n.º 17
0
 def _Reset(self):
     with self._server_state_mutex:
         self.ServerReset()  # Cleanup subclass internal states.
         self._connection = None
         self._server_handle = None
         if self._stderr_file is not None:
             utils.RemoveIfExists(self._stderr_file)
             self._stderr_file = None
Ejemplo n.º 18
0
 def _Reset(self):
     with self._server_state_mutex:
         self.ServerReset()
         self._connection = None
         self._server_handle = None
         if not self._server_keep_logfiles and self._stderr_file:
             utils.RemoveIfExists(self._stderr_file)
             self._stderr_file = None
Ejemplo n.º 19
0
  def SignalHandler( signum, frame ):
    # We reset stderr & stdout, just in case something tries to use them
    if stderr:
      tmp = sys.stderr
      sys.stderr = sys.__stderr__
      tmp.close()
    if stdout:
      tmp = sys.stdout
      sys.stdout = sys.__stdout__
      tmp.close()

    if not keep_logfiles:
      if stderr:
        utils.RemoveIfExists( stderr )
      if stdout:
        utils.RemoveIfExists( stdout )

    sys.exit()
Ejemplo n.º 20
0
def SetupOptions( options_file ):
  options = user_options_store.DefaultOptions()
  user_options = json.loads( ReadFile( options_file ) )
  options.update( user_options )
  utils.RemoveIfExists( options_file )
  hmac_secret = ToBytes( base64.b64decode( options[ 'hmac_secret' ] ) )
  del options[ 'hmac_secret' ]
  user_options_store.SetAll( options )
  return options, hmac_secret
Ejemplo n.º 21
0
    def _StopServer(self):
        with self._server_state_lock:
            if self._racerd_phandle:
                self._racerd_phandle.terminate()
                self._racerd_phandle.wait()
                self._racerd_phandle = None
                self._racerd_host = None

            if not self._keep_logfiles:
                # Remove stdout log
                if self._server_stdout:
                    utils.RemoveIfExists(self._server_stdout)
                    self._server_stdout = None

                # Remove stderr log
                if self._server_stderr:
                    utils.RemoveIfExists(self._server_stderr)
                    self._server_stderr = None
Ejemplo n.º 22
0
    def _CleanUp(self):
        utils.CloseStandardStreams(self._server_handle)

        self._do_tern_project_check = False

        self._server_handle = None
        self._server_port = None
        if not self._server_keep_logfiles:
            if self._server_stdout:
                utils.RemoveIfExists(self._server_stdout)
                self._server_stdout = None
            if self._server_stderr:
                utils.RemoveIfExists(self._server_stderr)
                self._server_stderr = None

        self._server_started = False
        self._server_working_dir = None
        self._server_project_file = None
Ejemplo n.º 23
0
def SetupOptions(options_file):
    options = user_options_store.DefaultOptions()
    if options_file:
        user_options = json.load(open(options_file, 'r'))
        options.update(user_options)
    utils.RemoveIfExists(options_file)
    hmac_secret = base64.b64decode(options['hmac_secret'])
    del options['hmac_secret']
    user_options_store.SetAll(options)
    return options, hmac_secret
Ejemplo n.º 24
0
    def _StopServer(self):
        with self._server_lock:
            if not self._ServerIsRunning():
                return

            self._SendCommand('exit')
            self._tsserver_handle.wait()

            if not self.user_options['server_keep_logfiles']:
                utils.RemoveIfExists(self._logfile)
                self._logfile = None
Ejemplo n.º 25
0
    def _CleanUp(self):
        _logger.info('+++++++++++cleanup vls')
        if not self._server_keep_logfiles:
            if self._server_stderr:
                utils.RemoveIfExists(self._server_stderr)
                self._server_stderr = None

        self._received_ready_message = threading.Event()
        self._project_dir = None
        self._server_init_status = 'Not started'
        self._server_started = False
        self._server_handle = None
        self._connection = None

        self.ServerReset()
Ejemplo n.º 26
0
    def _Reload(self, request_data):
        """
    Syncronize TSServer's view of the file to
    the contents of the unsaved buffer.
    """

        filename = request_data['filepath']
        contents = request_data['file_data'][filename]['contents']
        tmpfile = NamedTemporaryFile(delete=False)
        tmpfile.write(utils.ToBytes(contents))
        tmpfile.close()
        self._SendRequest('reload', {
            'file': filename,
            'tmpfile': tmpfile.name
        })
        utils.RemoveIfExists(tmpfile.name)
Ejemplo n.º 27
0
    def _CleanUp(self):
        if not self._server_keep_logfiles:
            if self._server_stderr:
                utils.RemoveIfExists(self._server_stderr)
                self._server_stderr = None

        if self._workspace_path and self._use_clean_workspace:
            try:
                shutil.rmtree(self._workspace_path)
            except OSError:
                _logger.exception(
                    'Failed to clean up workspace dir {0}'.format(
                        self._workspace_path))

        self._workspace_path = None
        self._project_dir = None
        self._received_ready_message = threading.Event()
        self._server_started = False

        self._server_handle = None
        self._connection = None

        self.ServerReset()
Ejemplo n.º 28
0
def RemoveIfExists_DoesntExist_test():
    tempfile = PathToTestFile('remove-if-exists')
    ok_(not os.path.exists(tempfile))
    utils.RemoveIfExists(tempfile)
    ok_(not os.path.exists(tempfile))
Ejemplo n.º 29
0
def RemoveIfExists_Exists_test():
    tempfile = PathToTestFile('remove-if-exists')
    open(tempfile, 'a').close()
    ok_(os.path.exists(tempfile))
    utils.RemoveIfExists(tempfile)
    ok_(not os.path.exists(tempfile))
Ejemplo n.º 30
0
 def _CleanLogfile(self):
     logging.shutdown()
     if not self._user_options['keep_logfiles']:
         if self._client_logfile:
             utils.RemoveIfExists(self._client_logfile)