Ejemplo n.º 1
0
def dataToStdout(data, forceOutput=False, bold=False, content_type=None):
    #处理输出到命令行

    if isinstance(data, str):
        message = stdoutencode(data)
    else:
        message = data
    sys.stdout.write(setColor(message.decode(), bold))
    try:
        sys.stdout.flush()
    except IOError:
        pass
Ejemplo n.º 2
0
def dataToStdout(data, forceOutput=False, bold=False, content_type=None):
    """
    Writes text to the stdout (console) stream
    """
    if isinstance(data, unicode):
        message = stdoutencode(data)
    else:
        message = data
    sys.stdout.write(setColor(message, bold))
    try:
        sys.stdout.flush()
    except IOError:
        pass
Ejemplo n.º 3
0
    def emit(self, record):
        try:
            message = stdoutencode(self.format(record))
            stream = self.stream

            if not self.is_tty:
                stream.write(message)
            else:
                self.output_colorized(message)
            stream.write(getattr(self, 'terminator', '\n'))

            self.flush()
        except (KeyboardInterrupt, SystemExit):
            raise
        except:
            self.handleError(record)
Ejemplo n.º 4
0
def dataToStdout(data, bold=False):
    """
    Writes text to the stdout (console) stream
    """

    message = ""

    if isinstance(data, unicode):
        message = stdoutencode(data)
    else:
        message = data

    sys.stdout.write(setColor(message, bold))

    try:
        sys.stdout.flush()
    except IOError:
        pass
Ejemplo n.º 5
0
    def emit(self, record):
        try:
            message = stdoutencode(self.format(record))
            stream = self.stream

            if not self.is_tty:
                if message and message[0] == "\r":
                    message = message[1:]
                stream.write(message)
            else:
                self.output_colorized(message)
            stream.write(getattr(self, 'terminator', '\n'))

            self.flush()
        except (KeyboardInterrupt, SystemExit):
            raise
        except:
            self.handleError(record)
Ejemplo n.º 6
0
def dataToStdout(data, bold=False):
    """
    Writes text to the stdout (console) stream
    """
    if conf['SCREEN_OUTPUT']:
        message = ""

        if isinstance(data, unicode):
            message = stdoutencode(data)
        else:
            message = data

        sys.stdout.write(setColor(message, bold))

        try:
            sys.stdout.flush()
        except IOError:
            pass
    return
Ejemplo n.º 7
0
def dataToStdout(data, bold=False):
    """
    Writes text to the stdout (console) stream
    """
    logging._acquireLock()
    if isinstance(data, unicode):
        message = stdoutencode(data)
    else:
        message = data

    sys.stdout.write(setColor(message, bold))

    try:
        sys.stdout.flush()
    except IOError:
        pass

    logging._releaseLock()
    return
Ejemplo n.º 8
0
def dataToStdout(data, bold=False):
    """
    Writes text to the stdout (console) stream
    """
    if 'quiet' not in conf or not conf.quiet:
        message = ""

        if isinstance(data, unicode):
            message = stdoutencode(data)
        else:
            message = data

        sys.stdout.write(setColor(message, bold))

        try:
            sys.stdout.flush()
        except IOError:
            pass
    return
Ejemplo n.º 9
0
def dataToStdout(data, bold=False):
    """
    Writes text to the stdout (console) stream
    """
    if conf.SCREEN_OUTPUT:
        if conf.ENGINE is ENGINE_MODE_STATUS.THREAD:
            logging._acquireLock()

        if isinstance(data, str):
            message = stdoutencode(data)
        else:
            message = data

        sys.stdout.write(setColor(message.decode('utf8'), bold))
        try:
            sys.stdout.flush()
        except IOError:
            pass

        if conf.ENGINE is ENGINE_MODE_STATUS.THREAD:
            logging._releaseLock()
    return
Ejemplo n.º 10
0
def dataToStdout(data, bold=False):
    """
    Writes text to the stdout (console) stream
    """
    if conf.SCREEN_OUTPUT:
        if conf.ENGINE is ENGINE_MODE_STATUS.THREAD:
            logging._acquireLock()

        if isinstance(data, unicode):
            message = stdoutencode(data)
        else:
            message = data

        sys.stdout.write(setColor(message, bold))

        try:
            sys.stdout.flush()
        except IOError:
            pass

        if conf.ENGINE is ENGINE_MODE_STATUS.THREAD:
            logging._releaseLock()
    return
Ejemplo n.º 11
0
 def emit(self, record):
     message = stdoutencode(FORMATTER.format(record))
     print >>LOGGER_OUTPUT, message.strip('\r')