fix: avoid confusing error message when connection to the murmur server fails.

This commit is contained in:
Terry Geng 2020-05-09 20:49:52 +08:00
parent a58af46f15
commit fbe3383b66
2 changed files with 9 additions and 1 deletions

View File

@ -13,6 +13,7 @@ import argparse
import os
import os.path
import pymumble_py3 as pymumble
import pymumble_py3.constants
import variables as var
import logging
import logging.handlers
@ -123,6 +124,10 @@ class MumbleBot:
self.mumble.set_codec_profile("audio")
self.mumble.start() # start the mumble thread
self.mumble.is_ready() # wait for the connection
if self.mumble.connected >= pymumble_py3.constants.PYMUMBLE_CONN_STATE_FAILED:
exit()
self.set_comment()
self.mumble.users.myself.unmute() # by sure the user is not muted
self.join_channel()

View File

@ -345,7 +345,10 @@ class LoggerIOWrapper(io.TextIOWrapper):
def write(self, text):
if isinstance(text, bytes):
self.logger.log(self.logging_level, text.decode('utf-8').rstrip())
msg = text.decode('utf-8').rstrip()
self.logger.log(self.logging_level, msg)
super().write(msg + "\n")
else:
self.logger.log(self.logging_level, text.rstrip())
super().write(text + "\n")