From d50ebb149214f8c22d6c9750e14767f9e836a887 Mon Sep 17 00:00:00 2001 From: Mike Hiretsky Date: Mon, 11 Oct 2010 11:41:11 +0400 Subject: [PATCH] Fix "IOError: [Errno 32] Broken pipe" bug. --- pym/cl_overriding.py | 10 ++++++++-- pym/cl_print.py | 11 +++++++++-- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/pym/cl_overriding.py b/pym/cl_overriding.py index a63cfae..79e5a0a 100644 --- a/pym/cl_overriding.py +++ b/pym/cl_overriding.py @@ -64,7 +64,10 @@ def printERROR(errMessage): errMessage = str(errMessage) errMessage += "\n" sys.stderr.write(errMessage) - sys.stderr.flush() + try: + sys.stderr.flush() + except: + exit(1) def printSUCCESS(message,printBR=True): """Вывод сообщения о успехе""" @@ -74,4 +77,7 @@ def printSUCCESS(message,printBR=True): if printBR: message += "\n" sys.stdout.write(message) - sys.stdout.flush() \ No newline at end of file + try: + sys.stdout.flush() + except IOError: + exit(1) diff --git a/pym/cl_print.py b/pym/cl_print.py index e094ffa..13cc456 100644 --- a/pym/cl_print.py +++ b/pym/cl_print.py @@ -17,6 +17,7 @@ import sys, struct, termios, fcntl from cl_utils import _toUNICODE +import cl_overriding class color_print(object): _printSysOut = sys.stdout @@ -115,7 +116,10 @@ class color_print(object): def defaultPrint(self, string): self._printSysOut.write(string) - self._printSysOut.flush() + try: + self._printSysOut.flush() + except IOError: + cl_overriding.exit(1) def printLine(self, argL, argR, offsetL=0, printBR=True): """Печатает справа и слева консоли цветные сообщения""" @@ -156,7 +160,10 @@ class color_print(object): colorDict[''](rightString) if printBR: self._printSysOut.write("\n") - self._printSysOut.flush() + try: + self._printSysOut.flush() + except IOError: + cl_overriding.exit(1) def printNotOK(self, string, offsetL=0, printBR=True): """Вывод на печать в случае сбоя"""