write to the console

def write(self, text, fg='black', bg='white'):
        '''write to the console'''
        if isinstance(text, str):
            sys.stdout.write(text)
        else:
            sys.stdout.write(str(text))
        sys.stdout.flush()
        if self.udp.connected():
            self.udp.writeln(text)
        if self.tcp.connected():
            self.tcp.writeln(text)