Exemplo n.º 1
0
 def _stderr_watcher(self):
     """Watch STDERR output of self.process."""
     start_msg = "Starting STDERR watcher for %s" % self.name
     server_name = "[%s] - " % self.name
     self.logger.debug(start_msg)
     self.stderr_deque.append((time(), "GSMT: %s" % start_msg))
     try:
         with self.process.stderr:
             for line in iter(self.process.stderr.readline, ''):
                 self.logger.error(server_name + remove_newline(line))
                 self.stderr_deque.append((time(), remove_newline(line)))
     finally:
         stop_msg = "Stopping STDERR watcher for %s" % self.name
         self.logger.debug(stop_msg)
         self.stderr_deque.append((time(), "GSMT: %s" % stop_msg))
Exemplo n.º 2
0
    def write(self, command, add_newline=True):
        r"""Write to stdin of process.

        -**parameters**, **types**, **return** and **return types**

             :param str command: Command for the game server.
             :param boolean add_newline: When true add \n to the command.
        """
        self.check_server_is_running()

        if add_newline:
            command = "%s\n" % command
        self.process.stdin.write(command)
        self.stdin_deque.append((time(), remove_newline(command)))
        self.process.stdin.flush()  # needed for Python3