Command.py 文件源码

python
阅读 28 收藏 0 点赞 0 评论 0

项目:hive 作者: tdeheurles 项目源码 文件源码
def _verbose(self, message):
        BLACK, RED, GREEN, YELLOW, BLUE, MAGENTA, CYAN, WHITE = range(8)

        # following from Python cookbook, #475186
        def has_colours(stream):
            if not hasattr(stream, "isatty"):
                return False
            if not stream.isatty():
                return False  # auto color only on TTYs
            try:
                import curses
                curses.setupterm()
                return curses.tigetnum("colors") > 2
            except:
                # guess false in case of error
                return False

        has_colours = has_colours(sys.stdout)

        def printout(text, colour=WHITE):
            if has_colours:
                seq = "\x1b[1;%dm" % (30 + colour) + text + "\x1b[0m\n"
                sys.stdout.write(seq)
            else:
                sys.stdout.write(text)

        if self.verboseMode:
            printout("hive-python: " + message, BLUE)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号