def _log(self, message, level): if (self._loglevel >= level): for line in message.split('\n'): output = "(" + str(level) + ") " + self._name + ":" output = output.ljust(15) output = output + util.try_encode(line, 'utf-8') print(output)
def _log(self, message, level): if(self._loglevel >= level): for line in message.split('\n'): output = "(" + str(level) + ") " + self._name + ":" output = output.ljust(15) output = output + util.try_encode(line, 'utf-8') print(output)
def _sendMessageUnsafe(self, message): """ write the message to stdout """ print(util.try_encode(message, self._encoding)) sys.stdout.flush() return True
def _sendMessageUnsafe(self, message): """ send the given line via the socket. """ self._log("tx: " + message, 3) try: self._socket.send(util.try_encode(message, self._encoding) + "\n") except Exception as e: self._log("failed sending %s: " % (message) + str(e), 1) return False return True
def _sendMessageUnsafe(self, message): """ write the message to stdout """ print(util.try_encode(message, self._encoding)) return True