コード例 #1
0
ファイル: terminalwriter.py プロジェクト: cdelp/electionSite
    def write(self, msg, **kw):
        if msg:
            if not isinstance(msg, (bytes, text)):
                msg = text(msg)
            oldcolors = None
            if self.hasmarkup and kw:
                handle = GetStdHandle(STD_OUTPUT_HANDLE)
                oldcolors = GetConsoleInfo(handle).wAttributes
                default_bg = oldcolors & 0x00F0
                attr = default_bg
                if kw.pop('bold', False):
                    attr |= FOREGROUND_INTENSITY

                if kw.pop('red', False):
                    attr |= FOREGROUND_RED
                elif kw.pop('blue', False):
                    attr |= FOREGROUND_BLUE
                elif kw.pop('green', False):
                    attr |= FOREGROUND_GREEN
                elif kw.pop('yellow', False):
                    attr |= FOREGROUND_GREEN | FOREGROUND_RED
                else:
                    attr |= oldcolors & 0x0007

                SetConsoleTextAttribute(handle, attr)
            write_out(self._file, msg)
            if oldcolors:
                SetConsoleTextAttribute(handle, oldcolors)
コード例 #2
0
ファイル: terminalwriter.py プロジェクト: Darriall/pypy
    def write(self, msg, **kw):
        if msg:
            if not isinstance(msg, (bytes, text)):
                msg = text(msg)
            oldcolors = None
            if self.hasmarkup and kw:
                handle = GetStdHandle(STD_OUTPUT_HANDLE)
                oldcolors = GetConsoleInfo(handle).wAttributes
                default_bg = oldcolors & 0x00F0
                attr = default_bg
                if kw.pop('bold', False):
                    attr |= FOREGROUND_INTENSITY

                if kw.pop('red', False):
                    attr |= FOREGROUND_RED
                elif kw.pop('blue', False):
                    attr |= FOREGROUND_BLUE
                elif kw.pop('green', False):
                    attr |= FOREGROUND_GREEN
                elif kw.pop('yellow', False):
                    attr |= FOREGROUND_GREEN|FOREGROUND_RED
                else:
                    attr |= oldcolors & 0x0007

                SetConsoleTextAttribute(handle, attr)
            write_out(self._file, msg)
            if oldcolors:
                SetConsoleTextAttribute(handle, oldcolors)
コード例 #3
0
ファイル: terminalwriter.py プロジェクト: steinbachr/OpenTapp
    def write(self, msg, **kw):
        if msg:
            if not isinstance(msg, (bytes, text)):
                msg = text(msg)
            oldcolors = None
            if self.hasmarkup and kw:
                handle = GetStdHandle(STD_OUTPUT_HANDLE)
                oldcolors = GetConsoleInfo(handle).wAttributes
                default_bg = oldcolors & 0x00F0
                attr = default_bg
                if kw.pop('bold', False):
                    attr |= FOREGROUND_INTENSITY

                if kw.pop('red', False):
                    attr |= FOREGROUND_RED
                elif kw.pop('blue', False):
                    attr |= FOREGROUND_BLUE
                elif kw.pop('green', False):
                    attr |= FOREGROUND_GREEN
                elif kw.pop('yellow', False):
                    attr |= FOREGROUND_GREEN|FOREGROUND_RED
                else:
                    attr |= oldcolors & 0x0007

                SetConsoleTextAttribute(handle, attr)
            try:
                self._file.write(msg)
            except UnicodeEncodeError:
                msg = msg.encode("unicode-escape").decode("ascii")
                self._file.write(msg)
            self._file.flush()
            if oldcolors:
                SetConsoleTextAttribute(handle, oldcolors)
コード例 #4
0
ファイル: terminalwriter.py プロジェクト: wythel/jenkins
    def write(self, msg, **kw):
        if msg:
            if not isinstance(msg, (bytes, text)):
                msg = text(msg)
            oldcolors = None
            if self.hasmarkup and kw:
                handle = GetStdHandle(STD_OUTPUT_HANDLE)
                oldcolors = GetConsoleInfo(handle).wAttributes
                default_bg = oldcolors & 0x00F0
                attr = default_bg
                if kw.pop('bold', False):
                    attr |= FOREGROUND_INTENSITY

                if kw.pop('red', False):
                    attr |= FOREGROUND_RED
                elif kw.pop('blue', False):
                    attr |= FOREGROUND_BLUE
                elif kw.pop('green', False):
                    attr |= FOREGROUND_GREEN
                elif kw.pop('yellow', False):
                    attr |= FOREGROUND_GREEN | FOREGROUND_RED
                else:
                    attr |= oldcolors & 0x0007

                SetConsoleTextAttribute(handle, attr)
            try:
                self._file.write(msg)
            except UnicodeEncodeError:
                msg = msg.encode("unicode-escape").decode("ascii")
                self._file.write(msg)
            self._file.flush()
            if oldcolors:
                SetConsoleTextAttribute(handle, oldcolors)
コード例 #5
0
ファイル: terminalwriter.py プロジェクト: cdelp/electionSite
 def write(self, msg, **kw):
     if msg:
         if not isinstance(msg, (bytes, text)):
             msg = text(msg)
         if self.hasmarkup and kw:
             markupmsg = self.markup(msg, **kw)
         else:
             markupmsg = msg
         write_out(self._file, markupmsg)
コード例 #6
0
ファイル: terminalwriter.py プロジェクト: Darriall/pypy
 def write(self, msg, **kw):
     if msg:
         if not isinstance(msg, (bytes, text)):
             msg = text(msg)
         if self.hasmarkup and kw:
             markupmsg = self.markup(msg, **kw)
         else:
             markupmsg = msg
         write_out(self._file, markupmsg)
コード例 #7
0
ファイル: terminalwriter.py プロジェクト: steinbachr/OpenTapp
 def write(self, msg, **kw):
     if msg:
         if not isinstance(msg, (bytes, text)):
             msg = text(msg)
         if self.hasmarkup and kw:
             markupmsg = self.markup(msg, **kw)
         else:
             markupmsg = msg
         try:
             self._file.write(markupmsg)
         except UnicodeEncodeError:
             msg = msg.encode("unicode-escape").decode("ascii")
             self._file.write(msg)
         self._file.flush()
コード例 #8
0
ファイル: terminalwriter.py プロジェクト: wythel/jenkins
 def write(self, msg, **kw):
     if msg:
         if not isinstance(msg, (bytes, text)):
             msg = text(msg)
         if self.hasmarkup and kw:
             markupmsg = self.markup(msg, **kw)
         else:
             markupmsg = msg
         try:
             self._file.write(markupmsg)
         except UnicodeEncodeError:
             msg = msg.encode("unicode-escape").decode("ascii")
             self._file.write(msg)
         self._file.flush()