Esempio n. 1
0
 def _postError(self, msg):
     """
     Post errors to the user once
     """
     if ('error', msg) not in self._posted_notifications:
         self._posted_notifications += [('error', msg)]
         vim_helpers.postVimError(msg)
Esempio n. 2
0
 def _postError(self, msg):
     """
     Post errors to the user once
     """
     if ('error', msg) not in self._posted_notifications:
         self._posted_notifications += [('error', msg)]
         vim_helpers.postVimError(msg)
Esempio n. 3
0
    def _setup(self):
        "Launches the hdlcc server"
        self._logger.info("Running vim_hdl client setup")

        vimhdl_path = p.abspath(p.join(p.dirname(__file__), '..', '..'))

        hdlcc_server = p.join(vimhdl_path, 'dependencies', 'hdlcc', 'hdlcc',
                              'code_checker_server.py')

        cmd = [hdlcc_server,
               '--host', self._host,
               '--port', str(self._port),
               '--stdout', '/tmp/hdlcc-stdout.log',
               '--stderr', '/tmp/hdlcc-stderr.log',
               '--attach-to-pid', str(os.getpid())] + \
                self._server_args

        self._logger.info("Starting hdlcc server with '%s'", " ".join(cmd))

        try:
            self._server = subp.Popen(cmd, stdout=subp.PIPE, stderr=subp.PIPE)
            if not self._isServerAlive():
                vim_helpers.postVimError("Failed to launch hdlcc server")
        except subp.CalledProcessError:
            self._logger.exception("Error calling '%s'", " ".join(cmd))
Esempio n. 4
0
 def postQueuedMessages(self):
     '''Because Vim doesn't allows commands from non-GUI threads,
     we enqueue messages generated by background threads and post
     them whenever Vim is ready'''
     while not self._ui_msg_queue.empty():
         msg = self._ui_msg_queue.get()
         if msg['type'] == 'info':
             vim_helpers.postVimInfo(msg['text'])
         elif msg['type'] == 'warning':
             vim_helpers.postVimWarning(msg['text'])
         elif msg['type'] == 'error':
             vim_helpers.postVimError(msg['text'])
Esempio n. 5
0
 def _postQueuedMessages(self):
     "Empty our queue in a single message"
     while not self._ui_queue.empty():
         messages = self._ui_queue.get()
         for severity, message in messages.json().get('ui_messages', []):
             if severity == 'info':
                 vim_helpers.postVimInfo(message)
             elif severity == 'warning':
                 vim_helpers.postVimWarning(message)
             elif severity == 'error':
                 vim_helpers.postVimError(message)
             else:
                 vim_helpers.postVimError(
                     "Unknown severity '%s' for message '%s'" %
                     (severity, message))
Esempio n. 6
0
 def _postQueuedMessages(self):
     """
     Empty our queue in a single message
     """
     while not self._ui_queue.empty():
         messages = self._ui_queue.get()
         for severity, message in messages.json().get('ui_messages', []):
             if severity == 'info':
                 vim_helpers.postVimInfo(message)
             elif severity == 'warning':
                 self._postWarning(message)
             elif severity == 'error':
                 self._postError(message)
             else:
                 vim_helpers.postVimError(
                     "Unknown severity '%s' for message '%s'" %
                     (severity, message))
Esempio n. 7
0
    def _startServerProcess(self):
        """
        Starts the hdlcc server
        """
        self._logger.info("Running vim_hdl client setup")

        vimhdl_path = p.abspath(p.join(p.dirname(__file__), '..', '..'))

        hdlcc_server = p.join(vimhdl_path, 'dependencies', 'hdlcc', 'hdlcc',
                              'hdlcc_server.py')

        cmd = [
            self._python, hdlcc_server, '--host', self._host, '--port',
            str(self._port), '--stdout', '/tmp/hdlcc-stdout.log', '--stderr',
            '/tmp/hdlcc-stderr.log', '--attach-to-pid',
            str(os.getpid()), '--log-level', self._log_level, '--log-stream',
            self._log_stream
        ]

        self._logger.info("Starting hdlcc server with '%s'", cmd)

        try:
            if _ON_WINDOWS:
                self._server = subp.Popen(
                    cmd,
                    stdout=subp.PIPE,
                    stderr=subp.PIPE,
                    creationflags=subp.CREATE_NEW_PROCESS_GROUP)
            else:
                self._server = subp.Popen(cmd,
                                          stdout=subp.PIPE,
                                          stderr=subp.PIPE,
                                          preexec_fn=os.setpgrp)

            if not self._isServerAlive():
                vim_helpers.postVimError("Failed to launch hdlcc server")
        except subp.CalledProcessError:
            self._logger.exception("Error calling '%s'", " ".join(cmd))
Esempio n. 8
0
    def _startServerProcess(self):
        """
        Starts the hdlcc server
        """
        self._logger.info("Running vim_hdl client setup")

        vimhdl_path = p.abspath(p.join(p.dirname(__file__), '..', '..'))

        hdlcc_server = p.join(vimhdl_path, 'dependencies', 'hdlcc', 'hdlcc',
                              'hdlcc_server.py')

        cmd = [self._python,
               hdlcc_server,
               '--host', self._host,
               '--port', str(self._port),
               '--stdout', '/tmp/hdlcc-stdout.log',
               '--stderr', '/tmp/hdlcc-stderr.log',
               '--attach-to-pid', str(os.getpid()),
               '--log-level', self._log_level,
               '--log-stream', self._log_stream]

        self._logger.info("Starting hdlcc server with '%s'", cmd)

        try:
            if _ON_WINDOWS:
                self._server = subp.Popen(
                    cmd, stdout=subp.PIPE, stderr=subp.PIPE,
                    creationflags=subp.CREATE_NEW_PROCESS_GROUP)
            else:
                self._server = subp.Popen(
                    cmd, stdout=subp.PIPE, stderr=subp.PIPE,
                    preexec_fn=os.setpgrp)

            if not self._isServerAlive():
                vim_helpers.postVimError("Failed to launch hdlcc server")
        except subp.CalledProcessError:
            self._logger.exception("Error calling '%s'", " ".join(cmd))
Esempio n. 9
0
 def test():
     vim_helpers.postVimError("Some error")
     vim.command.assert_called_with(
         "echohl ErrorMsg | echom 'Some error' | echohl None")
Esempio n. 10
0
 def test():
     vim_helpers.postVimError("Some error")
     vim.command.assert_called_with(
         "echohl ErrorMsg | echom 'Some error' | echohl None")